diff --git a/README b/README index c8c529ed86..0f1b5a43b4 100644 --- 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 --- diff --git a/actions/disfavor.php b/actions/disfavor.php index 740f7de933..02e01d6e00 100644 --- a/actions/disfavor.php +++ b/actions/disfavor.php @@ -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!')); diff --git a/actions/favor.php b/actions/favor.php index ec86b17e69..fe51e34a27 100644 --- a/actions/favor.php +++ b/actions/favor.php @@ -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. * diff --git a/actions/grouprss.php b/actions/grouprss.php index 0b7280a11c..2bdcaafb27 100644 --- a/actions/grouprss.php +++ b/actions/grouprss.php @@ -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()) { diff --git a/actions/groups.php b/actions/groups.php index b49d80f377..3d62843ed6 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -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(); diff --git a/actions/invite.php b/actions/invite.php index 5dcc836526..bdea4807d8 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -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; diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php index c1bf3bf5f2..2a4b2060d3 100644 --- a/actions/noticesearchrss.php +++ b/actions/noticesearchrss.php @@ -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; diff --git a/actions/public.php b/actions/public.php index 9851285c48..ef9ef0d1ab 100644 --- a/actions/public.php +++ b/actions/public.php @@ -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)); diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php index eb9ab5d8e9..3678213c3a 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -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; + } + + $notices[] = clone($notice); } - - if ($cnt > $this->rpp) { - break; - } - - $notices[] = clone($notice); } return $notices; diff --git a/actions/twitapisearchjson.php b/actions/twitapisearchjson.php index b0e3be687c..27a717bfc9 100644 --- a/actions/twitapisearchjson.php +++ b/actions/twitapisearchjson.php @@ -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 +} diff --git a/config.php.sample b/config.php.sample index d42bac9a69..a23b41b319 100644 --- a/config.php.sample +++ b/config.php.sample @@ -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'; diff --git a/install.php b/install.php index b94a929360..570b08edf4 100644 --- a/install.php +++ b/install.php @@ -72,6 +72,12 @@ function checkPrereqs()

Cannot write background directory: /background/

+

On your server, try this command: chmod a+w /background/

+ = $this->long_limit; + return strlen($url) >= common_config('site', 'shorturllength'); } protected function http_post($data) { diff --git a/lib/action.php b/lib/action.php index 6a2f9b0f19..3bfa6ba15b 100644 --- a/lib/action.php +++ b/lib/action.php @@ -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'); } diff --git a/lib/common.php b/lib/common.php index e2936f0751..5d451463b9 100644 --- a/lib/common.php +++ b/lib/common.php @@ -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', diff --git a/lib/facebookaction.php b/lib/facebookaction.php index a445750f7e..1ae90d53bd 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -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' => diff --git a/lib/groupeditform.php b/lib/groupeditform.php index 7e8d6eea3a..fbb39129bc 100644 --- a/lib/groupeditform.php +++ b/lib/groupeditform.php @@ -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) { diff --git a/lib/jsonsearchresultslist.php b/lib/jsonsearchresultslist.php index f786c20a80..7beea9328d 100644 --- a/lib/jsonsearchresultslist.php +++ b/lib/jsonsearchresultslist.php @@ -89,6 +89,7 @@ class JSONSearchResultsList function show() { $cnt = 0; + $this->max_id = 0; $time_start = microtime(true); diff --git a/lib/language.php b/lib/language.php index cd6498d30b..3ea3dd2aa0 100644 --- a/lib/language.php +++ b/lib/language.php @@ -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'), diff --git a/lib/subgroupnav.php b/lib/subgroupnav.php index 4a9b36ae8f..5209919232 100644 --- a/lib/subgroupnav.php +++ b/lib/subgroupnav.php @@ -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'), diff --git a/lib/util.php b/lib/util.php index 203506bbc0..461ca15c15 100644 --- a/lib/util.php +++ b/lib/util.php @@ -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), diff --git a/plugins/FBConnect/FBConnectPlugin.css b/plugins/FBConnect/FBConnectPlugin.css index 564fdaee9e..4ece66d4a9 100644 --- a/plugins/FBConnect/FBConnectPlugin.css +++ b/plugins/FBConnect/FBConnectPlugin.css @@ -10,13 +10,12 @@ #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; } diff --git a/plugins/FBConnect/FBConnectPlugin.php b/plugins/FBConnect/FBConnectPlugin.php index cd6e9cecfb..d45d2718c3 100644 --- a/plugins/FBConnect/FBConnectPlugin.php +++ b/plugins/FBConnect/FBConnectPlugin.php @@ -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)) {