]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.8.x' of git@gitorious.org:+laconica-developers/laconica/dev into...
authorEvan Prodromou <evan@controlyourself.ca>
Wed, 1 Jul 2009 16:58:49 +0000 (12:58 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Wed, 1 Jul 2009 16:58:49 +0000 (12:58 -0400)
23 files changed:
README
actions/disfavor.php
actions/favor.php
actions/grouprss.php
actions/groups.php
actions/invite.php
actions/noticesearchrss.php
actions/public.php
actions/twitapisearchatom.php
actions/twitapisearchjson.php
config.php.sample
install.php
lib/Shorturl_api.php
lib/action.php
lib/common.php
lib/facebookaction.php
lib/groupeditform.php
lib/jsonsearchresultslist.php
lib/language.php
lib/subgroupnav.php
lib/util.php
plugins/FBConnect/FBConnectPlugin.css
plugins/FBConnect/FBConnectPlugin.php

diff --git a/README b/README
index c8c529ed86d2b22cc72cec4a503fa565c69f93a1..0f1b5a43b485e17445599fea76b126e96503acdb 100644 (file)
--- a/README
+++ b/README
@@ -906,6 +906,9 @@ sslserver: use an alternate server name for SSL URLs, like
            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.
 
 db
 --
@@ -1081,6 +1084,13 @@ debug: if turned on, this will make the XMPP library blurt out all of
 public: an array of JIDs to send _all_ notices to. This is useful for
        participating in third-party search and archiving services.
 
+invite
+------
+
+For configuring invites.
+
+enabled: Whether to allow users to send invites. Default true.
+
 tag
 ---
 
index 740f7de9333707458259037dc25aba62b883b04d..02e01d6e006bd3747beca0bfdfb694fd530309d0 100644 (file)
@@ -75,7 +75,7 @@ class DisfavorAction extends Action
             return;
         }
         $fave            = new Fave();
