delete.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. require_once('../../../lib/base.php');
  17. OC_JSON::checkLoggedIn();
  18. $app = isset($_POST['app'])?$_POST['app']:null;
  19. $categories = isset($_POST['categories'])?$_POST['categories']:null;
  20. if(is_null($app)) {
  21. bailOut(OC_Contacts_App::$l10n->t('Application name not provided.'));
  22. }
  23. OC_JSON::checkAppEnabled($app);
  24. debug('The application "'.$app.'" uses the default file. OC_VObjects will not be updated.');
  25. if(is_null($categories)) {
  26. bailOut('No categories selected for deletion.');
  27. }
  28. $vcategories = new OC_VCategories($app);
  29. $vcategories->delete($categories);
  30. OC_JSON::success(array('data' => array('categories'=>$vcategories->categories())));