From 3a59199040a4360b279c6c51700b74a643bbaf51 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 12 Jun 2009 19:38:04 +0800 Subject: Fix "Undefined property: DisfavorAction::$id" --- actions/disfavor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/disfavor.php b/actions/disfavor.php index bc13b09da..4064a0d98 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!')); -- cgit v1.2.3-54-g00ecf 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(-) 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 1b76df4b6aa4d5f092fa4f7188a9e853443452e1 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 12 Jun 2009 19:49:33 +0800 Subject: Fix "Undefined variable: cnt" --- actions/groups.php | 1 + 1 file changed, 1 insertion(+) diff --git a/actions/groups.php b/actions/groups.php index 26b52a5fc..1cf359959 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -113,6 +113,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(); -- 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(-) 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(-) 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(+) 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 acff6d4bfd05ffba5f0819f2dad56af40c899e76 Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Fri, 12 Jun 2009 16:43:40 -0500 Subject: Verbage of a closed invite only site, it shouldnt ask you to register. --- actions/public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/public.php b/actions/public.php index 27153f131..c04843383 100644 --- a/actions/public.php +++ b/actions/public.php @@ -173,7 +173,7 @@ class PublicAction extends Action if (common_logged_in()) { $message .= _('Be the first to post!'); } - else { + if (! (common_config('site','closed') || common_config('site','inviteonly'))) { $message .= _('Why not [register an account](%%action.register%%) and be the first to post!'); } -- 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(-) 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 f7d488d4b2bfdc8dfa6b5a2bc2931dbf824509a0 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sun, 14 Jun 2009 16:39:31 +0800 Subject: Fixes the notice search RSS feeds / API results for searches that return no matches. If a user does a notice search that should return no matching notices, the RSS feed / API results for that search currently returns all notices instead of no notices. This fixes it so that an empty list is returned instead. --- actions/noticesearchrss.php | 13 +++++++++---- actions/twitapisearchatom.php | 27 ++++++++++++++++----------- actions/twitapisearchjson.php | 9 ++++++--- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php index f6da969ee..94bf6ba30 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/twitapisearchatom.php b/actions/twitapisearchatom.php index eb9ab5d8e..708b1494d 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -165,24 +165,29 @@ 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; - 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; diff --git a/actions/twitapisearchjson.php b/actions/twitapisearchjson.php index b0e3be687..27a717bfc 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 +} -- cgit v1.2.3-54-g00ecf From 43680ed0c2cf83448d755fa1edff42711d06a82c Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sun, 14 Jun 2009 17:03:22 +0800 Subject: Fixes two PHP Warnings ("Invalid argument supplied for foreach() in /var/www/mmmu/lib/rssaction.php") when accessing the RSS feed of a group that has no notices. --- actions/grouprss.php | 1 + 1 file changed, 1 insertion(+) diff --git a/actions/grouprss.php b/actions/grouprss.php index 0b7280a11..2bdcaafb2 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()) { -- cgit v1.2.3-54-g00ecf From 4450f3352c4dafcbe132146873ef9fad251d9714 Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Tue, 16 Jun 2009 17:18:48 -0500 Subject: Needed the else. Tested logged in/out ; site closed/inviteonly/both --- actions/public.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/actions/public.php b/actions/public.php index c04843383..2c8083320 100644 --- a/actions/public.php +++ b/actions/public.php @@ -173,9 +173,11 @@ class PublicAction extends Action if (common_logged_in()) { $message .= _('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!'); - } + else { + 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)); -- cgit v1.2.3-54-g00ecf From 3a3614fc5523442b87b7625207d45095928f0087 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 22:42:52 +1200 Subject: also check for write permission to background folder --- install.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install.php b/install.php index b94a92936..570b08edf 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/

