Revision: 12682
http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=12682&view=rev
Author: niclone
Date: 2008-04-25 02:57:06 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
Moving code from tiki-register.php to registrationlib to be reusable for external registration
Modified Paths:
--------------
users/niclone/branches/intertiki-register/lib/registration/registrationlib.php
users/niclone/branches/intertiki-register/templates/tiki-register.tpl
users/niclone/branches/intertiki-register/tiki-register.php
Modified: users/niclone/branches/intertiki-register/lib/registration/registrationlib.php
===================================================================
--- users/niclone/branches/intertiki-register/lib/registration/registrationlib.php 2008-04-25 06:56:24 UTC (rev 12681)
+++ users/niclone/branches/intertiki-register/lib/registration/registrationlib.php 2008-04-25 09:57:06 UTC (rev 12682)
@@ -439,6 +439,218 @@
ask_ticket('register');
}
+
+ /**
+ * return all informations needed to build a registration form
+ */
+ function get_registration_local_datas() {
+ global $userlib, $prefs;
+ $rd=array();
+
+ // about groups
+ $listgroups = $userlib->get_groups(0, -1, 'groupName_asc', '', '', 'n');
+ $choicegroups=array();
+ $rd['mandatoryChoiceGroups']=true;
+ foreach($listgroups['data'] as $k=>$gr) {
+ if ($gr['registrationChoice'] == 'y') {
+ $choicegroups[]=$gr;
+ if ($gr['groupName'] == 'Registered') $rd['mandatoryChoiceGroups'] = false;
+ }
+ }
+ if (!$rd['mandatoryChoiceGroups'])
+ $choicegroups[]=array('groupName' => '', 'groupDesc' => tra('no group'), 'registrationChoice' => 'y');
+ $rd['choicegroups']=$choicegroups;
+
+
+ //get custom fields
+ $rd['customfields'] = $this->get_customfields();
+
+ //some preferences
+ $rd['min_user_length'] = $prefs['min_user_length'];
+ $rd['min_pass_length'] = $prefs['min_pass_length'];
+ $rd['login_is_email'] = $prefs['login_is_email'];
+ $rd['lowercase_username'] = $prefs['lowercase_username'];
+ $rd['useRegisterPasscode'] = $prefs['useRegisterPasscode'];
+ $rd['pass_chr_num'] = $prefs['pass_chr_num'];
+ $rd['validateUsers'] = $prefs['validateUsers'];
+ $rd['validateEmail'] = $prefs['validateEmail'];
+
+ return $rd;
+ }
+
+
+ function register($rq, $rd=NULL) {
+ global $registrationlib, $userlib, $prefs, $patterns, $logslib, $tikilib, $notificationlib;
+ global $smarty; // <- must be used only for email notification
+
+ $result=array('error' => array(),
+ 'email_valid' => '',
+ );
+
+ if ($rd === NULL) $rd=get_register_local_datas();
+
+ if($rq['novalidation'] != 'yes' and ($rq["pass"] <> $rq["passAgain"]) and !isset($rq['openid_url'])) {
+ $result['error'][]=tra("The passwords don't match");
+ }
+
+ if($userlib->user_exists($rq["name"])) {
+ $result['error'][]=tra("User already exists");
+ }
+
+ if($prefs['rnd_num_reg'] == 'y') {
+ if (!isset($_SESSION['random_number']) || $_SESSION['random_number']!=$rq['antibotcode']) {
+ $result['error'][]=tra("Wrong registration code");
+ }
+ }
+
+ // VALIDATE NAME HERE
+ $n = strtolower($rq['name']);
+ if($n =='admin' || $n == 'anonymous' || $n == 'registered' || $n == strtolower(tra('Anonymous')) || $n == strtolower(tra('Registered'))) {
+ $result['error'][]=tra("Invalid username");
+ }
+
+ if(strlen($rq["name"])>200) {
+ $result['error'][]=tra("Username is too long");
+ }
+
+ if(strstr($rq["name"],' ')) {
+ $result['error'][]=tra("Username cannot contain whitespace");
+ }
+
+ if($prefs['lowercase_username'] == 'y') {
+ if(ereg("[[:upper:]]", $rq["name"])) {
+ $result['error'][]=tra("Username cannot contain uppercase letters");
+ }
+ }
+
+ //FALTA DEFINIR VALORES PADRÕES PARA AS DUAS VARIÁVEIS!!!
+ if(strlen($rq["name"])<$prefs['min_username_length']) {
+ $result['error'][]=tra("Username must be at least").' '.$prefs['min_username_length'].' '.tra("characters long");
+ }
+
+ if(strlen($rq["name"])>$prefs['max_username_length']) {
+ $result['error'][]=tra("Username cannot contain more than").' '.$prefs['max_username_length'].' '.tra("characters");
+ }
+
+ $polerr = $userlib->check_password_policy($rq["pass"]);
+ if ( !isset($rq['openid_url']) && (strlen($polerr)>0) ) {
+ $result['error'][]= $polerr;
+ }
+
+ if (!preg_match($patterns['login'],$rq["name"])) {
+ $result['error'][]=tra("Invalid username");
+ }
+
+ // Check the mode
+ if($prefs['useRegisterPasscode'] == 'y') {
+ if($rq['passcode']!=$prefs['registerPasscoder']) {
+ $result['error'][]=tra("Wrong passcode you need to know the passcode to register in this site");
+ }
+ }
+ if ((count($rd['choicegroups']) > 0) && $rd['$mandatoryChoiceGroups'] && empty($rq['chosenGroup'])) {
+ $result['error'][]=tra('You must choose a group');
+ }
+
+ if ($prefs['login_is_email'] == 'y') {
+ if (empty($rq['novalidation']) || $rq['novalidation'] != 'yes') {
+ $rq['email'] = $rq['name'];
+ } else {
+ $rq['name'] = $rq['email'];
+ }
+ }
+
+ $email_valid = 'y';
+ if (!validate_email($rq["email"],$prefs['validateEmail'])) {
+ $email_valid = 'n';
+ } elseif ($prefs['userTracker'] == 'y') {
+ $re = $userlib->get_group_info(isset($rq['chosenGroup'])? $rq['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'));
+ $result['userTrackerData']=$userTrackerData;
+ if (!isset($rq['trackit']) || (isset($rq['error']) && $rq['error'] == 'y')) {
+ $email_valid = 'n';// first pass or error
+ }
+ }
+ }
+
+ $result['email_valid']=$email_valid;
+ if (count($result['error']) || $result['email_valid'] != 'y') return $result;
+
+ if (isset($rq['openid_url'])) {
+ $openid_url = $rq['openid_url'];
+ } else {
+ $openid_url = '';
+ }
+ if($prefs['validateUsers'] == 'y' || (isset($prefs['validateRegistration']) && $prefs['validateRegistration'] == 'y')) {
+ $apass = addslashes(md5($tikilib->genPass()));
+ $userlib->send_validation_email($rq['name'], $apass, $rq['email']);
+
+ $userlib->add_user($rq["name"],$apass,$rq["email"],$rq["pass"], false, 'n', $openid_url);
+ if (isset($rq['chosenGroup']) && $userlib->get_registrationChoice($rq['chosenGroup']) == 'y') {
+ $userlib->set_default_group($rq['name'], $rq['chosenGroup']);
+ }
+ $logslib->add_log('register','created account '.$rq["name"]);
+ //$smarty->assign('showmsg','y'); // where is the $msg??
+ $result['msg']="yeah...";
+ } else {
+ $userlib->add_user($rq["name"],$rq["pass"],$rq["email"],'', false, 'n', $openid_url);
+ if (isset($rq['chosenGroup']) && $userlib->get_registrationChoice($rq['chosenGroup']) == 'y') {
+ $userlib->set_default_group($rq['name'], $rq['chosenGroup']);
+ }
+ $logslib->add_log('register','created account '.$rq["name"]);
+ $result['msg']=$smarty->fetch('mail/user_welcome_msg.tpl');
+ }
+
+ // save default user preferences
+ $tikilib->set_user_preference($rq['name'], 'theme', $prefs['style']);
+ $tikilib->set_user_preference($rq['name'], 'userbreadCrumb', $prefs['users_prefs_userbreadCrumb']);
+ $tikilib->set_user_preference($rq['name'], 'language', $prefs['users_prefs_language']);
+ $tikilib->set_user_preference($rq['name'], 'display_timezone', $prefs['users_prefs_display_timezone']);
+ $tikilib->set_user_preference($rq['name'], 'user_information', $prefs['users_prefs_user_information']);
+ $tikilib->set_user_preference($rq['name'], 'user_dbl', $prefs['users_prefs_user_dbl']);
+ $tikilib->set_user_preference($rq['name'], 'diff_versions', $prefs['users_prefs_diff_versions']);
+ $tikilib->set_user_preference($rq['name'], 'show_mouseover_user_info', $prefs['users_prefs_show_mouseover_user_info']);
+ $tikilib->set_user_preference($rq['name'], 'email is public', $prefs['users_prefs_email_is_public']);
+ $tikilib->set_user_preference($rq['name'], 'mailCharset', $prefs['users_prefs_mailCharset']);
+ $tikilib->set_user_preference($rq['name'], 'realName', '');
+ $tikilib->set_user_preference($rq['name'], 'homePage', '');
+ $tikilib->set_user_preference($rq['name'], 'lat', floatval(0));
+ $tikilib->set_user_preference($rq['name'], 'lon', floatval(0));
+ $tikilib->set_user_preference($rq['name'], 'country', '');
+ $tikilib->set_user_preference($rq['name'], 'mess_maxRecords',$prefs['users_prefs_mess_maxRecords']);
+ $tikilib->set_user_preference($rq['name'], 'mess_archiveAfter', $prefs['users_prefs_mess_archiveAfter']);
+ $tikilib->set_user_preference($rq['name'], 'mess_sendReadStatus', $prefs['users_prefs_mess_sendReadStatus']);
+ $tikilib->set_user_preference($rq['name'], 'minPrio',$prefs['users_prefs_minPrio']);
+ $tikilib->set_user_preference($rq['name'], 'allowMsgs', $prefs['users_prefs_allowMsgs']);
+ $tikilib->set_user_preference($rq['name'], 'mytiki_pages', $prefs['users_prefs_mytiki_pages']);
+ $tikilib->set_user_preference($rq['name'], 'mytiki_blogs',$prefs['users_prefs_mytiki_blogs']);
+ $tikilib->set_user_preference($rq['name'], 'mytiki_gals', $prefs['users_prefs_mytiki_gals']);
+ $tikilib->set_user_preference($rq['name'], 'mytiki_msgs', $prefs['users_prefs_mytiki_msgs']);
+ $tikilib->set_user_preference($rq['name'], 'mytiki_tasks', $prefs['users_prefs_mytiki_tasks']);
+ $tikilib->set_user_preference($rq['name'], 'mytiki_items', $prefs['users_prefs_mytiki_items']);
+ $tikilib->set_user_preference($rq['name'], 'mytiki_workflow', $prefs['users_prefs_mytiki_workflow']);
+ $tikilib->set_user_preference($rq['name'], 'tasks_maxRecords', $prefs['users_prefs_tasks_maxRecords']);
+
+ // Custom fields
+ foreach ($rd['customfields'] as $custpref=>$prefvalue ) {
+ if (isset($rq['customfields'][$rd['customfields'][$custpref]['prefName']]))
+ $tikilib->set_user_preference($rq["name"], $rd['customfields'][$custpref]['prefName'], $rq['customfields'][$rd['customfields'][$custpref]['prefName']]);
+ }
+
+ $emails = $notificationlib->get_mail_events('user_registers','*');
+ if (count($emails)) {
+ include_once("lib/notifications/notificationemaillib.php");
+ $smarty->assign('mail_user',$rq["name"]);
+ $smarty->assign('mail_date',$tikilib->now);
+ $smarty->assign('mail_site',$_SERVER["SERVER_NAME"]);
+ sendEmailNotification($emails, "email", "new_user_notification_subject.tpl", null, "new_user_notification.tpl");
+ }
+
+
+ return $result;
+ }
+
}
global $dbTiki;
Modified: users/niclone/branches/intertiki-register/templates/tiki-register.tpl
===================================================================
--- users/niclone/branches/intertiki-register/templates/tiki-register.tpl 2008-04-25 06:56:24 UTC (rev 12681)
+++ users/niclone/branches/intertiki-register/templates/tiki-register.tpl 2008-04-25 09:57:06 UTC (rev 12682)
@@ -4,7 +4,7 @@
<script src="lib/registration/register_ajax.js" type="text/javascript"></script>
{/if}
-{if $showmsg eq 'y'}
+{if $msg}
{$msg}
{elseif $userTrackerData}
@@ -29,19 +29,19 @@
<table class="normal">
- <tr><td class="formcolor">{if $prefs.login_is_email eq 'y'}{tr}Email{/tr}{else}{tr}Username{/tr}{/if}:</td>
+ <tr><td class="formcolor">{if $rd.login_is_email eq 'y'}{tr}Email{/tr}{else}{tr}Username{/tr}{/if}:</td>
<td class="formcolor">
<input style="float:left" type="text" name="name" id="name"
{if $prefs.feature_ajax eq 'y'}onKeyUp="return check_name()"{/if}/>
{if $prefs.feature_ajax eq'y'}<div id="checkfield" style="float:left"></div>{/if}
- {if $prefs.login_is_email eq 'y'}
+ {if $rd.login_is_email eq 'y'}
({tr}Use your email as login{/tr})
{else}
- {if $prefs.lowercase_username eq 'y'}({tr}lowercase only{/tr}){/if}</td>
+ {if $rd.lowercase_username eq 'y'}({tr}lowercase only{/tr}){/if}</td>
{/if}
</tr>
- {if $prefs.useRegisterPasscode eq 'y'}
+ {if $rd.useRegisterPasscode eq 'y'}
<tr><td class="formcolor">{tr}Passcode to register (not your user password){/tr}:</td>
<td class="formcolor"><input type="password" name="passcode" /></td></tr>
{/if}
@@ -49,8 +49,8 @@
<tr><td class="formcolor">{tr}Password{/tr}:</td>
<td class="formcolor"><input id='pass1' type="password" name="pass"
{if $prefs.feature_ajax eq 'y'}onKeyUp="check_pass()"{/if}/>
- {if $prefs.feature_ajax ne 'y' and $prefs.min_pass_length > 1}<br /><i>{$prefs.min_pass_length} {tr}characters long{/tr}</i>{/if}
- {if $prefs.feature_ajax ne 'y' and $prefs.pass_chr_num eq 'y'}<br /><i>{tr}Password must contain both letters and numbers{/tr}</i>{/if}
+ {if $prefs.feature_ajax ne 'y' and $rd.min_pass_length > 1}<br /><i>{$rd.min_pass_length} {tr}characters long{/tr}</i>{/if}
+ {if $prefs.feature_ajax ne 'y' and $rd.pass_chr_num eq 'y'}<br /><i>{tr}Password must contain both letters and numbers{/tr}</i>{/if}
</td>
</tr>
@@ -59,11 +59,11 @@
{if $prefs.feature_ajax eq'y'}onKeyUp="check_pass()"{/if}/>{if $prefs.feature_ajax eq'y'}<div style="float:left" id="checkpass"></div>{/if}</td>
</tr>
-{if $prefs.login_is_email ne 'y'}
+{if $rd.login_is_email ne 'y'}
<tr><td class="formcolor">{tr}Email{/tr}:</td>
<td class="formcolor"><input style="float:left" type="text" id="email" name="email"
- {if $prefs.validateUsers eq 'y' and $prefs.feature_ajax eq 'y'}onKeyUp="return check_mail()"{/if}/>{if $prefs.feature_ajax eq'y'}<div id="checkmail" style="float:left"></div>{/if}
- {if $prefs.validateUsers eq 'y' and $prefs.validateEmail ne 'y'}<br />
+ {if $rd.validateUsers eq 'y' and $prefs.feature_ajax eq 'y'}onKeyUp="return check_mail()"{/if}/>{if $prefs.feature_ajax eq'y'}<div id="checkmail" style="float:left"></div>{/if}
+ {if $rd.validateUsers eq 'y' and $rd.validateEmail ne 'y'}<br />
<div style="float:left">{tr}A valid email is mandatory to register{/tr}</div>{/if}</td>
</tr>
{/if}
@@ -77,9 +77,9 @@
{/section}
{* Groups *}
- {if isset($theChoiceGroup)}
- <input type="hidden" name="chosenGroup" value="{$theChoiceGroup|escape}" />
- {elseif $listgroups}
+ {if count($listgroups)==1}
+ <input type="hidden" name="chosenGroup" value="{$listgroups[0].groupName|escape}" />
+ {elseif count($listgroups)>1}
<tr><td class="formcolor">{tr}Select your group{/tr}</td><td class="formcolor">
{foreach item=gr from=$listgroups}
{if $gr.registrationChoice eq 'y'}<input type="radio" name="chosenGroup" value="{$gr.groupName|escape}">{if $gr.groupDesc}{$gr.groupDesc}{else}{$gr.groupName}{/if}</input><br />{/if}
Modified: users/niclone/branches/intertiki-register/tiki-register.php
===================================================================
--- users/niclone/branches/intertiki-register/tiki-register.php 2008-04-25 06:56:24 UTC (rev 12681)
+++ users/niclone/branches/intertiki-register/tiki-register.php 2008-04-25 09:57:06 UTC (rev 12682)
@@ -17,244 +17,81 @@
include_once('lib/registration/registrationlib.php');
include_once('lib/notifications/notificationlib.php');
-// Permission: needs p_register and not to be a slave
-if ($prefs['allowRegister'] != 'y' || ($prefs['feature_intertiki'] == 'y' && !empty($prefs['feature_intertiki_mymaster']))) {
- header("location: index.php");
- die;
+function register_error($errstr) {
+ $smarty->assign('msg',$errstr);
+ $smarty->display("error.tpl");
+ die;
}
-$smarty->assign('showmsg','n');
-// novalidation is set to yes if a user confirms his email is correct after tiki fails to validate it
-if (!isset($_REQUEST['novalidation'])) {
- if (!empty($_REQUEST['trackit']))
- $novalidation = 'yes'; // the user has already confirmed manually that SnowCheck is not working
- else
- $novalidation = '';
+if ($prefs['allowRegister'] != 'y') {
+ register_error(tra("Sorry, registration is not allowed"));
+}
+
+if (($prefs['feature_intertiki'] == 'y') && (!empty($prefs['feature_intertiki_mymaster']))) {
+ // get $rd on master
} else {
- $novalidation = $_REQUEST['novalidation'];
+ $rd=$registrationlib->get_registration_local_datas();
}
-//get custom fields
-$customfields = array();
-$customfields = $registrationlib->get_customfields();
-$smarty->assign_by_ref('customfields', $customfields);
-
-$listgroups = $userlib->get_groups(0, -1, 'groupName_asc', '', '', 'n');
-$nbChoiceGroups = 0;
-$mandatoryChoiceGroups = true;
-foreach ($listgroups['data'] as $gr) {
- if ($gr['registrationChoice'] == 'y') {
- ++$nbChoiceGroups;
- $theChoiceGroup = $gr['groupName'];
- if ($gr['groupName'] == 'Registered')
- $mandatoryChoiceGroups = false;
- }
+if (!$rd) {
+ register_error(tra("Sorry, registration is not available"));
}
-if ($nbChoiceGroups) {
- $smarty->assign('listgroups', $listgroups['data'] );
- if ($nbChoiceGroups == 1) {
- $smarty->assign_by_ref('theChoiceGroup', $theChoiceGroup);
- }
-}
-if(isset($_REQUEST['register']) && !empty($_REQUEST['name']) && (isset($_REQUEST['pass']) || isset($_SESSION['openid_url']))) {
- check_ticket('register');
- if($novalidation != 'yes' and ($_REQUEST["pass"] <> $_REQUEST["passAgain"]) and !isset($_SESSION['openid_url'])) {
- $smarty->assign('msg',tra("The passwords don't match"));
- $smarty->display("error.tpl");
- die;
- }
+function registration_setuppage($rd) {
+ global $smarty;
- if($userlib->user_exists($_REQUEST["name"])) {
- $smarty->assign('msg',tra("User already exists"));
- $smarty->display("error.tpl");
- die;
- }
-
- if($prefs['rnd_num_reg'] == 'y') {
- if (!isset($_SESSION['random_number']) || $_SESSION['random_number']!=$_REQUEST['antibotcode']) {
- $smarty->assign('msg',tra("Wrong registration code"));
- $smarty->display("error.tpl");
- die;
- }
- }
-
- // VALIDATE NAME HERE
- $n = strtolower($_REQUEST['name']);
- if($n =='admin' || $n == 'anonymous' || $n == 'registered' || $n == strtolower(tra('Anonymous')) || $n == strtolower(tra('Registered'))) {
- $smarty->assign('msg',tra("Invalid username"));
- $smarty->display("error.tpl");
- die;
- }
-
- if(strlen($_REQUEST["name"])>200) {
- $smarty->assign('msg',tra("Username is too long"));
- $smarty->display("error.tpl");
- die;
- }
-
- if(strstr($_REQUEST["name"],' ')) {
- $smarty->assign('msg',tra("Username cannot contain whitespace"));
- $smarty->display("error.tpl");
- die;
- }
+ $smarty->assign_by_ref('rd', $rd);
+ $smarty->assign('listgroups', $rd['choicegroups']);
+ $smarty->assign_by_ref('customfields', $rd['customfields']);
+}
- if($prefs['lowercase_username'] == 'y') {
- if(ereg("[[:upper:]]", $_REQUEST["name"])) {
- $smarty->assign('msg',tra("Username cannot contain uppercase letters"));
- $smarty->display("error.tpl");
- die;
- }
- }
- //FALTA DEFINIR VALORES PADRÕES PARA AS DUAS VARIÁVEIS!!!
- if(strlen($_REQUEST["name"])<$prefs['min_username_length']) {
- $smarty->assign('msg',tra("Username must be at least").' '.$prefs['min_username_length'].' '.tra("characters long"));
- $smarty->display("error.tpl");
- die;
- }
+registration_setuppage($rd);
- if(strlen($_REQUEST["name"])>$prefs['max_username_length']) {
- $smarty->assign('msg',tra("Username cannot contain more than").' '.$prefs['max_username_length'].' '.tra("characters"));
- $smarty->display("error.tpl");
- die;
- }
+if (isset($_REQUEST['register']) && !empty($_REQUEST['name']) && (isset($_REQUEST['pass']) || isset($_SESSION['openid_url']))) {
+ check_ticket('register');
- $polerr = $userlib->check_password_policy($_REQUEST["pass"]);
- if ( !isset($_SESSION['openid_url']) && (strlen($polerr)>0) ) {
- $smarty->assign('msg', $polerr);
- $smarty->display("error.tpl");
- die;
- }
-
- if (!preg_match($patterns['login'],$_REQUEST["name"])) {
- $smarty->assign('msg',tra("Invalid username"));
- $smarty->display("error.tpl");
- die;
- }
-
- // Check the mode
- if($prefs['useRegisterPasscode'] == 'y') {
- if($_REQUEST['passcode']!=$prefs['registerPasscode']) {
- $smarty->assign('msg',tra("Wrong passcode you need to know the passcode to register in this site"));
- $smarty->display("error.tpl");
- die;
- }
- }
- if ($nbChoiceGroups > 0 && $mandatoryChoiceGroups && empty($_REQUEST['chosenGroup'])) {
- $smarty->assign('msg',tra('You must choose a group'));
- $smarty->display("error.tpl");
- die;
- }
-
- 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'];
- }
+ foreach (array('name','pass','passAgain','antibotcode','passcode','chosenGroup',
+ 'email','trackit','error','customfields') as $k) {
+ if (isset($_REQUEST[$k])) $rq[$k]=$_REQUEST[$k];
}
- $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
- }
- }
- }
+ // novalidation is set to yes if a user confirms his email is correct after tiki fails to validate it
+ if (!isset($_REQUEST['novalidation'])) {
+ $rq['novalidation'] = empty($_REQUEST['trackit']) ? '' : 'yes'; // yes if the user has already confirmed manually that SnowCheck is not working
+ } else {
+ $rq['novalidation'] = $_REQUEST['novalidation'];
+ }
+
+ if (isset($_SESSION['openid_url'])) $rq['openid_url']=$_SESSION['openid_url'];
- 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()));
- $userlib->send_validation_email($_REQUEST['name'], $apass, $_REQUEST['email']);
-
- $userlib->add_user($_REQUEST["name"],$apass,$_REQUEST["email"],$_REQUEST["pass"], false, 'n', $openid_url);
- if (isset($_REQUEST['chosenGroup']) && $userlib->get_registrationChoice($_REQUEST['chosenGroup']) == 'y') {
- $userlib->set_default_group($_REQUEST['name'], $_REQUEST['chosenGroup']);
- }
- $logslib->add_log('register','created account '.$_REQUEST["name"]);
- $smarty->assign('showmsg','y');
- } else {
- $userlib->add_user($_REQUEST["name"],$_REQUEST["pass"],$_REQUEST["email"],'', false, 'n', $openid_url);
- if (isset($_REQUEST['chosenGroup']) && $userlib->get_registrationChoice($_REQUEST['chosenGroup']) == 'y') {
- $userlib->set_default_group($_REQUEST['name'], $_REQUEST['chosenGroup']);
- }
- $logslib->add_log('register','created account '.$_REQUEST["name"]);
- $smarty->assign('msg',$smarty->fetch('mail/user_welcome_msg.tpl'));
- $smarty->assign('showmsg','y');
- }
+ foreach ($rd['customfields'] as $custpref=>$prefvalue ) {
+ if (isset($_REQUEST[$rd['customfields'][$custpref]['prefName']]))
+ $rq['customfields'][$rd['customfields'][$custpref]['prefName']]=$_REQUEST[$rd['customfields'][$custpref]['prefName']];
+ }
- // save default user preferences
- $tikilib->set_user_preference($_REQUEST['name'], 'theme', $prefs['style']);
- $tikilib->set_user_preference($_REQUEST['name'], 'userbreadCrumb', $prefs['users_prefs_userbreadCrumb']);
- $tikilib->set_user_preference($_REQUEST['name'], 'language', $prefs['users_prefs_language']);
- $tikilib->set_user_preference($_REQUEST['name'], 'display_timezone', $prefs['users_prefs_display_timezone']);
- $tikilib->set_user_preference($_REQUEST['name'], 'user_information', $prefs['users_prefs_user_information']);
- $tikilib->set_user_preference($_REQUEST['name'], 'user_dbl', $prefs['users_prefs_user_dbl']);
- $tikilib->set_user_preference($_REQUEST['name'], 'diff_versions', $prefs['users_prefs_diff_versions']);
- $tikilib->set_user_preference($_REQUEST['name'], 'show_mouseover_user_info', $prefs['users_prefs_show_mouseover_user_info']);
- $tikilib->set_user_preference($_REQUEST['name'], 'email is public', $prefs['users_prefs_email_is_public']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mailCharset', $prefs['users_prefs_mailCharset']);
- $tikilib->set_user_preference($_REQUEST['name'], 'realName', '');
- $tikilib->set_user_preference($_REQUEST['name'], 'homePage', '');
- $tikilib->set_user_preference($_REQUEST['name'], 'lat', floatval(0));
- $tikilib->set_user_preference($_REQUEST['name'], 'lon', floatval(0));
- $tikilib->set_user_preference($_REQUEST['name'], 'country', '');
- $tikilib->set_user_preference($_REQUEST['name'], 'mess_maxRecords',$prefs['users_prefs_mess_maxRecords']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mess_archiveAfter', $prefs['users_prefs_mess_archiveAfter']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mess_sendReadStatus', $prefs['users_prefs_mess_sendReadStatus']);
- $tikilib->set_user_preference($_REQUEST['name'], 'minPrio',$prefs['users_prefs_minPrio']);
- $tikilib->set_user_preference($_REQUEST['name'], 'allowMsgs', $prefs['users_prefs_allowMsgs']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_pages', $prefs['users_prefs_mytiki_pages']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_blogs',$prefs['users_prefs_mytiki_blogs']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_gals', $prefs['users_prefs_mytiki_gals']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_msgs', $prefs['users_prefs_mytiki_msgs']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_tasks', $prefs['users_prefs_mytiki_tasks']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_items', $prefs['users_prefs_mytiki_items']);
- $tikilib->set_user_preference($_REQUEST['name'], 'mytiki_workflow', $prefs['users_prefs_mytiki_workflow']);
- $tikilib->set_user_preference($_REQUEST['name'], 'tasks_maxRecords', $prefs['users_prefs_tasks_maxRecords']);
-
- // Custom fields
- foreach ($customfields as $custpref=>$prefvalue ) {
-
-
- if (isset($_REQUEST[$customfields[$custpref]['prefName']]))
- $tikilib->set_user_preference($_REQUEST["name"], $customfields[$custpref]['prefName'], $_REQUEST[$customfields[$custpref]['prefName']]);
- }
-
- $emails = $notificationlib->get_mail_events('user_registers','*');
- if (count($emails)) {
- include_once("lib/notifications/notificationemaillib.php");
- $smarty->assign('mail_user',$_REQUEST["name"]);
- $smarty->assign('mail_date',$tikilib->now);
- $smarty->assign('mail_site',$_SERVER["SERVER_NAME"]);
- sendEmailNotification($emails, "email", "new_user_notification_subject.tpl", null, "new_user_notification.tpl");
- }
-
+ $result=$registrationlib->register($rq, $rd);
+ if (count($result['error'])) {
+ $msg=''; foreach($result['error'] as $errstr) $msg.=$errstr."<br>";
+ $smarty->assign('msg', $msg);
+ } else {
+ $email_valid=$result['email_valid'];
+ if (isset($result['userTrackerData'])) $smarty->assign('userTrackerData', $result['userTrackerData']);
+ $smarty->assign('msg', $result['msg']);
}
}
+
+
$smarty->assign('email_valid',$email_valid);
ask_ticket('register');
$_VALID = tra("Please enter a valid %s. No spaces, more than %d characters and contain %s");
-$smarty->assign('_PROMPT_UNAME', sprintf($_VALID, tra("username"), $prefs['min_user_length'], "0-9,a-z,A-Z") );
-$smarty->assign('_PROMPT_PASS', sprintf($_VALID, tra("password"), $prefs['min_pass_length'], "0-9,a-z,A-Z") );
-$smarty->assign('min_user_length', $prefs['min_user_length']);
-$smarty->assign('min_pass_length', $prefs['min_pass_length']);
+$smarty->assign('_PROMPT_UNAME', sprintf($_VALID, tra("username"), $rd['min_user_length'], "0-9,a-z,A-Z") );
+$smarty->assign('_PROMPT_PASS', sprintf($_VALID, tra("password"), $rd['min_pass_length'], "0-9,a-z,A-Z") );
+$smarty->assign('min_user_length', $rd['min_user_length']);
+$smarty->assign('min_pass_length', $rd['min_pass_length']);
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|