From 41cbb90faeabc0a6002b41d40d392f45a59a7aba Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:31:23 -0500 Subject: add (ugly) form to forward notices --- lib/forwardform.php | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/noticelist.php | 21 ++++++++ 2 files changed, 168 insertions(+) create mode 100644 lib/forwardform.php (limited to 'lib') diff --git a/lib/forwardform.php b/lib/forwardform.php new file mode 100644 index 000000000..2052856ae --- /dev/null +++ b/lib/forwardform.php @@ -0,0 +1,147 @@ +. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 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); +} + +require_once INSTALLDIR.'/lib/form.php'; + +/** + * Form for forwarding a notice + * + * @category Form + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ForwardForm extends Form +{ + /** + * Notice to forward + */ + + var $notice = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param Notice $notice notice to forward + */ + + function __construct($out=null, $notice=null) + { + parent::__construct($out); + + $this->notice = $notice; + } + + /** + * ID of the form + * + * @return int ID of the form + */ + + function id() + { + return 'forward-' . $this->notice->id; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('forward'); + } + + /** + * Include a session token for CSRF protection + * + * @return void + */ + + function sessionToken() + { + $this->out->hidden('token-' . $this->notice->id, + common_session_token()); + } + + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Forward this notice')); + } + + /** + * Data elements + * + * @return void + */ + + function formData() + { + $this->out->hidden('notice-n'.$this->notice->id, + $this->notice->id, + 'notice'); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('forward-submit-' . $this->notice->id, + _('Forward'), 'submit', null, _('Forward this notice')); + } + + /** + * Class of the form. + * + * @return string the form's class + */ + + function formClass() + { + return 'form_forward'; + } +} diff --git a/lib/noticelist.php b/lib/noticelist.php index 21cec528f..b38860880 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -212,6 +212,7 @@ class NoticeListItem extends Widget $this->out->elementStart('div', 'notice-options'); $this->showFaveForm(); $this->showReplyLink(); + $this->showForwardForm(); $this->showDeleteLink(); $this->out->elementEnd('div'); } @@ -530,6 +531,26 @@ class NoticeListItem extends Widget } } + /** + * show the form to forward a notice + * + * @return void + */ + + function showForwardForm() + { + $user = common_current_user(); + if ($user) { + $profile = $user->getProfile(); + if ($profile->hasForwarded($this->notice->id)) { + $this->out->text(_('Forwarded')); + } else { + $ff = new ForwardForm($this->out, $this->notice); + $ff->show(); + } + } + } + /** * if the user is the author, let them delete the notice * -- cgit v1.2.3-54-g00ecf