]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.8.x' into 0.9.x
authorEvan Prodromou <evan@controlyourself.ca>
Fri, 21 Aug 2009 19:42:11 +0000 (15:42 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Fri, 21 Aug 2009 19:42:11 +0000 (15:42 -0400)
Conflicts:
actions/updateprofile.php
actions/userauthorization.php
classes/User_group.php
index.php
install.php
lib/accountsettingsaction.php
lib/logingroupnav.php

20 files changed:
1  2 
README
actions/newnotice.php
actions/profilesettings.php
actions/register.php
actions/remotesubscribe.php
actions/shownotice.php
actions/twitapistatuses.php
actions/updateprofile.php
actions/userauthorization.php
classes/Notice.php
classes/User_group.php
index.php
install.php
js/util.js
lib/action.php
lib/common.php
lib/facebookaction.php
lib/unqueuemanager.php
lib/util.php
scripts/maildaemon.php

diff --cc README
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index b10554e8ba64ec28ee034b7e3a6993e44f9ab759,f6cb277aa7a6b98c1f11cbf6514b3dbe2b40a8fd..b020413b3563fd3e2ebc6b50872ba6a4aec74f50
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  
 -if (!defined('LACONICA')) { exit(1); }
 +if (!defined('LACONICA')) {
 +    exit(1);
 +}
  
 -require_once(INSTALLDIR.'/lib/omb.php');
 +require_once INSTALLDIR.'/lib/omb.php';
 +require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
  
 +/**
 + * Handle an updateprofile action
 + *
 + * @category Action
 + * @package  Laconica
 + * @author   Evan Prodromou <evan@controlyourself.ca>
 + * @author   Robin Millette <millette@controlyourself.ca>
 + * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 + * @link     http://laconi.ca/
 + */
  class UpdateprofileAction extends Action
  {
 -    
 -    function handle($args)
 -    {
 -        parent::handle($args);
 -        try {
 -            common_remove_magic_from_request();
 -            $req = OAuthRequest::from_request('POST', common_local_url('updateprofile'));
 -            # Note: server-to-server function!
 -            $server = omb_oauth_server();
 -            list($consumer, $token) = $server->verify_request($req);
 -            if ($this->update_profile($req, $consumer, $token)) {
 -                header('HTTP/1.1 200 OK');
 -                header('Content-type: text/plain');
 -                print "omb_version=".OMB_VERSION_01;
 -            }
 -        } catch (OAuthException $e) {
 -            $this->serverError($e->getMessage());
 -            return;
 -        }
 -    }
  
 -    function update_profile($req, $consumer, $token)
 +    /**
 +     * For initializing members of the class.
 +     *
 +     * @param array $argarray misc. arguments
 +     *
 +     * @return boolean true
 +     */
 +    function prepare($argarray)
      {
-         parent::prepare($argarray);
-         $license      = $_POST['omb_listenee_license'];
-         $site_license = common_config('license', 'url');
-         if (!common_compatible_license($license, $site_license)) {
-             $this->clientError(sprintf(_('Listenee stream license ‘%s’ is not '.
-                                           'compatible with site license ‘%s’.'),
-                                        $license, $site_license);
+         $version = $req->get_parameter('omb_version');
+         if ($version != OMB_VERSION_01) {
+             $this->clientError(_('Unsupported OMB version'), 400);
+             return false;
+         }
+         # First, check to see if listenee exists
+         $listenee =  $req->get_parameter('omb_listenee');
+         $remote = Remote_profile::staticGet('uri', $listenee);
+         if (!$remote) {
+             $this->clientError(_('Profile unknown'), 404);
+             return false;
+         }
+         # Second, check to see if they should be able to post updates!
+         # We see if there are any subscriptions to that remote user with
+         # the given token.
+         $sub = new Subscription();
+         $sub->subscribed = $remote->id;
+         $sub->token = $token->key;
+         if (!$sub->find(true)) {
+             $this->clientError(_('You did not send us that profile'), 403);
+             return false;
+         }
+         $profile = Profile::staticGet('id', $remote->id);
+         if (!$profile) {
+             # This one is our fault
+             $this->serverError(_('Remote profile with no matching profile'), 500);
+             return false;
+         }
+         $nickname = $req->get_parameter('omb_listenee_nickname');
+         if ($nickname && !Validate::string($nickname, array('min_length' => 1,
+                                                             'max_length' => 64,
+                                                             'format' => NICKNAME_FMT))) {
+             $this->clientError(_('Nickname must have only lowercase letters and numbers and no spaces.'));
+             return false;
+         }
+         $license = $req->get_parameter('omb_listenee_license');
+         if ($license && !common_valid_http_url($license)) {
+             $this->clientError(sprintf(_("Invalid license URL '%s'"), $license));
              return false;
          }
 -        $profile_url = $req->get_parameter('omb_listenee_profile');
 -        if ($profile_url && !common_valid_http_url($profile_url)) {
 -            $this->clientError(sprintf(_("Invalid profile URL '%s'."), $profile_url));
 -            return false;
 -        }
 -        # optional stuff
 -        $fullname = $req->get_parameter('omb_listenee_fullname');
 -        if ($fullname && mb_strlen($fullname) > 255) {
 -            $this->clientError(_("Full name is too long (max 255 chars)."));
 -            return false;
 -        }
 -        $homepage = $req->get_parameter('omb_listenee_homepage');
 -        if ($homepage && (!common_valid_http_url($homepage) || mb_strlen($homepage) > 255)) {
 -            $this->clientError(sprintf(_("Invalid homepage '%s'"), $homepage));
 -            return false;
 -        }
 -        $bio = $req->get_parameter('omb_listenee_bio');
 -        if ($bio && mb_strlen($bio) > 140) {
 -            $this->clientError(_("Bio is too long (max 140 chars)."));
 -            return false;
 -        }
 -        $location = $req->get_parameter('omb_listenee_location');
 -        if ($location && mb_strlen($location) > 255) {
 -            $this->clientError(_("Location is too long (max 255 chars)."));
 -            return false;
 -        }
 -        $avatar = $req->get_parameter('omb_listenee_avatar');
 -        if ($avatar) {
 -            if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
 -                $this->clientError(sprintf(_("Invalid avatar URL '%s'"), $avatar));
 -                return false;
 -            }
 -            $size = @getimagesize($avatar);
 -            if (!$size) {
 -                $this->clientError(sprintf(_("Can't read avatar URL '%s'"), $avatar));
 -                return false;
 -            }
 -            if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
 -                $this->clientError(sprintf(_("Wrong size image at '%s'"), $avatar));
 -                return false;
 -            }
 -            if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
 -                                          IMAGETYPE_PNG))) {
 -                $this->clientError(sprintf(_("Wrong image type for '%s'"), $avatar));
 -                return false;
 -            }
 -        }
 -
 -        $orig_profile = clone($profile);
 +        return true;
 +    }
  
 -        /* Use values even if they are an empty string. Parsing an empty string in
 -           updateProfile is the specified way of clearing a parameter in OMB. */
 -        if (!is_null($nickname)) {
 -            $profile->nickname = $nickname;
 -        }
 -        if (!is_null($profile_url)) {
 -            $profile->profileurl = $profile_url;
 -        }
 -        if (!is_null($fullname)) {
 -            $profile->fullname = $fullname;
 -        }
 -        if (!is_null($homepage)) {
 -            $profile->homepage = $homepage;
 -        }
 -        if (!is_null($bio)) {
 -            $profile->bio = $bio;
 -        }
 -        if (!is_null($location)) {
 -            $profile->location = $location;
 -        }
 +    function handle($args)
 +    {
 +        parent::handle($args);
  
 -        if (!$profile->update($orig_profile)) {
 -            $this->serverError(_('Could not save new profile info'), 500);
 -            return false;
 -        } else {
 -            if ($avatar) {
 -                $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
 -                copy($avatar, $temp_filename);
 -                $imagefile = new ImageFile($profile->id, $temp_filename);
 -                $filename = Avatar::filename($profile->id,
 -                                     image_type_to_extension($imagefile->type),
 -                                     null,
 -                                     common_timestamp());
 -                rename($temp_filename, Avatar::path($filename));
 -                if (!$profile->setOriginal($filename)) {
 -                    $this->serverError(_('Could not save avatar info'), 500);
 -                    return false;
 -                }
 -            }
 -            return true;
 +        try {
 +            $srv = new OMB_Service_Provider(null, omb_oauth_datastore(),
 +                                            omb_oauth_server());
 +            $srv->handleUpdateProfile();
 +        } catch (Exception $e) {
 +            $this->serverError($e->getMessage());
 +            return;
          }
      }
--}
- ?>
++}
index 54e0ee920b4a1ebbf9b822972952401c070e2983,7e397e8888b216ed5512cb8f57b0dcb050e2bcf4..3e7be97479116dfe634b963a441228fd9e8c95bf
@@@ -60,10 -44,14 +60,14 @@@ class UserauthorizationAction extends A
              $this->sendAuthorization();
          } else {
              if (!common_logged_in()) {
 -                # Go log in, and then come back
 +                /* Go log in, and then come back. */
                  common_set_returnto($_SERVER['REQUEST_URI']);
  
-                 common_redirect(common_local_url('login'));
+                 if (!common_config('site', 'openidonly')) {
+                     common_redirect(common_local_url('login'));
+                 } else {
+                     common_redirect(common_local_url('openidlogin'));
+                 }
                  return;
              }
  
              }
              if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
                                            IMAGETYPE_PNG))) {
 -                throw new OAuthException("Wrong image type for '$avatar'");
 +                throw new Exception(sprintf(_('Wrong image type for avatar URL '.
 +                                              '‘%s’.'), $avatar));
              }
          }
 -        $callback = $_GET['oauth_callback'];
 -        if ($callback && !common_valid_http_url($callback)) {
 -            throw new OAuthException("Invalid callback URL '$callback'");
 -        }
 -        if ($callback && $callback == common_local_url('finishremotesubscribe')) {
 -            throw new OAuthException("Callback URL '$callback' is for local site.");
 -        }
      }
  }
