From: Evan Prodromou Date: Mon, 28 Sep 2009 01:10:17 +0000 (-0400) Subject: Merge DeleteAction class into DeletenoticeAction X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a8d1b7e9c26b4449a4a1e0e250f9b6766b2d8e62;p=quix0rs-gnu-social.git Merge DeleteAction class into DeletenoticeAction The DeleteAction class checked for notice information, and only had one subclass: DeletenoticeAction. I couldn't figure out any other class that would subclass it, so I combined the two into a single class. --- diff --git a/actions/deletenotice.php b/actions/deletenotice.php index 3d040f2fa9..617fa9c17a 100644 --- a/actions/deletenotice.php +++ b/actions/deletenotice.php @@ -32,15 +32,44 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/deleteaction.php'; - -class DeletenoticeAction extends DeleteAction +class DeletenoticeAction extends Action { - var $error = null; + var $error = null; + var $user = null; + var $notice = null; + var $profile = null; + var $user_profile = null; + + function prepare($args) + { + parent::prepare($args); + + $this->user = common_current_user(); + $notice_id = $this->trimmed('notice'); + $this->notice = Notice::staticGet($notice_id); + + if (!$this->notice) { + common_user_error(_('No such notice.')); + exit; + } + + $this->profile = $this->notice->getProfile(); + $this->user_profile = $this->user->getProfile(); + + return true; + } function handle($args) { parent::handle($args); + + if (!common_logged_in()) { + common_user_error(_('Not logged in.')); + exit; + } else if ($this->notice->profile_id != $this->user_profile->id) { + common_user_error(_('Can\'t delete this notice.')); + exit; + } // XXX: Ajax! if ($_SERVER['REQUEST_METHOD'] == 'POST') { diff --git a/lib/deleteaction.php b/lib/deleteaction.php deleted file mode 100644 index f702820c61..0000000000 --- a/lib/deleteaction.php +++ /dev/null @@ -1,74 +0,0 @@ -. - * - * @category Personal - * @package StatusNet - * @author Evan Prodromou - * @author Sarven Capadisli - * @copyright 2008 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -class DeleteAction extends Action -{ - var $user = null; - var $notice = null; - var $profile = null; - var $user_profile = null; - - function prepare($args) - { - parent::prepare($args); - - $this->user = common_current_user(); - $notice_id = $this->trimmed('notice'); - $this->notice = Notice::staticGet($notice_id); - - if (!$this->notice) { - common_user_error(_('No such notice.')); - exit; - } - - $this->profile = $this->notice->getProfile(); - $this->user_profile = $this->user->getProfile(); - - return true; - } - - function handle($args) - { - parent::handle($args); - - if (!common_logged_in()) { - common_user_error(_('Not logged in.')); - exit; - } else if ($this->notice->profile_id != $this->user_profile->id) { - common_user_error(_('Can\'t delete this notice.')); - exit; - } - } - -}