-        $fave->user_id   = $this->id;
+        $fave->user_id   = $user->id;
         $fave->notice_id = $notice->id;
         if (!$fave->find(true)) {
             $this->clientError(_('This notice is not a favorite!'));
index ec86b17e699a6bab1a5edd6a99942a58f91fa7f6..fe51e34a272c8d73ddfd9244e2fda14d28a9fe10 100644 (file)
@@ -12,8 +12,6 @@
  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  * @link     http://laconi.ca/
  *
-
-/*
  * Laconica - a distributed open-source microblogging tool
  * Copyright (C) 2008, 2009, Control Yourself, Inc.
  *
index 0b7280a11c33648584096b95176eafb63fea7835..2bdcaafb27a56e17ea1bd556741e34ba70880599 100644 (file)
@@ -116,6 +116,7 @@ class groupRssAction extends Rss10Action
             return null;
         }
 
+        $notices = array();
         $notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
 
         while ($notice->fetch()) {
index b49d80f3779b96cc47401be41e8cc529d093efcf..3d62843ed678d54d08c9fd3ccb5ca897568a5c75 100644 (file)
@@ -115,6 +115,7 @@ class GroupsAction extends Action
         $groups->orderBy('created DESC');
         $groups->limit($offset, $limit);
 
+        $cnt = 0;
         if ($groups->find()) {
             $gl = new GroupList($groups, null, $this);
             $cnt = $gl->show();
index 5dcc836526317e7b124dd4c03ea2bca6606cdb2f..bdea4807d8a2f2ac0f7f8c1043d35c6d56d6595d 100644 (file)
@@ -35,7 +35,9 @@ class InviteAction extends CurrentUserDesignAction
     function handle($args)
     {
         parent::handle($args);
-        if (!common_logged_in()) {
+        if (!common_config('invite', 'enabled')) {
+            $this->clientError(_('Invites have been disabled.'));
+        } else if (!common_logged_in()) {
             $this->clientError(sprintf(_('You must be logged in to invite other users to use %s'),
                                         common_config('site', 'name')));
             return;
index c1bf3bf5f21db9311e3b9b60b6b170c592f50a9d..2a4b2060d3fa3f2d3781d429f27cbd5a372ce9a3 100644 (file)
@@ -67,11 +67,16 @@ class NoticesearchrssAction extends Rss10Action
 
         if (!$limit) $limit = 20;
         $search_engine->limit(0, $limit, true);
-        $search_engine->query($q);
-        $notice->find();
+        if (false === $search_engine->query($q)) {
+            $cnt = 0;
+        } else {
+            $cnt = $notice->find();
+        }
 
-        while ($notice->fetch()) {
-            $notices[] = clone($notice);
+        if ($cnt > 0) {
+            while ($notice->fetch()) {
+                $notices[] = clone($notice);
+            }
         }
 
         return $notices;
index 9851285c4821367288b1bd8c5797d3a4912ca840..ef9ef0d1ab0dc4ea451d29f1c1a016359533501c 100644 (file)
@@ -182,8 +182,10 @@ class PublicAction extends Action
             $message .= _('Be the first to post!');
         }
         else {
-            $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
-        }
+            if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
+                $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
+            }
+       }
 
         $this->elementStart('div', 'guide');
         $this->raw(common_markup_to_html($message));
index eb9ab5d8e9425add9688045321eb62aaa3ba7b05..3678213c3a9dbddd34050b9a4936b3f49d6a573f 100644 (file)
@@ -165,24 +165,30 @@ class TwitapisearchatomAction extends TwitterapiAction
         $search_engine->set_sort_mode('chron');
         $search_engine->limit(($this->page - 1) * $this->rpp,
             $this->rpp + 1, true);
-        $search_engine->query($q);
-        $this->cnt = $notice->find();
+        if (false === $search_engine->query($q)) {
+            $this->cnt = 0;
+        } else {
+            $this->cnt = $notice->find();
+        }
 
         $cnt = 0;
+        $this->max_id = 0;
 
-        while ($notice->fetch()) {
+        if ($this->cnt > 0) {
+            while ($notice->fetch()) {
 
-            ++$cnt;
+                ++$cnt;
 
-            if (!$this->max_id) {
-                $this->max_id = $notice->id;
-            }
+                if (!$this->max_id) {
+                    $this->max_id = $notice->id;
+                }
 
-            if ($cnt > $this->rpp) {
-                break;
-            }
+                if ($cnt > $this->rpp) {
+                    break;
+                }
 
-            $notices[] = clone($notice);
+                $notices[] = clone($notice);
+            }
         }
 
         return $notices;
index b0e3be687c1118da16e0f88584911b6a7b786c2e..27a717bfc988cc0bc7b2ef40a8fa24739a032ced 100644 (file)
@@ -124,8 +124,11 @@ class TwitapisearchjsonAction extends TwitterapiAction
         $search_engine = $notice->getSearchEngine('identica_notices');
         $search_engine->set_sort_mode('chron');
         $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1, true);
-        $search_engine->query($q);
-        $cnt = $notice->find();
+        if (false === $search_engine->query($q)) {
+            $cnt = 0;
+        } else {
+            $cnt = $notice->find();
+        }
 
         // TODO: since_id, lang, geocode
 
@@ -146,4 +149,4 @@ class TwitapisearchjsonAction extends TwitterapiAction
     {
         return true;
     }
-}
\ No newline at end of file
+}
index d42bac9a6920be6fd97332b5553f364f8b96fd76..a23b41b3192cec813849f0608828ad94fd28b7af 100644 (file)
@@ -86,6 +86,9 @@ $config['sphinx']['port'] = 3312;
 // $config['xmpp']['public'][] = 'someindexer@example.net';
 // $config['xmpp']['debug'] = false;
 
+// Turn off invites
+// $config['invite']['enabled'] = false;
+
 // Default locale info
 // $config['site']['timezone'] = 'Pacific/Auckland';
 // $config['site']['language'] = 'en_NZ';
index b94a9293607e7928659c4da53e09323283d61f5b..570b08edf473b13e709ece605656a279d89016de 100644 (file)
@@ -72,6 +72,12 @@ function checkPrereqs()
          <?
             $pass = false;
        }
+       if (!is_writable(INSTALLDIR.'/background/')) {
+         ?><p class="error">Cannot write background directory: <code><?php echo INSTALLDIR; ?>/background/</code></p>
+              <p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?>/background/</code></p>
+         <?
+            $pass = false;
+       }
 
        return $pass;
 }
index 29f4eb3a66ff3eefbe989d9f07c51e815ac2487a..22d5b4cb5442e762b05d7a0d9a85c0944f4ad8e3 100644 (file)
@@ -40,7 +40,7 @@ class ShortUrlApi
     }
 
     private function is_long($url) {
-        return strlen($url) >= $this->long_limit;
+        return strlen($url) >= common_config('site', 'shorturllength');
     }
 
     protected function http_post($data) {
index 6a2f9b0f19a551c31568f3e98461af170c690563..3bfa6ba15bd78d4b0818d457ded8635effe9e0c8 100644 (file)
@@ -421,11 +421,13 @@ class Action extends HTMLOutputter // lawsuit
                     $this->menuItem(common_local_url('smssettings'),
                                     _('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
                 }
-                $this->menuItem(common_local_url('invite'),
-                                _('Invite'),
-                                sprintf(_('Invite friends and colleagues to join you on %s'),
-                                        common_config('site', 'name')),
-                                false, 'nav_invitecontact');
+                if (common_config('invite', 'enabled')) {
+                    $this->menuItem(common_local_url('invite'),
+                                    _('Invite'),
+                                    sprintf(_('Invite friends and colleagues to join you on %s'),
+                                            common_config('site', 'name')),
+                                    false, 'nav_invitecontact');
+                }
                 $this->menuItem(common_local_url('logout'),
                                 _('Logout'), _('Logout from the site'), false, 'nav_logout');
             }
index e2936f0751d245a1179b5028d9b2ef25c84c56f8..5d451463b9ed9f4e794f67bc980becf80ea60fb8 100644 (file)
@@ -120,6 +120,7 @@ $config =
               'private' => false,
               'ssl' => 'never',
               'sslserver' => null,
+              'shorturllength' => 30,
               'dupelimit' => 60), # default for same person saying the same thing
         'syslog' =>
         array('appname' => 'laconica', # for syslog
@@ -175,6 +176,8 @@ $config =
               'host' => null, # only set if != server
               'debug' => false, # print extra debug info
               'public' => array()), # JIDs of users who want to receive the public stream
+        'invite' =>
+        array('enabled' => true),
         'sphinx' =>
         array('enabled' => false,
               'server' => 'localhost',
index a445750f7e00eee711f054a200c7ebc0dbd0f75e..1ae90d53bdeb534afd8a65a1f5f51c5b90a2b480 100644 (file)
@@ -213,12 +213,14 @@ class FacebookAction extends Action
             array('href' => 'index.php', 'title' => _('Home')), _('Home'));
         $this->elementEnd('li');
 
-        $this->elementStart('li',
-            array('class' =>
-                ($this->action == 'facebookinvite') ? 'current' : 'facebook_invite'));
-        $this->element('a',
-            array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
-        $this->elementEnd('li');
+        if (common_config('invite', 'enabled')) {
+            $this->elementStart('li',
+                array('class' =>
+                    ($this->action == 'facebookinvite') ? 'current' : 'facebook_invite'));
+            $this->element('a',
+                array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
+            $this->elementEnd('li');
+        }
 
         $this->elementStart('li',
             array('class' =>
index 7e8d6eea3ad93cb9d8f567e4dde8abfabe8f52b3..fbb39129bc3bc4f7b05f552b318bf0e94029b8c8 100644 (file)
@@ -130,30 +130,46 @@ class GroupEditForm extends Form
 
     function formData()
     {
+        if ($this->group) {
+            $id = $this->group->id;
+            $nickname = $this->group->nickname;
+            $fullname = $this->group->fullname;
+            $homepage = $this->group->homepage;
+            $description = $this->group->description;
+            $location = $this->group->location;
+        } else {
+            $id = '';
+            $nickname = '';
+            $fullname = '';
+            $homepage = '';
+            $description = '';
+            $location = '';
+        }
+
         $this->out->elementStart('ul', 'form_data');
         $this->out->elementStart('li');
-        $this->out->hidden('groupid', $this->group->id);
+        $this->out->hidden('groupid', $id);
         $this->out->input('nickname', _('Nickname'),
-                     ($this->out->arg('nickname')) ? $this->out->arg('nickname') : $this->group->nickname,
+                     ($this->out->arg('nickname')) ? $this->out->arg('nickname') : $nickname,
                      _('1-64 lowercase letters or numbers, no punctuation or spaces'));
         $this->out->elementEnd('li');
         $this->out->elementStart('li');
         $this->out->input('fullname', _('Full name'),
-                     ($this->out->arg('fullname')) ? $this->out->arg('fullname') : $this->group->fullname);
+                     ($this->out->arg('fullname')) ? $this->out->arg('fullname') : $fullname);
         $this->out->elementEnd('li');
         $this->out->elementStart('li');
         $this->out->input('homepage', _('Homepage'),
-                     ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $this->group->homepage,
+                     ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
                      _('URL of the homepage or blog of the group or topic'));
         $this->out->elementEnd('li');
         $this->out->elementStart('li');
         $this->out->textarea('description', _('Description'),
-                        ($this->out->arg('description')) ? $this->out->arg('description') : $this->group->description,
+                        ($this->out->arg('description')) ? $this->out->arg('description') : $description,
                         _('Describe the group or topic in 140 chars'));
         $this->out->elementEnd('li');
         $this->out->elementStart('li');
         $this->out->input('location', _('Location'),
-                     ($this->out->arg('location')) ? $this->out->arg('location') : $this->group->location,
+                     ($this->out->arg('location')) ? $this->out->arg('location') : $location,
                      _('Location for the group, if any, like "City, State (or Region), Country"'));
         $this->out->elementEnd('li');
         if (common_config('group', 'maxaliases') > 0) {
index f786c20a806ed53c3c55cff6eb9c0cbe0367dad5..7beea9328d27649d507b4e8a753324ae836648d5 100644 (file)
@@ -89,6 +89,7 @@ class JSONSearchResultsList
     function show()
     {
         $cnt = 0;
+        $this->max_id = 0;
 
         $time_start = microtime(true);
 
index cd6498d30b5d108677080a4b1494efa7e54d9a90..3ea3dd2aa0a5237412a980fb1266fce75d10e9e9 100644 (file)
@@ -108,7 +108,7 @@ function get_all_languages() {
                'el'      => array('q' => 0.1, 'lang' => 'el',    'name' => 'Greek', 'direction' => 'ltr'),
                'en-us'   => array('q' => 1, 'lang' => 'en_US', 'name' => 'English (US)', 'direction' => 'ltr'),
                'en-gb'   => array('q' => 1, 'lang' => 'en_GB', 'name' => 'English (British)', 'direction' => 'ltr'),
-               'en'      => array('q' => 1, 'lang' => 'en',    'name' => 'English', 'direction' => 'ltr'),
+               'en'      => array('q' => 1, 'lang' => 'en_US',    'name' => 'English (US)', 'direction' => 'ltr'),
                'es'      => array('q' => 1, 'lang' => 'es',    'name' => 'Spanish', 'direction' => 'ltr'),
                'fi'      => array('q' => 1, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'),
                'fr-fr'   => array('q' => 1, 'lang' => 'fr_FR', 'name' => 'French', 'direction' => 'ltr'),
index 4a9b36ae8fa1a198c7d2cb7d2be8f8732c4b62cb..52099192324ada24ea0f5c0c10f7ba199612dd37 100644 (file)
@@ -100,7 +100,7 @@ class SubGroupNav extends Widget
                                          $this->user->nickname),
                                  $action == 'usergroups',
                                  'nav_usergroups');
-            if (!is_null($cur) && $this->user->id === $cur->id) {
+            if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) {
                 $this->out->menuItem(common_local_url('invite'),
                                      _('Invite'),
                                      sprintf(_('Invite friends and colleagues to join you on %s'),
index 203506bbc06635424564962cab2829f4f0397254..461ca15c15dbb0cf20c4c67ecbc5021520e90462 100644 (file)
@@ -114,7 +114,7 @@ function common_check_user($nickname, $password)
         return false;
     }
     $user = User::staticGet('nickname', $nickname);
-    if (is_null($user)) {
+    if (is_null($user) || $user === false) {
         return false;
     } else {
         if (0 == strcmp(common_munge_password($password, $user->id),
index 564fdaee9e44e0eb550ff8c4f3749f50aceda494..4ece66d4a9e3e305d8c0deb8e24f4451427216e7 100644 (file)
 #site_nav_global_primary #nav_fb {
 position:relative;
 margin-left:18px;
-margin-right:-7px;
 }
 
 #nav_fb .fb_profile_pic_rendered img {
-position:relative;
-top:3px;
-left:0;
+position:absolute;
+top:-3px;
+left:-18px;
 display:inline;
 border:1px solid #3B5998;
 padding:1px;
@@ -25,7 +24,7 @@ padding:1px;
 #nav_fb img {
 position:absolute;
 top:-13px;
-left:-11px;
+left:-25px;
 display:inline;
 }
 
index cd6e9cecfbdfb5bf667d9e30a24f9207a723b074..d45d2718c360106d5f96d6cbafa31ea954bbd761 100644 (file)
@@ -273,11 +273,13 @@ class FBConnectPlugin extends Plugin
              $action->menuItem(common_local_url('smssettings'),
                  _('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
             }
-            $action->menuItem(common_local_url('invite'),
-                _('Invite'),
-                sprintf(_('Invite friends and colleagues to join you on %s'),
-                common_config('site', 'name')),
-                false, 'nav_invitecontact');
+            if (common_config('invite', 'enabled')) {
+                $action->menuItem(common_local_url('invite'),
+                    _('Invite'),
+                    sprintf(_('Invite friends and colleagues to join you on %s'),
+                    common_config('site', 'name')),
+                    false, 'nav_invitecontact');
+            }
 
             // Need to override the Logout link to make it do FB stuff
             if (!empty($fbuid)) {