- ?>
Simple merge
index e6e79ca6a3daa066c7e253d2124bea8a86d64917,ea19cbb97acff0b2a752ebc1793d02e81a94903b..310ecff1ef766726197eaa06457b6a3c5cfcc405
@@@ -298,19 -298,44 +298,60 @@@ class User_group extends Memcached_Data
          return $ids;
      }
  
 +    static function maxDescription()
 +    {
 +        $desclimit = common_config('group', 'desclimit');
 +        // null => use global limit (distinct from 0!)
 +        if (is_null($desclimit)) {
 +            $desclimit = common_config('site', 'textlimit');
 +        }
 +        return $desclimit;
 +    }
 +
 +    static function descriptionTooLong($desc)
 +    {
 +        $desclimit = self::maxDescription();
 +        return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit));
 +    }
++
+     function asAtomEntry($namespace=false, $source=false)
+     {
+         $xs = new XMLStringer(true);
+         if ($namespace) {
+             $attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
+                            'xmlns:thr' => 'http://purl.org/syndication/thread/1.0');
+         } else {
+             $attrs = array();
+         }
+         $xs->elementStart('entry', $attrs);
+         if ($source) {
+             $xs->elementStart('source');
+             $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name'));
+             $xs->element('link', array('href' => $this->permalink()));
+         }
+         if ($source) {
+             $xs->elementEnd('source');
+         }
+         $xs->element('title', null, $this->nickname);
+         $xs->element('summary', null, $this->description);
+         $xs->element('link', array('rel' => 'alternate',
+                                    'href' => $this->permalink()));
+         $xs->element('id', null, $this->permalink());
+         $xs->element('published', null, common_date_w3dtf($this->created));
+         $xs->element('updated', null, common_date_w3dtf($this->modified));
+         $xs->element('content', array('type' => 'html'), $this->description);
+         $xs->elementEnd('entry');
+         return $xs->getString();
+     }
  }
