rssmovedown.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. James Rose <[email protected]>
  21. */
  22. include "root.php";
  23. require_once "resources/require.php";
  24. require_once "resources/check_auth.php";
  25. require_once "config.php";
  26. if (permission_exists('content_edit')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //move down more than one level at a time
  37. //update v_rss set rss_order = (rss_order+1) where rss_order > 2 or rss_order = 2
  38. if (count($_GET)>0) {
  39. $rss_uuid = check_str($_GET["rss_uuid"]);
  40. $rss_order = check_str($_GET["rss_order"]);
  41. $sql = "SELECT rss_order FROM v_rss ";
  42. $sql .= "where domain_uuid = '$domain_uuid' ";
  43. $sql .= "and rss_category = '$rss_category' ";
  44. $sql .= "order by rss_order desc ";
  45. $sql .= "limit 1 ";
  46. //echo $sql."<br><br>";
  47. //return;
  48. $prep_statement = $db->prepare(check_sql($sql));
  49. $prep_statement->execute();
  50. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  51. foreach ($result as &$row) {
  52. //print_r( $row );
  53. $highestrss_order = $row[rss_order];
  54. }
  55. unset($prep_statement);
  56. if ($rss_order != $highestrss_order) {
  57. //move the current item's order number up
  58. $sql = "update v_rss set ";
  59. $sql .= "rss_order = (rss_order-1) "; //move down
  60. $sql .= "where domain_uuid = '$domain_uuid' ";
  61. $sql .= "and rss_order = ".($rss_order+1)." ";
  62. $sql .= "and rss_category = '$rss_category' ";
  63. //echo $sql."<br><br>";
  64. $db->exec(check_sql($sql));
  65. unset($sql);
  66. //move the selected item's order number down
  67. $sql = "update v_rss set ";
  68. $sql .= "rss_order = (rss_order+1) "; //move up
  69. $sql .= "where domain_uuid = '$domain_uuid' ";
  70. $sql .= "and rss_uuid = '$rss_uuid' ";
  71. $sql .= "and rss_category = '$rss_category' ";
  72. //echo $sql."<br><br>";
  73. $db->exec(check_sql($sql));
  74. unset($sql);
  75. }
  76. $_SESSION["message"] = $text['message-item-down'];
  77. header("Location: rsslist.php?rss_uuid=".$rss_uuid);
  78. return;
  79. }
  80. ?>