folder_edit.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. require_once ("./header.php");
  3. logged_in_only ();
  4. $foldername = set_post_foldername ();
  5. $public = set_post_bool_var ("public", false);
  6. $inherit = set_post_bool_var ("inherit", false);
  7. if ($folderid == "" || $folderid == "0"){
  8. message ("No Folder selected");
  9. }
  10. else if ($foldername == "") {
  11. $query = sprintf ("SELECT name, public FROM folder WHERE id='%d' AND user='%s' AND deleted!='1'",
  12. $mysql->escape ($folderid),
  13. $mysql->escape ($username));
  14. if ($mysql->query ($query)) {
  15. if (mysqli_num_rows ($mysql->result) == 1) {
  16. $row = mysqli_fetch_object ($mysql->result);
  17. }
  18. else {
  19. message ("No Folder to edit.");
  20. }
  21. }
  22. else {
  23. message ($mysql->error);
  24. }
  25. ?>
  26. <h2 class="title">Edit Folder</h2>
  27. <form action="<?php echo $_SERVER['SCRIPT_NAME'] . "?folderid=" . $folderid; ?>" id="fedit" method="POST">
  28. <p><input type=text name="foldername" size="50" value="<?php echo $row->name; ?>"> <?php echo $row->public ? $folder_opened_public : $folder_opened; ?></p>
  29. <p><input type="checkbox" name="public" <?php if ($row->public) {echo "checked";} ?>> Public</p>
  30. <p><input type="checkbox" name="inherit"> Inherit Public Status to all Subfolders and Bookmarks</p>
  31. <input type="submit" value=" OK ">
  32. <input type="button" value=" Cancel " onClick="self.close()">
  33. </form>
  34. <script>
  35. this.focus();
  36. document.getElementById('fedit').foldername.focus();
  37. </script>
  38. <?php
  39. }
  40. else {
  41. $query = sprintf ("UPDATE folder SET name='%s', public='%d' WHERE id='%d' AND user='%s'",
  42. $mysql->escape ($foldername),
  43. $mysql->escape ($public),
  44. $mysql->escape ($folderid),
  45. $mysql->escape ($username));
  46. if ($mysql->query ($query)) {
  47. if ($inherit) {
  48. require_once (ABSOLUTE_PATH . "folders.php");
  49. $tree = new folder;
  50. $tree->get_children ($folderid);
  51. if (count ($tree->get_children) > 0) {
  52. $sub_folders = implode (",", $tree->get_children);
  53. # set subfolders to public
  54. $query = sprintf ("UPDATE folder SET public='%d' WHERE id IN (%s) AND user='%s'",
  55. $mysql->escape ($public),
  56. $mysql->escape ($sub_folders),
  57. $mysql->escape ($username));
  58. if (! $mysql->query ($query)) {
  59. message ($mysql->error);
  60. }
  61. $sub_folders .= "," . $folderid;
  62. # set bookmarks to public as well
  63. $query = sprintf ("UPDATE bookmark SET public='%d' WHERE childof IN (%s) AND user='%s'",
  64. $mysql->escape ($public),
  65. $mysql->escape ($sub_folders),
  66. $mysql->escape ($username));
  67. if ($mysql->query ($query)) {
  68. echo '<script language="JavaScript">reloadclose();</script>';
  69. }
  70. else {
  71. message ($mysql->error);
  72. }
  73. }
  74. else {
  75. $query = sprintf ("UPDATE bookmark SET public='%d' WHERE childof='%d' AND user='%s'",
  76. $mysql->escape ($public),
  77. $mysql->escape ($folderid),
  78. $mysql->escape ($username));
  79. if ($mysql->query ($query)) {
  80. echo '<script language="JavaScript">reloadclose();</script>';
  81. }
  82. else {
  83. message ($mysql->error);
  84. }
  85. }
  86. }
  87. echo '<script language="JavaScript">reloadclose();</script>';
  88. }
  89. else {
  90. message ($mysql->error);
  91. }
  92. }
  93. require_once (ABSOLUTE_PATH . "footer.php");
  94. ?>