]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
save repeats from the form
authorEvan Prodromou <evan@status.net>
Fri, 11 Dec 2009 16:51:09 +0000 (11:51 -0500)
committerEvan Prodromou <evan@status.net>
Fri, 11 Dec 2009 16:51:09 +0000 (11:51 -0500)
actions/repeat.php
classes/Notice.php
lib/router.php

index 194833fe0cf56a56f9a69039549178ca720d32e0..a1c5f443fb70507876009423d9419d9c9d08e8de 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Forward action.
+ * Repeat action.
  *
  * PHP version 5
  *
@@ -33,7 +33,7 @@ if (!defined('STATUSNET')) {
 }
 
 /**
- * Forward action
+ * Repeat action
  *
  * @category Action
  * @package  StatusNet
@@ -42,7 +42,7 @@ if (!defined('STATUSNET')) {
  * @link     http://status.net/
  */
 
-class ForwardAction extends Action
+class RepeatAction extends Action
 {
     var $user = null;
     var $notice = null;
@@ -54,7 +54,7 @@ class ForwardAction extends Action
         $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;
         }
 
@@ -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 {
index 2282011882be8a2671ff0d004ff8782297f4b7b0..82753fbdd69fe77b7ba966029671e6dc56dd8c2c 100644 (file)
@@ -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));
+    }
 }
index 37525319f79ec9b7b8289c3b4a460366f6a02b4f..142206c16ad9f205955f1f7536c22a18c64100f1 100644 (file)
@@ -99,6 +99,7 @@ class Router
                           'groupblock', 'groupunblock',
                           'sandbox', 'unsandbox',
                           'silence', 'unsilence',
+                          'repeat',
                           'deleteuser');
 
             foreach ($main as $a) {