function wikiplugin_registermemberpayment($data, $params, $offset) { global $user, $tiki_p_payment_view; $headerlib = TikiLib::lib('header'); $smarty = TikiLib::lib('smarty'); static $i; $i++; if ($tiki_p_payment_view != 'y') { return tr('Insufficient Privileges'); } if (empty($user) && isset($_REQUEST['wp_member_users']) == true) { $user = end(explode('|', $_REQUEST['wp_member_users'])); $_SESSION['forceanon'] = 'y'; $_REQUEST['price'] = $_POST['price'] = $_GET['price'] = $params['price']; } $periodslabel = isset($params['periodslabel']) ? tr($params['periodslabel']) : 'Number of periods:'; $fixedperiodsDDL = ''; $fixedperiods = explode(';', isset($params['fixedperiods']) ? $params['fixedperiods'] : ''); foreach ($fixedperiods as $fixedperiod) { if (!empty($fixedperiod)) { $fixedperiod = explode(':', $fixedperiod); $name = $fixedperiod[0]; $value = !empty($fixedperiod[1]) ? $fixedperiod[1] : $fixedperiod[0]; $fixedperiodsDDL .= '<option value="' . trim($value) . '">' . trim($name) . '</option>'; } } if (empty($fixedperiodsDDL)) { $periods = '<input id="memberDuration' . $i . '" name="duration" value="1" />'; } else { $periods = '<select id="memberDuration' . $i . '" name="duration">' . $fixedperiodsDDL . '</select>'; } //force current user to not be used $params['currentuser'] = '******'; $memberPayment = TikiLib::lib('parser')->parse_data(wikiplugin_memberpayment($data, $params, $offset), array('is_html' => true)); if ($_SERVER['REQUEST_METHOD'] != 'POST') { if (isset($_POST['msg'])) { $_POST['msg'] = addslashes(htmlspecialchars($_POST['msg'])); $headerlib->add_jq_onready("\$.notify('" . $_POST['msg'] . "')"); } if (empty($user)) { include_once 'lib/smarty_tiki/function.user_registration.php'; $register = smarty_function_user_registration(array(), $smarty); } else { $register = "<table>\n\t\t\t\t<tr class='registerSubmitTr'>\n\t\t\t\t\t<td colspan='2'>\n\t\t\t\t\t\t<input type='hidden' id='name' value='{$user}' />\n\t\t\t\t\t\t<input type='submit' value='" . tr('Submit') . "' class='registerSubmit'/>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>"; } } $group = $params['group']; $headerlib->add_jq_onready(<<<JS var reg = \$('#memberRegister{$i}'), pay = \$('#memberPayment{$i}'), user = "******"; pay.find('.warning').insertAfter(pay); //just in case there are any warnings var submitBtn = reg.find('input.registerSubmit'), //both with and without trackers submitBtnTr = reg.find('tr.registerSubmitTr,div.input_submit_container'), trackerForm = \$('table.wikiplugin_tracker').parent('form'); if (!user) { \$('<tr class="grpMmbChk">\\ <td>{$group} Membership:</td>\\ <td>\\ <input type="checkbox" id="memberType{$i}" />\\ </td>\\ </tr>').insertBefore(submitBtnTr); } else { \$('<tr>\\ <td><b>{$group} Membership</b></td>\\ </tr>').insertBefore(submitBtnTr); } \$('<tr style="display: none;">\\ <td>{$periodslabel}</td>\\ <td>{$periods}</td>\\ </tr>') .insertBefore(submitBtnTr); \$('#memberType{$i}') .click(function() { \$('tr.grpMmbChk').next() .stop() .fadeToggle(); }) .click(); reg .bind('continueToPurchase', function() { pay.find('input[name="wp_member_users"]').val(\$('#memberRegister{$i} #name').val()); pay.find('input[name="wp_member_periods"]').val(\$('#memberDuration{$i}').val()); pay.find('input:last').click(); }) .find('input:last').click(function() { var frmData = reg.find('form').serialize(), invokeRegistration = function() { if (frmData) { \$.getJSON(\$.service('user', 'register') + '&' + frmData + '&noTemplate', function(data) { if (typeof data.result == "string") { if (\$('#memberType{$i}').is(':checked')) { \$('<input name="msg" />') .val(data.result) .prependTo(pay.find('form')); reg.trigger('continueToPurchase'); } else { //registered \$.notify(data.result); \$.notify(tr('You will be redirected in 5 seconds')); setTimeout(function() { document.location = 'tiki-index.php'; }, 5000); } } else { //errors \$.each(data.result, function(i) { \$.notify(data.result[i].msg); }); } }); } else { reg.trigger('continueToPurchase'); } }; //this is from a tracker, lets go ahead and submit the tracker data, then we will submit the other if (trackerForm.length > 0) { \$.post(trackerForm.attr('action'), trackerForm.serialize(), function(data) { console.log(data); invokeRegistration(); }); } else { invokeRegistration(); } return false; }); JS ); $paymentStyle = ''; $registerStyle = ''; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $registerStyle = 'display: none;'; } else { $paymentStyle = 'display: none;'; } return "~np~\n\t\t<div id='memberPayment{$i}' style='{$paymentStyle}'>{$memberPayment}</div>\n\t\t<div id='memberRegister{$i}' style='{$registerStyle}'>{$register}</div>\n\t~/np~"; }
/** * @param $mod_reference * @param $module_params * @return array|mixed|RegistrationError|string */ function module_register($mod_reference, $module_params) { $smarty = TikiLib::lib('smarty'); include_once 'lib/smarty_tiki/function.user_registration.php'; return smarty_function_user_registration($module_params, $smarty); }
/** * @param $mod_reference * @param $module_params * @return array|mixed|RegistrationError|string */ function module_register($mod_reference, $module_params) { global $smarty; include_once 'lib/smarty_tiki/function.user_registration.php'; return smarty_function_user_registration($module_params, $smarty); }
function wikiplugin_registermemberpayment($data, $params, $offset) { global $headerlib, $user, $smarty, $tiki_p_payment_view; static $i; $i++; if ($tiki_p_payment_view != 'y') { return tr('Insufficient Privileges'); } if (empty($user) && isset($_REQUEST['wp_member_users']) == true) { $user = end(explode('|', $_REQUEST['wp_member_users'])); $_SESSION['forceanon'] = 'y'; $_REQUEST['price'] = $_POST['price'] = $_GET['price'] = $params['price']; } $periodslabel = isset($params['periodslabel']) ? tr($params['periodslabel']) : 'Number of periods:'; $fixedperiodsDDL = ''; $fixedperiods = explode(';', isset($params['fixedperiods']) ? $params['fixedperiods'] : ''); foreach ($fixedperiods as $fixedperiod) { if (!empty($fixedperiod)) { $fixedperiod = explode(':', $fixedperiod); $name = $fixedperiod[0]; $value = !empty($fixedperiod[1]) ? $fixedperiod[1] : $fixedperiod[0]; $fixedperiodsDDL .= '<option value="' . trim($value) . '">' . trim($name) . '</option>'; } } if (empty($fixedperiodsDDL)) { $periods = '<input id="memberDuration' . $i . '" name="duration" value="1" />'; } else { $periods = '<select id="memberDuration' . $i . '" name="duration">' . $fixedperiodsDDL . '</select>'; } $memberPayment = TikiLib::lib('parser')->parse_data(wikiplugin_memberpayment($data, $params, $offset), array('is_html' => true)); if ($_SERVER['REQUEST_METHOD'] != 'POST') { if (isset($_POST['msg'])) { $_POST['msg'] = addslashes(htmlspecialchars($_POST['msg'])); $headerlib->add_jq_onready("\$.notify('" . $_POST['msg'] . "')"); } if (empty($user)) { include_once 'lib/smarty_tiki/function.user_registration.php'; $register = smarty_function_user_registration(array(), $smarty); } else { $register = "<table>\n\t\t\t\t<tr class='registerSubmitTr'>\n\t\t\t\t\t<td colspan='2'>\n\t\t\t\t\t\t<input type='hidden' id='name' value='{$user}' />\n\t\t\t\t\t\t<input type='submit' value='" . tr('Submit') . "' class='registerSubmit'/>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>"; } } $group = $params['group']; $headerlib->add_jq_onready(<<<JQ \t\tvar reg = \$('#memberRegister{$i}'), \t\t\tpay = \$('#memberPayment{$i}'), \t\t\tuser = "******"; \t\tpay.find('.warning').insertAfter(pay); //just in case there are any warnings \t\tvar submitBtn = reg.find('input.registerSubmit'), \t\t\tsubmitBtnTr = reg.find('tr.registerSubmitTr'); \t\tif (!user) { \t\t\t\$('<tr class="grpMmbChk">\\ \t\t\t\t<td>{$group} Membership:</td>\\ \t\t\t\t<td>\\ \t\t\t\t\t<input type="checkbox" id="memberType{$i}" />\\ \t\t\t\t</td>\\ \t\t\t</tr>').insertBefore(submitBtnTr); \t\t} else { \t\t\t\$('<tr>\\ \t\t\t\t<td><b>{$group} Membership</b></td>\\ \t\t\t</tr>').insertBefore(submitBtnTr); \t\t} \t\t\$('<tr style="display: none;">\\ \t\t\t<td>{$periodslabel}</td>\\ \t\t\t<td>{$periods}</td>\\ \t\t</tr>') \t\t\t.insertBefore(submitBtnTr); \t\t\$('#memberType{$i}') \t\t\t.click(function() { \t\t\t\t\$('tr.grpMmbChk').next() \t\t\t\t\t.stop() \t\t\t\t\t.fadeToggle(); \t\t\t}) \t\t\t.click(); \t\treg \t\t\t.bind('continueToPurchase', function() { \t\t\t\tpay.find('input[name="wp_member_users"]').val(\$('#memberRegister{$i} #name').val()); \t\t\t\tpay.find('input[name="wp_member_periods"]').val(\$('#memberDuration{$i}').val()); \t\t\t\tpay.find('input:last').click(); \t\t\t}) \t\t\t.find('input:last').click(function() { \t\t\t\tvar frmData = reg.find('form').serialize(); \t\t\t\tif (frmData) { \t\t\t\t\t\$.post(\$.service('user', 'register') + '&' + frmData, function(data) { \t\t\t\t\t\tdata = \$.parseJSON(data); \t\t\t\t\t\tif (typeof data == "string") { \t\t\t\t\t\t\tif (\$('#memberType{$i}').is(':checked')) { \t\t\t\t\t\t\t\t\$('<input name="msg" />') \t\t\t\t\t\t\t\t\t.val(data) \t\t\t\t\t\t\t\t\t.prependTo(pay.find('form')); \t\t\t\t\t\t\t\treg.trigger('continueToPurchase'); \t\t\t\t\t\t\t} else { //registered \t\t\t\t\t\t\t\t\$.notify(data); \t\t\t\t\t\t\t\t\$.notify(tr('You will be redirected in 5 seconds')); \t\t\t\t\t\t\t\tsetTimeout(function() { \t\t\t\t\t\t\t\t\tdocument.location = 'tiki-index.php'; \t\t\t\t\t\t\t\t}, 5000); \t\t\t\t\t\t\t} \t\t\t\t\t\t} else { //errors \t\t\t\t\t\t\t\$.each(data, function(i) { \t\t\t\t\t\t\t\t\$.notify(data[i]); \t\t\t\t\t\t\t}); \t\t\t\t\t\t} \t\t\t\t\t}); \t\t\t\t} else { \t\t\t\t\treg.trigger('continueToPurchase'); \t\t\t\t} \t\t\t\treturn false; \t\t\t}); JQ ); $paymentStyle = ''; $registerStyle = ''; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $registerStyle = 'display: none;'; } else { $paymentStyle = 'display: none;'; } return "~np~\n\t\t<div id='memberPayment{$i}' style='{$paymentStyle}'>{$memberPayment}</div>\n\t\t<div id='memberRegister{$i}' style='{$registerStyle}'>{$register}</div>\n\t~/np~"; }