Merge remote-tracking branch 'upstream/master'
authorRoland Haeder <roland@mxchange.org>
Sun, 15 Feb 2015 20:47:26 +0000 (21:47 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 15 Feb 2015 20:47:26 +0000 (21:47 +0100)
Conflicts:
actions/apiaccountverifycredentials.php
actions/apimediaupload.php
actions/apistatusesshow.php
actions/apitimelinepublic.php
actions/logout.php
actions/public.php
actions/register.php
lib/inboxnoticestream.php
plugins/Favorite/actions/apifavoritecreate.php
plugins/OStatus/actions/pushhub.php
plugins/OStatus/classes/Ostatus_profile.php
plugins/OStatus/scripts/update_ostatus_profiles.php
plugins/OpportunisticQM/lib/opportunisticqueuemanager.php
plugins/YammerImport/lib/yammerimporter.php
scripts/commandline.inc.php

Signed-off-by: Roland Haeder <roland@mxchange.org>
49 files changed:
1  2 
actions/apiaccountverifycredentials.php
actions/apimediaupload.php
actions/apistatusesshow.php
actions/apitimelinepublic.php
actions/attachment.php
actions/confirmaddress.php
actions/editpeopletag.php
actions/logout.php
actions/public.php
actions/recoverpassword.php
actions/register.php
actions/replies.php
actions/shownotice.php
actions/showprofiletag.php
actions/tag.php
classes/Notice.php
classes/User_group.php
extlib/DB/DataObject.php
extlib/DB/DataObject/Cast.php
extlib/DB/DataObject/Generator.php
extlib/DB/DataObject/createTables.php
lib/action.php
lib/attachmentlistitem.php
lib/default.php
lib/framework.php
lib/imagefile.php
lib/router.php
lib/util.php
plugins/AnonymousFave/actions/anonfavor.php
plugins/Bookmark/BookmarkPlugin.php
plugins/Favorite/actions/apifavoritecreate.php
plugins/Favorite/actions/atompubshowfavorite.php
plugins/Favorite/actions/showfavorites.php
plugins/Mapstraction/actions/map.php
plugins/OStatus/OStatusPlugin.php
plugins/OStatus/classes/FeedSub.php
plugins/OStatus/classes/Ostatus_profile.php
plugins/OStatus/lib/magicenvelope.php
plugins/OStatus/scripts/gcfeeds.php
plugins/OStatus/scripts/testfeed.php
plugins/OStatus/scripts/update_ostatus_profiles.php
plugins/Oembed/actions/oembed.php
plugins/QnA/classes/QnA_Answer.php
plugins/TwitterBridge/daemons/synctwitterfriends.php
plugins/TwitterBridge/daemons/twitterstatusfetcher.php
plugins/YammerImport/lib/yammerimporter.php
scripts/clear_jabber.php
scripts/commandline.inc.php
scripts/registeruser.php

index dfa366cbb61f492f0eede95beb7411c9a5d28763,9b98fa6d810ba384fbea24599c7f47ae4285c3bc..12daf3e1e6fe68150ea652154ee420bf32bf0ba8
@@@ -48,17 -48,9 +48,16 @@@ if (!defined('STATUSNET')) 
   */
  class ApiAccountVerifyCredentialsAction extends ApiAuthAction
  {
-      * @param array $args $_REQUEST data (unused)
 +    /**
 +     * Handle the request
 +     *
 +     * Check whether the credentials are valid and output the result
 +     *
-     function handle(array $args=array())
 +     * @return void
 +     */
+     protected function handle()
      {
-         parent::handle($args);
+         parent::handle();
  
          if (!in_array($this->format, array('xml', 'json'))) {
              // TRANS: Client error displayed when coming across a non-supported API method.
index 14c26d238f677f2cb0d92464e9d5613ae2db1655,8e59fec59c963c728b4c96456bcbd5def2247a86..8580b209a541893c0a699c32660a1ae2835dd751
@@@ -48,22 -48,14 +48,11 @@@ class ApiMediaUploadAction extends ApiA
       * Grab the file from the 'media' param, then store, and shorten
       *
       * @todo Upload throttle!
--     *
--     * @param array $args $_REQUEST data (unused)
--     *
       * @return void
       */
-     function handle(array $args=array())
+     protected function handle()
      {
-         parent::handle($args);
-         if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-             $this->clientError(
-                 // TRANS: Client error. POST is a HTTP command. It should not be translated.
-                 _('This method requires a POST.'),
-                 400, $this->format
-             );
-         }
+         parent::handle();
  
          // Workaround for PHP returning empty $_POST and $_FILES when POST
          // length > post_max_size in php.ini
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 6edbbdf293da8dc5fd7cd17d7d4df1fc57656de1,60aec3c83a48d37a21bf435fff4d0da2aa513424..b6d4efbf2303008034ea2c9357a53d71afe6007f
@@@ -54,36 -52,22 +52,27 @@@ class LogoutAction extends ManagedActio
          return false;
      }
  
-      * @param array $args array of arguments
-      *
 +    /**
 +     * Class handler.
 +     *
-     function handle(array $args=array())
 +     * @return nothing
 +     */
+     protected function doPreparation()
      {
-         parent::handle($args);
          if (!common_logged_in()) {
-             // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
-             $this->clientError(_('Not logged in.'));
-         } else {
-             if (Event::handle('StartLogout', array($this))) {
-                 $this->logout();
-             }
-             Event::handle('EndLogout', array($this));
-             if (common_config('singleuser', 'enabled')) {
-                 $user = User::singleUser();
-                 common_redirect(common_local_url('showstream',
-                                                  array('nickname' => $user->nickname)));
-             } else {
-                 common_redirect(common_local_url('public'), 303);
-             }
+             // TRANS: Error message displayed when trying to logout even though you are not logged in.
+             throw new AlreadyFulfilledException(_('Cannot log you out if you are not logged in.'));
          }
+         if (Event::handle('StartLogout', array($this))) {
+             $this->logout();
+         }
+         Event::handle('EndLogout', array($this));
+         common_redirect(common_local_url('startpage'));
      }
  
-     function logout()
+     // Accessed through the action on events
+     public function logout()
      {
          common_set_user(null);
          common_real_login(false); // not logged in
index 8e5da476466a93f36203917cf319e9c726ad4e31,06ee75b8d1c5fa9b72b52393b0554c90f1669f3a..b45bbeae7f78d4284dea3bf9c323231441c577f7
@@@ -53,23 -53,16 +53,23 @@@ class PublicAction extends ManagedActio
  
      var $page = null;
      var $notice;
-     var $userProfile = null;
+     protected $stream = null;
  
 -    function isReadOnly($args)
 +    function isReadOnly(array $args=array())
      {
          return true;
      }
  
-     function prepare(array $args=array())
 +    /**
 +     * Read and validate arguments
 +     *
 +     * @param array $args URL parameters
 +     *
 +     * @return boolean success value
 +     */
+     protected function doPreparation()
      {
-         parent::prepare($args);
          $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
  
          if ($this->page > MAX_PUBLIC_PAGE) {
          return true;
      }
  
-     function handle(array $args=array())
 +    /**
 +     * handle request
 +     *
 +     * Show the public stream, using recipe method showPage()
 +     *
 +     * @param array $args arguments, mostly unused
 +     *
 +     * @return void
 +     */
+     protected function streamPrepare()
      {
-         parent::handle($args);
-         $this->showPage();
+         if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
+             $this->stream = new PublicNoticeStream($this->scoped);
+         } else {
+             $this->stream = new ThreadingPublicNoticeStream($this->scoped);
+         }
      }
  
      /**
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc actions/tag.php
Simple merge
Simple merge
Simple merge
index 1232d184dfad1666e9fe532c6c29dbf832635f78,684a98c92a4c3a1e42edf8ba37ac88a5d4eb20e7..684a98c92a4c3a1e42edf8ba37ac88a5d4eb20e7
mode 100644,100755..100644
index 59cc0af279dcf2834b4bc71d06a51d163694ed5f,a31f536cd53e1f0b270af1cb270ddee9a693ef52..a31f536cd53e1f0b270af1cb270ddee9a693ef52
mode 100644,100755..100644
index c06d6ed610244b86ac83936e497dfd7d56a847ae,a712e6d9eb5a4d9580a7ef6a177dea0ba7175b7e..a712e6d9eb5a4d9580a7ef6a177dea0ba7175b7e
mode 100644,100755..100644
index ed2e738b78514d5cf82fbc7623cb1d298ad182bc,1295d252b88e4328b54a3e515421dcdb8f9e2923..1295d252b88e4328b54a3e515421dcdb8f9e2923
mode 100644,100755..100644
diff --cc lib/action.php
Simple merge
Simple merge
diff --cc lib/default.php
Simple merge
Simple merge
Simple merge
diff --cc lib/router.php
Simple merge
diff --cc lib/util.php
Simple merge
Simple merge
index ea94958ebcc7955483b457dab66a2537d2cbdec9,736bd7b0a19eaa720cf49040bd9255912f9c4afa..8a273740534c639b6f681a78cbd2677681b23c2f
@@@ -50,22 -50,16 +50,21 @@@ class ApiFavoriteCreateAction extends A
  {
      var $notice = null;
  
-      * @param array $args $_REQUEST args
-      *
+     protected $needPost = true;
 +    /**
 +     * Take arguments for running
 +     *
-     function prepare(array $args=array())
 +     * @return boolean success flag
 +     */
+     protected function prepare(array $args=array())
      {
          parent::prepare($args);
  
-         $this->user   = $this->auth_user;
          $this->notice = Notice::getKV($this->arg('id'));
-         if ($this->notice->repeat_of != '' ) {
+         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;
      }
  
-      * @param array $args $_REQUEST data (unused)
-      *
 +    /**
 +     * Handle the request
 +     *
 +     * Check the format and show the user info
 +     *
-     function handle(array $args=array())
 +     * @return void
 +     */
+     protected function handle()
      {
-         parent::handle($args);
-         if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-             $this->clientError(
-                 // TRANS: Client error. POST is a HTTP command. It should not be translated.
-                 _('This method requires a POST.'),
-                 400,
-                 $this->format
-             );
-             return;
-         }
+         parent::handle();
  
          if (!in_array($this->format, array('xml', 'json'))) {
              $this->clientError(
Simple merge
Simple merge
Simple merge
index d698ba81a36339c56c315ef9bbb1310d8f157f11,79098c64048ed31705b54ecfb94259619dad826d..d5ad33a91e8c258582d0f7cc33d473af55a602e6
@@@ -1261,12 -1259,15 +1260,15 @@@ class Ostatus_profile extends Managed_D
  
          // @todo FIXME: This should be better encapsulated
          // ripped from oauthstore.php (for old OMB client)
 -        $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
 +        $temp_filename = tempnam(common_get_temp_dir(), 'listener_avatar');
          try {
-             if (!copy($url, $temp_filename)) {
-                 // TRANS: Server exception. %s is a URL.
-                 throw new ServerException(sprintf(_m('Unable to fetch avatar from %s to %s.'), $url, $temp_filename));
+             $imgData = HTTPClient::quickGet($url);
+             // Make sure it's at least an image file. ImageFile can do the rest.
+             if (false === getimagesizefromstring($imgData)) {
+                 throw new UnsupportedMediaException(_('Downloaded group avatar was not an image.'));
              }
+             file_put_contents($temp_filename, $imgData);
+             unset($imgData);    // No need to carry this in memory.
  
              if ($this->isGroup()) {
                  $id = $this->group_id;
Simple merge
index 94ead535fb1eb31127b0d1273f4bd4ee0e1c4a55,a95cd54dbc8d8b636106e598a4ddeca56b7bcc62..f1db4b358ff35b0497457ad75ef27086a411ee30
@@@ -24,10 -27,15 +27,15 @@@ $helptext = <<<END_OF_HEL
  gcfeeds.php [options]
  Clean up feeds that no longer have subscribers.
  
+     -d --delete-inactive    Delete inactive feeds from feedsub table.
  END_OF_HELP;
  
 -require_once INSTALLDIR.'/scripts/commandline.inc';
 +require_once INSTALLDIR.'/scripts/commandline.inc.php';
  
+ $delete_inactive = have_option('d', 'delete-inactive');
+ $delcount = 0;
  $feedsub = new FeedSub();
  $feedsub->find();
  while ($feedsub->fetch()) {
Simple merge
Simple merge
Simple merge
index 6af0302f7749f7d3e420c4181493c27fdcac7587,0992882670f251b633d654c9e362f39c0567109a..abd41dd99e271028e44acdf54d1524e5fd8e6695
@@@ -161,9 -159,13 +161,13 @@@ class YammerImporte
              // Save "likes" as favorites...
              foreach ($data['faves'] as $nickname) {
                  $user = User::getKV('nickname', $nickname);
 -                if ($user) {
 +                if ($user instanceof User) {
-                     Fave::addNew($user->getProfile(), $notice);
+                     try {
+                         Fave::addNew($user->getProfile(), $notice);
+                     } catch (Exception $e) {
+                         // failed, let's move to the next
+                         common_debug('YammerImport failed favoriting a notice: '.$e->getMessage());
+                     }
                  }
              }
  
Simple merge
index 0a5257cdd5a2ec35652bbd890b0e4788bd8cc2bc,0000000000000000000000000000000000000000..1244187b873bb40ec0d2dd7f00fd16c766530e1b
mode 100644,000000..100644
--- /dev/null
@@@ -1,247 -1,0 +1,248 @@@
 +<?php
 +/*
 + * StatusNet - a distributed open-source microblogging tool
 + * Copyright (C) 2008, 2009, StatusNet, Inc.
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU Affero General Public License as published by
 + * the Free Software Foundation, either version 3 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU Affero General Public License for more details.
 + *
 + * You should have received a copy of the GNU Affero General Public License
 + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +// -*- mode: php -*-
 +
 +# Abort if called from a web server
 +
 +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
 +    print "This script must be run from the command line\n";
 +    exit();
 +}
 +
 +define('GNUSOCIAL', true);
 +define('STATUSNET', true); //compatibility
 +
 +// Set various flags so we don't time out on long-running processes
 +
 +ini_set("max_execution_time", "0");
 +ini_set("max_input_time", "0");
 +set_time_limit(0);
 +mb_internal_encoding('UTF-8');
 +error_reporting(0);
++# DEBUG: error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
 +
 +// Add extlib to our path so we can get Console_Getopt
 +
 +$_extra_path = array(INSTALLDIR.'/extlib/');
 +
 +set_include_path(implode(PATH_SEPARATOR, $_extra_path) . PATH_SEPARATOR . get_include_path());
 +
 +require_once 'Console/Getopt.php';
 +
 +// Note: $shortoptions and $longoptions should be pre-defined!
 +
 +$_default_shortoptions = 'qvhc:s:p:';
 +
 +$_default_longoptions = array('quiet', 'verbose', 'help', 'conf=', 'server=', 'path=');
 +
 +if (isset($shortoptions)) {
 +    $shortoptions .= $_default_shortoptions;
 +} else {
 +    $shortoptions = $_default_shortoptions;
 +}
 +
 +if (isset($longoptions)) {
 +    $longoptions = array_merge($longoptions, $_default_longoptions);
 +} else {
 +    $longoptions = $_default_longoptions;
 +}
 +
 +$parser = new Console_Getopt();
 +
 +$result = $parser->getopt($argv, $shortoptions, $longoptions);
 +
 +if (PEAR::isError($result)) {
 +    print $result->getMessage()."\n";
 +    exit(1);
 +} else {
 +    list($options, $args) = $result;
 +}
 +
 +function show_help()
 +{
 +    global $helptext;
 +
 +    $_default_help_text = <<<END_OF_DEFAULT
 +      General options:
 +
 +    -q --quiet           Quiet (little output)
 +    -v --verbose         Verbose (lots of output)
 +    -c --conf=<filename> Use <filename> as config file
 +    -s --server=<name>   Use <name> as server name
 +    -p --path=<path>     Use <path> as path name
 +    -h --help            Show this message and quit.
 +
 +END_OF_DEFAULT;
 +    if (isset($helptext)) {
 +        print $helptext;
 +    }
 +    print $_default_help_text;
 +    exit(0);
 +}
 +
 +foreach ($options as $option) {
 +
 +    switch ($option[0]) {
 +     case '--server':
 +     case 's':
 +        $server = $option[1];
 +        break;
 +
 +     case '--path':
 +     case 'p':
 +        $path = $option[1];
 +        break;
 +
 +     case '--conf':
 +     case 'c':
 +        $conffile = $option[1];
 +        break;
 +
 +     case '--help':
 +     case 'h':
 +        show_help();
 +    }
 +}
 +
 +require_once INSTALLDIR . '/lib/common.php';
 +
 +set_error_handler('common_error_handler');
 +
 +// Set up the language infrastructure so we can localize anything that
 +// needs to be sent out to users, such as mail notifications.
 +common_init_language();
 +
 +function _make_matches($opt, $alt)
 +{
 +    $matches = array();
 +
 +    if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) {
 +        $matches[] = '--'.$opt;
 +    } else {
 +        $matches[] = $opt;
 +    }
 +
 +    if (!empty($alt)) {
 +        if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) {
 +            $matches[] = '--'.$alt;
 +        } else {
 +            $matches[] = $alt;
 +        }
 +    }
 +
 +    return $matches;
 +}
 +
 +function have_option($opt, $alt=null)
 +{
 +    global $options;
 +
 +    $matches = _make_matches($opt, $alt);
 +
 +    foreach ($options as $option) {
 +        if (in_array($option[0], $matches)) {
 +            return true;
 +        }
 +    }
 +
 +    return false;
 +}
 +
 +function get_option_value($opt, $alt=null)
 +{
 +    global $options;
 +
 +    $matches = _make_matches($opt, $alt);
 +
 +    foreach ($options as $option) {
 +        if (in_array($option[0], $matches)) {
 +            return $option[1];
 +        }
 +    }
 +
 +    return null;
 +}
 +
 +class NoUserArgumentException extends Exception
 +{
 +}
 +
 +function getUser()
 +{
 +    $user = null;
 +
 +    if (have_option('i', 'id')) {
 +        $id = get_option_value('i', 'id');
 +        $user = User::getKV('id', $id);
 +        if (empty($user)) {
 +            throw new Exception("Can't find user with id '$id'.");
 +        }
 +    } else if (have_option('n', 'nickname')) {
 +        $nickname = get_option_value('n', 'nickname');
 +        $user = User::getKV('nickname', $nickname);
 +        if (empty($user)) {
 +            throw new Exception("Can't find user with nickname '$nickname'");
 +        }
 +    } else {
 +        throw new NoUserArgumentException("No user argument specified.");
 +    }
 +
 +    return $user;
 +}
 +
 +/** "Printf not quiet" */
 +
 +function printfnq()
 +{
 +    if (have_option('q', 'quiet')) {
 +        return null;
 +    }
 +
 +    $cargs  = func_num_args();
 +
 +    if ($cargs == 0) {
 +        return 0;
 +    }
 +
 +    $args   = func_get_args();
 +    $format = array_shift($args);
 +
 +    return vprintf($format, $args);
 +}
 +
 +/** "Print when verbose" */
 +
 +function printfv()
 +{
 +    if (!have_option('v', 'verbose')) {
 +        return null;
 +    }
 +
 +    $cargs  = func_num_args();
 +
 +    if ($cargs == 0) {
 +        return 0;
 +    }
 +
 +    $args   = func_get_args();
 +    $format = array_shift($args);
 +
 +    return vprintf($format, $args);
 +}
Simple merge