PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/s3db3.5.10/resource/deleteclass.php

https://code.google.com/p/s3db/
PHP | 149 lines | 111 code | 25 blank | 13 comment | 13 complexity | 53bbca03203fb87496f7626deb9dfb5f MD5 | raw file
  1. <?php
  2. #deleterule.php is a form for changing rules, classes or not
  3. #Includes links to edit and delete resource, as well as edit rules
  4. #Helena F Deus (helenadeus@gmail.com)
  5. ini_set('display_errors',0);
  6. if($_REQUEST['su3d'])
  7. ini_set('display_errors',1);
  8. if($_SERVER['HTTP_X_FORWARDED_HOST']!='') $def = $_SERVER['HTTP_X_FORWARDED_HOST'];
  9. else $def = $_SERVER['HTTP_HOST'];
  10. if(file_exists('../config.inc.php')) {
  11. include('../config.inc.php');}
  12. else{
  13. Header('Location: http://'.$def.'/s3db/');
  14. exit;}
  15. #just to know where we are...
  16. $thisScript = end(explode('/', $_SERVER['SCRIPT_FILENAME'])).'?'.$_SERVER['argv'][0];
  17. $key = $_GET['key'];
  18. #Get the key, send it to check validity
  19. include_once('../core.header.php');
  20. if($key)
  21. $user_id = get_entry('access_keys', 'account_id', 'key_id', $key, $db);
  22. else
  23. $user_id = $_SESSION['user']['account_id'];
  24. #Universal variables
  25. $project_id = $_REQUEST['project_id'];
  26. $class_id = ($_REQUEST['collection_id']!='')?$_REQUEST['collection_id']:$_REQUEST['class_id'];
  27. $rule_id = $_REQUEST['rule_id'];
  28. #info about resource
  29. $resource_info = URIinfo('C'.$class_id, $user_id, $key, $db);
  30. # echo '<pre>';print_r($resource_info);
  31. $uni = compact('db', 'user_id');
  32. if($class_id=='')
  33. {
  34. echo "Please indicate the resource ou intend to delete (for example &collection_id=xxx)";
  35. exit;
  36. }
  37. if(!$resource_info['delete'])
  38. {#check projectAcl
  39. echo "User cannot delete this resource!!";
  40. exit;
  41. }
  42. else
  43. {
  44. if($_POST['delete'] != '' && $class_id!='')
  45. {
  46. $s3ql=$uni;
  47. $s3ql['delete'] = 'collection';
  48. $s3ql['where']['collection_id'] = $class_id;
  49. if($s3ql['flag']=='unlink')
  50. {$s3ql['where']['project_id']=$project_id;
  51. $s3ql['flag']='unlink';
  52. }
  53. else
  54. $s3ql['flag']='all';
  55. $s3ql['format']='html';
  56. #echo '<pre>';print_r($s3ql);exit;
  57. $done = S3QLaction($s3ql);
  58. #ereg('<error>([0-9]+)</error>(.*)<message>(.*)</message>', $done, $s3qlout);
  59. $msg = html2cell($done);
  60. if($msg[2]['error_code']==0)
  61. {
  62. Header('Location:'.$action['project']); #since resource has became extinct, redirect to the project's page
  63. exit;
  64. }
  65. else {
  66. echo $msg[2]['message'];
  67. }
  68. }
  69. #include all the javascript functions for the menus...
  70. include('../S3DBjavascript.php');
  71. #and the short menu for the resource script
  72. #$rule_info = URIinfo('R'.$resource_info['rule_id'], $user_id, $key, $db);
  73. $message = "Do you really want to delete this class? <br /><br /><b>All the resources of ".$resource_info['entity'].", rules and statements associated with them will be deleted!!!</b>";
  74. ?>
  75. <table class="middle" width="100%" align="center">
  76. <tr><td>
  77. <table class="insidecontents" width="90%" align="center" border="0">
  78. <tr><td class="message" colspan="9"><br /></td></tr>
  79. <tr bgcolor="#80BBFF"><td align="center" colspan="8">Delete Class<input type="hidden" name="rule_id" value="7"></td></tr>
  80. <tr class="odd">
  81. <?php
  82. echo '<td class="message" colspan="8">'.$message.'</b><br /><br /></td>';
  83. ?>
  84. </tr>
  85. <tr class="even">
  86. <td width="5%">Collection ID</td>
  87. <td width="5%">Owner</td>
  88. <td width="15%">Create Date</td>
  89. <td width="10%">Name</td>
  90. <!-- <td width="10%">Verb</td>
  91. <td width="10%">Object</sup></td> -->
  92. <td width="20%">Notes</td>
  93. </tr>
  94. <tr class="odd">
  95. <?php
  96. echo '<td width="5%"><b>'.$resource_info['collection_id'].'</b></td>
  97. <td width="5%"><b>'.find_user_loginID(array('account_id'=>$resource_info['created_by'], 'db'=>$db)).'</b></td>
  98. <td width="15%"><b>'.$resource_info['created_on'].'</b></td>
  99. <td width="10%"><b>'.$resource_info['entity'].'</b></td>
  100. <!-- <td width="10%"><b>'.$rule_info['verb'].'</b></td>
  101. <td width="10%"><b>'.$rule_info['object'].'</sup></td> -->
  102. <td width="20%">'.$resource_info['notes'].'<b></b></td>';
  103. ?>
  104. <td><select name="flag" size="5">
  105. <option value="all" selected>Delete this collection and all dependencies</option>
  106. <option value="unlink">Unlink this collection from project</option>
  107. <!-- <option value="all">Delete this class and all dependences</option> -->
  108. </select></td>
  109. </tr>
  110. </table>
  111. </td></tr>
  112. </table>
  113. <table class="bottom" width="100%" align="center">
  114. <tr><td>
  115. <table class="insidecontents" width="90%" align="center" border="0">
  116. <tr><td align="left">
  117. <?php
  118. echo '<form name= "deleterule" action = "'.$action['deleteclass'].'" method="POST">';
  119. echo '<input type="submit" name="delete" value="OK">&nbsp;&nbsp;&nbsp;&nbsp;';
  120. echo '<input type="button" name="cancel" value="Cancel" onClick="window.location=\''.$action['resource'].'\'"><br /><br /></td></tr>';
  121. echo '</table></td></tr></form>';
  122. }
  123. ?>