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 f65015b24a8448ecbb12b3897992cdaf6b563212 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli 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(-) (limited to 'lib') 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 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(-) (limited to 'lib') 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(-) (limited to 'lib') 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 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(-) (limited to 'lib') 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 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(+) (limited to 'lib') 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(-) (limited to 'lib') 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(-) (limited to 'lib') 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 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(-) (limited to 'lib') 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 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(-) (limited to 'lib') 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(-) (limited to 'lib') 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 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 From f61645aef803d7d39d03fddb25106bb9eae06060 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 1 Jul 2009 11:38:10 -0400 Subject: take out session handler notification --- lib/util.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index f9ff38c8a..203506bbc 100644 --- a/lib/util.php +++ b/lib/util.php @@ -145,7 +145,6 @@ function common_ensure_session() } if (!common_have_session()) { if (common_config('sessions', 'handle')) { - common_log(LOG_INFO, "Using our own session handler"); Session::setSaveHandler(); } @session_start(); -- cgit v1.2.3-54-g00ecf From 8a8390c1a78a2586bb2e9e10bfcb3502739d8d76 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 1 Jul 2009 12:58:16 -0400 Subject: exclude p argument when calculating selfUrl --- lib/action.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/action.php b/lib/action.php index 89a8c8f4d..6a2f9b0f1 100644 --- a/lib/action.php +++ b/lib/action.php @@ -247,7 +247,6 @@ class Action extends HTMLOutputter // lawsuit 'src' => common_path('js/jquery.joverlay.min.js')), ' '); - Event::handle('EndShowJQueryScripts', array($this)); } if (Event::handle('StartShowLaconicaScripts', array($this))) { @@ -964,12 +963,16 @@ class Action extends HTMLOutputter // lawsuit $action = $this->trimmed('action'); $args = $this->args; unset($args['action']); + if (common_config('site', 'fancy')) { + unset($args['p']); + } if (array_key_exists('submit', $args)) { unset($args['submit']); } foreach (array_keys($_COOKIE) as $cookie) { unset($args[$cookie]); } + return common_local_url($action, $args); } -- cgit v1.2.3-54-g00ecf From 734f631e1ea9022c6de492e0d2979c9ca00585a4 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 1 Jul 2009 18:40:14 -0700 Subject: Show correct number of profile avatars and 'all' link in subs asides --- lib/profileaction.php | 8 ++++++-- lib/profileminilist.php | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/profileaction.php b/lib/profileaction.php index 2519922b2..eeb5dbe48 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -108,7 +108,9 @@ class ProfileAction extends OwnerDesignAction $this->element('h2', null, _('Subscriptions')); - if ($profile) { + $cnt = 0; + + if (!empty($profile)) { $pml = new ProfileMiniList($profile, $this); $cnt = $pml->show(); if ($cnt == 0) { @@ -137,7 +139,9 @@ class ProfileAction extends OwnerDesignAction $this->element('h2', null, _('Subscribers')); - if ($profile) { + $cnt = 0; + + if (!empty($profile)) { $pml = new ProfileMiniList($profile, $this); $cnt = $pml->show(); if ($cnt == 0) { diff --git a/lib/profileminilist.php b/lib/profileminilist.php index 09bef6f7c..357b4a2db 100644 --- a/lib/profileminilist.php +++ b/lib/profileminilist.php @@ -47,6 +47,7 @@ define('PROFILES_PER_MINILIST', 27); class ProfileMiniList extends ProfileList { + function startList() { $this->out->elementStart('ul', 'entities users xoxo'); @@ -56,6 +57,23 @@ class ProfileMiniList extends ProfileList { return new ProfileMiniListItem($profile, $this->action); } + + function showProfiles() + { + $cnt = 0; + + while ($this->profile->fetch()) { + $cnt++; + if ($cnt > PROFILES_PER_MINILIST) { + break; + } + $pli = $this->newListItem($this->profile); + $pli->show(); + } + + return $cnt; + } + } class ProfileMiniListItem extends ProfileListItem -- cgit v1.2.3-54-g00ecf