9 * @author Evan Prodromou <evan@status.net>
10 * @author Robin Millette <millette@status.net>
11 * @author Mikael Nordfeldth <mmn@hethane.se>
12 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13 * @link http://www.gnu.org/software/social/
15 * StatusNet - the distributed open-source microblogging tool
16 * Copyright (C) 2008, 2009, StatusNet, Inc.
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU Affero General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Affero General Public License for more details.
28 * You should have received a copy of the GNU Affero General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 if (!defined('GNUSOCIAL')) { exit(1); }
35 * DisfavorAction class.
39 * @author Evan Prodromou <evan@status.net>
40 * @author Robin Millette <millette@status.net>
41 * @author Mikael Nordfeldth <mmn@hethane.se>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://www.gnu.org/software/social/
45 class DisfavorAction extends FormAction
47 public function showForm($msg=null, $success=false)
50 common_redirect(common_local_url('showfavorites',
51 array('nickname' => $this->scoped->nickname)), 303);
53 parent::showForm($msg, $success);
56 protected function handlePost()
58 $id = $this->trimmed('notice');
59 $notice = Notice::getKV($id);
60 if (!$notice instanceof Notice) {
61 $this->serverError(_('Notice not found'));
65 $fave->user_id = $this->scoped->id;
66 $fave->notice_id = $notice->id;
67 if (!$fave->find(true)) {
68 throw new NoResultException($fave);
70 $result = $fave->delete();
72 common_log_db_error($fave, 'DELETE', __FILE__);
73 // TRANS: Server error displayed when removing a favorite from the database fails.
74 $this->serverError(_('Could not delete favorite.'));
76 $this->scoped->blowFavesCache();
77 if (StatusNet::isAjax()) {
78 $this->startHTML('text/xml;charset=utf-8');
79 $this->elementStart('head');
80 // TRANS: Title for page on which favorites can be added.
81 $this->element('title', null, _('Add to favorites'));
82 $this->elementEnd('head');
83 $this->elementStart('body');
84 $favor = new FavorForm($this, $notice);
86 $this->elementEnd('body');