diff --cc index.php
index 372a8536ecb9144369e7a2b837d925dac25253d5,be62fe1f344561f87893d6e46ea1bf6ff8d5bf1d..d8434a6cfede495fb57ef980088bf069cd517820
+++ b/index.php
@@@ -105,22 -105,27 +105,41 @@@ function checkMirror($action_obj, $args
      }
  }
  
 +function isLoginAction($action)
 +{
 +    static $loginActions =  array('login', 'openidlogin', 'finishopenidlogin',
 +                                  'recoverpassword', 'api', 'doc', 'register');
 +
 +    $login = null;
 +
 +    if (Event::handle('LoginAction', array($action, &$login))) {
 +        $login = in_array($action, $loginActions);
 +    }
 +
 +    return $login;
 +}
 +
  function main()
  {
+     // fake HTTP redirects using lighttpd's 404 redirects
+     if (strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false) {
+         $_lighty_url = $base_url.$_SERVER['REQUEST_URI'];
+         $_lighty_url = @parse_url($_lighty_url);
+         if ($_lighty_url['path'] != '/index.php' && $_lighty_url['path'] != '/') {
+             $_lighty_path = preg_replace('/^'.preg_quote(common_config('site','path')).'\//', '', substr($_lighty_url['path'], 1));
+             $_SERVER['QUERY_STRING'] = 'p='.$_lighty_path;
+             if ($_lighty_url['query'])
+                 $_SERVER['QUERY_STRING'] .= '&'.$_lighty_url['query'];
+             parse_str($_lighty_url['query'], $_lighty_query);
+             foreach ($_lighty_query as $key => $val) {
+                 $_GET[$key] = $_REQUEST[$key] = $val;
+             }
+             $_GET['p'] = $_REQUEST['p'] = $_lighty_path;
+         }
+     }
+     $_SERVER['REDIRECT_URL'] = preg_replace("/\?.+$/", "", $_SERVER['REQUEST_URI']);
      // quick check for fancy URL auto-detection support in installer.
      if (isset($_SERVER['REDIRECT_URL']) && (preg_replace("/^\/$/","",(dirname($_SERVER['REQUEST_URI']))) . '/check-fancy') === $_SERVER['REDIRECT_URL']) {
          die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs.");
diff --cc install.php
Simple merge
diff --cc js/util.js
index 3a0a8d9a7a927a6ae05ade21215a379a873f579e,f09ce838c4bb216ca404508d3b0c35003a29fd86..4f731f30a1e62aa6e9d0b6001f2aa62cc889072c
   */
  
  $(document).ready(function(){
+       var counterBlackout = false;
+       
        // count character on keyup
        function counter(event){
 -              var maxLength = 140;
 +         if (maxLength <= 0) {
 +              return;
 +         }
                var currentLength = $("#notice_data-text").val().length;
                var remaining = maxLength - currentLength;
                var counter = $("#notice_text-count");
diff --cc lib/action.php
Simple merge
diff --cc lib/common.php
Simple merge
Simple merge
Simple merge
diff --cc lib/util.php
Simple merge
Simple merge