PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/core/ajax/vcategories/delete.php

https://github.com/jlgg/simple_trash
PHP | 40 lines | 26 code | 8 blank | 6 comment | 2 complexity | 3a5fc6a6ca7e488dc0e7da0401370908 MD5 | raw file
Possible License(s): AGPL-3.0, AGPL-1.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. function bailOut($msg) {
  9. OC_JSON::error(array('data' => array('message' => $msg)));
  10. OC_Log::write('core', 'ajax/vcategories/delete.php: '.$msg, OC_Log::DEBUG);
  11. exit();
  12. }
  13. function debug($msg) {
  14. OC_Log::write('core', 'ajax/vcategories/delete.php: '.$msg, OC_Log::DEBUG);
  15. }
  16. OCP\JSON::checkLoggedIn();
  17. OCP\JSON::callCheck();
  18. $l = OC_L10N::get('core');
  19. $type = isset($_POST['type']) ? $_POST['type'] : null;
  20. $categories = isset($_POST['categories']) ? $_POST['categories'] : null;
  21. if(is_null($type)) {
  22. bailOut($l->t('Object type not provided.'));
  23. }
  24. debug('The application using category type "'
  25. . $type
  26. . '" uses the default file for deletion. OC_VObjects will not be updated.');
  27. if(is_null($categories)) {
  28. bailOut($l->t('No categories selected for deletion.'));
  29. }
  30. $vcategories = new OC_VCategories($type);
  31. $vcategories->delete($categories);
  32. OC_JSON::success(array('data' => array('categories'=>$vcategories->categories())));