From db4993970ec7a84dad0561a6ea3c9243d2064545 Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 04:08:05 +0000 Subject: (Un)subscribe AJAX forms --- actions/subscribe.php | 5 +++-- actions/unsubscribe.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'actions') diff --git a/actions/subscribe.php b/actions/subscribe.php index b6f03f0f1..171332734 100644 --- a/actions/subscribe.php +++ b/actions/subscribe.php @@ -64,12 +64,13 @@ class SubscribeAction extends Action } if ($this->boolean('ajax')) { - common_start_html('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8', true); $this->elementStart('head'); $this->element('title', null, _('Subscribed')); $this->elementEnd('head'); $this->elementStart('body'); - common_unsubscribe_form($other->getProfile()); + $unsubscribe = new UnsubscribeForm($this, $other->getProfile()); + $unsubscribe->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php index 32511a4b4..f9dd6f821 100644 --- a/actions/unsubscribe.php +++ b/actions/unsubscribe.php @@ -66,12 +66,13 @@ class UnsubscribeAction extends Action } if ($this->boolean('ajax')) { - common_start_html('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8', true); $this->elementStart('head'); $this->element('title', null, _('Unsubscribed')); $this->elementEnd('head'); $this->elementStart('body'); - common_subscribe_form($other); + $subscribe = new SubscribeForm($this, $other); + $subscribe->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { -- cgit v1.2.3-54-g00ecf From 047c87d1cc55b71310e7e37110718e62f8f3fd17 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 20 Jan 2009 22:20:17 -0800 Subject: Converted DeleteAction and DeletenoticeAction to new uiredesign zeitgeist --- actions/deletenotice.php | 114 +++++++++++++++++++++++++++++++++++------------ lib/deleteaction.php | 72 +++++++++++++++++------------- 2 files changed, 126 insertions(+), 60 deletions(-) (limited to 'actions') diff --git a/actions/deletenotice.php b/actions/deletenotice.php index bae0eac1b..efef95441 100644 --- a/actions/deletenotice.php +++ b/actions/deletenotice.php @@ -1,9 +1,12 @@ . + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008 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/deleteaction.php'); +require_once INSTALLDIR.'/lib/deleteaction.php'; class DeletenoticeAction extends DeleteAction { + var $error = null; + function handle($args) { parent::handle($args); - # XXX: Ajax! + // XXX: Ajax! if ($_SERVER['REQUEST_METHOD'] == 'POST') { - $this->delete_notice(); + $this->deleteNotice(); } else if ($_SERVER['REQUEST_METHOD'] == 'GET') { - $this->show_form(); + $this->showForm(); } } - function get_instructions() + /** + * Show the page notice + * + * Shows instructions for the page + * + * @return void + */ + + function showPageNotice() { - return _('You are about to permanently delete a notice. Once this is done, it cannot be undone.'); + $instr = $this->getInstructions(); + $output = common_markup_to_html($instr); + + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('div'); } - function get_title() + function getInstructions() + { + return _('You are about to permanently delete a notice. ' . + 'Once this is done, it cannot be undone.'); + } + + function title() { return _('Delete notice'); } - function show_form($error=null) + /** + * Wrapper for showing a page + * + * Stores an error and shows the page + * + * @param string $error Error, if any + * + * @return void + */ + + function showForm($error = null) { - $user = common_current_user(); + $this->error = $error; + $this->showPage(); + } + + /** + * Insert delete notice form into the content + * + * @return void + */ - common_show_header($this->get_title(), array($this, 'show_header'), $error, - array($this, 'show_top')); + function showContent() + { $this->elementStart('form', array('id' => 'notice_delete_form', 'method' => 'post', 'action' => common_local_url('deletenotice'))); $this->hidden('token', common_session_token()); $this->hidden('notice', $this->trimmed('notice')); $this->elementStart('p'); - $this->element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?')); + $this->element('span', array('id' => 'confirmation_text'), + _('Are you sure you want to delete this notice?')); $this->element('input', array('id' => 'submit_no', 'name' => 'submit', @@ -69,33 +122,38 @@ class DeletenoticeAction extends DeleteAction 'value' => _('Yes'))); $this->elementEnd('p'); $this->elementEnd('form'); - common_show_footer(); } - function delete_notice() + function deleteNotice() { - # 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; } - $url = common_get_returnto(); + + $url = common_get_returnto(); $confirmed = $this->trimmed('submit'); + if ($confirmed == _('Yes')) { - $user = common_current_user(); - $notice_id = $this->trimmed('notice'); - $notice = Notice::staticGet($notice_id); + $replies = new Reply; - $replies->get('notice_id', $notice_id); + $replies->get('notice_id', $this->notice->id); + + common_dequeue_notice($this->notice); - common_dequeue_notice($notice); if (common_config('memcached', 'enabled')) { $notice->blowSubsCache(); } + $replies->delete(); - $notice->delete(); + $this->notice->delete(); + } else { + if ($url) { common_set_returnto(null); } else { diff --git a/lib/deleteaction.php b/lib/deleteaction.php index 9e89c0a54..91c6487a9 100644 --- a/lib/deleteaction.php +++ b/lib/deleteaction.php @@ -1,9 +1,12 @@ . + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008 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); +} class DeleteAction extends Action { + var $user = null; + var $notice = null; + var $profile = null; + var $user_profile = null; - function handle($args) + function prepare($args) { - parent::handle($args); - $user = common_current_user(); - $notice_id = $this->trimmed('notice'); - $notice = Notice::staticGet($notice_id); - if (!$notice) { + parent::prepare($args); + + $this->user = common_current_user(); + $notice_id = $this->trimmed('notice'); + $this->notice = Notice::staticGet($notice_id); + + if (!$this->notice) { common_user_error(_('No such notice.')); exit; } - $profile = $notice->getProfile(); - $user_profile = $user->getProfile(); + $this->profile = $this->notice->getProfile(); + $this->user_profile = $this->user->getProfile(); + + return true; + } + + function handle($args) + { + parent::handle($args); if (!common_logged_in()) { common_user_error(_('Not logged in.')); exit; - } else if ($notice->profile_id != $user_profile->id) { + } else if ($this->notice->profile_id != $this->user_profile->id) { common_user_error(_('Can\'t delete this notice.')); exit; } } - function show_top($arr=null) - { - $instr = $this->get_instructions(); - $output = common_markup_to_html($instr); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); - } - - function get_title() - { - return null; - } - - function show_header() - { - return; - } } -- cgit v1.2.3-54-g00ecf From 6c7842129841878b65c1d686de64f98f1edcb16f Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 06:31:53 +0000 Subject: Moved common_profile_new_message_nudge() to showstream.php --- actions/nudge.php | 2 +- actions/showstream.php | 21 +++++++++++++++++++-- lib/nudgeform.php | 17 +++++++++++++++-- lib/util.php | 19 ------------------- 4 files changed, 35 insertions(+), 24 deletions(-) (limited to 'actions') diff --git a/actions/nudge.php b/actions/nudge.php index bb80ce357..456106459 100644 --- a/actions/nudge.php +++ b/actions/nudge.php @@ -88,7 +88,7 @@ class NudgeAction extends Action $this->notify($user, $other); if ($this->boolean('ajax')) { - common_start_html('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8', true); $this->elementStart('head'); $this->element('title', null, _('Nudge sent')); $this->elementEnd('head'); diff --git a/actions/showstream.php b/actions/showstream.php index 3882af845..a411fae5b 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -326,7 +326,24 @@ class ShowstreamAction extends Action } $this->elementEnd('li'); - common_profile_new_message_nudge($cur, $this->user, $this->profile); +// common_profile_new_message_nudge($cur, $this->user, $this->profile); + + $user = User::staticGet('id', $this->profile->id); + if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { + $this->elementStart('li', array('id' => 'user_send_a_new_message')); + $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id))), + _('Send a message')); + $this->elementEnd('li'); + + if ($user->email && $user->emailnotifynudge) { + $this->elementStart('li', array('id' => 'user_nudge')); + $nf = new NudgeForm($this, $user); + $nf->show(); + $this->elementEnd('li'); + } + } + + if ($cur && $cur->id != $this->profile->id) { $blocked = $cur->hasBlocked($this->profile); @@ -349,7 +366,7 @@ class ShowstreamAction extends Action $url = common_local_url('remotesubscribe', array('nickname' => $this->profile->nickname)); $this->element('a', array('href' => $url, - 'id' => 'remotesubscribe'), + 'id' => 'user_subscribe_remote'), _('Subscribe')); } diff --git a/lib/nudgeform.php b/lib/nudgeform.php index 7d04e11e4..6374a7698 100644 --- a/lib/nudgeform.php +++ b/lib/nudgeform.php @@ -77,9 +77,22 @@ class NudgeForm extends Form function id() { - return 'nudge'; + return 'form_user_nudge'; } + + /** + * class of the form + * + * @return string of the form class + */ + + function formClass() + { + return 'form_user_nudge'; + } + + /** * Action of the form * @@ -102,4 +115,4 @@ class NudgeForm extends Form { $this->out->submit('submit', _('Send a nudge')); } -} \ No newline at end of file +} diff --git a/lib/util.php b/lib/util.php index 73c4cdcc8..ed7284183 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1645,25 +1645,6 @@ function common_nudge_response() common_element('p', array('id' => 'nudge_response'), _('Nudge sent!')); } -// XXX: Refactor this code -function common_profile_new_message_nudge ($cur, $profile) -{ - $user = User::staticGet('id', $profile->id); - - if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { - common_element_start('li', array('id' => 'profile_send_a_new_message')); - common_element('a', array('href' => common_local_url('newmessage', array('to' => $user->id))), - _('Send a message')); - common_element_end('li'); - - if ($user->email && $user->emailnotifynudge) { - common_element_start('li', array('id' => 'profile_nudge')); - common_nudge_form($user); - common_element_end('li'); - } - } -} - function common_cache_key($extra) { return 'laconica:' . common_keyize(common_config('site', 'name')) . ':' . $extra; -- cgit v1.2.3-54-g00ecf From 27b627c09451c099b18a7cde90f6a028f820046c Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 06:54:17 +0000 Subject: Made user_actions styles more consistent --- actions/showstream.php | 2 +- theme/base/css/display.css | 15 ++++++++++----- theme/identica/css/display.css | 9 +++++---- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index a411fae5b..6ed6abc9e 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -330,7 +330,7 @@ class ShowstreamAction extends Action $user = User::staticGet('id', $this->profile->id); if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { - $this->elementStart('li', array('id' => 'user_send_a_new_message')); + $this->elementStart('li', array('id' => 'user_send-a-message')); $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id))), _('Send a message')); $this->elementEnd('li'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 5b17fa53a..c60097145 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -611,16 +611,25 @@ width:100%; } #user_actions a { text-decoration:none; +font-weight:bold; +width:100%; +display:block; } .form_user_block input.submit, -.form_user_unblock input.submit { +.form_user_unblock input.submit, +#user_send-a-message a, +.form_user_nudge input.submit { border:0; padding-left:20px; } +#user_send-a-message a { +padding:4px 4px 4px 23px; + +} #user_subscribe input.submit, @@ -631,13 +640,9 @@ padding-left:20px; #user_send-a-message form { -clear:left; -width:322px; -margin-top:18px; } #user_send-a-message textarea { -width:96%; } .user_tags ul { diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index e3b5310f7..2b91c5504 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -41,7 +41,9 @@ color:#fff; a, div.notice-options input, .form_user_block input.submit, -.form_user_unblock input.submit { +.form_user_unblock input.submit, +#user_send-a-message a, +.form_user_nudge input.submit { color:#002E6E; } @@ -63,8 +65,7 @@ background-color:#CEE1E9; #notice_text-count { color:#333; } -#form_notice.warning #notice_text-count, -#user_actions a { +#form_notice.warning #notice_text-count { color:#000; } @@ -131,7 +132,7 @@ background-image:url(../../base/images/icons/icon_vcard.gif); } -.form_user_send-a-message input.submit, +#user_send-a-message a, .form_user_nudge input.submit, .form_user_block input.submit, .form_user_unblock input.submit { -- cgit v1.2.3-54-g00ecf From 92e2f3babc89863518b8711a1b62661752d806f5 Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 07:14:43 +0000 Subject: Added @title to user_action inputs and anchor and form legends --- actions/showstream.php | 5 +++-- lib/blockform.php | 14 +++++++++++++- lib/nudgeform.php | 14 +++++++++++++- lib/subscribeform.php | 13 ++++++++++++- lib/unblockform.php | 13 ++++++++++++- lib/unsubscribeform.php | 12 +++++++++++- 6 files changed, 64 insertions(+), 7 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index 6ed6abc9e..76249d14d 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -331,8 +331,9 @@ class ShowstreamAction extends Action $user = User::staticGet('id', $this->profile->id); if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { $this->elementStart('li', array('id' => 'user_send-a-message')); - $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id))), - _('Send a message')); + $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)), + 'title' => _('Send a direct message to this user')), + _('Message')); $this->elementEnd('li'); if ($user->email && $user->emailnotifynudge) { diff --git a/lib/blockform.php b/lib/blockform.php index b7790681d..ea22c1cec 100644 --- a/lib/blockform.php +++ b/lib/blockform.php @@ -112,6 +112,18 @@ class BlockForm extends Form return common_local_url('block'); } + + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Block this user')); + } + + /** * Data elements of the form * @@ -138,6 +150,6 @@ class BlockForm extends Form function formActions() { - $this->out->submit('submit', _('Block')); + $this->out->submit('submit', _('block'), 'submit', null, _('Block this user')); } } diff --git a/lib/nudgeform.php b/lib/nudgeform.php index 6374a7698..7380462a7 100644 --- a/lib/nudgeform.php +++ b/lib/nudgeform.php @@ -105,6 +105,18 @@ class NudgeForm extends Form array('nickname' => $this->profile->nickname)); } + + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Nudge this user')); + } + + /** * Action elements * @@ -113,6 +125,6 @@ class NudgeForm extends Form function formActions() { - $this->out->submit('submit', _('Send a nudge')); + $this->out->submit('submit', _('Nudge'), 'submit', null, _('Send a nudge to this user')); } } diff --git a/lib/subscribeform.php b/lib/subscribeform.php index 231e740a7..c65134e46 100644 --- a/lib/subscribeform.php +++ b/lib/subscribeform.php @@ -104,6 +104,17 @@ class SubscribeForm extends Form return common_local_url('subscribe'); } + + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Subscribe to this user')); + } + /** * Data elements of the form * @@ -125,6 +136,6 @@ class SubscribeForm extends Form function formActions() { - $this->out->submit('submit', _('Subscribe')); + $this->out->submit('submit', _('Subscribe'), 'submit', null, _('Subscribe to this user')); } } diff --git a/lib/unblockform.php b/lib/unblockform.php index 025011a82..6a8831b29 100644 --- a/lib/unblockform.php +++ b/lib/unblockform.php @@ -110,6 +110,17 @@ class UnblockForm extends Form return common_local_url('unblock'); } + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Unblock this user')); + } + + /** * Data elements of the form * @@ -136,6 +147,6 @@ class UnblockForm extends Form function formActions() { - $this->out->submit('submit', _('Unblock')); + $this->out->submit('submit', _('Unblock'), 'submit', null, _('Unblock this user')); } } diff --git a/lib/unsubscribeform.php b/lib/unsubscribeform.php index 092369db7..ce91a1340 100644 --- a/lib/unsubscribeform.php +++ b/lib/unsubscribeform.php @@ -103,6 +103,16 @@ class UnsubscribeForm extends Form return common_local_url('unsubscribe'); } + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Unsubscribe from this user')); + } + /** * Data elements of the form * @@ -124,6 +134,6 @@ class UnsubscribeForm extends Form function formActions() { - $this->out->submit('submit', _('Unsubscribe')); + $this->out->submit('submit', _('Unsubscribe'), 'submit', null, _('Unsubscribe from this user')); } } -- cgit v1.2.3-54-g00ecf