2012-03-12 17:07:48 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function bailOut($msg) {
|
|
|
|
OC_JSON::error(array('data' => array('message' => $msg)));
|
2012-09-04 14:21:00 +04:00
|
|
|
OC_Log::write('core', 'ajax/vcategories/delete.php: '.$msg, OC_Log::DEBUG);
|
2012-03-12 17:07:48 +04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
function debug($msg) {
|
2012-09-04 14:21:00 +04:00
|
|
|
OC_Log::write('core', 'ajax/vcategories/delete.php: '.$msg, OC_Log::DEBUG);
|
2012-03-12 17:07:48 +04:00
|
|
|
}
|
|
|
|
|
2012-10-19 02:06:18 +04:00
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::callCheck();
|
|
|
|
|
|
|
|
$l = OC_L10N::get('core');
|
|
|
|
|
|
|
|
$type = isset($_POST['type']) ? $_POST['type'] : null;
|
|
|
|
$categories = isset($_POST['categories']) ? $_POST['categories'] : null;
|
|
|
|
|
|
|
|
if(is_null($type)) {
|
|
|
|
bailOut($l->t('Object type not provided.'));
|
|
|
|
}
|
2012-03-12 17:07:48 +04:00
|
|
|
|
2012-11-05 19:32:20 +04:00
|
|
|
debug('The application using category type "'
|
|
|
|
. $type
|
|
|
|
. '" uses the default file for deletion. OC_VObjects will not be updated.');
|
2012-03-12 17:07:48 +04:00
|
|
|
|
|
|
|
if(is_null($categories)) {
|
2012-10-19 02:06:18 +04:00
|
|
|
bailOut($l->t('No categories selected for deletion.'));
|
2012-03-12 17:07:48 +04:00
|
|
|
}
|
|
|
|
|
2012-10-19 02:06:18 +04:00
|
|
|
$vcategories = new OC_VCategories($type);
|
2012-03-12 17:07:48 +04:00
|
|
|
$vcategories->delete($categories);
|
|
|
|
OC_JSON::success(array('data' => array('categories'=>$vcategories->categories())));
|