]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
change Notice::saveNew() to use named arguments for little-used options
authorEvan Prodromou <evan@status.net>
Fri, 11 Dec 2009 16:29:51 +0000 (11:29 -0500)
committerEvan Prodromou <evan@status.net>
Fri, 11 Dec 2009 16:29:51 +0000 (11:29 -0500)
actions/apistatusesupdate.php
actions/newnotice.php
classes/Notice.php
lib/command.php
lib/oauthstore.php
plugins/Facebook/facebookaction.php

index 85a7c8c08409ae7f9acf8f7167eba41270c39e3e..10bbc5ace0619a3cf7a6cc519459b8afa3a6b281 100644 (file)
@@ -231,19 +231,22 @@ class ApiStatusesUpdateAction extends ApiAuthAction
                 }
             }
 
-            $this->notice = Notice::saveNew(
-                $this->user->id,
-                html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'),
-                $this->source,
-                1,
-                $reply_to,
-                null,
-                null,
-                empty($location) ? null : $location->lat,
-                empty($location) ? null : $location->lon,
-                empty($location) ? null : $location->location_id,
-                empty($location) ? null : $location->location_ns
-            );
+            $content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'),
+
+            $options = array('reply_to' => $reply_to);
+
+            if (!empty($location)) {
+                $options['lat'] = $location->lat;
+                $options['lon'] = $location->lon;
+                $options['location_id'] = $location->location_id;
+                $options['location_ns'] = $location->location_ns;
+            }
+
+            $this->notice =
+              Notice::saveNew($this->user->id,
+                              $content,
+                              $this->source,
+                              $options);
 
             if (isset($upload)) {
                 $upload->attachToNotice($this->notice);
index dd6da0b01c1b438f91b8904e5abb85bbbce4244c..c6c70e32600bb69ac1abf3e74eec43bdb6ee295a 100644 (file)
@@ -187,10 +187,12 @@ class NewnoticeAction extends Action
             }
         }
 
-        $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
-                                  ($replyto == 'false') ? null : $replyto,
-                                  null, null,
-                                  $lat, $lon, $location_id, $location_ns);
+        $notice = Notice::saveNew($user->id, $content_shortened, 'web',
+                                  array('reply_to' => ($replyto == 'false') ? null : $replyto,
+                                        'lat' => $lat,
+                                        'lon' => $lon,
+                                        'location_id' => $location_id,
+                                        'location_ns' => $location_ns));
 
         if (isset($upload)) {
             $upload->attachToNotice($notice);
index c36c5a9c6b771b3dbc9896d63cf01ef9cf507f4f..4422866fa10945c1978476aa14066c39b0a6256b 100644 (file)
@@ -167,9 +167,18 @@ class Notice extends Memcached_DataObject
         }
     }
 
-    static function saveNew($profile_id, $content, $source=null,
-                            $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null,
-                            $lat=null, $lon=null, $location_id=null, $location_ns=null) {
+    static function saveNew($profile_id, $content, $source, $options=null) {
+
+        if (!empty($options)) {
+            extract($options);
+            if (!isset($reply_to)) {
+                $reply_to = NULL;
+            }
+        }
+
+        if (empty($is_local)) {
+            $is_local = Notice::LOCAL_PUBLIC;
+        }
 
         $profile = Profile::staticGet($profile_id);
 
index 450db9da37372968e8572e648749178c0cc97e84..085331f825eebf86609d0495afcf9b6f1135fbf0 100644 (file)
@@ -433,8 +433,9 @@ class ReplyCommand extends Command
             return;
         }
 
-        $notice = Notice::saveNew($this->user->id, $this->text, $channel->source(), 1,
-                                  $notice->id);
+        $notice = Notice::saveNew($this->user->id, $this->text, $channel->source(),
+                                  array('reply_to' => $notice->id));
+
         if ($notice) {
             $channel->output($this->user, sprintf(_('Reply to %s sent'), $recipient->nickname));
         } else {
index e34bf8a5ed8782d4430713caca155879447b3a56..df63cc1512c12e800158d335606c52a8b9294b6c 100644 (file)
@@ -359,9 +359,8 @@ class StatusNetOAuthDataStore extends OAuthDataStore
         $notice = Notice::saveNew($author->id,
                                   $omb_notice->getContent(),
                                   'omb',
-                                  false,
-                                  null,
-                                  $omb_notice->getIdentifierURI());
+                                  array('is_local' => Notice::REMOTE_OMB,
+                                        'uri' => $omb_notice->getIdentifierURI()));
 
         common_broadcast_notice($notice, true);
     }
index 705bb2780d006474f157735de3075a0af2b67dbd..24bf215fd9cf0e65f16d92f359d957cba8ec6bb0 100644 (file)
@@ -445,8 +445,9 @@ class FacebookAction extends Action
         $replyto = $this->trimmed('inreplyto');
 
         try {
-            $notice = Notice::saveNew($user->id, $content,
-                                      'web', 1, ($replyto == 'false') ? null : $replyto);
+            $notice = Notice::saveNew($user->id, $content, 'web',
+                                      array('reply_to' => ($replyto == 'false') ? null : $replyto));
+
         } catch (Exception $e) {
             $this->showPage($e->getMessage());
             return;