]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.9.x' into 1.0.x
authorBrion Vibber <brion@pobox.com>
Thu, 28 Oct 2010 23:26:34 +0000 (16:26 -0700)
committerBrion Vibber <brion@pobox.com>
Thu, 28 Oct 2010 23:26:34 +0000 (16:26 -0700)
1  2 
README
actions/apiaccountupdatedeliverydevice.php
classes/User.php
lib/util.php

diff --combined README
index 1adde7fac7335c81ee3012b0ff4041948cbefc3a,6872634b88835f89ff599de749ca075601c24d23..a4189cfae8741a36352838e80a7f41859264e32d
--- 1/README
--- 2/README
+++ b/README
@@@ -3,7 -3,7 +3,7 @@@ READM
  ------
  
  StatusNet 0.9.6 "Man on the Moon"
- 19 October 2010
+ 25 October 2010 - RELEASE CANDIDATE
  
  This is the README file for StatusNet, the Open Source microblogging
  platform. It includes installation instructions, descriptions of
@@@ -865,7 -865,9 +865,7 @@@ sslserver: use an alternate server nam
      parameters correctly so that both the SSL server and the
      "normal" server can access the session cookie and
      preferably other cookies as well.
 -shorturllength: Length of URL at which URLs in a message exceeding 140
 -    characters will be sent to the user's chosen
 -    shortening service.
 +shorturllength: ignored. See 'url' section below.
  dupelimit: minimum time allowed for one person to say the same thing
      twice. Default 60s. Anything lower is considered a user
      or UI error.
@@@ -1528,22 -1530,6 +1528,22 @@@ external: external links in notices. On
      nofollowed on profile, notice, and favorites page. Default is
      'sometimes'.
  
 +url
 +---
 +
 +Everybody loves URL shorteners. These are some options for fine-tuning
 +how and when the server shortens URLs.
 +
 +shortener: URL shortening service to use by default. Users can override
 +           individually. 'ur1.ca' by default.
 +maxlength: If an URL is strictly longer than this limit, it will be
 +           shortened. Note that the URL shortener service may return an
 +           URL longer than this limit. Defaults to 25. Users can
 +           override. If set to 0, all URLs will be shortened.
 +maxnoticelength: If a notice is strictly longer than this limit, all
 +           URLs in the notice will be shortened. Users can override.
 +           -1 means the text limit for notices.
 +
  Plugins
  =======
  
index d5be6dc6528cb77ab36c9d4e828f3ad5de310d95,ec87c4c953b74e5fedcdcb44e0a09d1b58622b3d..e7d44dc44d879c1965ad5ae6d36f3dd643b44fff
@@@ -53,7 -53,6 +53,6 @@@ class ApiAccountUpdateDeliveryDeviceAct
       * @param array $args $_REQUEST args
       *
       * @return boolean success flag
