<?php
/**
- * Forward action.
+ * Repeat action.
*
* PHP version 5
*
}
/**
- * Forward action
+ * Repeat action
*
* @category Action
* @package StatusNet
* @link http://status.net/
*/
-class ForwardAction extends Action
+class RepeatAction extends Action
{
var $user = null;
var $notice = null;
$this->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;
}
}
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;
}
$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;
}
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 {
$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);
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));
+ }
}