]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'nightly' of gitorious.org:social/mainline into nightly
authorRoland Haeder <roland@mxchange.org>
Tue, 10 Mar 2015 17:17:50 +0000 (18:17 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 10 Mar 2015 17:18:38 +0000 (18:18 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
1  2 
classes/Notice.php
lib/default.php
lib/installer.php
lib/noticelistitem.php
plugins/AnonymousFave/actions/anonfavor.php
plugins/Favorite/actions/apifavoritecreate.php

diff --combined classes/Notice.php
index 86eee49321a22ec89ec56e9edb3f29359a767b6a,61b18a8710a3f44f1bc413db414bcb0503d2cf51..0ef25476caae583b220c9cc5bcbf43e1f31d5934
@@@ -313,6 -313,16 +313,16 @@@ class Notice extends Managed_DataObjec
          return $notice;
      }
  
+     public static function getById($id)
+     {
+         $notice = new Notice();
+         $notice->id = $id;
+         if (!$notice->find(true)) {
+             throw new NoResultException($notice);
+         }
+         return $notice;
+     }
      /**
       * Extract #hashtags from this notice's content and save them to the database.
       */
       * Record the given set of hash tags in the db for this notice.
       * Given tag strings will be normalized and checked for dupes.
       */
 -    function saveKnownTags($hashtags)
 +    function saveKnownTags(array $hashtags)
      {
          //turn each into their canonical tag
          //this is needed to remove dupes before saving e.g. #hash.tag = #hashtag
       * @return Notice
       * @throws ClientException
       */
 -    static function saveNew($profile_id, $content, $source, array $options=null) {
 +    static function saveNew($profile_id, $content, $source, array $options=array()) {
          $defaults = array('uri' => null,
                            'url' => null,
                            'conversation' => null,   // URI of conversation
                            'object_type' => null,
                            'verb' => null);
  
 -        if (!empty($options) && is_array($options)) {
 +        /*
 +         * Above type-hint is already array, so simply count it, this saves
 +         * "some" CPU cycles.
 +         */
 +        if (count($options) > 0) {
              $options = array_merge($defaults, $options);
 -            extract($options);
 -        } else {
 -            extract($defaults);
          }
  
 +        extract($options);
 +
          if (!isset($is_local)) {
              $is_local = Notice::LOCAL_PUBLIC;
          }
diff --combined lib/default.php
index 239260f28bae20b9c355758cf37498c65b8ad717,8b15d57857892ecb895cadd553cf0de2e4a86b74..1427c2d28b3424a20926988f144ec492c1dc2afa
@@@ -132,7 -132,7 +132,7 @@@ $default 
                'delete' => false,
                'move' => true),
          'image' =>
 -        array('jpegquality' => 85),
 +        array('jpegquality' => 95),
          'avatar' =>
          array('server' => null,
                'dir' => INSTALLDIR . '/avatar/',
          array('server' => null,
                'dir' => INSTALLDIR . '/file/',
                'path' => $_path . '/file/',
 +              'chmod' => 0644,        // Access rights (chmod) for any attachments
                'sslserver' => null,
                'sslpath' => null,
                'ssl' => null,
          array('disabled' => true),
          'plugins' =>
          array('core' => array(
+                             'ActivityVerb' => array(),
                              'AuthCrypt' => array(),
                              'Cronish' => array(),
                              'Favorite' => array(),
diff --combined lib/installer.php
index bfb56021682c09e0466296f17eab2d469b60fd8b,9e2936ca82dc5860c10e00827197787fef4c24ac..6b0278ee0b81b8dc83b97795dec26ea1d7c578b4
@@@ -224,7 -224,7 +224,7 @@@ abstract class Installe
          }
          // @fixme hardcoded list; should use Nickname::isValid()
          // if/when it's safe to have loaded the infrastructure here
-         $blacklist = array('main', 'panel', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook');
+         $blacklist = array('main', 'panel', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook', 'activity');
          if (in_array($this->adminNick, $blacklist)) {
              $this->updateStatus('The user nickname "' . htmlspecialchars($this->adminNick) .
                           '" is reserved.', true);
              }
          }
  
 -        if (!$conn instanceof DB_common) {
 +        if (!is_object($conn)) {
 +            // No object at all
 +            throw new Exception('Fatal error: conn is no object.');
 +        } elseif (!$conn instanceof DB_common) {
              // Is not the right instance
              throw new Exception('Cannot connect to database: ' . $conn->getMessage());
          }
diff --combined lib/noticelistitem.php
index 49e11e513a010bfa59398b002056a171f87c4c8a,9c2f2ed4060b463c5d39241250e3e24cf63409f1..dda16507e473fbe4b3c6fdd0c663b536f94e7888
@@@ -63,6 -63,7 +63,7 @@@ class NoticeListItem extends Widge
      protected $id_prefix = null;
      protected $options = true;
      protected $maxchars = 0;   // if <= 0 it means use full posts
+     protected $item_tag = 'li';
  
      /**
       * constructor
              }
          }
          // string preferences
-         foreach(array('id_prefix') as $key) {
+         foreach(array('id_prefix', 'item_tag') as $key) {
              if (array_key_exists($key, $prefs)) {
                  $this->$key = $prefs[$key];
              }
      {
          if (Event::handle('StartShowNoticeOptions', array($this))) {
              $user = common_current_user();
 -            if ($user) {
 +
 +            if ($user instanceof User) {
                  $this->out->elementStart('div', 'notice-options');
                  if (Event::handle('StartShowNoticeOptionItems', array($this))) {
                      $this->showReplyLink();
                  }
                  $this->out->elementEnd('div');
              }
 +
              Event::handle('EndShowNoticeOptions', array($this));
          }
      }
                  $class .= ' notice-source-'.$this->notice->source;
              }
              $id_prefix = (strlen($this->id_prefix) ? $this->id_prefix . '-' : '');
-             $this->out->elementStart('li', array('class' => $class,
+             $this->out->elementStart($this->item_tag, array('class' => $class,
                                                   'id' => "${id_prefix}notice-${id}"));
              Event::handle('EndOpenNoticeListItemElement', array($this));
          }
index eacd7753310f4753d1f0607b44ea6015e397f3a9,287c25cbe98455c12c698e7c31bbfa471554deea..6ce0e84a16d76347b7d3438eda68d51bbc03c152
@@@ -47,7 -47,7 +47,7 @@@ class AnonFavorAction extends Redirecti
       *
       * @return void
       */
 -    function handle($args)
 +    function handle(array $args=array())
      {
          parent::handle($args);
  
          $notice = Notice::getKV($id);
          $token  = $this->checkSessionToken();
  
-         if (Fave::existsForProfile($notice, $profile)) {
-             // TRANS: Client error.
-             throw new AlreadyFulfilledException(_m('This notice is already a favorite!'));
-         }
          // Throws exception
          $stored = Fave::addNew($profile, $notice);
  
index 8a273740534c639b6f681a78cbd2677681b23c2f,7e63b199e2285a9fd77327816a40a2a7dbe0c51d..7ff8f391b2466309df4d109866c1e16df438cf49
@@@ -52,19 -52,14 +52,19 @@@ class ApiFavoriteCreateAction extends A
  
      protected $needPost = true;
  
 +    /**
 +     * Take arguments for running
 +     *
 +     * @return boolean success flag
 +     */
      protected function prepare(array $args=array())
      {
          parent::prepare($args);
  
          $this->notice = Notice::getKV($this->arg('id'));
          if (!empty($this->notice->repeat_of)) {
 -                common_log(LOG_DEBUG, 'Trying to Fave '.$this->notice->id.', repeat of '.$this->notice->repeat_of);
 -                common_log(LOG_DEBUG, 'Will Fave '.$this->notice->repeat_of.' instead');
 +                common_debug('Trying to Fave '.$this->notice->id.', repeat of '.$this->notice->repeat_of);
 +                common_debug('Will Fave '.$this->notice->repeat_of.' instead');
                  $real_notice_id = $this->notice->repeat_of;
                  $this->notice = Notice::getKV($real_notice_id);
          }
          return true;
      }
  
 +    /**
 +     * Handle the request
 +     *
 +     * Check the format and show the user info
 +     *
 +     * @return void
 +     */
      protected function handle()
      {
          parent::handle();
              );
          }
  
-         // Note: Twitter lets you fave things repeatedly via API.
-         if (Fave::existsForProfile($this->notice, $this->scoped)) {
-             $this->clientError(
-                 // TRANS: Client error displayed when trying to mark a notice favourite that already is a favourite.
-                 _('This status is already a favorite.'),
-                 403,
-                 $this->format
-             );
+         try {
+             $stored = Fave::addNew($this->scoped, $this->notice);
+         } catch (AlreadyFulfilledException $e) {
+             // Note: Twitter lets you fave things repeatedly via API.
+             $this->clientError($e->getMessage(), 403);
          }
  
-         // throws exception on failure
-         $stored = Fave::addNew($this->scoped, $this->notice);
          if ($this->format == 'xml') {
              $this->showSingleXmlStatus($this->notice);
          } elseif ($this->format == 'json') {