-      *
       */
      function prepare($args)
      {
          if (strtolower($this->device) == 'sms') {
              $this->user->smsnotify = true;
          } elseif (strtolower($this->device) == 'im') {
 -            $this->user->jabbernotify = true;
 +            //TODO IM is pluginized now, so what should we do?
 +            //Enable notifications for all IM plugins?
 +            //For now, don't do anything
 +            //$this->user->jabbernotify = true;
          } elseif (strtolower($this->device == 'none')) {
              $this->user->smsnotify    = false;
 -            $this->user->jabbernotify = false;
 +            //TODO IM is pluginized now, so what should we do?
 +            //Disable notifications for all IM plugins?
 +            //For now, don't do anything
 +            //$this->user->jabbernotify = false;
          }
  
          $result = $this->user->update($original);
diff --combined classes/User.php
index 9188938b18e90da331380125559b4bc9dd60fdfa,7345dc7f94ad68aa31277d4a9a21ad4d0a21d00e..5914f0b806efaab5ea305e8431d0cd511bf4f9a9
@@@ -48,6 -48,11 +48,6 @@@ class User extends Memcached_DataObjec
      public $language;                        // varchar(50)
      public $timezone;                        // varchar(50)
      public $emailpost;                       // tinyint(1)   default_1
 -    public $jabber;                          // varchar(255)  unique_key
 -    public $jabbernotify;                    // tinyint(1)
 -    public $jabberreplies;                   // tinyint(1)
 -    public $jabbermicroid;                   // tinyint(1)   default_1
 -    public $updatefrompresence;              // tinyint(1)
      public $sms;                             // varchar(64)  unique_key
      public $carrier;                         // int(4)
      public $smsnotify;                       // tinyint(1)
@@@ -88,7 -93,7 +88,7 @@@
      {
          $this->_connect();
          $parts = array();
 -        foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
 +        foreach (array('nickname', 'email', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
              if (strcmp($this->$k, $orig->$k) != 0) {
                  $parts[] = $k . ' = ' . $this->_quote($this->$k);
              }
      static function singleUser()
      {
          if (common_config('singleuser', 'enabled')) {
+             $user = null;
              $nickname = common_config('singleuser', 'nickname');
-             if ($nickname) {
+             if (!empty($nickname)) {
                  $user = User::staticGet('nickname', $nickname);
-             } else {
+             }
+             // if there was no nickname or no user by that nickname,
+             // try the site owner.
+             if (empty($user)) {
                  $user = User::siteOwner();
              }
-             if ($user) {
+             if (!empty($user)) {
                  return $user;
              } else {
                  // TRANS: Server exception.
diff --combined lib/util.php
index f5077f6011e96ef33f872aa7ceac78886a38ad45,d50fa2081432246d91eab3f7c196b5a0c81ea443..5094b2712644d066a2730f0f91c3e3d886f87f95
@@@ -157,38 -157,22 +157,38 @@@ function common_timezone(
      return common_config('site', 'timezone');
  }
  
 +function common_valid_language($lang)
 +{
 +    if ($lang) {
 +        // Validate -- we don't want to end up with a bogus code
 +        // left over from some old junk.
 +        foreach (common_config('site', 'languages') as $code => $info) {
 +            if ($info['lang'] == $lang) {
 +                return true;
 +            }
 +        }
 +    }
 +    return false;
 +}
 +
  function common_language()
  {
 +    // Allow ?uselang=xx override, very useful for debugging
 +    // and helping translators check usage and context.
 +    if (isset($_GET['uselang'])) {
 +        $uselang = strval($_GET['uselang']);
 +        if (common_valid_language($uselang)) {
 +            return $uselang;
 +        }
 +    }
 +
      // If there is a user logged in and they've set a language preference
      // then return that one...
      if (_have_config() && common_logged_in()) {
          $user = common_current_user();
 -        $user_language = $user->language;
 -
 -        if ($user->language) {
 -            // Validate -- we don't want to end up with a bogus code
 -            // left over from some old junk.
 -            foreach (common_config('site', 'languages') as $code => $info) {
 -                if ($info['lang'] == $user_language) {
 -                    return $user_language;
 -                }
 -            }
 +
 +        if (common_valid_language($user->language)) {
 +            return $user->language;
          }
      }
  
@@@ -342,7 -326,8 +342,8 @@@ function common_set_cookie($key, $value
                       $value,
                       $expiration,
                       $cookiepath,
-                      $server);
+                      $server,
+                      common_config('site', 'ssl')=='always');
  }
  
  define('REMEMBERME', 'rememberme');
@@@ -927,21 -912,9 +928,21 @@@ function common_linkify($url) 
  
  function common_shorten_links($text, $always = false)
  {
 -    $maxLength = Notice::maxContent();
 -    if (!$always && ($maxLength == 0 || mb_strlen($text) <= $maxLength)) return $text;
 -    return common_replace_urls_callback($text, array('File_redirection', 'makeShort'));
 +    common_debug("common_shorten_links() called");
 +
 +    $user = common_current_user();
 +
 +    $maxLength = User_urlshortener_prefs::maxNoticeLength($user);
 +
 +    common_debug("maxLength = $maxLength");
 +
 +    if ($always || mb_strlen($text) > $maxLength) {
 +        common_debug("Forcing shortening");
 +        return common_replace_urls_callback($text, array('File_redirection', 'forceShort'));
 +    } else {
 +        common_debug("Not forcing shortening");
 +        return common_replace_urls_callback($text, array('File_redirection', 'makeShort'));
 +    }
  }
  
  /**
@@@ -1325,8 -1298,14 +1326,8 @@@ function common_redirect($url, $code=30
      exit;
  }
  
 -function common_broadcast_notice($notice, $remote=false)
 -{
 -    // DO NOTHING!
 -}
 +// Stick the notice on the queue
  
 -/**
 - * Stick the notice on the queue.
 - */
  function common_enqueue_notice($notice)
  {
      static $localTransports = array('omb',
          $transports[] = 'plugin';
      }
  
 -    $xmpp = common_config('xmpp', 'enabled');
 -
 -    if ($xmpp) {
 -        $transports[] = 'jabber';
 -    }
 -
      // We can skip these for gatewayed notices.
      if ($notice->isLocal()) {
          $transports = array_merge($transports, $localTransports);
 -        if ($xmpp) {
 -            $transports[] = 'public';
 -        }
      }
  
      if (Event::handle('StartEnqueueNotice', array($notice, &$transports))) {
@@@ -1880,6 -1868,21 +1881,6 @@@ function common_session_token(
      return $_SESSION['token'];
  }
  
 -function common_cache_key($extra)
 -{
 -    return Cache::key($extra);
 -}
 -
 -function common_keyize($str)
 -{
 -    return Cache::keyize($str);
 -}
 -
 -function common_memcache()
 -{
 -    return Cache::instance();
 -}
 -
  function common_license_terms($uri)
  {
      if(preg_match('/creativecommons.org\/licenses\/([^\/]+)/', $uri, $matches)) {
@@@ -1920,42 -1923,30 +1921,42 @@@ function common_database_tablename($tab
  /**
   * Shorten a URL with the current user's configured shortening service,
   * or ur1.ca if configured, or not at all if no shortening is set up.
 - * Length is not considered.
   *
 - * @param string $long_url
 + * @param string  $long_url original URL
 + * @param boolean $force    Force shortening (used when notice is too long)
 + *
   * @return string may return the original URL if shortening failed
   *
   * @fixme provide a way to specify a particular shortener
   * @fixme provide a way to specify to use a given user's shortening preferences
   */
 -function common_shorten_url($long_url)
 +
 +function common_shorten_url($long_url, $force = false)
  {
 +    common_debug("Shortening URL '$long_url' (force = $force)");
 +
      $long_url = trim($long_url);
 +
      $user = common_current_user();
 -    if (empty($user)) {
 -        // common current user does not find a user when called from the XMPP daemon
 -        // therefore we'll set one here fix, so that XMPP given URLs may be shortened
 -        $shortenerName = 'ur1.ca';
 -    } else {
 -        $shortenerName = $user->urlshorteningservice;
 +
 +    $maxUrlLength = User_urlshortener_prefs::maxUrlLength($user);
 +    common_debug("maxUrlLength = $maxUrlLength");
 +
 +    // $force forces shortening even if it's not strictly needed
 +
 +    if (mb_strlen($long_url) < $maxUrlLength && !$force) {
 +        common_debug("Skipped shortening URL.");
 +        return $long_url;
      }
  
 -    if(Event::handle('StartShortenUrl', array($long_url,$shortenerName,&$shortenedUrl))){
 +    $shortenerName = User_urlshortener_prefs::urlShorteningService($user);
 +
 +    common_debug("Shortener name = '$shortenerName'");
 +
 +    if (Event::handle('StartShortenUrl', array($long_url, $shortenerName, &$shortenedUrl))) {
          //URL wasn't shortened, so return the long url
          return $long_url;
 -    }else{
 +    } else {
          //URL was shortened, so return the result
          return trim($shortenedUrl);
      }