edittags.inc.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Insipid
  4. * Personal web-bookmark-system
  5. *
  6. * Copyright 2016-2019 Johannes Keßler
  7. *
  8. * Development starting from 2011: Johannes Keßler
  9. * https://www.bananas-playground.net/projekt/insipid/
  10. *
  11. * creator:
  12. * Luke Reeves <luke@neuro-tech.net>
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation, either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
  26. *
  27. */
  28. $submitFeedback = false;
  29. $formData = false;
  30. # very simple security check.
  31. # can/should be extended in the future.
  32. Summoner::simpleAuth();
  33. if(isset($_POST['tag']) && !empty($_POST['tag']) && isset($_POST['updateTags'])) {
  34. $tagData = $_POST['tag'];
  35. $deleteTagData = array();
  36. if(isset($_POST['deleteTag'])) {
  37. $deleteTagData = $_POST['deleteTag'];
  38. }
  39. $newTag = $_POST['newTag'];
  40. # first deletion, then update and then add
  41. # adding a new one which matches an existing one will update it.
  42. $submitFeedback['message'] = array();
  43. $submitFeedback['status'] = 'success';
  44. if(!empty($deleteTagData)) {
  45. $submitFeedback['message'][] = 'Tags deleted successfully.';
  46. foreach($deleteTagData as $k=>$v) {
  47. if($v == "delete") {
  48. $tagObj = new Tag($DB);
  49. $load = $tagObj->initbyid($k);
  50. if($load !== false) {
  51. $tagObj->delete();
  52. }
  53. else {
  54. $submitFeedback['message'][] = 'Tags could not be deleted.';
  55. $submitFeedback['status'] = 'error';
  56. }
  57. }
  58. }
  59. }
  60. if(!empty($newTag)) {
  61. $submitFeedback['message'][] = 'Tags added successfully.';
  62. $tagArr = Summoner::prepareTagOrCategoryStr($newTag);
  63. foreach($tagArr as $c) {
  64. $tagObj = new Tag($DB);
  65. $do = $tagObj->initbystring($c);
  66. if($do === false) {
  67. $submitFeedback['message'][] = 'Tag could not be added.';
  68. $submitFeedback['status'] = 'error';
  69. }
  70. }
  71. }
  72. }
  73. # show all the tags we have
  74. $tagCollection = $Management->tags(false, true);
  75. $subHeadline = 'All the tags <i class="ion-md-filing"></i>';