PageRenderTime 81ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/core/ajax/vcategories/removeFromFavorites.php

https://github.com/sezuan/core
PHP | 38 lines | 25 code | 7 blank | 6 comment | 3 complexity | d1243a4bd03a2f6006e5da3053488938 MD5 | raw file
 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 */
 8function bailOut($msg) {
 9	OC_JSON::error(array('data' => array('message' => $msg)));
10	OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: '.$msg, OC_Log::DEBUG);
11	exit();
12}
13function debug($msg) {
14	OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: '.$msg, OC_Log::DEBUG);
15}
16
17OCP\JSON::checkLoggedIn();
18OCP\JSON::callCheck();
19
20$l = OC_L10N::get('core');
21
22$id = isset($_POST['id']) ? strip_tags($_POST['id']) : null;
23$type = isset($_POST['type']) ? $_POST['type'] : null;
24
25if(is_null($type)) {
26	bailOut($l->t('Object type not provided.'));
27}
28
29if(is_null($id)) {
30	bailOut($l->t('%s ID not provided.', array($type)));
31}
32
33$categories = new OC_VCategories($type);
34if(!$categories->removeFromFavorites($id, $type)) {
35	bailOut($l->t('Error removing %s from favorites.', array($id)));
36}
37
38OC_JSON::success();