From 056c20495937fe45fe0f7204b112dbfe6931a855 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 30 Nov 2009 14:03:11 +0100 Subject: nicer subscription styles Ignore-this: e1b3b815b5ebb0da320bff997c4fed4b darcs-hash:20091130130311-6e07b-03ccfc52abb3dcc0764eed5784d81f8416841328.gz --- inc/actions.php | 20 +++++++++----------- inc/lang/en/lang.php | 2 +- inc/template.php | 34 +++++++++++++++++----------------- 3 files changed, 27 insertions(+), 29 deletions(-) (limited to 'inc') diff --git a/inc/actions.php b/inc/actions.php index 900409a90..1fda0584e 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -558,19 +558,21 @@ function act_export($act){ * @author Adrian Lang */ function act_subscription($act){ - if ($_SERVER['REQUEST_METHOD'] !== 'POST') { - // No post to handle, let tpl_subscribe manage the request. - return $act; - } + global $lang; + global $INFO; + global $ID; - // Get and preprocess data. + // get and preprocess data. $params = array(); foreach(array('target', 'style', 'action') as $param) { - if (isset($_POST["subscribe_$param"])) { - $params[$param] = $_POST["subscribe_$param"]; + if (isset($_REQUEST["sub_$param"])) { + $params[$param] = $_REQUEST["sub_$param"]; } } + // any action given? if not just return and show the subscription page + if(!$params['action']) return $act; + // Handle POST data, may throw exception. trigger_event('ACTION_HANDLE_SUBSCRIBE', $params, 'subscription_handle_post'); @@ -579,9 +581,6 @@ function act_subscription($act){ $data = $params['data']; $action = $params['action']; - global $lang; - global $INFO; - // Perform action. require_once DOKU_INC . 'inc/subscription.php'; if (!subscription_set($_SERVER['REMOTE_USER'], $target, $style, $data)) { @@ -591,7 +590,6 @@ function act_subscription($act){ } msg(sprintf($lang["subscr_{$action}_success"], hsc($INFO['userinfo']['name']), prettyprint_id($target)), 1); - global $ID; act_redirect($ID, $act); // Assure that we have valid data if act_redirect somehow fails. diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index b97713a75..98ded12ca 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -223,7 +223,7 @@ $lang['subscr_m_new_header'] = 'Add subscription'; $lang['subscr_m_current_header'] = 'Current subscriptions'; $lang['subscr_m_unsubscribe'] = 'Unsubscribe'; $lang['subscr_m_subscribe'] = 'Subscribe'; - +$lang['subscr_m_receive'] = 'Receive'; $lang['subscr_style_every'] = 'email on every change'; $lang['subscr_style_digest'] = 'digest email of changes for each page'; $lang['subscr_style_list'] = 'list of changed pages since last email'; diff --git a/inc/template.php b/inc/template.php index 6b0314b84..84fbda051 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1366,24 +1366,21 @@ function tpl_subscribe() { echo '

' . $lang['subscr_m_not_subscribed'] . '

'; } else { echo ''; } @@ -1403,12 +1400,15 @@ function tpl_subscribe() { 'list' => $lang['subscr_style_list'], ); - $form = new Doku_Form(array('id' => 'subscribe')); - $form->addElement('

' . 'Subscribe to' . '

'); - $form->addRadioSet('subscribe_target', $targets); - $form->addElement('

' . 'Receive' . '

'); - $form->addRadioSet('subscribe_style', $styles); - $form->addHidden('subscribe_action', 'subscribe'); + $form = new Doku_Form(array('id' => 'subscribe__form')); + $form->startFieldset($lang['subscr_m_subscribe']); + $form->addRadioSet('sub_target', $targets); + $form->startFieldset($lang['subscr_m_receive']); + $form->addRadioSet('sub_style', $styles); + $form->addHidden('sub_action', 'subscribe'); + $form->addHidden('do', 'subscribe'); + $form->addHidden('id', $ID); + $form->endFieldset(); $form->addElement(form_makeButton('submit', 'subscribe', $lang['subscr_m_subscribe'])); html_form('SUBSCRIBE', $form); echo ''; -- cgit v1.2.3