core /core/ajax/vcategories/removeFromFavorites.php

Language PHP Lines 39
MD5 Hash d1243a4bd03a2f6006e5da3053488938
Repository https://github.com/sezuan/core.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?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)));
	OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: '.$msg, OC_Log::DEBUG);
	exit();
}
function debug($msg) {
	OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: '.$msg, OC_Log::DEBUG);
}

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)) {
	bailOut($l->t('%s ID not provided.', array($type)));
}

$categories = new OC_VCategories($type);
if(!$categories->removeFromFavorites($id, $type)) {
	bailOut($l->t('Error removing %s from favorites.', array($id)));
}

OC_JSON::success();
Back to Top