2012-10-19 02:07:41 +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-11-01 06:06:20 +04:00
|
|
|
OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: '.$msg, OC_Log::DEBUG);
|
2012-10-19 02:07:41 +04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
function debug($msg) {
|
2012-11-01 06:06:20 +04:00
|
|
|
OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: '.$msg, OC_Log::DEBUG);
|
2012-10-19 02:07:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::callCheck();
|
|
|
|
|
|
|
|
$l = OC_L10N::get('core');
|
|
|
|
|
|
|
|
$id = isset($_POST['id']) ? strip_tags($_POST['id']) : null;
|
|
|
|
$type = isset($_POST['type']) ? $_POST['type'] : null;
|
|
|
|
|
|
|
|
if(is_null($type)) {
|
|
|
|
bailOut($l->t('Object type not provided.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(is_null($id)) {
|
2013-02-07 19:49:36 +04:00
|
|
|
bailOut($l->t('%s ID not provided.', array($type)));
|
2012-10-19 02:07:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
$categories = new OC_VCategories($type);
|
|
|
|
if(!$categories->removeFromFavorites($id, $type)) {
|
2013-02-07 19:49:36 +04:00
|
|
|
bailOut($l->t('Error removing %s from favorites.', array($id)));
|
2012-10-19 02:07:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
OC_JSON::success();
|