]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Merge remote branch 'gitorious/0.9.x' into 0.9.x
[quix0rs-gnu-social.git] / classes / Notice.php
index 79626f8898535a032e90367f4f4f6c2c9aef7ed8..85c7dabea48f5d9f31667042cab2c5b07ed8fccd 100644 (file)
@@ -524,10 +524,8 @@ class Notice extends Memcached_DataObject
         $notice = new Notice();
         $notice->profile_id = $profile_id;
         $notice->content = $content;
-        if (common_config('db','type') == 'pgsql')
-          $notice->whereAdd('extract(epoch from now() - created) < ' . common_config('site', 'dupelimit'));
-        else
-          $notice->whereAdd('now() - created < ' . common_config('site', 'dupelimit'));
+        $threshold = common_sql_date(time() - common_config('site', 'dupelimit'));
+        $notice->whereAdd(sprintf("created > '%s'", $notice->escape($threshold)));
 
         $cnt = $notice->count();
         return ($cnt == 0);
@@ -904,7 +902,7 @@ class Notice extends Memcached_DataObject
     {
         if (!is_array($group_ids)) {
             // TRANS: Server exception thrown when no array is provided to the method saveKnownGroups().
-            throw new ServerException(_("Bad type provided to saveKnownGroups"));
+            throw new ServerException(_('Bad type provided to saveKnownGroups.'));
         }
 
         $groups = array();
@@ -1117,7 +1115,7 @@ class Notice extends Memcached_DataObject
                     common_log_db_error($reply, 'INSERT', __FILE__);
                     // TRANS: Server exception thrown when a reply cannot be saved.
                     // TRANS: %1$d is a notice ID, %2$d is the ID of the mentioned user.
-                    throw new ServerException(sprintf(_("Could not save reply for %1$d, %2$d."), $this->id, $mentioned->id));
+                    throw new ServerException(sprintf(_('Could not save reply for %1$d, %2$d.'), $this->id, $mentioned->id));
                 } else {
                     $replied[$mentioned->id] = 1;
                     self::blow('reply:stream:%d', $mentioned->id);
@@ -1613,6 +1611,35 @@ class Notice extends Memcached_DataObject
             Event::handle('EndActivityGeo', array(&$this, &$xs, $lat, $lon));
         }
 
+        // @fixme check this logic
+
+        if ($this->isLocal()) {
+
+            $selfUrl = common_local_url('ApiStatusesShow', array('id' => $this->id,
+                                                                 'format' => 'atom'));
+
+            if (Event::handle('StartActivityRelSelf', array(&$this, &$xs, &$selfUrl))) {
+                $xs->element('link', array('rel' => 'self',
+                                           'type' => 'application/atom+xml',
+                                           'href' => $selfUrl));
+                Event::handle('EndActivityRelSelf', array(&$this, &$xs, $selfUrl));
+            }
+
+            if (!empty($cur) && $cur->id == $this->profile_id) {
+
+                // note: $selfUrl may have been changed by a plugin
+                $relEditUrl = common_local_url('ApiStatusesShow', array('id' => $this->id,
+                                                                        'format' => 'atom'));
+
+                if (Event::handle('StartActivityRelEdit', array(&$this, &$xs, &$relEditUrl))) {
+                    $xs->element('link', array('rel' => 'edit',
+                                               'type' => 'application/atom+xml',
+                                               'href' => $relEditUrl));
+                    Event::handle('EndActivityRelEdit', array(&$this, &$xs, $relEditUrl));
+                }
+            }
+        }
+
         if (Event::handle('StartActivityEnd', array(&$this, &$xs))) {
             $xs->elementEnd('entry');
             Event::handle('EndActivityEnd', array(&$this, &$xs));
@@ -2034,6 +2061,7 @@ class Notice extends Memcached_DataObject
     {
         // We always insert for the author so they don't
         // have to wait
+        Event::handle('StartNoticeDistribute', array($this));
 
         $user = User::staticGet('id', $this->profile_id);
         if (!empty($user)) {