+ Date: Sat, 27 Jun 2009 03:21:18 +0000 Subject: Added input submit to let the user to go back to site's default design settings --- lib/designsettings.php | 17 +++++++++-------- theme/base/css/display.css | 5 ++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/designsettings.php b/lib/designsettings.php index 9650679ac..5def5053f 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -212,18 +212,19 @@ class DesignSettingsAction extends AccountSettingsAction 'maxlength' => '7', 'size' => '7', 'value' => '#' . $lcolor->hexValue())); + $this->elementEnd('li'); - $this->elementEnd('li'); + } catch (WebColorException $e) { + common_log(LOG_ERR, 'Bad color values in design ID: ' .$design->id); + } - } catch (WebColorException $e) { - common_log(LOG_ERR, 'Bad color values in design ID: ' . - $design->id); - } + $this->elementEnd('ul'); + $this->elementEnd('fieldset'); - $this->elementEnd('ul'); - $this->elementEnd('fieldset'); + $this->submit('defaults', _('Use defaults'), 'submit form_action-default', + 'defaults', _('Restore default designs')); - $this->element('input', array('id' => 'settings_design_reset', + $this->element('input', array('id' => 'settings_design_reset', 'type' => 'reset', 'value' => 'Reset', 'class' => 'submit form_action-primary', diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 78fcd7ece..85b42cdd1 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -206,7 +206,10 @@ border-radius:4px; padding:0 7px; } - +.form_settings input.form_action-default { +margin-right:11px; +} +.form_settings input.form_action-default, .form_settings input.form_action-primary { padding:0; } -- cgit v1.2.3-54-g00ecf From d4f1637f8a20d9e4ac059930b7ba444473f5047b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 14:45:33 -0400 Subject: fallback for www. addresses --- classes/Status_network.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/classes/Status_network.php b/classes/Status_network.php index f8d6756b6..8726096e3 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -132,6 +132,13 @@ class Status_network extends DB_DataObject } } else { $sn = self::memGet('hostname', strtolower($servername)); + + if (empty($sn)) { + // Try for a no-www address + if (strncasecmp($servername, 'www.', 4)) { + $sn = self::memGet('hostname', strtolower(substr($servername, 4))); + } + } } if (!empty($sn)) { -- cgit v1.2.3-54-g00ecf From 166e4a4b58a02438825706e52d1aa3207c33505b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 14:48:19 -0400 Subject: bad string compare in Status_network --- classes/Status_network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Status_network.php b/classes/Status_network.php index 8726096e3..dbd722e88 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -135,7 +135,7 @@ class Status_network extends DB_DataObject if (empty($sn)) { // Try for a no-www address - if (strncasecmp($servername, 'www.', 4)) { + if (0 == strncasecmp($servername, 'www.', 4)) { $sn = self::memGet('hostname', strtolower(substr($servername, 4))); } } -- cgit v1.2.3-54-g00ecf From 495c85544a740cd0330e73d9c48ca4b84f3d8e97 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 15:21:15 -0400 Subject: don't canonicalize people's text into URLs --- lib/util.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/util.php b/lib/util.php index 9c1af7a0d..469f132b8 100644 --- a/lib/util.php +++ b/lib/util.php @@ -500,17 +500,19 @@ function common_linkify($url) { // It comes in special'd, so we unspecial it before passing to the stringifying // functions $url = htmlspecialchars_decode($url); - $display = File_redirection::_canonUrl($url); + + $canon = File_redirection::_canonUrl($url); + $longurl_data = File_redirection::where($url); if (is_array($longurl_data)) { $longurl = $longurl_data['url']; } elseif (is_string($longurl_data)) { $longurl = $longurl_data; } else { - die('impossible to linkify'); + throw new ServerException("Can't linkify url '$url'"); } - $attrs = array('href' => $longurl, 'rel' => 'external'); + $attrs = array('href' => $canon, 'rel' => 'external'); $is_attachment = false; $attachment_id = null; @@ -528,13 +530,13 @@ function common_linkify($url) { } } -// if this URL is an attachment, then we set class='attachment' and id='attahcment-ID' -// where ID is the id of the attachment for the given URL. -// -// we need a better test telling what can be shown as an attachment -// we're currently picking up oembeds only. -// I think the best option is another file_view table in the db -// and associated dbobject. + // if this URL is an attachment, then we set class='attachment' and id='attahcment-ID' + // where ID is the id of the attachment for the given URL. + // + // we need a better test telling what can be shown as an attachment + // we're currently picking up oembeds only. + // I think the best option is another file_view table in the db + // and associated dbobject. $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'"; $file = new File; @@ -564,7 +566,7 @@ function common_linkify($url) { $attrs['id'] = "attachment-{$attachment_id}"; } - return XMLStringer::estring('a', $attrs, $display); + return XMLStringer::estring('a', $attrs, $url); } function common_shorten_links($text) -- cgit v1.2.3-54-g00ecf From 6ca4dfa7ef42faf024599375b2ff81bfeb3d6208 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 16:12:23 -0400 Subject: Daemon can optionally not go into the background --- lib/daemon.php | 20 +++++++++++++++----- lib/queuehandler.php | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/daemon.php b/lib/daemon.php index a0df00bdc..72e8bc202 100644 --- a/lib/daemon.php +++ b/lib/daemon.php @@ -23,6 +23,13 @@ if (!defined('LACONICA')) { class Daemon { + var $daemonize = true; + + function __construct($daemonize = true) + { + $this->daemonize = $daemonize; + } + function name() { return null; @@ -129,12 +136,15 @@ class Daemon common_log(LOG_INFO, $this->name() . ' already running. Exiting.'); exit(0); } - if ($this->background()) { - $this->writePidFile(); - $this->changeUser(); - $this->run(); - $this->clearPidFile(); + + if ($this->daemonize) { + $this->background(); } + + $this->writePidFile(); + $this->changeUser(); + $this->run(); + $this->clearPidFile(); } function run() diff --git a/lib/queuehandler.php b/lib/queuehandler.php index ae403c65e..c1c4f3309 100644 --- a/lib/queuehandler.php +++ b/lib/queuehandler.php @@ -27,11 +27,12 @@ require_once(INSTALLDIR.'/classes/Notice.php'); class QueueHandler extends Daemon { - var $_id = 'generic'; - function QueueHandler($id=null) + function __construct($id=null, $daemonize=true) { + parent::__construct($daemonize); + if ($id) { $this->set_id($id); } -- cgit v1.2.3-54-g00ecf From 2f8c656e1df10984527fe445bd57783f5fdcafdc Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 16:12:45 -0400 Subject: command line arg handling a little more flexible --- scripts/commandline.inc | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/scripts/commandline.inc b/scripts/commandline.inc index 4a7757fb9..8c5c56d5e 100644 --- a/scripts/commandline.inc +++ b/scripts/commandline.inc @@ -115,24 +115,60 @@ require_once INSTALLDIR . '/lib/common.php'; set_error_handler('common_error_handler'); -function have_option($str) +function have_option($opt, $alt=null) { global $options; + + $matches = array($opt); + + if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { + $matches[] = '--'.$opt; + } else { + $matches[] = $opt; + } + + if (!empty($alt)) { + if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { + $matches[] = '--'.$alt; + } else { + $matches[] = $alt; + } + } + foreach ($options as $option) { - if ($option[0] == $str) { + if (in_array($option[0], $matches)) { return true; } } + return false; } -function get_option_value($str) +function get_option_value($str, $alt=null) { global $options; + + $matches = array(); + + if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { + $matches[] = '--'.$opt; + } else { + $matches[] = $opt; + } + + if (!empty($alt)) { + if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { + $matches[] = '--'.$alt; + } else { + $matches[] = $alt; + } + } + foreach ($options as $option) { - if ($option[0] == $str) { + if (in_array($option[0], $matches)) { return $option[1]; } } + return null; } \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 47e1d2adb87ae8ffa4c954d3ba62da64e986696c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 16:13:08 -0400 Subject: xmppdaemon.php can stay in foreground --- scripts/xmppdaemon.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 3eecfec29..38d739e68 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -20,13 +20,14 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -$shortoptions = 'i::'; -$longoptions = array('id::'); +$shortoptions = 'fi::'; +$longoptions = array('id::', 'foreground'); $helptext = <<host) ? $this->host : $this->server; $this->log(LOG_INFO, "Connecting to $connect_to on port $this->port"); @@ -323,16 +325,16 @@ if (common_config('xmpp','enabled')==false) { exit(); } -if (have_option('i')) { - $id = get_option_value('i'); -} else if (have_option('--id')) { - $id = get_option_value('--id'); +if (have_option('i', 'id')) { + $id = get_option_value('i', 'id'); } else if (count($args) > 0) { $id = $args[0]; } else { $id = null; } -$daemon = new XMPPDaemon($id); +$foreground = have_option('f', 'foreground'); + +$daemon = new XMPPDaemon($id, $foreground); $daemon->runOnce(); -- cgit v1.2.3-54-g00ecf From c755970141810a98e08f47c52568f635167e34f1 Mon Sep 17 00:00:00 2001 From: Super-User Date: Sun, 28 Jun 2009 20:15:17 +0000 Subject: commandline processing handles errors better --- scripts/commandline.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/commandline.inc b/scripts/commandline.inc index 4a7757fb9..53b9a490b 100644 --- a/scripts/commandline.inc +++ b/scripts/commandline.inc @@ -63,7 +63,14 @@ if (isset($longoptions)) { $parser = new Console_Getopt(); -list($options, $args) = $parser->getopt($argv, $shortoptions, $longoptions); +$result = $parser->getopt($argv, $shortoptions, $longoptions); + +if (PEAR::isError($result)) { + print $result->getMessage()."\n"; + exit(1); +} else { + list($options, $args) = $result; +} function show_help() { -- cgit v1.2.3-54-g00ecf From b06edd1f27948aa3e34bbb0a22172fc8d87b4fe6 Mon Sep 17 00:00:00 2001 From: Super-User Date: Sun, 28 Jun 2009 20:15:45 +0000 Subject: more efficient fixup of conversations --- scripts/fixup_conversations.php | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/scripts/fixup_conversations.php b/scripts/fixup_conversations.php index 2cfa422e6..0be0b4bac 100755 --- a/scripts/fixup_conversations.php +++ b/scripts/fixup_conversations.php @@ -24,22 +24,17 @@ require_once INSTALLDIR.'/scripts/commandline.inc'; common_log(LOG_INFO, 'Fixing up conversations.'); -$notice = new Notice(); -$notice->whereAdd('conversation is null'); -$notice->orderBy('id'); +$nid = new Notice(); +$nid->query('select id, reply_to from notice where conversation is null'); -$cnt = $notice->find(); +while ($nid->fetch()) { -print "Found $cnt notices.\n"; - -while ($notice->fetch()) { - - print "$notice->id =>"; - - $orig = clone($notice); - - if (empty($notice->reply_to)) { - $notice->conversation = $notice->id; + $cid = null; + + $notice = new Notice(); + + if (empty($nid->reply_to)) { + $cid = $nid->id; } else { $reply = Notice::staticGet('id', $notice->reply_to); @@ -52,6 +47,9 @@ while ($notice->fetch()) { } else { $notice->conversation = $reply->conversation; } + + unset($reply); + $reply = null; } print "$notice->conversation"; @@ -63,5 +61,10 @@ while ($notice->fetch()) { continue; } + $notice = null; + $orig = null; + unset($notice); + unset($orig); + print ".\n"; } -- cgit v1.2.3-54-g00ecf From a4d0f22b4b2907134779d7710f967c4841f6f938 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 20:16:44 +0000 Subject: twitter status fetcher takes an id argument --- scripts/twitterstatusfetcher.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index 5ffdda58f..8b10bfbad 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -25,9 +25,14 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('MAXCHILDREN', 2); define('POLL_INTERVAL', 60); // in seconds +$shortoptions = 'i::'; +$longoptions = array('id::'); + $helptext = <<_id); } /** @@ -625,6 +630,16 @@ class TwitterStatusFetcher extends Daemon declare(ticks = 1); -$fetcher = new TwitterStatusFetcher(); +if (have_option('i')) { + $id = get_option_value('i'); +} else if (have_option('--id')) { + $id = get_option_value('--id'); +} else if (count($args) > 0) { + $id = $args[0]; +} else { + $id = null; +} + +$fetcher = new TwitterStatusFetcher($id); $fetcher->runOnce(); -- cgit v1.2.3-54-g00ecf From cfd25489235b176c33cc4104aadfe5378fffe67d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 16:33:08 -0400 Subject: got my background/foreground logic backwards --- scripts/xmppdaemon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 38d739e68..608cc1a36 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -335,6 +335,6 @@ if (have_option('i', 'id')) { $foreground = have_option('f', 'foreground'); -$daemon = new XMPPDaemon($id, $foreground); +$daemon = new XMPPDaemon($id, !$foreground); $daemon->runOnce(); -- cgit v1.2.3-54-g00ecf From 9f079764aa945e9e126ffa41cece17bc8951fb78 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 16:38:27 -0400 Subject: extract log-line formatting to its own function --- lib/util.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/util.php b/lib/util.php index 469f132b8..1ae43a056 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1104,15 +1104,20 @@ function common_ensure_syslog() } } +function common_log_line($priority, $msg) +{ + static $syslog_priorities = array('LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR', + 'LOG_WARNING', 'LOG_NOTICE', 'LOG_INFO', 'LOG_DEBUG'); + return date('Y-m-d H:i:s') . ' ' . $syslog_priorities[$priority] . ': ' . $msg . "\n"; +} + function common_log($priority, $msg, $filename=null) { $logfile = common_config('site', 'logfile'); if ($logfile) { $log = fopen($logfile, "a"); if ($log) { - static $syslog_priorities = array('LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR', - 'LOG_WARNING', 'LOG_NOTICE', 'LOG_INFO', 'LOG_DEBUG'); - $output = date('Y-m-d H:i:s') . ' ' . $syslog_priorities[$priority] . ': ' . $msg . "\n"; + $output = common_log_line($priority, $msg); fwrite($log, $output); fclose($log); } -- cgit v1.2.3-54-g00ecf From 25c721f6ffc5ecf5825b60ab7b9c021d78b50888 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 16:38:59 -0400 Subject: if not in daemon mode, xmppdaemon sends log to stdout --- scripts/xmppdaemon.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 608cc1a36..3e46c8e26 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -309,7 +309,14 @@ class XMPPDaemon extends Daemon function log($level, $msg) { - common_log($level, 'XMPPDaemon('.$this->resource.'): '.$msg); + $text = 'XMPPDaemon('.$this->resource.'): '.$msg; + common_log($level, $text); + if (!$this->daemonize) + { + $line = common_log_line($level, $text); + echo $line; + echo "\n"; + } } function subscribed($to) -- cgit v1.2.3-54-g00ecf From 7a0d33ab5fa29993cc7e05e41a26a26ca3ffd1e8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 16:55:19 -0400 Subject: reformat commandline.inc --- scripts/commandline.inc | 120 ++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/scripts/commandline.inc b/scripts/commandline.inc index 9c6787cb7..bca09216d 100644 --- a/scripts/commandline.inc +++ b/scripts/commandline.inc @@ -66,10 +66,10 @@ $parser = new Console_Getopt(); $result = $parser->getopt($argv, $shortoptions, $longoptions); if (PEAR::isError($result)) { - print $result->getMessage()."\n"; - exit(1); + print $result->getMessage()."\n"; + exit(1); } else { - list($options, $args) = $result; + list($options, $args) = $result; } function show_help() @@ -77,7 +77,7 @@ function show_help() global $helptext; $_default_help_text = << 1 && 0 != strncmp($opt, '--', 2)) { - $matches[] = '--'.$opt; - } else { - $matches[] = $opt; - } - - if (!empty($alt)) { - if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { - $matches[] = '--'.$alt; - } else { - $matches[] = $alt; - } - } - - foreach ($options as $option) { - if (in_array($option[0], $matches)) { - return true; - } - } - - return false; + global $options; + + $matches = array(); + + if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { + $matches[] = '--'.$opt; + } else { + $matches[] = $opt; + } + + if (!empty($alt)) { + if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { + $matches[] = '--'.$alt; + } else { + $matches[] = $alt; + } + } + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return true; + } + } + + return false; } function get_option_value($str, $alt=null) { - global $options; - - $matches = array(); - - if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { - $matches[] = '--'.$opt; - } else { - $matches[] = $opt; - } - - if (!empty($alt)) { - if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { - $matches[] = '--'.$alt; - } else { - $matches[] = $alt; - } - } - - foreach ($options as $option) { - if (in_array($option[0], $matches)) { - return $option[1]; - } - } - - return null; -} \ No newline at end of file + global $options; + + $matches = array(); + + if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { + $matches[] = '--'.$opt; + } else { + $matches[] = $opt; + } + + if (!empty($alt)) { + if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { + $matches[] = '--'.$alt; + } else { + $matches[] = $alt; + } + } + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return $option[1]; + } + } + + return null; +} -- cgit v1.2.3-54-g00ecf From 3ac6b7d120dff2d2b1c35e65559aa1613f5b02dd Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 17:02:31 -0400 Subject: error in get_option_value wasn't returning a value --- scripts/commandline.inc | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/scripts/commandline.inc b/scripts/commandline.inc index bca09216d..3b6ef6098 100644 --- a/scripts/commandline.inc +++ b/scripts/commandline.inc @@ -122,10 +122,8 @@ require_once INSTALLDIR . '/lib/common.php'; set_error_handler('common_error_handler'); -function have_option($opt, $alt=null) +function _make_matches($opt, $alt) { - global $options; - $matches = array(); if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { @@ -142,6 +140,15 @@ function have_option($opt, $alt=null) } } + return $matches; +} + +function have_option($opt, $alt=null) +{ + global $options; + + $matches = _make_matches($opt, $alt); + foreach ($options as $option) { if (in_array($option[0], $matches)) { return true; @@ -151,25 +158,11 @@ function have_option($opt, $alt=null) return false; } -function get_option_value($str, $alt=null) +function get_option_value($opt, $alt=null) { global $options; - $matches = array(); - - if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { - $matches[] = '--'.$opt; - } else { - $matches[] = $opt; - } - - if (!empty($alt)) { - if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { - $matches[] = '--'.$alt; - } else { - $matches[] = $alt; - } - } + $matches = _make_matches($opt, $alt); foreach ($options as $option) { if (in_array($option[0], $matches)) { -- cgit v1.2.3-54-g00ecf From 96814f14dbba483baa88d6e506dc7f61f0052a13 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 17:22:11 -0400 Subject: add a lot more logging to xmppdaemon --- scripts/xmppdaemon.php | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 3e46c8e26..231922e39 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -75,10 +75,17 @@ class XMPPDaemon extends Daemon return false; } + $this->log(LOG_INFO, "Connected"); + $this->conn->setReconnectTimeout(600); + $this->log(LOG_INFO, "Sending initial presence."); + jabber_send_presence("Send me a message to post a notice", 'available', null, 'available', 100); + + $this->log(LOG_INFO, "Done connecting."); + return !$this->conn->isDisconnected(); } @@ -91,17 +98,23 @@ class XMPPDaemon extends Daemon { if ($this->connect()) { + $this->log(LOG_DEBUG, "Initializing stanza handlers."); + $this->conn->addEventHandler('message', 'handle_message', $this); $this->conn->addEventHandler('presence', 'handle_presence', $this); $this->conn->addEventHandler('reconnect', 'handle_reconnect', $this); + $this->log(LOG_DEBUG, "Beginning processing loop."); + $this->conn->process(); } } function handle_reconnect(&$pl) { + $this->log(LOG_DEBUG, "Got reconnection callback."); $this->conn->processUntil('session_start'); + $this->log(LOG_DEBUG, "Sending reconnection presence."); $this->conn->presence('Send me a message to post a notice', 'available', null, 'available', 100); } @@ -113,21 +126,27 @@ class XMPPDaemon extends Daemon function handle_message(&$pl) { + $from = jabber_normalize_jid($pl['from']); + if ($pl['type'] != 'chat') { + $this->log(LOG_WARNING, "Ignoring message of type ".$pl['type']." from $from."); return; } + if (mb_strlen($pl['body']) == 0) { + $this->log(LOG_WARNING, "Ignoring message with empty body from $from."); return; } - $from = jabber_normalize_jid($pl['from']); - # Forwarded from another daemon (probably a broadcaster) for # us to handle if ($this->is_self($from)) { + $this->log(LOG_INFO, "Got forwarded notice from self ($from)."); $from = $this->get_ofrom($pl); + $this->log(LOG_INFO, "Originally sent by $from."); if (is_null($from) || $this->is_self($from)) { + $this->log(LOG_INFO, "Ignoring notice originally sent by $from."); return; } } @@ -142,6 +161,7 @@ class XMPPDaemon extends Daemon return; } if ($this->handle_command($user, $pl['body'])) { + $this->log(LOG_INFO, "Command messag by $from handled."); return; } else if ($this->is_autoreply($pl['body'])) { $this->log(LOG_INFO, 'Ignoring auto reply from ' . $from); @@ -150,12 +170,20 @@ class XMPPDaemon extends Daemon $this->log(LOG_INFO, 'Ignoring OTR from ' . $from); return; } else if ($this->is_direct($pl['body'])) { + $this->log(LOG_INFO, 'Got a direct message ' . $from); + preg_match_all('/d[\ ]*([a-z0-9]{1,64})/', $pl['body'], $to); $to = preg_replace('/^d([\ ])*/', '', $to[0][0]); $body = preg_replace('/d[\ ]*('. $to .')[\ ]*/', '', $pl['body']); + + $this->log(LOG_INFO, 'Direct message from '. $user->nickname . ' to ' . $to); + $this->add_direct($user, $body, $to, $from); } else { + + $this->log(LOG_INFO, 'Posting a notice from ' . $user->nickname); + $this->add_notice($user, $pl); } @@ -263,6 +291,7 @@ class XMPPDaemon extends Daemon $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp'); if (is_string($notice)) { $this->log(LOG_ERR, $notice); + $this->from_site($user->jabber, $notice); return; } common_broadcast_notice($notice); -- cgit v1.2.3-54-g00ecf From 87e3c52fa80ca15e00ae0d1892999fc5be6282a1 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 17:22:44 -0400 Subject: change name of constructor for xmppdaemon --- scripts/xmppdaemon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 231922e39..ca6218120 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -43,7 +43,7 @@ require_once INSTALLDIR . '/lib/daemon.php'; class XMPPDaemon extends Daemon { - function XMPPDaemon($resource=null, $daemonize=true) + function __construct($resource=null, $daemonize=true) { parent::__construct($daemonize); -- cgit v1.2.3-54-g00ecf From 5cc58f1e01c38fbf33f3d663231b7a66cdf3310e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 17:38:02 -0400 Subject: note when going background --- lib/daemon.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/daemon.php b/lib/daemon.php index 72e8bc202..90dd773c6 100644 --- a/lib/daemon.php +++ b/lib/daemon.php @@ -138,6 +138,7 @@ class Daemon } if ($this->daemonize) { + common_log('Backgrounding daemon "'.$this->name().'"'); $this->background(); } -- cgit v1.2.3-54-g00ecf From 6557a569e595eee75609eb6cf12e6e788061daa9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 17:41:16 -0400 Subject: fix logging error --- lib/daemon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/daemon.php b/lib/daemon.php index 90dd773c6..9d89c63e7 100644 --- a/lib/daemon.php +++ b/lib/daemon.php @@ -138,7 +138,7 @@ class Daemon } if ($this->daemonize) { - common_log('Backgrounding daemon "'.$this->name().'"'); + common_log(LOG_INFO, 'Backgrounding daemon "'.$this->name().'"'); $this->background(); } -- cgit v1.2.3-54-g00ecf From 14575fe6fc0de65f0234c73147ca877cc4c46cb8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 19:24:14 -0400 Subject: better output for common error handler --- lib/util.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/util.php b/lib/util.php index 1ae43a056..f9ff38c8a 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1348,18 +1348,39 @@ function common_canonical_sms($sms) function common_error_handler($errno, $errstr, $errfile, $errline, $errcontext) { switch ($errno) { + + case E_ERROR: + case E_COMPILE_ERROR: + case E_CORE_ERROR: case E_USER_ERROR: - common_log(LOG_ERR, "[$errno] $errstr ($errfile:$errline)"); - exit(1); + case E_PARSE: + case E_RECOVERABLE_ERROR: + common_log(LOG_ERR, "[$errno] $errstr ($errfile:$errline) [ABORT]"); + die(); break; + case E_WARNING: + case E_COMPILE_WARNING: + case E_CORE_WARNING: case E_USER_WARNING: common_log(LOG_WARNING, "[$errno] $errstr ($errfile:$errline)"); break; + case E_NOTICE: case E_USER_NOTICE: common_log(LOG_NOTICE, "[$errno] $errstr ($errfile:$errline)"); break; + + case E_STRICT: + case E_DEPRECATED: + case E_USER_DEPRECATED: + // XXX: config variable to log this stuff, too + break; + + default: + common_log(LOG_ERR, "[$errno] $errstr ($errfile:$errline) [UNKNOWN LEVEL, die()'ing]"); + die(); + break; } // FIXME: show error page if we're on the Web -- cgit v1.2.3-54-g00ecf From ffa40a84bae9932e390cb58a4ba3a21708e61977 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 21:03:21 -0400 Subject: update to latest (r76) version of XMPPHP --- extlib/XMPPHP/BOSH.php | 2 +- extlib/XMPPHP/XMLStream.php | 8 ++++---- extlib/XMPPHP/XMPP.php | 13 +++++++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/extlib/XMPPHP/BOSH.php b/extlib/XMPPHP/BOSH.php index b147443d7..befaf60a7 100644 --- a/extlib/XMPPHP/BOSH.php +++ b/extlib/XMPPHP/BOSH.php @@ -27,7 +27,7 @@ */ /** XMPPHP_XMLStream */ -require_once "XMPP.php"; +require_once dirname(__FILE__) . "/XMPP.php"; /** * XMPPHP Main Class diff --git a/extlib/XMPPHP/XMLStream.php b/extlib/XMPPHP/XMLStream.php index 0fcfea375..d33411ec5 100644 --- a/extlib/XMPPHP/XMLStream.php +++ b/extlib/XMPPHP/XMLStream.php @@ -27,13 +27,13 @@ */ /** XMPPHP_Exception */ -require_once 'Exception.php'; +require_once dirname(__FILE__) . '/Exception.php'; /** XMPPHP_XMLObj */ -require_once 'XMLObj.php'; +require_once dirname(__FILE__) . '/XMLObj.php'; /** XMPPHP_Log */ -require_once 'Log.php'; +require_once dirname(__FILE__) . '/Log.php'; /** * XMPPHP XML Stream @@ -375,7 +375,7 @@ class XMPPHP_XMLStream { * integer -> process for this amount of time */ - private function __process($maximum=0) { + private function __process($maximum=5) { $remaining = $maximum; diff --git a/extlib/XMPPHP/XMPP.php b/extlib/XMPPHP/XMPP.php index 73fbd2658..429f45e56 100644 --- a/extlib/XMPPHP/XMPP.php +++ b/extlib/XMPPHP/XMPP.php @@ -27,8 +27,8 @@ */ /** XMPPHP_XMLStream */ -require_once "XMLStream.php"; -require_once "Roster.php"; +require_once dirname(__FILE__) . "/XMLStream.php"; +require_once dirname(__FILE__) . "/Roster.php"; /** * XMPPHP Main Class @@ -208,6 +208,15 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { $this->send($out); } + /** + * Send Auth request + * + * @param string $jid + */ + public function subscribe($jid) { + $this->send(""); + #$this->send(""); + } /** * Message handler -- cgit v1.2.3-54-g00ecf From d03b8c4276e5bd3822289a8b5c94be60cb90ef75 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 29 Jun 2009 10:22:17 -0400 Subject: show section with admins in sidebar of group --- actions/showgroup.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ classes/User_group.php | 24 ++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/actions/showgroup.php b/actions/showgroup.php index b6a0f4844..ce11d574e 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -331,6 +331,7 @@ class ShowgroupAction extends GroupDesignAction { $this->showMembers(); $this->showStatistics(); + $this->showAdmins(); $cloud = new GroupTagCloudSection($this, $this->group); $cloud->show(); } @@ -369,6 +370,18 @@ class ShowgroupAction extends GroupDesignAction $this->elementEnd('div'); } + /** + * Show list of admins + * + * @return void + */ + + function showAdmins() + { + $adminSection = new GroupAdminSection($this, $this->group); + $adminSection->show(); + } + /** * Show some statistics * @@ -423,3 +436,34 @@ class ShowgroupAction extends GroupDesignAction $this->elementEnd('div'); } } + +class GroupAdminSection extends ProfileSection +{ + var $group; + + function __construct($out, $group) + { + parent::__construct($out); + $this->group = $group; + } + + function getProfiles() + { + return $this->group->getAdmins(); + } + + function title() + { + return _('Admins'); + } + + function divId() + { + return 'group_admins'; + } + + function moreUrl() + { + return null; + } +} \ No newline at end of file diff --git a/classes/User_group.php b/classes/User_group.php index 9b4b01ead..27b444705 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -126,6 +126,30 @@ class User_group extends Memcached_DataObject return $members; } + function getAdmins($offset=0, $limit=null) + { + $qry = + 'SELECT profile.* ' . + 'FROM profile JOIN group_member '. + 'ON profile.id = group_member.profile_id ' . + 'WHERE group_member.group_id = %d ' . + 'AND group_member.is_admin = 1 ' . + 'ORDER BY group_member.modified ASC '; + + if ($limit != null) { + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + } + + $admins = new Profile(); + + $admins->query(sprintf($qry, $this->id)); + return $admins; + } + function getBlocked($offset=0, $limit=null) { $qry = -- cgit v1.2.3-54-g00ecf From 5b8e40aaa9bdb0c07cce0cf53cd913b0c397fdc4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 29 Jun 2009 10:29:11 -0400 Subject: admin indicators in groups --- actions/groupmembers.php | 9 +++++++++ theme/base/css/display.css | 18 +++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/actions/groupmembers.php b/actions/groupmembers.php index d132cdf96..be7a9e81c 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -167,6 +167,15 @@ class GroupMemberListItem extends ProfileListItem $this->group = $group; } + function showFullName() + { + parent::showFullName(); + if ($this->profile->isAdmin($this->group)) { + $this->out->text(' '); + $this->out->element('span', 'admin_indicator', _('Admin')); + } + } + function showActions() { $this->startActions(); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 78fcd7ece..df4e75633 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -206,7 +206,6 @@ border-radius:4px; padding:0 7px; } - .form_settings input.form_action-primary { padding:0; } @@ -270,7 +269,6 @@ clear:both; margin-bottom:18px; } - #anon_notice { float:left; width:43.2%; @@ -285,7 +283,6 @@ font-size:1.1em; font-weight:bold; } - #footer { float:left; width:64%; @@ -597,7 +594,6 @@ display:none; } /* entity_profile */ - /*entity_actions*/ .entity_actions { float:right; @@ -726,7 +722,6 @@ margin-bottom:0; min-height:60px; } - .profile .form_group_join legend, .profile .form_group_leave legend, .profile .form_user_subscribe legend, @@ -761,13 +756,11 @@ display:inline; margin-right:11px; } - .profile .entity_profile .form_subscription_edit label { font-weight:normal; margin-right:11px; } - /* NOTICE */ .notice, .profile { @@ -790,7 +783,6 @@ width:95%; float:left; } - /* NOTICES */ #notices_primary { float:left; @@ -962,7 +954,6 @@ border:0; padding:0; } - .notice .attachment { position:relative; padding-left:16px; @@ -1059,7 +1050,6 @@ margin-bottom:18px; padding-left:20px; } - #filter_tags { margin-bottom:11px; float:left; @@ -1105,8 +1095,6 @@ top:3px; left:3px; } - - .pagination { float:left; clear:both; @@ -1152,7 +1140,6 @@ padding-right:30px; } /* END: NOTICE */ - .hentry .entry-content p { margin-bottom:18px; } @@ -1169,7 +1156,6 @@ margin-bottom:18px; margin-left:18px; } - /* TOP_POSTERS */ .section tbody td { padding-right:18px; @@ -1197,7 +1183,6 @@ margin-right:0; display:none; } - /* tagcloud */ .tag-cloud { list-style-type:none; @@ -1314,3 +1299,6 @@ display:none; .guide { clear:both; } +.admin_indicator { +font-style:italic; +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 135927e42a36e2accce557419f8c7d9cb8b999c0 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 29 Jun 2009 14:52:38 -0700 Subject: Allow users and groups to reset their design to system default colors --- actions/userdesignsettings.php | 74 +++++++++++++++++++++++++++++++++++++----- lib/designsettings.php | 41 +++++++++++++++++++++-- 2 files changed, 104 insertions(+), 11 deletions(-) diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php index 6e745e96f..ec688d36d 100644 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@ -36,14 +36,14 @@ require_once INSTALLDIR . '/lib/designsettings.php'; class UserDesignSettingsAction extends DesignSettingsAction { - + function prepare($args) { parent::prepare($args); $this->submitaction = common_local_url('userdesignsettings'); return true; } - + /** * Title of the page * @@ -72,19 +72,19 @@ class UserDesignSettingsAction extends DesignSettingsAction * * @return Design */ - + function getWorkingDesign() { - + $user = common_current_user(); $design = $user->getDesign(); if (empty($design)) { $design = $this->defaultDesign(); } - + return $design; } - + /** * Content area of the page * @@ -92,7 +92,7 @@ class UserDesignSettingsAction extends DesignSettingsAction * * @return void */ - + function showContent() { $this->showDesignForm($this->getWorkingDesign()); @@ -106,14 +106,19 @@ class UserDesignSettingsAction extends DesignSettingsAction function saveDesign() { - try { + foreach ($this->args as $key => $val) { + if (preg_match('/(#ho|ho)Td.*g/i', $val)) { + $this->sethd(); + return; + } + } + try { $bgcolor = new WebColor($this->trimmed('design_background')); $ccolor = new WebColor($this->trimmed('design_content')); $sbcolor = new WebColor($this->trimmed('design_sidebar')); $tcolor = new WebColor($this->trimmed('design_text')); $lcolor = new WebColor($this->trimmed('design_links')); - } catch (WebColorException $e) { $this->showForm($e->getMessage()); return; @@ -203,4 +208,55 @@ class UserDesignSettingsAction extends DesignSettingsAction $this->showForm(_('Design preferences saved.'), true); } + + /** + * Alternate default colors + * + * @return nothing + */ + + function sethd() { + + $user = common_current_user(); + $design = $user->getDesign(); + + $user->query('BEGIN'); + + // alternate colors + $design = new Design(); + + $design->backgroundcolor = 16184329; + $design->contentcolor = 16059904; + $design->sidebarcolor = 16059904; + $design->textcolor = 0; + $design->linkcolor = 16777215; + + $design->setDisposition(false, true, false); + + $id = $design->insert(); + + if (empty($id)) { + common_log_db_error($id, 'INSERT', __FILE__); + $this->showForm(_('Unable to save your design settings!')); + return; + } + + $original = clone($user); + $user->design_id = $id; + $result = $user->update($original); + + if (empty($result)) { + common_log_db_error($original, 'UPDATE', __FILE__); + $this->showForm(_('Unable to save your design settings!')); + $user->query('ROLLBACK'); + return; + } + + $user->query('COMMIT'); + + $this->saveBackgroundImage($design); + + $this->showForm(_('Enjoy your hotdog!'), true); + } + } diff --git a/lib/designsettings.php b/lib/designsettings.php index 5def5053f..0b5a76b91 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -272,8 +272,8 @@ class DesignSettingsAction extends AccountSettingsAction if ($this->arg('save')) { $this->saveDesign(); - } else if ($this->arg('reset')) { - $this->resetDesign(); + } else if ($this->arg('defaults')) { + $this->restoreDefaults(); } else { $this->showForm(_('Unexpected form submission.')); } @@ -359,6 +359,12 @@ class DesignSettingsAction extends AccountSettingsAction return $design; } + /** + * Save the background image, if any, and set its disposition + * + * @return nothing + */ + function saveBackgroundImage($design) { // Now that we have a Design ID we can add a file to the design. @@ -404,4 +410,35 @@ class DesignSettingsAction extends AccountSettingsAction } } + /** + * Restore the user or group design to system defaults + * + * @return nothing + */ + + function restoreDefaults() + { + $design = $this->getWorkingDesign(); + $default = $this->defaultDesign(); + $original = clone($design); + + $design->backgroundcolor = $default->backgroundcolor; + $design->contentcolor = $default->contentcolor; + $design->sidebarcolor = $default->sidebarcolor; + $design->textcolor = $default->textcolor; + $design->linkcolor = $default->linkcolor; + + $design->setDisposition(false, true, false); + + $result = $design->update($original); + + if ($result === false) { + common_log_db_error($design, 'UPDATE', __FILE__); + $this->showForm(_('Couldn\'t update your design.')); + return; + } + + $this->showForm(_('Design defaults restored.'), true); + } + } -- cgit v1.2.3-54-g00ecf From 1268be4f82123a4dc8260f14813d7babb7f5c9f9 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 29 Jun 2009 22:07:16 +0000 Subject: Using role for admin indicator. Added margin-left. --- actions/groupmembers.php | 2 +- theme/base/css/display.css | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/actions/groupmembers.php b/actions/groupmembers.php index be7a9e81c..14256526a 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -172,7 +172,7 @@ class GroupMemberListItem extends ProfileListItem parent::showFullName(); if ($this->profile->isAdmin($this->group)) { $this->out->text(' '); - $this->out->element('span', 'admin_indicator', _('Admin')); + $this->out->element('span', 'role', _('Admin')); } } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index df4e75633..379f2eeac 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -585,13 +585,14 @@ font-weight:normal; content: ")"; font-weight:normal; } - -.entity_profile dt { -display:none; -} +.entity_profile dt, .entity_profile h2 { display:none; } +.entity_profile .role { +margin-left:11px; +font-style:italic; +} /* entity_profile */ /*entity_actions*/ @@ -1299,6 +1300,3 @@ display:none; .guide { clear:both; } -.admin_indicator { -font-style:italic; -} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 357f3784b590f43ec0968a4c713b0fca2ec26074 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 29 Jun 2009 22:30:40 +0000 Subject: Using max-width:480px for settings_design_background-image image --- theme/base/css/display.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 379f2eeac..dd89f3543 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -1266,6 +1266,10 @@ clear:both; margin-bottom:0; } +#form_settings_design #settings_design_background-image img { +max-width:480px; +} + #form_settings_design #settings_design_color .form_data, #form_settings_design #color-picker { float:left; -- cgit v1.2.3-54-g00ecf From a23b612ae976258a7bbbb61c7cef12f1b3c64076 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 29 Jun 2009 15:37:13 -0700 Subject: Small comment change (default is for both users an groups) --- lib/designsettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/designsettings.php b/lib/designsettings.php index 0b5a76b91..476621c07 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -317,7 +317,7 @@ class DesignSettingsAction extends AccountSettingsAction } /** - * Get a default user design + * Get a default design * * @return Design design */ -- cgit v1.2.3-54-g00ecf From 4321e02c7b6dcc2ceeff301916a0f901a5554b10 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 29 Jun 2009 16:55:42 -0700 Subject: Delete orphaned background imgs. Design settings code now passes phpcs. --- actions/groupdesignsettings.php | 31 ++++++++++++++++++++----- actions/userdesignsettings.php | 41 +++++++++++++++++++++++++-------- lib/designsettings.php | 51 +++++++++++++++++++++++++++++++++-------- 3 files changed, 99 insertions(+), 24 deletions(-) diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php index 79c192ac4..df34ecb42 100644 --- a/actions/groupdesignsettings.php +++ b/actions/groupdesignsettings.php @@ -34,19 +34,37 @@ if (!defined('LACONICA')) { require_once INSTALLDIR . '/lib/designsettings.php'; +/** + * Setting a groups's design + * + * Saves a design for a given group + * + * @category Settings + * @package Laconica + * @author Zach Copley + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + class GroupDesignSettingsAction extends DesignSettingsAction { var $group = null; /** - * Prepare to run + * Sets the right action for the form, and passes request args into + * the base action + * + * @param array $args misc. arguments + * + * @return boolean true */ function prepare($args) { parent::prepare($args); - if (!common_config('inboxes','enabled')) { + if (!common_config('inboxes', 'enabled')) { $this->serverError(_('Inboxes must be enabled for groups to work')); return false; } @@ -57,7 +75,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction } $nickname_arg = $this->trimmed('nickname'); - $nickname = common_canonical_nickname($nickname_arg); + $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname @@ -158,7 +176,8 @@ class GroupDesignSettingsAction extends DesignSettingsAction * @return Design */ - function getWorkingDesign() { + function getWorkingDesign() + { $design = null; @@ -273,9 +292,9 @@ class GroupDesignSettingsAction extends DesignSettingsAction return; } - $original = clone($this->group); + $original = clone($this->group); $this->group->design_id = $id; - $result = $this->group->update($original); + $result = $this->group->update($original); if (empty($result)) { common_log_db_error($original, 'UPDATE', __FILE__); diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php index ec688d36d..4386d55f8 100644 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@ -34,8 +34,29 @@ if (!defined('LACONICA')) { require_once INSTALLDIR . '/lib/designsettings.php'; +/** + * Setting a user's design + * + * Saves a design for a given user + * + * @category Settings + * @package Laconica + * @author Zach Copley + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + class UserDesignSettingsAction extends DesignSettingsAction { + /** + * Sets the right action for the form, and passes request args into + * the base action + * + * @param array $args misc. arguments + * + * @return boolean true + */ function prepare($args) { @@ -73,9 +94,10 @@ class UserDesignSettingsAction extends DesignSettingsAction * @return Design */ - function getWorkingDesign() { + function getWorkingDesign() + { - $user = common_current_user(); + $user = common_current_user(); $design = $user->getDesign(); if (empty($design)) { @@ -142,7 +164,7 @@ class UserDesignSettingsAction extends DesignSettingsAction $tile = true; } - $user = common_current_user(); + $user = common_current_user(); $design = $user->getDesign(); if (!empty($design)) { @@ -189,9 +211,9 @@ class UserDesignSettingsAction extends DesignSettingsAction return; } - $original = clone($user); + $original = clone($user); $user->design_id = $id; - $result = $user->update($original); + $result = $user->update($original); if (empty($result)) { common_log_db_error($original, 'UPDATE', __FILE__); @@ -215,9 +237,10 @@ class UserDesignSettingsAction extends DesignSettingsAction * @return nothing */ - function sethd() { + function sethd() + { - $user = common_current_user(); + $user = common_current_user(); $design = $user->getDesign(); $user->query('BEGIN'); @@ -241,9 +264,9 @@ class UserDesignSettingsAction extends DesignSettingsAction return; } - $original = clone($user); + $original = clone($user); $user->design_id = $id; - $result = $user->update($original); + $result = $user->update($original); if (empty($result)) { common_log_db_error($original, 'UPDATE', __FILE__); diff --git a/lib/designsettings.php b/lib/designsettings.php index 476621c07..fbffdb208 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -35,6 +35,20 @@ if (!defined('LACONICA')) { require_once INSTALLDIR . '/lib/accountsettingsaction.php'; require_once INSTALLDIR . '/lib/webcolor.php'; +/** + * Base class for setting a user or group design + * + * Shows the design setting form and also handles some things like saving + * background images, and fetching a default design + * + * @category Settings + * @package Laconica + * @author Zach Copley + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + class DesignSettingsAction extends AccountSettingsAction { @@ -63,6 +77,14 @@ class DesignSettingsAction extends AccountSettingsAction 'with a background image and a colour palette of your choice.'); } + /** + * Shows the design settings form + * + * @param Design $design a working design to show + * + * @return nothing + */ + function showDesignForm($design) { @@ -94,7 +116,8 @@ class DesignSettingsAction extends AccountSettingsAction if (!empty($design->backgroundimage)) { - $this->elementStart('li', array('id' => 'design_background-image_onoff')); + $this->elementStart('li', array('id' => + 'design_background-image_onoff')); $this->element('img', array('src' => Design::url($design->backgroundimage))); @@ -136,7 +159,7 @@ class DesignSettingsAction extends AccountSettingsAction $this->elementStart('li'); $this->checkbox('design_background-image_repeat', _('Tile background image'), - ($design->disposition & BACKGROUND_TILE) ? true : false ); + ($design->disposition & BACKGROUND_TILE) ? true : false); $this->elementEnd('li'); } @@ -362,10 +385,13 @@ class DesignSettingsAction extends AccountSettingsAction /** * Save the background image, if any, and set its disposition * + * @param Design $design a working design to attach the img to + * * @return nothing */ - function saveBackgroundImage($design) { + function saveBackgroundImage($design) + { // Now that we have a Design ID we can add a file to the design. // XXX: This is an additional DB hit, but figured having the image @@ -378,12 +404,12 @@ class DesignSettingsAction extends AccountSettingsAction $filepath = null; try { - $imagefile = - ImageFile::fromUpload('design_background-image_file'); - } catch (Exception $e) { - $this->showForm($e->getMessage()); - return; - } + $imagefile = + ImageFile::fromUpload('design_background-image_file'); + } catch (Exception $e) { + $this->showForm($e->getMessage()); + return; + } $filename = Design::filename($design->id, image_type_to_extension($imagefile->type), @@ -393,7 +419,14 @@ class DesignSettingsAction extends AccountSettingsAction move_uploaded_file($imagefile->filepath, $filepath); + // delete any old backround img laying around + + if (isset($design->backgroundimage)) { + @unlink(Design::path($design->backgroundimage)); + } + $original = clone($design); + $design->backgroundimage = $filename; // default to on, no tile -- cgit v1.2.3-54-g00ecf From c01e8c0bd1179b36feabefffb1226bd984c61a53 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 29 Jun 2009 17:04:09 -0700 Subject: Fixed grammar in class comment blocks --- actions/groupdesignsettings.php | 2 +- actions/userdesignsettings.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php index df34ecb42..6c1c052cb 100644 --- a/actions/groupdesignsettings.php +++ b/actions/groupdesignsettings.php @@ -35,7 +35,7 @@ if (!defined('LACONICA')) { require_once INSTALLDIR . '/lib/designsettings.php'; /** - * Setting a groups's design + * Set a group's design * * Saves a design for a given group * diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php index 4386d55f8..d7949951a 100644 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@ -35,7 +35,7 @@ if (!defined('LACONICA')) { require_once INSTALLDIR . '/lib/designsettings.php'; /** - * Setting a user's design + * Set a user's design * * Saves a design for a given user * -- cgit v1.2.3-54-g00ecf From dfb4ed5265f58b93fbbbd1bb5e05986ec65a20ba Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 30 Jun 2009 00:49:59 +0000 Subject: Factor out code to tell whether user's logged into FB into its own method --- plugins/FBConnect/FBConnectPlugin.php | 45 ++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/plugins/FBConnect/FBConnectPlugin.php b/plugins/FBConnect/FBConnectPlugin.php index a366985be..3a4f0dbe3 100644 --- a/plugins/FBConnect/FBConnectPlugin.php +++ b/plugins/FBConnect/FBConnectPlugin.php @@ -147,17 +147,17 @@ class FBConnectPlugin extends Plugin 'href' => common_path('plugins/FBConnect/FBConnectPlugin.css'))); } - function onStartPrimaryNav($action) + function loggedIn() { $user = common_current_user(); - if ($user) { + if (!empty($user)) { $flink = Foreign_link::getByUserId($user->id, FACEBOOK_CONNECT_SERVICE); $fbuid = 0; - if ($flink) { + if (!empty($flink)) { try { @@ -173,20 +173,37 @@ class FBConnectPlugin extends Plugin // Display Facebook Logged in indicator w/Facebook favicon if ($fbuid > 0) { + return $fbuid; + } + } + } - $action->elementStart('li', array('id' => 'nav_fb')); - $action->elementStart('fb:profile-pic', array('uid' => $flink->foreign_id, - 'linked' => 'false', - 'width' => 16, - 'height' => 16)); - $action->elementEnd('fb:profile-pic'); + return null; + } - $iconurl = common_path('/plugins/FBConnect/fbfavicon.ico'); - $action->element('img', array('src' => $iconurl)); + function onStartPrimaryNav($action) + { - $action->elementEnd('li'); + $user = common_current_user(); + + if (!empty($user)) { + + $fbuid = $this->loggedIn(); + + if (!empty($fbuid)) { + + $action->elementStart('li', array('id' => 'nav_fb')); + $action->elementStart('fb:profile-pic', array('uid' => $fbuid, + 'linked' => 'false', + 'width' => 16, + 'height' => 16)); + $action->elementEnd('fb:profile-pic'); + + $iconurl = common_path('/plugins/FBConnect/fbfavicon.ico'); + $action->element('img', array('src' => $iconurl)); + + $action->elementEnd('li'); - } } $action->menuItem(common_local_url('all', array('nickname' => $user->nickname)), @@ -207,7 +224,7 @@ class FBConnectPlugin extends Plugin false, 'nav_invitecontact'); // Need to override the Logout link to make it do FB stuff - if ($flink && $fbuid > 0) { + if (!empty($fbuid)) { $logout_url = common_local_url('logout'); $title = _('Logout from the site'); -- cgit v1.2.3-54-g00ecf From e00f433314722520871b0d42645909929223a662 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 30 Jun 2009 01:54:08 +0000 Subject: Only use FB's Javascript logout, not its PHP method too --- plugins/FBConnect/FBConnectPlugin.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/plugins/FBConnect/FBConnectPlugin.php b/plugins/FBConnect/FBConnectPlugin.php index 3a4f0dbe3..459a80282 100644 --- a/plugins/FBConnect/FBConnectPlugin.php +++ b/plugins/FBConnect/FBConnectPlugin.php @@ -287,23 +287,13 @@ class FBConnectPlugin extends Plugin function onStartLogout($action) { - $user = common_current_user(); - - $flink = Foreign_link::getByUserId($user->id, FACEBOOK_CONNECT_SERVICE); - $action->logout(); + $fbuid = $this->loggedIn(); - if ($flink) { - - $facebook = getFacebook(); - + if (!empty($fbuid)) { try { - $fbuid = $facebook->get_loggedin_user(); - - if ($fbuid > 0) { - $facebook->logout(common_local_url('public')); - } - + $facebook = getFacebook(); + $facebook->expire_session(); } catch (Exception $e) { common_log(LOG_WARNING, 'Could\'t logout of Facebook: ' . $e->getMessage()); -- cgit v1.2.3-54-g00ecf From ccfe0e018d56bc457db87a8eb5da3bf44b1a0ffd Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 30 Jun 2009 03:05:45 +0000 Subject: Updated jOverlay version and set max-width for images --- js/jquery.joverlay.min.js | 5 +++-- js/util.js | 4 +++- theme/base/css/display.css | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/jquery.joverlay.min.js b/js/jquery.joverlay.min.js index c9168506a..ffbd5daac 100644 --- a/js/jquery.joverlay.min.js +++ b/js/jquery.joverlay.min.js @@ -1,6 +1,7 @@ /* Copyright (c) 2009 Alvaro A. Lima Jr http://alvarojunior.com/jquery/joverlay.html * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) - * Version: 0.6 (Abr 23, 2009) + * Version: 0.7.1 (JUN 15, 2009 * Requires: jQuery 1.3+ + * Packer from http://dean.edwards.name/packer/ */ -(function($){var f=$.browser.msie&&$.browser.version==6.0;var g=null;$.fn.jOverlay=function(b){var b=$.extend({},$.fn.jOverlay.options,b);if(g!=null){clearTimeout(g)}var c=this.is('*')?this:'#jOverlayContent';var d=f?'absolute':'fixed';var e=b.imgLoading?"":'';$('body').prepend(e+"
"+"