From a5724cca4956e3fcfe359bd72b4d874832b31393 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 11 Dec 2009 10:10:25 -0500 Subject: do some moving around of forwarding stuff --- actions/repeat.php | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 actions/repeat.php (limited to 'actions/repeat.php') diff --git a/actions/repeat.php b/actions/repeat.php new file mode 100644 index 000000000..194833fe0 --- /dev/null +++ b/actions/repeat.php @@ -0,0 +1,122 @@ + + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + * + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 2009, StatusNet, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Forward action + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ + +class ForwardAction extends Action +{ + var $user = null; + var $notice = null; + + function prepare($args) + { + parent::prepare($args); + + $this->user = common_current_user(); + + if (empty($this->user)) { + $this->clientError(_("Only logged-in users can forward notices.")); + return false; + } + + $id = $this->trimmed('notice'); + + if (empty($id)) { + $this->clientError(_("No notice specified.")); + return false; + } + + $this->notice = Notice::staticGet('id', $id); + + if (empty($this->notice)) { + $this->clientError(_("No notice specified.")); + return false; + } + + if ($this->user->id == $this->notice->profile_id) { + $this->clientError(_("You can't forward your own notice.")); + return false; + } + + $token = $this->trimmed('token-'.$id); + + if (empty($token) || $token != common_session_token()) { + $this->clientError(_("There was a problem with your session token. Try again, please.")); + return false; + } + + $profile = $this->user->getProfile(); + + if ($profile->hasForwarded($id)) { + $this->clientError(_("You already forwarded that notice.")); + return false; + } + + return true; + } + + /** + * Class handler. + * + * @param array $args query arguments + * + * @return void + */ + + function handle($args) + { + $forward = Forward::saveNew($this->user->id, $this->notice->id); + + if ($this->boolean('ajax')) { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, _('Forwarded')); + $this->elementEnd('head'); + $this->elementStart('body'); + $this->element('p', array('id' => 'forward_response'), _('Forwarded!')); + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + // FIXME! + } + } +} -- cgit v1.2.3-54-g00ecf From afc86a86d36dc8101c81d5d009546e4629db34a3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 11 Dec 2009 11:51:09 -0500 Subject: save repeats from the form --- actions/repeat.php | 20 ++++++++++---------- classes/Notice.php | 23 ++++++++++++++++++++++- lib/router.php | 1 + 3 files changed, 33 insertions(+), 11 deletions(-) (limited to 'actions/repeat.php') diff --git a/actions/repeat.php b/actions/repeat.php index 194833fe0..a1c5f443f 100644 --- a/actions/repeat.php +++ b/actions/repeat.php @@ -1,7 +1,7 @@ user = common_current_user(); if (empty($this->user)) { - $this->clientError(_("Only logged-in users can forward notices.")); + $this->clientError(_("Only logged-in users can repeat notices.")); return false; } @@ -73,7 +73,7 @@ class ForwardAction extends Action } if ($this->user->id == $this->notice->profile_id) { - $this->clientError(_("You can't forward your own notice.")); + $this->clientError(_("You can't repeat your own notice.")); return false; } @@ -86,8 +86,8 @@ class ForwardAction extends Action $profile = $this->user->getProfile(); - if ($profile->hasForwarded($id)) { - $this->clientError(_("You already forwarded that notice.")); + if ($profile->hasRepeated($id)) { + $this->clientError(_("You already repeated that notice.")); return false; } @@ -104,15 +104,15 @@ class ForwardAction extends Action function handle($args) { - $forward = Forward::saveNew($this->user->id, $this->notice->id); + $repeat = $this->notice->repeat($this->user->id, 'web'); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); - $this->element('title', null, _('Forwarded')); + $this->element('title', null, _('Repeated')); $this->elementEnd('head'); $this->elementStart('body'); - $this->element('p', array('id' => 'forward_response'), _('Forwarded!')); + $this->element('p', array('id' => 'repeat_response'), _('Repeated!')); $this->elementEnd('body'); $this->elementEnd('html'); } else { diff --git a/classes/Notice.php b/classes/Notice.php index 228201188..82753fbdd 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -236,7 +236,14 @@ class Notice extends Memcached_DataObject $notice->source = $source; $notice->uri = $uri; - $notice->reply_to = self::getReplyTo($reply_to, $profile_id, $source, $final); + // Handle repeat case + + if (isset($repeat_of)) { + $notice->repeat_of = $repeat_of; + $notice->reply_to = $repeat_of; + } else { + $notice->reply_to = self::getReplyTo($reply_to, $profile_id, $source, $final); + } if (!empty($notice->reply_to)) { $reply = Notice::staticGet('id', $notice->reply_to); @@ -1434,4 +1441,18 @@ class Notice extends Memcached_DataObject return $location; } + + function repeat($repeater_id, $source) + { + $author = Profile::staticGet('id', $this->profile_id); + + // FIXME: truncate on long repeats...? + + $content = sprintf(_('RT @%1$s %2$s'), + $author->nickname, + $this->content); + + return self::saveNew($repeater_id, $content, $source, + array('repeat_of' => $this->id)); + } } diff --git a/lib/router.php b/lib/router.php index 37525319f..142206c16 100644 --- a/lib/router.php +++ b/lib/router.php @@ -99,6 +99,7 @@ class Router 'groupblock', 'groupunblock', 'sandbox', 'unsandbox', 'silence', 'unsilence', + 'repeat', 'deleteuser'); foreach ($main as $a) { -- cgit v1.2.3-54-g00ecf From f8b187d5a4ac5eab1f025d61e30d5244cef6123d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 14 Dec 2009 18:09:08 -0500 Subject: Initial representation for repeated notice --- actions/repeat.php | 4 +++- lib/noticelist.php | 4 +++- theme/base/css/display.css | 15 +++++++++------ theme/base/images/icons/icons-01.gif | Bin 3154 -> 3201 bytes theme/base/images/icons/twotone/green/recycle-02.gif | Bin 0 -> 77 bytes theme/default/css/display.css | 6 +++++- theme/identica/css/display.css | 6 +++++- 7 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 theme/base/images/icons/twotone/green/recycle-02.gif (limited to 'actions/repeat.php') diff --git a/actions/repeat.php b/actions/repeat.php index a1c5f443f..38d6efa6c 100644 --- a/actions/repeat.php +++ b/actions/repeat.php @@ -112,7 +112,9 @@ class RepeatAction extends Action $this->element('title', null, _('Repeated')); $this->elementEnd('head'); $this->elementStart('body'); - $this->element('p', array('id' => 'repeat_response'), _('Repeated!')); + $this->element('p', array('id' => 'repeat_response', + 'class' => 'repeated'), + _('Repeated!')); $this->elementEnd('body'); $this->elementEnd('html'); } else { diff --git a/lib/noticelist.php b/lib/noticelist.php index dd0a361c0..2165222ee 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -627,7 +627,9 @@ class NoticeListItem extends Widget if ($user && $user->id != $this->notice->profile_id) { $profile = $user->getProfile(); if ($profile->hasRepeated($this->notice->id)) { - $this->out->text(_('Repeated')); + $this->out->element('span', array('class' => 'repeated', + 'title' => _('Notice repeated')), + _('Repeated')); } else { $rf = new RepeatForm($this->out, $this->notice); $rf->show(); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 0173d2fbb..2f4636391 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -964,7 +964,7 @@ float:left; font-size:0.95em; margin-left:59px; min-width:60%; -max-width:74%; +max-width:70%; } #showstream .notice div.entry-content, #shownotice .notice div.entry-content { @@ -996,7 +996,7 @@ left:0; .notice-options { position:relative; font-size:0.95em; -width:90px; +width:125px; float:right; } @@ -1007,16 +1007,18 @@ float:left; .notice-options .notice_reply, .notice-options .form_repeat, .notice-options .form_favor, -.notice-options .form_disfavor { +.notice-options .form_disfavor, +.notice-options .repeated { float:left; -margin-left:20%; +margin-left:14%; } .notice-options .form_favor, .notice-options .form_disfavor { margin-left:0; } .notice-options input, -.notice-options a { +.notice-options a, +.notice-options .repeated { text-indent:-9999px; outline:none; } @@ -1047,7 +1049,8 @@ display:none; border:0; padding:0; } -.notice-options a { +.notice-options a, +.notice-options .repeated { width:16px; height:16px; } diff --git a/theme/base/images/icons/icons-01.gif b/theme/base/images/icons/icons-01.gif index 5909d7b19..417327881 100644 Binary files a/theme/base/images/icons/icons-01.gif and b/theme/base/images/icons/icons-01.gif differ diff --git a/theme/base/images/icons/twotone/green/recycle-02.gif b/theme/base/images/icons/twotone/green/recycle-02.gif new file mode 100644 index 000000000..060a8c72f Binary files /dev/null and b/theme/base/images/icons/twotone/green/recycle-02.gif differ diff --git a/theme/default/css/display.css b/theme/default/css/display.css index e0dda3de2..f1d9a9d0b 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -173,7 +173,8 @@ button.close, .entity_moderation p, .entity_sandbox input.submit, .entity_silence input.submit, -.entity_delete input.submit { +.entity_delete input.submit, +.notice-options .repeated { background-image:url(../../base/images/icons/icons-01.gif); background-repeat:no-repeat; background-color:transparent; @@ -338,6 +339,9 @@ background-position:0 -658px; .notice-options form.form_repeat input.submit { background-position:0 -1582px; } +.notice-options .repeated { +background-position:0 -1648px; +} .notices div.entry-content, .notices div.notice-options { diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 999af973c..aa02070ac 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -173,7 +173,8 @@ button.close, .entity_moderation p, .entity_sandbox input.submit, .entity_silence input.submit, -.entity_delete input.submit { +.entity_delete input.submit, +.notice-options .repeated { background-image:url(../../base/images/icons/icons-01.gif); background-repeat:no-repeat; background-color:transparent; @@ -337,6 +338,9 @@ background-position:0 -658px; .notice-options form.form_repeat input.submit { background-position:0 -1582px; } +.notice-options .repeated { +background-position:0 -1648px; +} .notices div.entry-content, .notices div.notice-options { -- cgit v1.2.3-54-g00ecf From 90c378a81f78215e3bf85cc64a2224dd07f12d8c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Dec 2009 12:29:37 -0500 Subject: broadcast for repeats --- actions/repeat.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actions/repeat.php') diff --git a/actions/repeat.php b/actions/repeat.php index 38d6efa6c..b75523498 100644 --- a/actions/repeat.php +++ b/actions/repeat.php @@ -106,6 +106,8 @@ class RepeatAction extends Action { $repeat = $this->notice->repeat($this->user->id, 'web'); + common_broadcast_notice($repeat); + if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); -- cgit v1.2.3-54-g00ecf