From 216ada5cc4cc73eb8c9d22e9ad19cec0d07ff9ea Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 12 Jun 2009 19:48:26 +0800 Subject: Fix "Trying to get property of non-object" errors in groupeditform.php --- lib/groupeditform.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/groupeditform.php b/lib/groupeditform.php index ca674f3c8..3014dd1c5 100644 --- a/lib/groupeditform.php +++ b/lib/groupeditform.php @@ -131,30 +131,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'); $this->out->elementEnd('ul'); -- cgit v1.2.3-54-g00ecf From cfea2b0c4e21bc61ec250c8f34ec8c9aa6536e83 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 12 Jun 2009 19:55:41 +0800 Subject: Fix "Trying to get property of non-object" errors when accessing the people search results page --- lib/peoplesearchresults.php | 2 +- lib/profilelist.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/peoplesearchresults.php b/lib/peoplesearchresults.php index d3f840852..9cd162baa 100644 --- a/lib/peoplesearchresults.php +++ b/lib/peoplesearchresults.php @@ -56,7 +56,7 @@ class PeopleSearchResults extends ProfileList function __construct($profile, $terms, $action) { - parent::__construct($profile, $terms, $action); + parent::__construct($profile, null, $action); $this->terms = array_map('preg_quote', array_map('htmlspecialchars', $terms)); $this->pattern = '/('.implode('|',$terms).')/i'; diff --git a/lib/profilelist.php b/lib/profilelist.php index a4cc23555..c22da00cb 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -208,7 +208,7 @@ class ProfileList extends Widget } $this->out->elementEnd('li'); $this->out->elementStart('li', 'entity_block'); - if ($user->id == $this->owner->id) { + if ($this->owner && $user->id == $this->owner->id) { $this->showBlockForm(); } $this->out->elementEnd('li'); -- cgit v1.2.3-54-g00ecf From e2b20bd1e6087594b6069117ccb675f751ddc17a Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 12 Jun 2009 19:58:30 +0800 Subject: Fix "Trying to get property of non-object" errors when a user tries to log in using an unknown nickname --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index b3a94a5a0..32e178b3e 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), -- cgit v1.2.3-54-g00ecf From 53f31a247e4355318e8a997451930a1b1772099c Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 12 Jun 2009 20:03:18 +0800 Subject: Fix missing max_id in API search calls --- actions/twitapisearchatom.php | 1 + lib/jsonsearchresultslist.php | 1 + 2 files changed, 2 insertions(+) (limited to 'lib') diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php index eb9ab5d8e..c223a7e27 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -169,6 +169,7 @@ class TwitapisearchatomAction extends TwitterapiAction $this->cnt = $notice->find(); $cnt = 0; + $this->max_id = 0; while ($notice->fetch()) { diff --git a/lib/jsonsearchresultslist.php b/lib/jsonsearchresultslist.php index f786c20a8..7beea9328 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); -- cgit v1.2.3-54-g00ecf From 6d308f6ffe3f894c60fafaea3ceaef86d30dfe1d Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sun, 14 Jun 2009 16:17:22 +0800 Subject: Adds $config['invite']['enabled'] to enable/disable invites. The invite function may not applicable for private and/or closed installs. This adds a configuration option to enable/disable invites (defaulting to enabled), hides the "Invite" nav item when necessary, and adds a check to actions/invite.php. Note that I haven't tried the Facebook application so I didn't add any checks to actions/facebookinvite.php. --- README | 7 +++++++ actions/invite.php | 4 +++- config.php.sample | 3 +++ lib/action.php | 12 +++++++----- lib/common.php | 2 ++ lib/facebookaction.php | 14 ++++++++------ lib/subgroupnav.php | 2 +- plugins/FBConnect/FBConnectPlugin.php | 12 +++++++----- 8 files changed, 38 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/README b/README index 2099f94d6..679fa8ee3 100644 --- a/README +++ b/README @@ -1067,6 +1067,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/invite.php b/actions/invite.php index 7e52cdbcc..9631f7a7f 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -35,7 +35,9 @@ class InviteAction extends Action 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/config.php.sample b/config.php.sample index 636f4cf8e..2e5bcaca0 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/lib/action.php b/lib/action.php index 89a8c8f4d..12d122f12 100644 --- a/lib/action.php +++ b/lib/action.php @@ -422,11 +422,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 6bf4ad21f..b51661f2a 100644 --- a/lib/common.php +++ b/lib/common.php @@ -130,6 +130,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 a445750f7..1ae90d53b 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/subgroupnav.php b/lib/subgroupnav.php index 4a9b36ae8..520991923 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/plugins/FBConnect/FBConnectPlugin.php b/plugins/FBConnect/FBConnectPlugin.php index a366985be..11dc568a9 100644 --- a/plugins/FBConnect/FBConnectPlugin.php +++ b/plugins/FBConnect/FBConnectPlugin.php @@ -200,11 +200,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 ($flink && $fbuid > 0) { -- cgit v1.2.3-54-g00ecf From c3cffaf9c798fef99754ebd1e9d9ee1a0f3a0231 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 10 Jun 2009 13:16:11 +0000 Subject: Laconica defaults to a locale 'en' which uses language 'en'. Unfortunately, this language doesn't exist -- properly it's en_US. This causes a lot of spammy messages in syslog. This fix simply changes 'en' to have the same properties as 'en-us', i.e. a language of en_US and a description of 'English (US)'. --- lib/language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/language.php b/lib/language.php index cd6498d30..3ea3dd2aa 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'), -- cgit v1.2.3-54-g00ecf From b416df93128e6ffc42ad62233f92ab617f809de1 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 11 Jun 2009 13:07:41 +0000 Subject: Add site-wide option to change the length at which URLs are auto-shortened --- README | 3 +++ lib/Shorturl_api.php | 2 +- lib/common.php | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/README b/README index e02fa02d3..0f1b5a43b 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 -- diff --git a/lib/Shorturl_api.php b/lib/Shorturl_api.php index 29f4eb3a6..22d5b4cb5 100644 --- a/lib/Shorturl_api.php +++ b/lib/Shorturl_api.php @@ -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) { diff --git a/lib/common.php b/lib/common.php index e10f24b3b..5d451463b 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 -- cgit v1.2.3-54-g00ecf