function wikiplugin_vote($data, $params) { global $smarty, $tikilib, $user, $prefs, $tiki_p_admin_trackers, $tiki_p_view_trackers, $trklib; include_once('lib/trackers/trackerlib.php'); extract($params, EXTR_SKIP); if ($prefs['feature_trackers'] != 'y' || !isset($trackerId) || !($tracker = $trklib->get_tracker($trackerId))) { return $smarty->fetch("wiki-plugins/error_tracker.tpl"); } $smarty->assign_by_ref('tracker', $tracker); if (isset($float)) { $smarty->assign('float', $float); } else { $smarty->assign('float', ''); } if ($trklib->get_user_item($trackerId, array('oneUserItem'=>'y'))) { $smarty->assign('has_already_voted', 'y'); } else { $smarty->assign('has_already_voted', 'n'); } if (empty($fields)) { $fields = $trklib->list_tracker_fields($trackerId); $ff = array(); foreach ($fields['data'] as $field) { if ($field['type'] != 'u' && $field['type'] != 'I' && $field['type'] != 'g' && $field['isPublic'] == 'y') { $ff[] = $field['fieldId']; } } if (!empty($ff)) { $params['fields'] = implode(':', $ff); } } if (isset($show_creator) && $show_creator == 'y') { $tracker = $trklib->get_tracker($trackerId); $smarty->assign_by_ref('tracker_creator', $tracker['user']); } $smarty->assign('options', ''); if ($tikilib->user_has_perm_on_object($user, $trackerId, 'tracker', 'tiki_p_create_tracker_items')) { $options = $trklib->get_tracker_options($trackerId); if (!empty($options['start']) || !empty($options['end'])) $smarty->assign_by_ref('options', $options); if ((!empty($options['start']) && $tikilib->now < $options['start']) || (!empty($options['end']) && $tikilib->now > $options['end'])) { $smarty->assign('p_create_tracker_items', 'n'); $smarty->assign('vote', ''); } else { $smarty->assign('p_create_tracker_items', 'y');// to have different vote in the same page include_once('lib/wiki-plugins/wikiplugin_tracker.php'); $vote = wikiplugin_tracker($data, $params); $smarty->assign_by_ref('vote', $vote); } } else { $smarty->assign('p_create_tracker_items', 'n'); } if (!isset($show_stat) || $show_stat == 'y') { $show_stat = 'y'; if (isset($show_stat_only_after) && $show_stat_only_after == 'y') { if (!isset($options)) { $options = $trklib->get_tracker_options($trackerId); if (!empty($options['start']) || !empty($options['end'])) $smarty->assign_by_ref('options', $options); } if (!empty($options['end']) && $tikilib->now < $options['end']) $show_stat = 'n'; } if ($show_stat == 'y') { include_once('lib/wiki-plugins/wikiplugin_trackerstat.php'); $stat = wikiplugin_trackerstat($data, $params); $smarty->assign_by_ref('stat', $stat); } else { $smarty->assign('stat', ''); } } else { $smarty->assign('stat', ''); } $smarty->assign('date', $tikilib->now); return $smarty->fetch('wiki-plugins/wikiplugin_vote.tpl'); }
function onContinue($homepageUrl) { global $user, $prefs; $userlib = TikiLib::lib('user'); $tikilib = TikiLib::lib('tiki'); $registrationlib = TikiLib::lib('registration'); $trklib = TikiLib::lib('trk'); // Run the parent first parent::onContinue($homepageUrl); //get custom fields $customfields = $registrationlib->get_customfields(); $needs_validation_js = true; if ($registrationlib->merged_prefs['userTracker'] == 'y') { $chosenGroup = 'Registered'; $re = $userlib->get_group_info($chosenGroup); if (!empty($re['usersTrackerId']) && (!empty($re['registrationUsersFieldIds']) && $prefs['feature_userWizardDifferentUsersFieldIds'] != 'y' or $prefs['feature_userWizardDifferentUsersFieldIds'] == 'y' && !empty($prefs['feature_userWizardUsersFieldIds']))) { $needs_validation_js = false; include_once 'lib/wiki-plugins/wikiplugin_tracker.php'; if (isset($_REQUEST['name'])) { $user = $_REQUEST['name']; // so that one can set user preferences at registration time $_REQUEST['iTRACKER'] = 1; // only one tracker plugin on registration } $userWizardDetailsFieldIds = ''; if ($prefs['feature_userWizardDifferentUsersFieldIds'] != 'y' or empty($prefs['feature_userWizardUsersFieldIds'])) { $userWizardDetailsFieldIds = $re['registrationUsersFieldIds']; } elseif ($prefs['feature_userWizardDifferentUsersFieldIds'] == 'y' and !empty($prefs['feature_userWizardUsersFieldIds'])) { $userWizardDetailsFieldIds = $prefs['feature_userWizardUsersFieldIds']; } if (!is_array($userWizardDetailsFieldIds)) { $userWizardDetailsFieldIds = explode(':', $userWizardDetailsFieldIds); } $userTrackerData = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => $userWizardDetailsFieldIds, 'showdesc' => 'n', 'showmandatory' => 'y', 'embedded' => 'n', 'action' => 'Save_User_Details', 'registration' => 'n', 'userField' => $re['usersFieldId'])); $tr = TikiLib::lib('trk')->get_tracker($re['usersTrackerId']); $utid = $userlib->get_tracker_usergroup($user); if (isset($utid['usersTrackerId'])) { $_REQUEST['trackerId'] = $utid['usersTrackerId']; $_REQUEST["itemId"] = $trklib->get_item_id($_REQUEST['trackerId'], $utid['usersFieldId'], $user); } $definition = Tracker_Definition::get($_REQUEST['trackerId']); $xfields = array('data' => $definition->getFields()); } } }
/** * @package tikiwiki */ // (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project // // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. // $Id$ require_once 'tiki-setup.php'; $access->check_feature(array('feature_trackers', 'feature_ajax', 'wikiplugin_tracker')); include_once 'lib/wiki-plugins/wikiplugin_tracker.php'; $json_data = array(); $re = $userlib->get_group_info(isset($_REQUEST['chosenGroup']) ? $_REQUEST['chosenGroup'] : 'Registered'); if (!empty($re['usersTrackerId']) && !empty($re['registrationUsersFieldIds'])) { $json_data['res'] = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => explode(':', $re['registrationUsersFieldIds']), 'showdesc' => 'y', 'showmandatory' => 'y', 'embedded' => 'y', 'action' => tra('Register'), 'registration' => 'n', 'formtag' => 'n', '_ajax_form_ins_id' => 'group')); } else { $json_data['res'] = $_REQUEST['chosenGroup']; $json_data['debug'] = $re; } if ($prefs['feature_jquery_validation'] === 'y') { // dig out the new rules for the js validation foreach ($headerlib->js as $rank) { foreach ($rank as $js) { if (strpos($js, 'ajaxTrackerValidation_group') !== false) { if (preg_match('/validation:\\{([\\s\\S]*?\\})\\s*\\};/s', $js, $m)) { // get the rules and messages from the js function //$m = preg_replace('/\s(?:ignore|submitHandler).*/', '', $m[1]); // lose a couple of duplicate options $m = preg_replace('/,\\s*\\}\\s*$/m', '}', $m[1]); // a trailing comma $o = preg_replace_callback('/(\\w*):/', 'group_tracker_ajax_quote', $m);
function smarty_function_user_registration($params, $smarty) { global $prefs, $https_mode, $base_url_https, $user; $registrationlib = TikiLib::lib('registration'); $userlib = TikiLib::lib('user'); if ($prefs['allowRegister'] != 'y') { return; } $errorreportlib = TikiLib::lib('errorreport'); $_VALID = tra("Please enter a valid %s. No spaces, more than %d characters and contain %s"); $smarty->assign('_PROMPT_UNAME', sprintf($_VALID, tra("username"), $registrationlib->merged_prefs['min_username_length'], "0-9,a-z,A-Z")); $smarty->assign('_PROMPT_PASS', sprintf($_VALID, tra("password"), $registrationlib->merged_prefs['min_pass_length'], "0-9,a-z,A-Z")); $smarty->assign('min_username_length', $registrationlib->merged_prefs['min_username_length']); $smarty->assign('min_pass_length', $registrationlib->merged_prefs['min_pass_length']); if (is_a($registrationlib->merged_prefs, "RegistrationError")) { $errorreportlib->report($registrationlib->merged_prefs->msg); } $smarty->assignByRef('merged_prefs', $registrationlib->merged_prefs); $smarty->assign('allowRegister', 'y'); // Used for OpenID associations $smarty->assign('openid_associate', 'n'); // NOTE that this is not a standard access check, it checks for the opposite of that, i.e. whether logged in already if (!empty($user)) { TikiLib::lib('access')->redirect($prefs['tikiIndex'], tr('You are logged in')); // note that this message might appear also when the user logs in for first time so it has to generic for either case return; } $smarty->assign('showmsg', 'n'); // ensure ssl if (!$https_mode && $prefs['https_login'] == 'required') { TikiLib::lib('access')->redirect($base_url_https . 'tiki-register.php'); return; } //get custom fields $customfields = $registrationlib->get_customfields(); $smarty->assignByRef('customfields', $customfields); //groups choice if (count($registrationlib->merged_prefs['choosable_groups'])) { $smarty->assign('listgroups', $registrationlib->merged_prefs['choosable_groups']); if (count($registrationlib->merged_prefs['choosable_groups']) == 1) { $smarty->assignByRef('theChoiceGroup', $registrationlib->merged_prefs['choosable_groups'][0]['groupName']); } if ($registrationlib->merged_prefs['userTracker'] == 'y') { $smarty->assign('trackerEditFormId', 1); // switch on to make mandatory_star *'s appear even though the tracker form is loaded by ajax } } if (isset($_REQUEST['register']) && $_SERVER['REQUEST_METHOD'] == 'POST') { check_ticket('register'); $cookie_name = $prefs['session_cookie_name']; if (ini_get('session.use_cookie') && !isset($_COOKIE[$cookie_name])) { $errorreportlib->report(tra("You have to enable cookies to be able to login to this site")); return ''; } if ($registrationlib->merged_prefs['http_referer_registration_check'] === 'y') { global $base_host; if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], $base_host) === false) { $errorreportlib->report(tra('Request not from this host.')); return ''; } } $smarty->assign('errortype', 'no_redirect_login'); //result is empty if fields (including antibot) validate and new user is successfully created //no user notification at this stage if user tracker is used $result = $registrationlib->register_new_user($_REQUEST); if (empty($result)) { $_REQUEST['valerror'] = false; } else { $_REQUEST['valerror'] = $result; if (is_array($result)) { foreach ($result as $r) { $errorreportlib->report($r->msg); } } elseif (is_a($result, 'RegistrationError')) { $errorreportlib->report($result->msg); } elseif (is_string($result) && $registrationlib->merged_prefs['userTracker'] !== 'y') { // more to do for usertrackers return $result; } elseif (!empty($result['msg']) && $registrationlib->merged_prefs['userTracker'] !== 'y') { return $result['msg']; } } } $outputtowiki = ''; $outputwiki = ''; if ($prefs['user_register_prettytracker_output'] == 'y') { $outputtowiki = $prefs["user_register_prettytracker_outputtowiki"]; $outputwiki = $prefs["user_register_prettytracker_outputwiki"]; } $needs_validation_js = true; if ($registrationlib->merged_prefs['userTracker'] == 'y') { $chosenGroup = 'Registered'; if (count($registrationlib->merged_prefs['choosable_groups']) > 0 && isset($_REQUEST['chosenGroup'])) { $chosenGroup = $_REQUEST['chosenGroup']; if (!$userlib->group_exists($chosenGroup) || $userlib->get_registrationChoice($chosenGroup) !== 'y') { $result = null; // invalid group chosen $smarty->assign('msg', ''); $smarty->assign('showmsg', 'n'); $chosenGroup = ''; } } $re = $userlib->get_group_info($chosenGroup); if (!empty($re['usersTrackerId']) && !empty($re['registrationUsersFieldIds'])) { $needs_validation_js = false; include_once 'lib/wiki-plugins/wikiplugin_tracker.php'; if (isset($_REQUEST['name'])) { $user = $_REQUEST['name']; // so that one can set user preferences at registration time $_REQUEST['iTRACKER'] = 1; // only one tracker plugin on registration } if (!is_array($re['registrationUsersFieldIds'])) { $re['registrationUsersFieldIds'] = explode(':', $re['registrationUsersFieldIds']); } if ($registrationlib->merged_prefs["user_register_prettytracker"] == 'y' && !empty($registrationlib->merged_prefs["user_register_prettytracker_tpl"])) { if (substr($registrationlib->merged_prefs["user_register_prettytracker_tpl"], -4) == ".tpl") { $userTrackerData = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => $re['registrationUsersFieldIds'], 'showdesc' => 'y', 'showmandatory' => 'y', 'embedded' => 'n', 'action' => tra('Register'), 'registration' => 'y', 'tpl' => $registrationlib->merged_prefs["user_register_prettytracker_tpl"], 'userField' => $re['usersFieldId'], 'outputwiki' => $outputwiki, 'outputtowiki' => $outputtowiki)); } else { $userTrackerData = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => $re['registrationUsersFieldIds'], 'showdesc' => 'y', 'showmandatory' => 'y', 'embedded' => 'n', 'action' => tra('Register'), 'registration' => 'y', 'wiki' => $registrationlib->merged_prefs["user_register_prettytracker_tpl"], 'userField' => $re['usersFieldId'], 'outputwiki' => $outputwiki, 'outputtowiki' => $outputtowiki)); } } else { $userTrackerData = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => $re['registrationUsersFieldIds'], 'showdesc' => 'y', 'showmandatory' => 'y', 'embedded' => 'n', 'action' => tra('Register'), 'registration' => 'y', 'userField' => $re['usersFieldId'])); } $tr = TikiLib::lib('trk')->get_tracker($re['usersTrackerId']); if (!empty($tr['description'])) { $smarty->assign('userTrackerHasDescription', true); } if (isset($_REQUEST['error']) && $_REQUEST['error'] === 'y') { $result = null; $smarty->assign('msg', ''); $smarty->assign('showmsg', 'n'); } else { if (isset($_REQUEST['name'])) { // user tracker saved ok $result = $registrationlib->register_new_user($_REQUEST); if (is_array($result)) { foreach ($result as $r) { $errorreportlib->report($r->msg); } } else { if (is_a($result, 'RegistrationError')) { $errorreportlib->report($result->msg); } else { $user = ''; // reset $user return $result; } } } } $user = ''; // reset $user for security reasons $smarty->assign('userTrackerData', $userTrackerData); } } if ($needs_validation_js) { $registrationlib->addRegistrationFormValidationJs(); } $smarty->assign('email_valid', 'y'); return $smarty->fetch('user_registration.tpl'); }
} if ($prefs['login_is_email'] == 'y') { if (empty($_REQUEST['novalidation']) || $_REQUEST['novalidation'] != 'yes') { $_POST['email'] = $_REQUEST['email'] = $_REQUEST['name']; } else { $_POST['name'] = $_REQUEST['name'] = $_REQUEST['email']; } } $email_valid = 'y'; if (!validate_email($_REQUEST["email"], $prefs['validateEmail'])) { $email_valid = 'n'; } elseif ($prefs['userTracker'] == 'y') { $re = $userlib->get_group_info(isset($_REQUEST['chosenGroup']) ? $_REQUEST['chosenGroup'] : 'Registered'); if (!empty($re['usersTrackerId']) && !empty($re['registrationUsersFieldIds'])) { include_once 'lib/wiki-plugins/wikiplugin_tracker.php'; $userTrackerData = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => $re['registrationUsersFieldIds'], 'showdesc' => 'y', 'showmandatory' => 'y', 'embedded' => 'n')); $smarty->assign('userTrackerData', $userTrackerData); if (!isset($_REQUEST['trackit']) || isset($_REQUEST['error']) && $_REQUEST['error'] == 'y') { $email_valid = 'n'; // first pass or error } } } if ($email_valid == 'y') { if (isset($_SESSION['openid_url'])) { $openid_url = $_SESSION['openid_url']; } else { $openid_url = ''; } if ($prefs['validateUsers'] == 'y' || isset($prefs['validateRegistration']) && $prefs['validateRegistration'] == 'y') { $apass = addslashes(md5($tikilib->genPass()));
function renderInput($context = array()) { if ($this->getOption(6) && !$context['in_ajax_form']) { $context['in_ajax_form'] = true; require_once 'lib/wiki-plugins/wikiplugin_tracker.php'; $params = array('trackerId' => $this->getOption(0), 'ignoreRequestItemId' => 'y', '_ajax_form_ins_id' => $this->getInsertId()); if ($this->getOption(7)) { $params['wiki'] = $this->getOption(7); } $form = wikiplugin_tracker('', $params); $form = preg_replace(array('/<!--.*?-->/', '/\\s+/', '/^~np~/', '/~\\/np~/'), array('', ' ', '', ''), $form); // remove comments etc if ($this->getOption(3)) { $displayFieldId = $this->getOption(3); if (strpos($displayFieldId, '|') !== false) { $displayFieldId = substr($displayFieldId, 0, strpos($displayFieldId, '|')); } } else { $displayFieldId = $this->getOption(1); } TikiLib::lib('header')->add_jq_onready(' $("select[name=' . $this->getInsertId() . ']").change(function(e, val) { if ($(this).val() == -1) { var $d = $("<div id=\'add_dialog_' . $this->getInsertId() . '\' style=\'display:none\'>' . addslashes($form) . '</div>") .appendTo(document.body); var w = $d.width() * 1.4; var h = $d.height() * 2.0; if ($(document.body).width() < w) { w = $(document.body).width() * 0.8; } if ($(document.body).height() < h) { h = $(document.body).height() * 0.8; } $d.dialog({ width: w, height: h, title: "' . $this->getOption(6) . '", modal: true, buttons: { "Add": function() { var $f = $("form", this).append($("<input type=\'hidden\' name=\'ajax_add\' value=\'1\' />")); if (typeof $f.valid === "function" && $f.valid()) { ajaxLoadingShow($f); $.post( $f.attr("action"), $f.serialize(), function(data, status) { if (data && data.data) { for (var i = 0; i < data.data.length; i++) { var a = data.data[i]; if ( a && a["fieldId"] == ' . $displayFieldId . ' ) { var $o = $("<option value=\'" + data["itemId"] + "\'>" + a["value"] + "</option>"); $("select[name=' . $this->getInsertId() . '] > option:first").after($o); $("select[name=' . $this->getInsertId() . ']")[0].selectedIndex = 1; } } } ajaxLoadingHide(); $d.dialog( "close" ); return; }, "json"); } }, Cancel: function() { $("select[name=' . $this->getInsertId() . ']")[0].selectedIndex = 0; $( this ).dialog( "close" ); } }, create: function(event, ui) { ajaxTrackerFormInit_' . $this->getInsertId() . '(); } }).find(".input_submit_container").remove(); } }); '); } if ($this->getOption(12)) { $context['selectMultipleValues'] = true; } else { $context['selectMultipleValues'] = false; } if ($preselection = $this->getPreselection()) { $context['preselection'] = $preselection; } else { $context['preselection'] = ''; } return $this->renderTemplate('trackerinput/itemlink.tpl', $context); }
function smarty_function_user_registration($params, $smarty) { global $prefs, $userlib, $https_mode, $base_url_https, $registrationlib, $user; if ($prefs['allowRegister'] != 'y') { return; } $errorreportlib = TikiLib::lib('errorreport'); include_once 'lib/registration/registrationlib.php'; $_VALID = tra("Please enter a valid %s. No spaces, more than %d characters and contain %s"); $smarty->assign('_PROMPT_UNAME', sprintf($_VALID, tra("username"), $registrationlib->merged_prefs['min_username_length'], "0-9,a-z,A-Z")); $smarty->assign('_PROMPT_PASS', sprintf($_VALID, tra("password"), $registrationlib->merged_prefs['min_pass_length'], "0-9,a-z,A-Z")); $smarty->assign('min_username_length', $registrationlib->merged_prefs['min_username_length']); $smarty->assign('min_pass_length', $registrationlib->merged_prefs['min_pass_length']); if (is_a($registrationlib->merged_prefs, "RegistrationError")) { $errorreportlib->report($registrationlib->merged_prefs->msg); } $smarty->assignByRef('merged_prefs', $registrationlib->merged_prefs); $smarty->assign('allowRegister', 'y'); // Used for OpenID associations $smarty->assign('openid_associate', 'n'); // NOTE that this is not a standard access check, it checks for the opposite of that, i.e. whether logged in already if (!empty($user)) { TikiLib::lib('access')->redirect($prefs['tikiIndex'], tr('You are already logged in')); return; } $smarty->assign('showmsg', 'n'); // ensure ssl if (!$https_mode && $prefs['https_login'] == 'required') { TikiLib::lib('access')->redirect($base_url_https . 'tiki-register.php'); return; } //get custom fields $customfields = $registrationlib->get_customfields(); $smarty->assignByRef('customfields', $customfields); //groups choice if (count($registrationlib->merged_prefs['choosable_groups'])) { $smarty->assign('listgroups', $registrationlib->merged_prefs['choosable_groups']); if (count($registrationlib->merged_prefs['choosable_groups']) == 1) { $smarty->assignByRef('theChoiceGroup', $registrationlib->merged_prefs['choosable_groups'][0]['groupName']); } if ($registrationlib->merged_prefs['userTracker'] == 'y') { $smarty->assign('trackerEditFormId', 1); // switch on to make mandatory_star *'s appear even though the tracker form is loaded by ajax } } if (isset($_REQUEST['register']) && $_SERVER['REQUEST_METHOD'] == 'POST') { check_ticket('register'); $cookie_name = $prefs['session_cookie_name']; if (ini_get('session.use_cookie') && !isset($_COOKIE[$cookie_name])) { $errorreportlib->report(tra("You have to enable cookies to be able to login to this site")); return ''; } if ($registrationlib->merged_prefs['http_referer_registration_check'] === 'y') { global $base_host; if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], $base_host) === false) { $errorreportlib->report(tra('Request not from this host.')); return ''; } } $smarty->assign('errortype', 'no_redirect_login'); //result is empty if fields (including antibot) validate and new user is successfully created //no user notification at this stage if user tracker is used $result = $registrationlib->register_new_user($_REQUEST); if (empty($result)) { $_REQUEST['valerror'] = false; } else { $_REQUEST['valerror'] = $result; if (is_array($result)) { foreach ($result as $r) { $errorreportlib->report($r->msg); } } elseif (is_a($result, 'RegistrationError')) { $errorreportlib->report($result->msg); } elseif (is_string($result) && $registrationlib->merged_prefs['userTracker'] !== 'y') { // more to do for usertrackers return $result; } elseif (!empty($result['msg']) && $registrationlib->merged_prefs['userTracker'] !== 'y') { return $result['msg']; } } } $outputtowiki = ''; $outputwiki = ''; if ($prefs['user_register_prettytracker_output'] == 'y') { $outputtowiki = $prefs["user_register_prettytracker_outputtowiki"]; $outputwiki = $prefs["user_register_prettytracker_outputwiki"]; } $needs_validation_js = true; if ($registrationlib->merged_prefs['userTracker'] == 'y') { $chosenGroup = 'Registered'; if (count($registrationlib->merged_prefs['choosable_groups']) > 0 && isset($_REQUEST['chosenGroup'])) { $chosenGroup = $_REQUEST['chosenGroup']; if (!$userlib->group_exists($chosenGroup) || $userlib->get_registrationChoice($chosenGroup) !== 'y') { $result = null; // invalid group chosen $smarty->assign('msg', ''); $smarty->assign('showmsg', 'n'); $chosenGroup = ''; } } $re = $userlib->get_group_info($chosenGroup); if (!empty($re['usersTrackerId']) && !empty($re['registrationUsersFieldIds'])) { $needs_validation_js = false; include_once 'lib/wiki-plugins/wikiplugin_tracker.php'; if (isset($_REQUEST['name'])) { $user = $_REQUEST['name']; // so that one can set user preferences at registration time $_REQUEST['iTRACKER'] = 1; // only one tracker plugin on registration } if ($registrationlib->merged_prefs["user_register_prettytracker"] == 'y' && !empty($registrationlib->merged_prefs["user_register_prettytracker_tpl"])) { if (substr($registrationlib->merged_prefs["user_register_prettytracker_tpl"], -4) == ".tpl") { $userTrackerData = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => $re['registrationUsersFieldIds'], 'showdesc' => 'y', 'showmandatory' => 'y', 'embedded' => 'n', 'action' => tra('Register'), 'registration' => 'y', 'tpl' => $registrationlib->merged_prefs["user_register_prettytracker_tpl"], 'userField' => $re['usersFieldId'], 'outputwiki' => $outputwiki, 'outputtowiki' => $outputtowiki)); } else { $userTrackerData = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => $re['registrationUsersFieldIds'], 'showdesc' => 'y', 'showmandatory' => 'y', 'embedded' => 'n', 'action' => tra('Register'), 'registration' => 'y', 'wiki' => $registrationlib->merged_prefs["user_register_prettytracker_tpl"], 'userField' => $re['usersFieldId'], 'outputwiki' => $outputwiki, 'outputtowiki' => $outputtowiki)); } } else { $userTrackerData = wikiplugin_tracker('', array('trackerId' => $re['usersTrackerId'], 'fields' => $re['registrationUsersFieldIds'], 'showdesc' => 'y', 'showmandatory' => 'y', 'embedded' => 'n', 'action' => tra('Register'), 'registration' => 'y', 'userField' => $re['usersFieldId'])); } $tr = TikiLib::lib('trk')->get_tracker($re['usersTrackerId']); if (!empty($tr['description'])) { $smarty->assign('userTrackerHasDescription', true); } if (isset($_REQUEST['error']) && $_REQUEST['error'] === 'y') { $result = null; $smarty->assign('msg', ''); $smarty->assign('showmsg', 'n'); } else { if (isset($_REQUEST['name'])) { // user tracker saved ok $result = $registrationlib->register_new_user($_REQUEST); if (is_array($result)) { foreach ($result as $r) { $errorreportlib->report($r->msg); } } else { if (is_a($result, 'RegistrationError')) { $errorreportlib->report($result->msg); } else { $user = ''; // reset $user return $result; } } } } $user = ''; // reset $user for security reasons $smarty->assign('userTrackerData', $userTrackerData); } } if ($needs_validation_js && $prefs['feature_jquery_validation'] === 'y') { $js_m = ''; $js = ' $("form[name=RegForm]").validate({ rules: { name: { required: true,'; if ($prefs['login_is_email'] === 'y') { $js .= ' email: true,'; } $js .= ' remote: { url: "validate-ajax.php", type: "post", data: { validator: "username", input: function() { return $("#name").val(); } } } }, email: { required: true, email: true }, pass: { required: true, remote: { url: "validate-ajax.php", type: "post", data: { validator: "password", input: function() { return $("#pass1").val(); } } } }, passAgain: { equalTo: "#pass1" }'; if ($prefs['user_must_choose_group'] === 'y') { $choosable_groups = $registrationlib->merged_prefs['choosable_groups']; $js .= ', chosenGroup: { required: true }'; $js_m .= ' "chosenGroup": { required: "' . tra('One of these groups is required') . '"}, '; } if (extension_loaded('gd') && function_exists('imagepng') && function_exists('imageftbbox') && $prefs['feature_antibot'] == 'y' && empty($user) && $prefs['recaptcha_enabled'] != 'y') { // antibot validation $js .= ', "captcha[input]": { required: true, remote: { url: "validate-ajax.php", type: "post", data: { validator: "captcha", parameter: function() { return $jq("#captchaId").val(); }, input: function() { return $jq("#antibotcode").val(); } } } } '; $js_m .= ' "captcha[input]": { required: "' . tra('This field is required') . '"}, '; } $js .= '}, messages: {' . $js_m . ' name: { required: "This field is required"}, email: { email: "Invalid email", required: "This field is required"}, pass: { required: "This field is required"}, passAgain: { equalTo: "Passwords do not match"} }, submitHandler: function(){process_submit(this.currentForm);} }); '; TikiLib::lib('header')->add_jq_onready($js); } $smarty->assign('email_valid', 'y'); return $smarty->fetch('user_registration.tpl'); }
function renderInput($context = array()) { $data = array('list' => $this->getItemList()); if ($this->getOption('addItems') && empty($context['in_ajax_form'])) { $context['in_ajax_form'] = true; require_once 'lib/wiki-plugins/wikiplugin_tracker.php'; $params = array('trackerId' => $this->getOption('trackerId'), 'ignoreRequestItemId' => 'y', '_ajax_form_ins_id' => $this->getInsertId()); if ($this->getOption('addItemsWikiTpl')) { $params['wiki'] = $this->getOption('addItemsWikiTpl'); } $form = wikiplugin_tracker('', $params); $form = preg_replace(array('/<!--.*?-->/', '/\\s+/', '/^~np~/', '/~\\/np~/'), array('', ' ', '', ''), $form); // remove comments etc if ($displayFieldsList = $this->getDisplayFieldsListArray()) { $displayFieldId = $displayFieldsList[0]; if (is_string($displayFieldId) && strpos($displayFieldId, '|') !== false) { $displayFieldId = substr($displayFieldId, 0, strpos($displayFieldId, '|')); } } else { $displayFieldId = $this->getOption('fieldId'); } TikiLib::lib('header')->add_jq_onready('$("select[name=' . $this->getInsertId() . ']").change(function(e, val) { var $select = $(this); if ($select.val() == -1) { var $d = $("<div id=\'add_dialog_' . $this->getInsertId() . '\' style=\'display:none\'/>") .html(' . json_encode($form) . ') .appendTo(document.body); var w = $d.width() * 1.4; var h = $d.height() * 2.0; if ($(document.body).width() < w) { w = $(document.body).width() * 0.8; } if ($(document.body).height() < h) { h = $(document.body).height() * 0.8; } $d.dialog({ width: w, height: h, title: ' . json_encode($this->getOption('addItems')) . ', modal: true, buttons: { "Add": function() { var $f = $("form", this).append($("<input type=\'hidden\' name=\'ajax_add\' value=\'1\' />")); if (typeof $f.valid === "function" && $f.valid()) { ajaxLoadingShow($f); $.post( $f.attr("action"), $f.serialize(), function(data, status) { if (data && data.data) { $.each(data.data, function (i, a) { if ( a && a.fieldId == ' . intval($displayFieldId) . ' ) { if ("string" !== typeof a.value && a.pvalue) { a.value = a.pvalue; } var $o = $("<option/>") .val(data.itemId) .text(a.value); $select .append($o) .val(data.itemId); } }); } ajaxLoadingHide(); $d.dialog( "close" ); $select.trigger("chosen:updated"); return; }, "json"); } }, Cancel: function() { $select.val(""); $( this ).dialog( "close" ); } }, create: function(event, ui) { ajaxTrackerFormInit_' . $this->getInsertId() . '(); } }).find(".input_submit_container").remove(); } }); '); } $data['selectMultipleValues'] = (bool) $this->getOption('selectMultipleValues'); // 'crossSelect' overrides the preselection reference, which is enabled, when a cross reference Item Link <-> Item Link // When selecting a value another item link can provide the relation, then the cross link can point to several records having the same linked value. // Example Contact and Report links to a Company. Report also links to Contact. When selecting Contact, Only Contacts in the same company as the Report is linked to, should be made visible. // When 'crossSelect' is enabled // 1) The dropdown list is no longer disabled (else disabled) // 2) All rows in the remote tracker matching the criterea are displayed in the dropdown list (else only 1 row is displayed) $method = $this->getOption('preSelectFieldMethod'); if ($method == 'crossSelect') { $data['crossSelect'] = 'y'; } else { $data['crossSelect'] = 'n'; } // Prepare for 'crossSelect' $linkValue = false; // Value which links the tracker items if ($data['crossSelect'] === 'y') { // Check if itemId is set / used. // If not, it must be set here $itemData = $this->getItemData(); if (empty($itemData['itemId'])) { if (!empty($_REQUEST['itemId'])) { $linkValue = $_REQUEST['itemId']; } } else { $linkValue = $itemData['itemId']; } } if ($preselection = $this->getPreselection($linkValue)) { $data['preselection'] = $preselection; } else { $data['preselection'] = ''; } $data['filter'] = $this->buildFilter(); if ($data['crossSelect'] === 'y') { $fullList = $data['list']; if (!empty($preselection) && is_array($preselection)) { $data['remoteData'] = array_intersect_key($fullList, array_flip($preselection)); } else { $data['remoteData'] = $fullList; } } return $this->renderTemplate('trackerinput/itemlink.tpl', $context, $data); }