From eaa81d25fa7bd954132ce7f901fae69b0d46ec1a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 22:57:15 +0000 Subject: Convert all actions to use new UI functions I did a massive search-and-replace to get all the action subclasses to use the new output function (common_element() -> $this->element(), etc.) There's still a lot to do, but it's a first step --- actions/openidsettings.php | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'actions/openidsettings.php') diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 039236048..9265b5ea6 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -39,28 +39,28 @@ class OpenidsettingsAction extends SettingsAction $this->form_header(_('OpenID settings'), $msg, $success); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'openidadd', 'action' => common_local_url('openidsettings'))); - common_hidden('token', common_session_token()); - common_element('h2', null, _('Add OpenID')); - common_element('p', null, + $this->hidden('token', common_session_token()); + $this->element('h2', null, _('Add OpenID')); + $this->element('p', null, _('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); - common_element_start('p'); - common_element('label', array('for' => 'openid_url'), + $this->elementStart('p'); + $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); - common_element('input', array('name' => 'openid_url', + $this->element('input', array('name' => 'openid_url', 'type' => 'text', 'id' => 'openid_url')); - common_element('input', array('type' => 'submit', + $this->element('input', array('type' => 'submit', 'id' => 'add', 'name' => 'add', 'class' => 'submit', 'value' => _('Add'))); - common_element_end('p'); - common_element_end('form'); + $this->elementEnd('p'); + $this->elementEnd('form'); $oid = new User_openid(); $oid->user_id = $user->id; @@ -69,48 +69,48 @@ class OpenidsettingsAction extends SettingsAction if ($cnt > 0) { - common_element('h2', null, _('Remove OpenID')); + $this->element('h2', null, _('Remove OpenID')); if ($cnt == 1 && !$user->password) { - common_element('p', null, + $this->element('p', null, _('Removing your only OpenID would make it impossible to log in! ' . 'If you need to remove it, add another OpenID first.')); if ($oid->fetch()) { - common_element_start('p'); - common_element('a', array('href' => $oid->canonical), + $this->elementStart('p'); + $this->element('a', array('href' => $oid->canonical), $oid->display); - common_element_end('p'); + $this->elementEnd('p'); } } else { - common_element('p', null, + $this->element('p', null, _('You can remove an OpenID from your account '. 'by clicking the button marked "Remove".')); $idx = 0; while ($oid->fetch()) { - common_element_start('form', array('method' => 'POST', + $this->elementStart('form', array('method' => 'POST', 'id' => 'openiddelete' . $idx, 'action' => common_local_url('openidsettings'))); - common_element_start('p'); - common_hidden('token', common_session_token()); - common_element('a', array('href' => $oid->canonical), + $this->elementStart('p'); + $this->hidden('token', common_session_token()); + $this->element('a', array('href' => $oid->canonical), $oid->display); - common_element('input', array('type' => 'hidden', + $this->element('input', array('type' => 'hidden', 'id' => 'openid_url'.$idx, 'name' => 'openid_url', 'value' => $oid->canonical)); - common_element('input', array('type' => 'submit', + $this->element('input', array('type' => 'submit', 'id' => 'remove'.$idx, 'name' => 'remove', 'class' => 'submit', 'value' => _('Remove'))); - common_element_end('p'); - common_element_end('form'); + $this->elementEnd('p'); + $this->elementEnd('form'); $idx++; } } -- cgit v1.2.3-54-g00ecf From 2f99a257a0d8bd773ea96249b13b134fcfbc99cd Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 16 Jan 2009 20:25:46 +0000 Subject: Make the OpenID settings work with new framework --- actions/finishaddopenid.php | 112 ++++++++++++++++++++++++++++----- actions/openidsettings.php | 147 ++++++++++++++++++++++++++++++++------------ 2 files changed, 202 insertions(+), 57 deletions(-) (limited to 'actions/openidsettings.php') diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php index 708e8d4bf..8f10505cf 100644 --- a/actions/finishaddopenid.php +++ b/actions/finishaddopenid.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/openid.php'); +require_once INSTALLDIR.'/lib/openid.php'; + +/** + * Complete adding an OpenID + * + * Handle the return from an OpenID verification + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ class FinishaddopenidAction extends Action { + var $msg = null; + + /** + * Handle the redirect back from OpenID confirmation + * + * Check to see if the user's logged in, and then try + * to use the OpenID login system. + * + * @param array $args $_REQUEST arguments + * + * @return void + */ function handle($args) { @@ -30,13 +66,20 @@ class FinishaddopenidAction extends Action if (!common_logged_in()) { $this->clientError(_('Not logged in.')); } else { - $this->try_login(); + $this->tryLogin(); } } - - function try_login() - { + /** + * Try to log in using OpenID + * + * Check the OpenID for validity; potentially store it. + * + * @return void + */ + + function tryLogin() + { $consumer =& oid_consumer(); $response = $consumer->complete(common_local_url('finishaddopenid')); @@ -46,10 +89,11 @@ class FinishaddopenidAction extends Action return; } else if ($response->status == Auth_OpenID_FAILURE) { // Authentication failed; display the error message. - $this->message(sprintf(_('OpenID authentication failed: %s'), $response->message)); + $this->message(sprintf(_('OpenID authentication failed: %s'), + $response->message)); } else if ($response->status == Auth_OpenID_SUCCESS) { - $display = $response->getDisplayIdentifier(); + $display = $response->getDisplayIdentifier(); $canonical = ($response->endpoint && $response->endpoint->canonicalID) ? $response->endpoint->canonicalID : $display; @@ -60,6 +104,7 @@ class FinishaddopenidAction extends Action } $cur =& common_current_user(); + $other = oid_get_user($canonical); if ($other) { @@ -71,7 +116,7 @@ class FinishaddopenidAction extends Action return; } - # start a transaction + // start a transaction $cur->query('BEGIN'); @@ -88,7 +133,7 @@ class FinishaddopenidAction extends Action } } - # success! + // success! $cur->query('COMMIT'); @@ -98,10 +143,43 @@ class FinishaddopenidAction extends Action } } + /** + * Show a failure message + * + * Something went wrong. Save the message, and show the page. + * + * @param string $msg Error message to show + * + * @return void + */ + function message($msg) { - common_show_header(_('OpenID Login')); - $this->element('p', null, $msg); - common_show_footer(); + $this->message = $msg; + $this->showPage(); + } + + /** + * Title of the page + * + * @return string title + */ + + function title() + { + return _('OpenID Login'); + } + + /** + * Show error message + * + * @return void + */ + + function showPageNotice() + { + if ($this->message) { + $this->element('p', 'error', $this->message); + } } } diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 9265b5ea6..a21a9869e 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/settingsaction.php'); -require_once(INSTALLDIR.'/lib/openid.php'); +require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/openid.php'; + +/** + * Settings for OpenID + * + * Lets users add, edit and delete OpenIDs from their account + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ class OpenidsettingsAction extends SettingsAction { + /** + * Title of the page + * + * @return string Page title + */ - function get_instructions() + function title() { - return _('[OpenID](%%doc.openid%%) lets you log into many sites ' . - ' with the same user account. '. - ' Manage your associated OpenIDs from here.'); + return _('OpenID settings'); } - function show_form($msg=null, $success=false) + /** + * Instructions for use + * + * @return string Instructions for use + */ + + function getInstructions() { + return _('[OpenID](%%doc.openid%%) lets you log into many sites ' . + ' with the same user account. '. + ' Manage your associated OpenIDs from here.'); + } - $user = common_current_user(); + /** + * Show the form for OpenID management + * + * We have one form with a few different submit buttons to do different things. + * + * @return void + */ - $this->form_header(_('OpenID settings'), $msg, $success); + function showContent() + { + $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'openidadd', - 'action' => - common_local_url('openidsettings'))); + 'id' => 'openidadd', + 'action' => + common_local_url('openidsettings'))); $this->hidden('token', common_session_token()); $this->element('h2', null, _('Add OpenID')); $this->element('p', null, _('If you want to add an OpenID to your account, ' . - 'enter it in the box below and click "Add".')); + 'enter it in the box below and click "Add".')); $this->elementStart('p'); $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); @@ -63,6 +108,7 @@ class OpenidsettingsAction extends SettingsAction $this->elementEnd('form'); $oid = new User_openid(); + $oid->user_id = $user->id; $cnt = $oid->find(); @@ -74,8 +120,10 @@ class OpenidsettingsAction extends SettingsAction if ($cnt == 1 && !$user->password) { $this->element('p', null, - _('Removing your only OpenID would make it impossible to log in! ' . - 'If you need to remove it, add another OpenID first.')); + _('Removing your only OpenID '. + 'would make it impossible to log in! ' . + 'If you need to remove it, '. + 'add another OpenID first.')); if ($oid->fetch()) { $this->elementStart('p'); @@ -88,14 +136,15 @@ class OpenidsettingsAction extends SettingsAction $this->element('p', null, _('You can remove an OpenID from your account '. - 'by clicking the button marked "Remove".')); + 'by clicking the button marked "Remove".')); $idx = 0; while ($oid->fetch()) { - $this->elementStart('form', array('method' => 'POST', - 'id' => 'openiddelete' . $idx, - 'action' => - common_local_url('openidsettings'))); + $this->elementStart('form', + array('method' => 'POST', + 'id' => 'openiddelete' . $idx, + 'action' => + common_local_url('openidsettings'))); $this->elementStart('p'); $this->hidden('token', common_session_token()); $this->element('a', array('href' => $oid->canonical), @@ -115,47 +164,65 @@ class OpenidsettingsAction extends SettingsAction } } } - - common_show_footer(); } - function handle_post() + /** + * Handle a POST request + * + * Muxes to different sub-functions based on which button was pushed + * + * @return void + */ + + function handlePost() { - # CSRF protection + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); return; } if ($this->arg('add')) { - $result = oid_authenticate($this->trimmed('openid_url'), 'finishaddopenid'); - if (is_string($result)) { # error message - $this->show_form($result); + $result = oid_authenticate($this->trimmed('openid_url'), + 'finishaddopenid'); + if (is_string($result)) { // error message + $this->showForm($result); } } else if ($this->arg('remove')) { - $this->remove_openid(); + $this->removeOpenid(); } else { - $this->show_form(_('Something weird happened.')); + $this->showForm(_('Something weird happened.')); } } - function remove_openid() - { + /** + * Handles a request to remove an OpenID from the user's account + * + * Validates input and, if everything is OK, deletes the OpenID. + * Reloads the form with a success or error notification. + * + * @return void + */ + function removeOpenid() + { $openid_url = $this->trimmed('openid_url'); + $oid = User_openid::staticGet('canonical', $openid_url); + if (!$oid) { - $this->show_form(_('No such OpenID.')); + $this->showForm(_('No such OpenID.')); return; } $cur = common_current_user(); if (!$cur || $oid->user_id != $cur->id) { - $this->show_form(_('That OpenID does not belong to you.')); + $this->showForm(_('That OpenID does not belong to you.')); return; } $oid->delete(); - $this->show_form(_('OpenID removed.'), true); + $this->showForm(_('OpenID removed.'), true); return; } } -- cgit v1.2.3-54-g00ecf From 2561199e59ce6c4f4390443bda6d17d709ce1e36 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 00:06:31 +0000 Subject: OpenID form settings markup --- actions/openidsettings.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'actions/openidsettings.php') diff --git a/actions/openidsettings.php b/actions/openidsettings.php index a21a9869e..f24c81795 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -85,26 +85,31 @@ class OpenidsettingsAction extends SettingsAction $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'openidadd', + 'id' => 'form_openid_add', + 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Add OpenID')); $this->hidden('token', common_session_token()); - $this->element('h2', null, _('Add OpenID')); - $this->element('p', null, + $this->element('p', 'form_guide', _('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); - $this->elementStart('p'); + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); $this->element('input', array('name' => 'openid_url', 'type' => 'text', 'id' => 'openid_url')); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->element('input', array('type' => 'submit', 'id' => 'add', 'name' => 'add', 'class' => 'submit', 'value' => _('Add'))); - $this->elementEnd('p'); + $this->elementEnd('fieldset'); $this->elementEnd('form'); $oid = new User_openid(); -- cgit v1.2.3-54-g00ecf From b9fb70ee70ecd465f5843241b308f2b8680120f6 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 00:46:33 +0000 Subject: Markup clean up and styles --- actions/emailsettings.php | 7 +++---- actions/openidsettings.php | 15 ++++++++------- lib/action.php | 3 +-- theme/base/css/display.css | 4 ++++ 4 files changed, 16 insertions(+), 13 deletions(-) (limited to 'actions/openidsettings.php') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 090df30dd..355470815 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -90,7 +90,7 @@ class EmailsettingsAction extends SettingsAction 'action' => common_local_url('emailsettings'))); - $this->elementStart('fieldset',array('id' => 'settings_email_address')); + $this->elementStart('fieldset', array('id' => 'settings_email_address')); $this->element('legend', null, _('Address')); $this->hidden('token', common_session_token()); @@ -123,7 +123,7 @@ class EmailsettingsAction extends SettingsAction $this->elementEnd('fieldset'); if ($user->email) { - $this->elementStart('fieldset',array('id' => 'settings_email_incoming')); + $this->elementStart('fieldset', array('id' => 'settings_email_incoming')); $this->element('legend',_('Incoming email')); if ($user->incomingemail) { $this->elementStart('p'); @@ -180,9 +180,8 @@ class EmailsettingsAction extends SettingsAction $user->emailmicroid); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->elementEnd('fieldset'); - $this->submit('save', _('Save')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/actions/openidsettings.php b/actions/openidsettings.php index f24c81795..6f17f154c 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -85,11 +85,11 @@ class OpenidsettingsAction extends SettingsAction $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'form_openid_add', + 'id' => 'form_settings_openid_add', 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); - $this->elementStart('fieldset'); + $this->elementStart('fieldset', array('id' => 'settings_openid_add')); $this->element('legend', null, _('Add OpenID')); $this->hidden('token', common_session_token()); $this->element('p', 'form_guide', @@ -105,7 +105,7 @@ class OpenidsettingsAction extends SettingsAction $this->elementEnd('li'); $this->elementEnd('ul'); $this->element('input', array('type' => 'submit', - 'id' => 'add', + 'id' => 'settings_openid_add_action-submit', 'name' => 'add', 'class' => 'submit', 'value' => _('Add'))); @@ -139,7 +139,7 @@ class OpenidsettingsAction extends SettingsAction } else { - $this->element('p', null, + $this->element('p', 'form_guide', _('You can remove an OpenID from your account '. 'by clicking the button marked "Remove".')); $idx = 0; @@ -147,10 +147,11 @@ class OpenidsettingsAction extends SettingsAction while ($oid->fetch()) { $this->elementStart('form', array('method' => 'POST', - 'id' => 'openiddelete' . $idx, + 'id' => 'form_settings_openid_delete' . $idx, + 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); - $this->elementStart('p'); + $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('a', array('href' => $oid->canonical), $oid->display); @@ -163,7 +164,7 @@ class OpenidsettingsAction extends SettingsAction 'name' => 'remove', 'class' => 'submit', 'value' => _('Remove'))); - $this->elementEnd('p'); + $this->elementEnd('fieldset'); $this->elementEnd('form'); $idx++; } diff --git a/lib/action.php b/lib/action.php index 1622047c0..35f6f2e3e 100644 --- a/lib/action.php +++ b/lib/action.php @@ -565,8 +565,7 @@ class Action extends HTMLOutputter // lawsuit if ($is_selected) { $lattrs['class'] = 'current'; } - (is_null($id)) ? $lattrs : $lattrs['id'] = $id; - $this->elementStart('li', $lattrs); + $this->elementStart('li', (is_null($id)) ? $lattrs : $lattr['id'] = $id); $attrs['href'] = $url; if ($title) { $attrs['title'] = $title; diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 294119c55..3aee52088 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -99,6 +99,10 @@ form input.submit { /* FORM SETTINGS */ +.form_settings { +margin-bottom:29px; +} + .form_settings fieldset { padding:0; border:0; -- cgit v1.2.3-54-g00ecf From 97c98cf59ace088e487e130182ff4dc99d2d408b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 17 Jan 2009 22:30:44 +0000 Subject: Break up settings into two tabset Made two tabsets: account and connect. Removed "Invite" from the global nav to make room. --- actions/avatarsettings.php | 4 +- actions/emailsettings.php | 7 +- actions/imsettings.php | 4 +- actions/openidsettings.php | 4 +- actions/othersettings.php | 4 +- actions/passwordsettings.php | 161 ++++++++++++++++++ actions/profilesettings.php | 378 ++++++++++++------------------------------ actions/smssettings.php | 5 +- actions/twittersettings.php | 7 +- lib/accountsettingsaction.php | 134 +++++++++++++++ lib/action.php | 82 ++++----- lib/connectsettingsaction.php | 129 ++++++++++++++ lib/rssaction.php | 97 ++++++++--- lib/settingsaction.php | 15 -- lib/settingsgroupnav.php | 112 ------------- lib/util.php | 4 + 16 files changed, 665 insertions(+), 482 deletions(-) create mode 100644 actions/passwordsettings.php create mode 100644 lib/accountsettingsaction.php create mode 100644 lib/connectsettingsaction.php delete mode 100644 lib/settingsgroupnav.php (limited to 'actions/openidsettings.php') diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index de5473d9f..a9b381b0a 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -32,7 +32,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; /** * Upload an avatar @@ -47,7 +47,7 @@ require_once INSTALLDIR.'/lib/settingsaction.php'; * @link http://laconi.ca/ */ -class AvatarsettingsAction extends SettingsAction +class AvatarsettingsAction extends AccountSettingsAction { /** * Title of the page diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 355470815..b1f13c18c 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -32,7 +32,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; /** * Settings for email @@ -47,7 +47,7 @@ require_once INSTALLDIR.'/lib/settingsaction.php'; * @see Widget */ -class EmailsettingsAction extends SettingsAction +class EmailsettingsAction extends AccountSettingsAction { /** * Title of the page @@ -103,7 +103,7 @@ class EmailsettingsAction extends SettingsAction $confirm = $this->getConfirmation(); if ($confirm) { $this->element('p', array('id' => 'email_unconfirmed'), $confirm->address); - $this->element('p', array('class' => 'form_note'), + $this->element('p', array('class' => 'form_note'), _('Awaiting confirmation on this address. '. 'Check your inbox (and spam box!) for a message '. 'with further instructions.')); @@ -143,7 +143,6 @@ class EmailsettingsAction extends SettingsAction $this->elementEnd('fieldset'); } - $this->elementStart('fieldset', array('id' => 'settings_email_preferences')); $this->element('legend', null, _('Preferences')); diff --git a/actions/imsettings.php b/actions/imsettings.php index 3e578b307..98951ac30 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -31,7 +31,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/connectsettingsaction.php'; require_once INSTALLDIR.'/lib/jabber.php'; /** @@ -46,7 +46,7 @@ require_once INSTALLDIR.'/lib/jabber.php'; * @see SettingsAction */ -class ImsettingsAction extends SettingsAction +class ImsettingsAction extends ConnectSettingsAction { /** * Title of the page diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 6f17f154c..257aac8d0 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -31,7 +31,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; require_once INSTALLDIR.'/lib/openid.php'; /** @@ -46,7 +46,7 @@ require_once INSTALLDIR.'/lib/openid.php'; * @link http://laconi.ca/ */ -class OpenidsettingsAction extends SettingsAction +class OpenidsettingsAction extends AccountSettingsAction { /** * Title of the page diff --git a/actions/othersettings.php b/actions/othersettings.php index 51f6f8197..a7664d74e 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -19,9 +19,9 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/settingsaction.php'); +require_once(INSTALLDIR.'/lib/accountsettingsaction.php'); -class OthersettingsAction extends SettingsAction +class OthersettingsAction extends AccountSettingsAction { function get_instructions() diff --git a/actions/passwordsettings.php b/actions/passwordsettings.php new file mode 100644 index 000000000..f96da13bd --- /dev/null +++ b/actions/passwordsettings.php @@ -0,0 +1,161 @@ +. + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; + +/** + * Change password + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class PasswordsettingsAction extends AccountSettingsAction +{ + /** + * Title of the page + * + * @return string Title of the page + */ + + function title() + { + return _('Change password'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ + + function getInstructions() + { + return _('Change your password.'); + } + + /** + * Content area of the page + * + * Shows a form for changing the password + * + * @return void + */ + + function showContent() + { + $user = common_current_user(); + $this->elementStart('form', array('method' => 'POST', + 'id' => 'password', + 'action' => + common_local_url('profilesettings'))); + + $this->hidden('token', common_session_token()); + + // Users who logged in with OpenID won't have a pwd + if ($user->password) { + $this->password('oldpassword', _('Old password')); + } + $this->password('newpassword', _('New password'), + _('6 or more characters')); + $this->password('confirm', _('Confirm'), + _('same as password above')); + $this->submit('changepass', _('Change')); + $this->elementEnd('form'); + } + + /** + * Handle a post + * + * Validate input and save changes. Reload the form with a success + * or error message. + * + * @return void + */ + + function handlePost() + { + // CSRF protection + + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); + return; + } + + $user = common_current_user(); + assert(!is_null($user)); // should already be checked + + // FIXME: scrub input + + $newpassword = $this->arg('newpassword'); + $confirm = $this->arg('confirm'); + + if (0 != strcmp($newpassword, $confirm)) { + $this->showForm(_('Passwords don\'t match.')); + return; + } + + if ($user->password) { + $oldpassword = $this->arg('oldpassword'); + + if (!common_check_user($user->nickname, $oldpassword)) { + $this->showForm(_('Incorrect old password')); + return; + } + } + + $original = clone($user); + + $user->password = common_munge_password($newpassword, $user->id); + + $val = $user->validate(); + if ($val !== true) { + $this->showForm(_('Error saving user; invalid.')); + return; + } + + if (!$user->update($original)) { + $this->serverError(_('Can\'t save new password.')); + return; + } + + $this->showForm(_('Password saved.'), true); + } +} \ No newline at end of file diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 6ad3f2ef5..c31f76227 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; -require_once(INSTALLDIR.'/lib/settingsaction.php'); +/** + * Change profile settings + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ -class ProfilesettingsAction extends SettingsAction +class ProfilesettingsAction extends AccountSettingsAction { + /** + * Title of the page + * + * @return string Title of the page + */ - function get_instructions() + function title() { - return _('You can update your personal profile info here '. - 'so people know more about you.'); + return _('Profile settings'); } - function show_form($msg=null, $success=false) - { - $this->form_header(_('Profile settings'), $msg, $success); - $this->show_settings_form(); - $this->element('h2', null, _('Avatar')); - $this->show_avatar_form(); - $this->element('h2', null, _('Change password')); - $this->show_password_form(); -// $this->element('h2', null, _('Delete my account')); -// $this->show_delete_form(); - common_show_footer(); - } + /** + * Instructions for use + * + * @return instructions for use + */ - function handle_post() + function getInstructions() { - - # CSRF protection - - $token = $this->trimmed('token'); - if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); - return; - } - - if ($this->arg('save')) { - $this->save_profile(); - } else if ($this->arg('upload')) { - $this->upload_avatar(); - } else if ($this->arg('crop')) { - $this->crop_avatar(); - } else if ($this->arg('changepass')) { - $this->change_password(); - } else { - $this->show_form(_('Unexpected form submission.')); - } - + return _('You can update your personal profile info here '. + 'so people know more about you.'); } - function show_settings_form() - { + /** + * Content area of the page + * + * Shows a form for uploading an avatar. + * + * @return void + */ + function showContent() + { $user = common_current_user(); $profile = $user->getProfile(); @@ -78,9 +87,9 @@ class ProfilesettingsAction extends SettingsAction 'id' => 'profilesettings', 'action' => common_local_url('profilesettings'))); $this->hidden('token', common_session_token()); - + # too much common patterns here... abstractable? - + $this->input('nickname', _('Nickname'), ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname, _('1-64 lowercase letters or numbers, no punctuation or spaces')); @@ -100,16 +109,24 @@ class ProfilesettingsAction extends SettingsAction _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated')); $language = common_language(); - $this->dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), true, $language); + $this->dropdown('language', _('Language'), + get_nice_language_list(), _('Preferred language'), + true, $language); + $timezone = common_timezone(); $timezones = array(); foreach(DateTimeZone::listIdentifiers() as $k => $v) { $timezones[$v] = $v; } - $this->dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone); + $this->dropdown('timezone', _('Timezone'), + $timezones, _('What timezone are you normally in?'), + true, $timezone); - $this->checkbox('autosubscribe', _('Automatically subscribe to whoever subscribes to me (best for non-humans)'), - ($this->arg('autosubscribe')) ? $this->boolean('autosubscribe') : $user->autosubscribe); + $this->checkbox('autosubscribe', + _('Automatically subscribe to whoever '. + 'subscribes to me (best for non-humans)'), + ($this->arg('autosubscribe')) ? + $this->boolean('autosubscribe') : $user->autosubscribe); $this->submit('save', _('Save')); @@ -117,105 +134,26 @@ class ProfilesettingsAction extends SettingsAction } - function show_avatar_form() - { - - $user = common_current_user(); - $profile = $user->getProfile(); - - if (!$profile) { - common_log_db_error($user, 'SELECT', __FILE__); - $this->serverError(_('User without matching profile')); - return; - } - - $original = $profile->getOriginalAvatar(); - - - $this->elementStart('form', array('enctype' => 'multipart/form-data', - 'method' => 'POST', - 'id' => 'avatar', - 'action' => - common_local_url('profilesettings'))); - $this->hidden('token', common_session_token()); - - if ($original) { - $this->elementStart('div', array('id'=>'avatar_original', 'class'=>'avatar_view')); - $this->element('h3', null, _("Original:")); - $this->elementStart('div', array('id'=>'avatar_original_view')); - $this->element('img', array('src' => $original->url, - 'class' => 'avatar original', - 'width' => $original->width, - 'height' => $original->height, - 'alt' => $user->nickname)); - $this->elementEnd('div'); - $this->elementEnd('div'); - } - - $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - - if ($avatar) { - $this->elementStart('div', array('id'=>'avatar_preview', 'class'=>'avatar_view')); - $this->element('h3', null, _("Preview:")); - $this->elementStart('div', array('id'=>'avatar_preview_view')); - $this->element('img', array('src' => $original->url,//$avatar->url, - 'class' => 'avatar profile', - 'width' => AVATAR_PROFILE_SIZE, - 'height' => AVATAR_PROFILE_SIZE, - 'alt' => $user->nickname)); - $this->elementEnd('div'); - $this->elementEnd('div'); - - foreach(array('avatar_crop_x', 'avatar_crop_y', 'avatar_crop_w', 'avatar_crop_h') as $crop_info) { - $this->element('input', array('name' => $crop_info, - 'type' => 'hidden', - 'id' => $crop_info)); - } - $this->submit('crop', _('Crop')); - } - - $this->element('input', array('name' => 'MAX_FILE_SIZE', - 'type' => 'hidden', - 'id' => 'MAX_FILE_SIZE', - 'value' => MAX_AVATAR_SIZE)); - - $this->elementStart('p'); - - $this->element('input', array('name' => 'avatarfile', - 'type' => 'file', - 'id' => 'avatarfile')); - $this->elementEnd('p'); + /** + * Handle a post + * + * Validate input and save changes. Reload the form with a success + * or error message. + * + * @return void + */ - $this->submit('upload', _('Upload')); - $this->elementEnd('form'); - - } - - function show_password_form() + function handlePost() { + # CSRF protection - $user = common_current_user(); - $this->elementStart('form', array('method' => 'POST', - 'id' => 'password', - 'action' => - common_local_url('profilesettings'))); - - $this->hidden('token', common_session_token()); - - # Users who logged in with OpenID won't have a pwd - if ($user->password) { - $this->password('oldpassword', _('Old password')); + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); + return; } - $this->password('newpassword', _('New password'), - _('6 or more characters')); - $this->password('confirm', _('Confirm'), - _('same as password above')); - $this->submit('changepass', _('Change')); - $this->elementEnd('form'); - } - function save_profile() - { $nickname = $this->trimmed('nickname'); $fullname = $this->trimmed('fullname'); $homepage = $this->trimmed('homepage'); @@ -225,38 +163,38 @@ class ProfilesettingsAction extends SettingsAction $language = $this->trimmed('language'); $timezone = $this->trimmed('timezone'); $tagstring = $this->trimmed('tags'); - + # Some validation if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) { - $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.')); + $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.')); return; } else if (!User::allowed_nickname($nickname)) { - $this->show_form(_('Not a valid nickname.')); + $this->showForm(_('Not a valid nickname.')); return; } else if (!is_null($homepage) && (strlen($homepage) > 0) && !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) { - $this->show_form(_('Homepage is not a valid URL.')); + $this->showForm(_('Homepage is not a valid URL.')); return; } else if (!is_null($fullname) && strlen($fullname) > 255) { - $this->show_form(_('Full name is too long (max 255 chars).')); + $this->showForm(_('Full name is too long (max 255 chars).')); return; } else if (!is_null($bio) && strlen($bio) > 140) { - $this->show_form(_('Bio is too long (max 140 chars).')); + $this->showForm(_('Bio is too long (max 140 chars).')); return; } else if (!is_null($location) && strlen($location) > 255) { - $this->show_form(_('Location is too long (max 255 chars).')); + $this->showForm(_('Location is too long (max 255 chars).')); return; } else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) { - $this->show_form(_('Timezone not selected.')); + $this->showForm(_('Timezone not selected.')); return; - } else if ($this->nickname_exists($nickname)) { - $this->show_form(_('Nickname already in use. Try another one.')); + } else if ($this->nicknameExists($nickname)) { + $this->showForm(_('Nickname already in use. Try another one.')); return; } else if (!is_null($language) && strlen($language) > 50) { - $this->show_form(_('Language is too long (max 50 chars).')); + $this->showForm(_('Language is too long (max 50 chars).')); return; } @@ -265,14 +203,14 @@ class ProfilesettingsAction extends SettingsAction } else { $tags = array(); } - + foreach ($tags as $tag) { if (!common_valid_profile_tag($tag)) { - $this->show_form(sprintf(_('Invalid tag: "%s"'), $tag)); + $this->showForm(sprintf(_('Invalid tag: "%s"'), $tag)); return; } } - + $user = common_current_user(); $user->query('BEGIN'); @@ -346,139 +284,29 @@ class ProfilesettingsAction extends SettingsAction } # Set the user tags - + $result = $user->setSelfTags($tags); if (!$result) { $this->serverError(_('Couldn\'t save tags.')); return; } - + $user->query('COMMIT'); common_broadcast_profile($profile); - $this->show_form(_('Settings saved.'), true); + $this->showForm(_('Settings saved.'), true); } - - function upload_avatar() - { - switch ($_FILES['avatarfile']['error']) { - case UPLOAD_ERR_OK: # success, jump out - break; - case UPLOAD_ERR_INI_SIZE: - case UPLOAD_ERR_FORM_SIZE: - $this->show_form(_('That file is too big.')); - return; - case UPLOAD_ERR_PARTIAL: - @unlink($_FILES['avatarfile']['tmp_name']); - $this->show_form(_('Partial upload.')); - return; - default: - $this->show_form(_('System error uploading file.')); - return; - } - - $info = @getimagesize($_FILES['avatarfile']['tmp_name']); - - if (!$info) { - @unlink($_FILES['avatarfile']['tmp_name']); - $this->show_form(_('Not an image or corrupt file.')); - return; - } - - switch ($info[2]) { - case IMAGETYPE_GIF: - case IMAGETYPE_JPEG: - case IMAGETYPE_PNG: - break; - default: - $this->show_form(_('Unsupported image file format.')); - return; - } - - $user = common_current_user(); - $profile = $user->getProfile(); - - if ($profile->setOriginal($_FILES['avatarfile']['tmp_name'])) { - $this->show_form(_('Avatar updated.'), true); - } else { - $this->show_form(_('Failed updating avatar.')); - } - - @unlink($_FILES['avatarfile']['tmp_name']); - } - - function crop_avatar() { - - $user = common_current_user(); - $profile = $user->getProfile(); - - $x = $this->arg('avatar_crop_x'); - $y = $this->arg('avatar_crop_y'); - $w = $this->arg('avatar_crop_w'); - $h = $this->arg('avatar_crop_h'); - - if ($profile->crop_avatars($x, $y, $w, $h)) { - $this->show_form(_('Avatar updated.'), true); - } else { - $this->show_form(_('Failed updating avatar.')); - } - } - - function nickname_exists($nickname) + function nicknameExists($nickname) { $user = common_current_user(); $other = User::staticGet('nickname', $nickname); if (!$other) { - return false; + return false; } else { return $other->id != $user->id; } } - - function change_password() - { - - $user = common_current_user(); - assert(!is_null($user)); # should already be checked - - # FIXME: scrub input - - $newpassword = $this->arg('newpassword'); - $confirm = $this->arg('confirm'); - $token = $this->arg('token'); - - if (0 != strcmp($newpassword, $confirm)) { - $this->show_form(_('Passwords don\'t match.')); - return; - } - - if ($user->password) { - $oldpassword = $this->arg('oldpassword'); - - if (!common_check_user($user->nickname, $oldpassword)) { - $this->show_form(_('Incorrect old password')); - return; - } - } - - $original = clone($user); - - $user->password = common_munge_password($newpassword, $user->id); - - $val = $user->validate(); - if ($val !== true) { - $this->show_form(_('Error saving user; invalid.')); - return; - } - - if (!$user->update($original)) { - $this->serverError(_('Can\'t save new password.')); - return; - } - - $this->show_form(_('Password saved.'), true); - } } diff --git a/actions/smssettings.php b/actions/smssettings.php index 6d3c54942..845266d18 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -31,7 +31,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/connectsettingsaction.php'; /** * Settings for SMS @@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/settingsaction.php'; * @see SettingsAction */ -class SmssettingsAction extends SettingsAction +class SmssettingsAction extends ConnectSettingsAction { /** * Title of the page @@ -151,7 +151,6 @@ class SmssettingsAction extends SettingsAction $this->elementStart('fieldset', array('id' => 'settings_sms_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); $this->elementStart('li'); $this->checkbox('smsnotify', diff --git a/actions/twittersettings.php b/actions/twittersettings.php index cd070cb45..597623c80 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -31,7 +31,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/connectsettingsaction.php'; define('SUBSCRIPTIONS', 80); @@ -47,7 +47,7 @@ define('SUBSCRIPTIONS', 80); * @see SettingsAction */ -class TwittersettingsAction extends SettingsAction +class TwittersettingsAction extends ConnectSettingsAction { /** * Title of the page @@ -129,7 +129,8 @@ class TwittersettingsAction extends SettingsAction $this->elementEnd('ul'); $this->elementEnd('fieldset'); - $this->elementStart('fieldset', array('id' => 'settings_twitter_preferences')); + $this->elementStart('fieldset', + array('id' => 'settings_twitter_preferences')); $this->element('legend', null, _('Preferences')); $this->elementStart('ul'); diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php new file mode 100644 index 000000000..46090b8c1 --- /dev/null +++ b/lib/accountsettingsaction.php @@ -0,0 +1,134 @@ +. + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/settingsaction.php'; + +/** + * Base class for account settings actions + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see Widget + */ + +class AccountSettingsAction extends SettingsAction +{ + /** + * Show the local navigation menu + * + * This is the same for all settings, so we show it here. + * + * @return void + */ + + function showLocalNav() + { + $menu = new AccountSettingsNav($this); + $menu->show(); + } +} + +/** + * A widget for showing the settings group local nav menu + * + * @category Widget + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see HTMLOutputter + */ + +class AccountSettingsNav extends Widget +{ + var $action = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + + function __construct($action=null) + { + parent::__construct($action); + $this->action = $action; + } + + /** + * Show the menu + * + * @return void + */ + + function show() + { + # action => array('prompt', 'title') + $menu = + array('profilesettings' => + array(_('Profile'), + _('Change your profile settings')), + 'avatarsettings' => + array(_('Avatar'), + _('Upload an avatar')), + 'passwordsettings' => + array(_('Password'), + _('Change your password')), + 'emailsettings' => + array(_('Email'), + _('Change email handling')), + 'openidsettings' => + array(_('OpenID'), + _('Add or remove OpenIDs')), + 'othersettings' => + array(_('Other'), + _('Other options'))); + + $action_name = $this->action->trimmed('action'); + $this->action->elementStart('ul', array('class' => 'nav')); + + foreach ($menu as $menuaction => $menudesc) { + $this->action->menuItem(common_local_url($menuaction), + $menudesc[0], + $menudesc[1], + $action_name === $menuaction); + } + + $this->action->elementEnd('ul'); + } +} diff --git a/lib/action.php b/lib/action.php index 71520b84e..e62a032b6 100644 --- a/lib/action.php +++ b/lib/action.php @@ -208,20 +208,20 @@ class Action extends HTMLOutputter // lawsuit $this->showLogo(); $this->showPrimaryNav(); $this->showSiteNotice(); - if (common_logged_in()) { - $this->showNoticeForm(); - } else { - $this->showAnonymousMessage(); - } + if (common_logged_in()) { + $this->showNoticeForm(); + } else { + $this->showAnonymousMessage(); + } $this->elementEnd('div'); } function showLogo() { $this->elementStart('address', array('id' => 'site_contact', - 'class' => 'vcard')); + 'class' => 'vcard')); $this->elementStart('a', array('class' => 'url home bookmark', - 'href' => common_local_url('public'))); + 'href' => common_local_url('public'))); if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) { $this->element('img', array('class' => 'logo photo', @@ -237,21 +237,21 @@ class Action extends HTMLOutputter // lawsuit { $this->elementStart('dl', array('id' => 'site_nav_global_primary')); $this->element('dt', null, _('Primary site navigation')); - $this->elementStart('dd'); + $this->elementStart('dd'); $user = common_current_user(); $this->elementStart('ul', array('class' => 'nav')); if ($user) { $this->menuItem(common_local_url('all', array('nickname' => $user->nickname)), - _('Home')); + _('Home')); } $this->menuItem(common_local_url('peoplesearch'), _('Search')); if ($user) { $this->menuItem(common_local_url('profilesettings'), - _('Settings')); - $this->menuItem(common_local_url('invite'), - _('Invite')); + _('Account')); + $this->menuItem(common_local_url('imsettings'), + _('Connect')); $this->menuItem(common_local_url('logout'), - _('Logout')); + _('Logout')); } else { $this->menuItem(common_local_url('login'), _('Login')); if (!common_config('site', 'closed')) { @@ -260,25 +260,25 @@ class Action extends HTMLOutputter // lawsuit $this->menuItem(common_local_url('openidlogin'), _('OpenID')); } $this->menuItem(common_local_url('doc', array('title' => 'help')), - _('Help')); + _('Help')); $this->elementEnd('ul'); - $this->elementEnd('dd'); + $this->elementEnd('dd'); $this->elementEnd('dl'); } // Revist. Should probably do an hAtom pattern here function showSiteNotice() { - $text = common_config('site', 'notice'); - if ($text) { - $this->elementStart('dl', array('id' => 'site_notice', - 'class' => 'system_notice')); - $this->element('dt', null, _('Site notice')); - $this->element('dd', null, $text); - $this->elementEnd('dl'); - } + $text = common_config('site', 'notice'); + if ($text) { + $this->elementStart('dl', array('id' => 'site_notice', + 'class' => 'system_notice')); + $this->element('dt', null, _('Site notice')); + $this->element('dd', null, $text); + $this->elementEnd('dl'); + } } - + // MAY overload if no notice form needed... or direct message box???? function showNoticeForm() @@ -289,9 +289,9 @@ class Action extends HTMLOutputter // lawsuit function showAnonymousMessage() { - // needs to be defined by the class + // needs to be defined by the class } - + function showCore() { $this->elementStart('div', array('id' => 'core')); @@ -331,13 +331,13 @@ class Action extends HTMLOutputter // lawsuit function showPageNoticeBlock() { - $this->elementStart('dl', array('id' => 'page_notice', - 'class' => 'system_notice')); - $this->element('dt', null, _('Page notice')); - $this->elementStart('dd'); - $this->showPageNotice(); - $this->elementEnd('dd'); - $this->elementEnd('dl'); + $this->elementStart('dl', array('id' => 'page_notice', + 'class' => 'system_notice')); + $this->element('dt', null, _('Page notice')); + $this->elementStart('dd'); + $this->showPageNotice(); + $this->elementEnd('dd'); + $this->elementEnd('dl'); } // SHOULD overload (unless there's not a notice) @@ -345,7 +345,7 @@ class Action extends HTMLOutputter // lawsuit function showPageNotice() { } - + // MUST overload function showContent() @@ -391,17 +391,17 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('dd', null); $this->elementStart('ul', array('class' => 'nav')); $this->menuItem(common_local_url('doc', array('title' => 'help')), - _('Help')); + _('Help')); $this->menuItem(common_local_url('doc', array('title' => 'about')), - _('About')); + _('About')); $this->menuItem(common_local_url('doc', array('title' => 'faq')), - _('FAQ')); + _('FAQ')); $this->menuItem(common_local_url('doc', array('title' => 'privacy')), - _('Privacy')); + _('Privacy')); $this->menuItem(common_local_url('doc', array('title' => 'source')), - _('Source')); + _('Source')); $this->menuItem(common_local_url('doc', array('title' => 'contact')), - _('Contact')); + _('Contact')); $this->elementEnd('ul'); $this->elementEnd('dd'); $this->elementEnd('dl'); @@ -567,7 +567,7 @@ class Action extends HTMLOutputter // lawsuit } (is_null($id)) ? $lattrs : $lattrs['id'] = $id; - + $this->elementStart('li', $lattrs); $attrs['href'] = $url; if ($title) { diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php new file mode 100644 index 000000000..30629680e --- /dev/null +++ b/lib/connectsettingsaction.php @@ -0,0 +1,129 @@ +. + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/settingsaction.php'; + +/** + * Base class for connection settings actions + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see Widget + */ + +class ConnectSettingsAction extends SettingsAction +{ + /** + * Show the local navigation menu + * + * This is the same for all settings, so we show it here. + * + * @return void + */ + + function showLocalNav() + { + $menu = new ConnectSettingsNav($this); + $menu->show(); + } +} + +/** + * A widget for showing the connect group local nav menu + * + * @category Widget + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see HTMLOutputter + */ + +class ConnectSettingsNav extends Widget +{ + var $action = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + + function __construct($action=null) + { + parent::__construct($action); + $this->action = $action; + } + + /** + * Show the menu + * + * @return void + */ + + function show() + { + # action => array('prompt', 'title') + $menu = + array('imsettings' => + array(_('IM'), + _('Updates by instant messenger (IM)')), + 'smssettings' => + array(_('SMS'), + _('Updates by SMS')), + 'twittersettings' => + array(_('Twitter'), + _('Twitter integration options'))); + + $action_name = $this->action->trimmed('action'); + $this->action->elementStart('ul', array('class' => 'nav')); + + foreach ($menu as $menuaction => $menudesc) { + if ($menuaction == 'imsettings' && + !common_config('xmpp', 'enabled')) { + continue; + } + $this->action->menuItem(common_local_url($menuaction), + $menudesc[0], + $menudesc[1], + $action_name === $menuaction); + } + + $this->action->elementEnd('ul'); + } +} diff --git a/lib/rssaction.php b/lib/rssaction.php index 9564cfb46..2c532912b 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -1,9 +1,12 @@ . + * + * @category Mail + * @package Laconica + * @author Evan Prodromou + * @author Earle Martin + * @copyright 2008-9 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ */ if (!defined('LACONICA')) { exit(1); } @@ -23,35 +34,84 @@ define('DEFAULT_RSS_LIMIT', 48); class Rss10Action extends Action { - # This will contain the details of each feed item's author and be used to generate SIOC data. + var $creators = array(); + var $limit = DEFAULT_RSS_LIMIT; + + /** + * Constructor + * + * Just wraps the Action constructor. + * + * @param string $output URI to output to, default = stdout + * @param boolean $indent Whether to indent output, default true + * + * @see Action::__construct + */ - function is_readonly() + function __construct($output='php://output', $indent=true) + { + parent::__construct($output, $indent); + } + + /** + * Do we need to write to the database? + * + * @return boolean true + */ + + function isReadonly() { return true; } + /** + * Read arguments and initialize members + * + * @param array $args Arguments from $_REQUEST + * @return boolean success + */ + + function prepare($args) + { + $this->limit = (int) $this->trimmed('limit'); + if ($this->limit == 0) { + $this->limit = DEFAULT_RSS_LIMIT; + } + return true; + } + + /** + * Handle a request + * + * @param array $args Arguments from $_REQUEST + * + * @return void + */ + function handle($args) { parent::handle($args); - $limit = (int) $this->trimmed('limit'); - if ($limit == 0) { - $limit = DEFAULT_RSS_LIMIT; - } $this->show_rss($limit); } - function init() - { - return true; - } - - function get_notices() + /** + * Get the notices to output in this stream + * + * @return array an array of Notice objects sorted in reverse chron + */ + + function getNotices() { return array(); } + /** + * Get a description of the channel + * + * Returns an array with the following + * @return array function get_channel() { return array('url' => '', @@ -67,11 +127,6 @@ class Rss10Action extends Action function show_rss($limit=0) { - - if (!$this->init()) { - return; - } - $notices = $this->get_notices($limit); $this->init_rss(); diff --git a/lib/settingsaction.php b/lib/settingsaction.php index 8624803ac..dfe1f114b 100644 --- a/lib/settingsaction.php +++ b/lib/settingsaction.php @@ -31,8 +31,6 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsgroupnav.php'; - /** * Base class for settings group of actions * @@ -149,17 +147,4 @@ class SettingsAction extends Action return ''; } - /** - * Show the local navigation menu - * - * This is the same for all settings, so we show it here. - * - * @return void - */ - - function showLocalNav() - { - $menu = new SettingsGroupNav($this); - $menu->show(); - } } diff --git a/lib/settingsgroupnav.php b/lib/settingsgroupnav.php deleted file mode 100644 index bd66c65a6..000000000 --- a/lib/settingsgroupnav.php +++ /dev/null @@ -1,112 +0,0 @@ -. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/widget.php'; - -/** - * A widget for showing the settings group local nav menu - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - * - * @see HTMLOutputter - */ - -class SettingsGroupNav extends Widget -{ - var $action = null; - - /** - * Construction - * - * @param Action $action current action, used for output - */ - - function __construct($action=null) - { - parent::__construct($action); - $this->action = $action; - } - - /** - * Show the menu - * - * @return void - */ - - function show() - { - # action => array('prompt', 'title') - $menu = - array('profilesettings' => - array(_('Profile'), - _('Change your profile settings')), - 'emailsettings' => - array(_('Email'), - _('Change email handling')), - 'openidsettings' => - array(_('OpenID'), - _('Add or remove OpenIDs')), - 'smssettings' => - array(_('SMS'), - _('Updates by SMS')), - 'imsettings' => - array(_('IM'), - _('Updates by instant messenger (IM)')), - 'twittersettings' => - array(_('Twitter'), - _('Twitter integration options')), - 'othersettings' => - array(_('Other'), - _('Other options'))); - - $action_name = $this->action->trimmed('action'); - $this->action->elementStart('ul', array('class' => 'nav')); - - foreach ($menu as $menuaction => $menudesc) { - if ($menuaction == 'imsettings' && - !common_config('xmpp', 'enabled')) { - continue; - } - $this->action->menuItem(common_local_url($menuaction), - $menudesc[0], - $menudesc[1], - $action_name === $menuaction); - } - - $this->action->elementEnd('ul'); - } -} diff --git a/lib/util.php b/lib/util.php index 9ca817eab..d67c64972 100644 --- a/lib/util.php +++ b/lib/util.php @@ -770,6 +770,8 @@ function common_fancy_url($action, $args=null) return common_path('main/openid'); case 'profilesettings': return common_path('settings/profile'); + case 'passwordsettings': + return common_path('settings/password'); case 'emailsettings': return common_path('settings/email'); case 'openidsettings': @@ -852,6 +854,8 @@ function common_fancy_url($action, $args=null) return common_path($path); case 'imsettings': return common_path('settings/im'); + case 'avatarsettings': + return common_path('settings/avatar'); case 'peoplesearch': return common_path('search/people' . (($args) ? ('?' . http_build_query($args)) : '')); case 'noticesearch': -- cgit v1.2.3-54-g00ecf From 7749228f52d914d4949cb5fa139cdd6ade4ead6e Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 21:22:31 +0000 Subject: OpenID settings remove style --- actions/openidsettings.php | 4 ++-- theme/base/css/display.css | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'actions/openidsettings.php') diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 257aac8d0..126d2c992 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -124,7 +124,7 @@ class OpenidsettingsAction extends AccountSettingsAction if ($cnt == 1 && !$user->password) { - $this->element('p', null, + $this->element('p', 'form_guide', _('Removing your only OpenID '. 'would make it impossible to log in! ' . 'If you need to remove it, '. @@ -162,7 +162,7 @@ class OpenidsettingsAction extends AccountSettingsAction $this->element('input', array('type' => 'submit', 'id' => 'remove'.$idx, 'name' => 'remove', - 'class' => 'submit', + 'class' => 'submit remove', 'value' => _('Remove'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 08805c1e0..76e52ffc9 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -84,18 +84,11 @@ left:0; padding:4px 7px; -moz-border-radius:4px; } - form label.submit { display:none; } -form .error_message { -display:block; -} -.form_response { -margin-bottom:18px; -} - -form input.submit { +.form_settings input.remove { +margin-left:11px; } -- cgit v1.2.3-54-g00ecf From 0b5f0f4faaf04fdf13dbd5dea1f081b9e1cc6071 Mon Sep 17 00:00:00 2001 From: sarven Date: Mon, 19 Jan 2009 03:09:13 +0000 Subject: Renamed form_datas to form_data --- actions/emailsettings.php | 4 ++-- actions/imsettings.php | 4 ++-- actions/login.php | 2 +- actions/openidsettings.php | 2 +- actions/othersettings.php | 2 +- actions/profilesettings.php | 2 +- actions/register.php | 2 +- actions/smssettings.php | 8 ++++---- actions/twittersettings.php | 4 ++-- lib/noticeform.php | 2 +- theme/base/css/display.css | 22 +++++++++++----------- 11 files changed, 27 insertions(+), 27 deletions(-) (limited to 'actions/openidsettings.php') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 7ae62fb55..b84acb214 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -110,7 +110,7 @@ class EmailsettingsAction extends AccountSettingsAction $this->hidden('email', $confirm->address); $this->submit('cancel', _('Cancel')); } else { - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('email', _('Email Address'), ($this->arg('email')) ? $this->arg('email') : null, @@ -146,7 +146,7 @@ class EmailsettingsAction extends AccountSettingsAction $this->elementStart('fieldset', array('id' => 'settings_email_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('emailnotifysub', _('Send me notices of new subscriptions through email.'), diff --git a/actions/imsettings.php b/actions/imsettings.php index edbd81b57..e0f5ede3a 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -113,7 +113,7 @@ class ImsettingsAction extends ConnectSettingsAction $this->hidden('jabber', $confirm->address); $this->submit('cancel', _('Cancel')); } else { - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('jabber', _('IM Address'), ($this->arg('jabber')) ? $this->arg('jabber') : null, @@ -131,7 +131,7 @@ class ImsettingsAction extends ConnectSettingsAction $this->elementStart('fieldset', array('id' => 'settings_im_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('jabbernotify', _('Send me notices through Jabber/GTalk.'), diff --git a/actions/login.php b/actions/login.php index 9fa501a5d..11cf1f02a 100644 --- a/actions/login.php +++ b/actions/login.php @@ -223,7 +223,7 @@ class LoginAction extends Action 'action' => common_local_url('login'))); $this->elementStart('fieldset'); $this->element('legend', null, _('Login to site')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('nickname', _('Nickname')); $this->elementEnd('li'); diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 126d2c992..92469d20f 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -95,7 +95,7 @@ class OpenidsettingsAction extends AccountSettingsAction $this->element('p', 'form_guide', _('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); diff --git a/actions/othersettings.php b/actions/othersettings.php index cbb2c0cb9..b542233ca 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -107,7 +107,7 @@ class OthersettingsAction extends AccountSettingsAction 'metamark.net' => 'metamark.net' ); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 12251b83b..6dd4775e5 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -93,7 +93,7 @@ class ProfilesettingsAction extends AccountSettingsAction # too much common patterns here... abstractable? - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('nickname', _('Nickname'), ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname, diff --git a/actions/register.php b/actions/register.php index 08243c1e2..159daaa73 100644 --- a/actions/register.php +++ b/actions/register.php @@ -343,7 +343,7 @@ class RegisterAction extends Action $this->hidden('code', $code); } - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('nickname', _('Nickname'), $this->trimmed('nickname'), _('1-64 lowercase letters or numbers, '. diff --git a/actions/smssettings.php b/actions/smssettings.php index 489fd1f58..f89cbe1ab 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -113,7 +113,7 @@ class SmssettingsAction extends ConnectSettingsAction $this->hidden('carrier', $confirm->address_extra); $this->submit('cancel', _('Cancel')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('code', _('Confirmation code'), null, _('Enter the code you received on your phone.')); @@ -121,7 +121,7 @@ class SmssettingsAction extends ConnectSettingsAction $this->elementEnd('ul'); $this->submit('confirm', _('Confirm')); } else { - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('sms', _('SMS Phone number'), ($this->arg('sms')) ? $this->arg('sms') : null, @@ -156,7 +156,7 @@ class SmssettingsAction extends ConnectSettingsAction $this->elementStart('fieldset', array('id' => 'settings_sms_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('smsnotify', _('Send me notices through SMS; '. @@ -448,7 +448,7 @@ class SmssettingsAction extends ConnectSettingsAction $cnt = $carrier->find(); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('label', array('for' => 'carrier'), _('Mobile carrier')); $this->elementStart('select', array('name' => 'carrier', diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 079099123..efc8215cd 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -104,7 +104,7 @@ class TwittersettingsAction extends ConnectSettingsAction $this->elementStart('fieldset', array('id' => 'settings_twitter_account')); $this->element('legend', null, _('Twitter Account')); $this->hidden('token', common_session_token()); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); if ($fuser) { $this->elementStart('li'); $this->element('span', 'twitter_user', $fuser->nickname); @@ -133,7 +133,7 @@ class TwittersettingsAction extends ConnectSettingsAction array('id' => 'settings_twitter_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('noticesync', _('Automatically send my notices to Twitter.'), diff --git a/lib/noticeform.php b/lib/noticeform.php index d6a3aa9c2..f0205f1c1 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -123,7 +123,7 @@ class NoticeForm extends Form { $user = common_current_user(); - $this->out->elementStart('ul', 'form_datas'); + $this->out->elementStart('ul', 'form_data'); $this->out->elementStart('li', array('id' => 'notice_text')); $this->out->element('label', array('for' => 'notice_data-text'), sprintf(_('What\'s up, %s?'), $user->nickname)); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 716f3256f..d659a4b4c 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -114,17 +114,17 @@ font-style:italic; } -.form_settings .form_datas li { +.form_settings .form_data li { width:100%; float:left; } -.form_settings .form_datas label { +.form_settings .form_data label { float:left; } -.form_settings .form_datas textarea, -.form_settings .form_datas select, -.form_settings .form_datas input { +.form_settings .form_data textarea, +.form_settings .form_data select, +.form_settings .form_data input { margin-left:11px; float:left; } @@ -149,7 +149,7 @@ font-weight:bold; display:none; } -.form_settings .form_datas p.form_guide { +.form_settings .form_data p.form_guide { clear:both; margin-left:163px; margin-bottom:0; @@ -424,7 +424,7 @@ display:block; font-size:1.3em; margin-bottom:7px; } -#form_notice .form_datas li { +#form_notice .form_data li { float:left; } @@ -979,12 +979,12 @@ background-color:#D1D9E4; #user_actions #user_subscribe .form_note, -#user_actions #user_subscribe .form_datas, +#user_actions #user_subscribe .form_data, #user_actions #user_subscribe .form_actions label { display:none; } #form_user-relationship .form_note, -#form_user-relationship .form_datas, +#form_user-relationship .form_data, #form_user-relationship .form_actions label { display:block; } @@ -992,7 +992,7 @@ display:block; #user_actions #user-relationship_submit { margin-bottom:0; } -#form_user-relationship .form_datas li label { +#form_user-relationship .form_data li label { margin-right:11px; } @@ -1070,7 +1070,7 @@ font-size:2.2em; -#form_settings_photo .form_datas { +#form_settings_photo .form_data { clear:both; } -- cgit v1.2.3-54-g00ecf