From 6aa6fd68b47d90b878f5ebf91318d3362e13dcd4 Mon Sep 17 00:00:00 2001 From: e107steved Date: Fri, 12 Jun 2009 20:41:35 +0000 Subject: [PATCH] Various bug fixes, bug creations, tweaks and changes --- e107_admin/prefs.php | 15 ++-- e107_admin/users.php | 43 ++++++------ e107_handlers/user_handler.php | 58 +++++++++++++++- e107_handlers/validator_class.php | 6 +- e107_languages/English/lan_signup.php | 7 +- e107_plugins/alt_auth/alt_auth_adminmenu.php | 18 ----- e107_plugins/alt_auth/alt_auth_conf.php | 16 ++--- .../alt_auth/alt_auth_login_class.php | 69 ++++++++++++------- signup.php | 60 ++++++++-------- usersettings.php | 12 ++-- 10 files changed, 179 insertions(+), 125 deletions(-) diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index fa2aea8d1..560a3c63b 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -9,9 +9,9 @@ * Administration - Site Preferences * * $Source: /cvs_backup/e107_0.8/e107_admin/prefs.php,v $ - * $Revision: 1.29 $ - * $Date: 2009-03-06 20:09:08 $ - * $Author: e107coders $ + * $Revision: 1.30 $ + * $Date: 2009-06-12 20:41:34 $ + * $Author: e107steved $ * */ require_once ("../class2.php"); @@ -134,7 +134,7 @@ if(isset($_POST['updateprefs'])) } } -if($e107->sql->db_Select("plugin", "plugin_path", "plugin_installflag='1' AND plugin_path='alt_auth'")) +if (plugInstalled('alt_auth')) { $authlist[] = "e107"; $handle = opendir(e_PLUGIN."alt_auth"); @@ -1071,13 +1071,12 @@ $text .= " $auth_dropdown = ''; if($authlist) { - $auth_dropdown = $frm->select_open('auth_method'); + $auth_dropdown = "\n".$frm->select_open('auth_method')."\n"; foreach($authlist as $a) { - $s = ($pref['auth_method'] == $a ? " selected='selected' " : ""); - $auth_dropdown .= $frm->option($a, $s, ($pref['auth_method'] == $a)); + $auth_dropdown .= $frm->option($a, $a, ($pref['auth_method'] == $a))."\n"; } - $auth_dropdown .= ""; + $auth_dropdown .= "\n"; } else { diff --git a/e107_admin/users.php b/e107_admin/users.php index 511b27586..8953639f8 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -9,9 +9,9 @@ * Administration Area - Users * * $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $ -* $Revision: 1.33 $ -* $Date: 2009-04-27 10:42:14 $ -* $Author: secretr $ +* $Revision: 1.34 $ +* $Date: 2009-06-12 20:41:34 $ +* $Author: e107steved $ * */ require_once('../class2.php'); @@ -278,13 +278,10 @@ if (isset($_POST['adduser'])) { // Save separate password encryption for use with email address $user_data['user_prefs'] = serialize(array('email_password' => $userMethods->HashPassword($savePassword, $user_data['user_email']))); } - if (varsettrue($pref['user_new_period'])) - { - $user_data['user_class'] = user_class::ucAdd(e_UC_NEWUSER, $user_data['user_class']); // Probationary user class - } + $userMethods->userClassUpdate($allData['data'], 'userall'); // Set any initial classes $userMethods->addNonDefaulted($user_data); validatorClass::addFieldTypes($userMethods->userVettingInfo,$allData); - //FIXME - (SecretR) there is a better way to fix this (missing default value, sql error in strict mod) + //FIXME - (SecretR) there is a better way to fix this (missing default value, sql error in strict mode - user_realm is to be deleted from DB later) $allData['data']['user_realm'] = ''; if ($sql -> db_Insert('user', $allData)) { @@ -292,6 +289,7 @@ if (isset($_POST['adduser'])) $admin_log->log_event('USET_02',"UName: {$user_data['user_name']}; Email: {$user_data['user_email']}",E_LOG_INFORMATIVE); // Add to user audit trail $admin_log->user_audit(USER_AUDIT_ADD_ADMIN,$user_data, 0,$user_data['user_loginname']); + $e_event->trigger('userfull', $user_data); // send everything available for user data - bit sparse compared with user-generated signup if (isset($_POST['sendconfemail'])) { // Send confirmation email to user require_once(e_HANDLER.'mail.php'); @@ -440,10 +438,12 @@ if (isset($_POST['useraction']) && $_POST['useraction'] == 'deluser') { if ($_POST['confirm']) { - if ($sql->db_Delete("user", "user_id='".$_POST['userid']."' AND user_perms != '0' AND user_perms != '0.'")) + $uid = intval($_POST['userid']); + if ($sql->db_Delete("user", "user_id=".$uid." AND user_perms != '0' AND user_perms != '0.'")) { - $sql->db_Delete("user_extended", "user_extended_id='".$_POST['userid']."' "); - $admin_log->log_event('USET_07',str_replace('--UID--',$_POST['userid'],USRLAN_163),E_LOG_INFORMATIVE); + $sql->db_Delete("user_extended", "user_extended_id='".$uid."' "); + $admin_log->log_event('USET_07',str_replace('--UID--',$uid,USRLAN_163),E_LOG_INFORMATIVE); + $e_event->trigger('userdelete', $temp = array('user_id' => $uid)); $user->show_message(USRLAN_10); } if(!$sub_action){ $sub_action = "user_id"; } @@ -525,20 +525,19 @@ if (isset($_POST['useraction']) && $_POST['useraction'] == "verify") { if ($row = $sql->db_Fetch()) { - // Add in the initial classes, if this is the time - $init_classes = ''; - if ($pref['init_class_stage'] == '2') + $dbData = array(); + $dbData['WHERE'] = "user_id=".$uid; + $dbData['data'] = array('user_ban'=>'0', 'user_sess'=>''); + // Add in the initial classes as necessary + if ($userMethods->userClassUpdate($row, 'userall')) { - $init_classes = explode(',',varset($pref['initial_user_classes'],'')); - if ($init_classes) - { // Update the user classes - $row['user_class'] = $tp->toDB(implode(',',array_unique(array_merge($init_classes, explode(',',$row['user_class']))))); - $init_classes = ", user_class='".$row['user_class']."' "; - } + $dbData['data']['user_class'] = $row['user_class']; } - $sql->db_Update("user", "user_ban='0'{$init_classes} WHERE user_id='".$uid."' "); + $userMethods->addNonDefaulted($dbData); + validatorClass::addFieldTypes($userMethods->userVettingInfo,$dbData); + $sql->db_Update('user',$dbData); $admin_log->log_event('USET_10',str_replace(array('--UID--','--NAME--'),array($row['user_id'],$row['user_name']),USRLAN_166),E_LOG_INFORMATIVE); - // $e_event->trigger("userveri", $row); // We do this from signup.php - should we do it here? + $e_event->trigger('userfull', $row); // 'New' event $user->show_message(USRLAN_86); if(!$action){ $action = "main"; } diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index bfde2c227..a220aa61a 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -9,8 +9,8 @@ * Handler - user-related functions * * $Source: /cvs_backup/e107_0.8/e107_handlers/user_handler.php,v $ - * $Revision: 1.9 $ - * $Date: 2009-04-23 19:58:28 $ + * $Revision: 1.10 $ + * $Date: 2009-06-12 20:41:34 $ * $Author: e107steved $ * */ @@ -525,7 +525,8 @@ Following fields auto-filled in code as required: // Returns TRUE if additions made, FALSE if no change. function addNonDefaulted(&$userInfo) { - $nonDefaulted = array('user_signature' => '', 'user_prefs' => '', 'user_class' => '', 'user_perms' => ''); +// $nonDefaulted = array('user_signature' => '', 'user_prefs' => '', 'user_class' => '', 'user_perms' => ''); + $nonDefaulted = array('user_signature' => '', 'user_prefs' => '', 'user_class' => '', 'user_perms' => '', 'user_realm' => ''); // Delete when McFly finished $ret = FALSE; foreach ($nonDefaulted as $k => $v) { @@ -557,7 +558,58 @@ Following fields auto-filled in code as required: return $temp1; } + + // Called to update initial user classes, probationary user class etc + function userClassUpdate(&$user, $event='userveri') + { + global $pref, $tp; + + $initClasses = array(); + $doClasses = FALSE; + $doProbation = FALSE; + $ret = FALSE; + switch ($event) + { + case 'userall' : + $doClasses = TRUE; + $doProbation = TRUE; + break; + case 'userfull' : // A 'fully fledged' user + if (!$pref['user_reg_veri'] || ($pref['init_class_stage'] == '2')) + { + $doClasses = TRUE; + } + $doProbation = TRUE; + break; + case 'userpartial' : + if ($pref['init_class_stage'] == '1') + { // Set initial classes if to be done on partial signup, or if selected to add them now + $doClasses = TRUE; + } + $doProbation = TRUE; + break; + } + if ($doClasses) + { + if (isset($pref['initial_user_classes'])) { $initClasses = explode(',',$pref['initial_user_classes']); } // Any initial user classes to be set at some stage + if ($doProbation && (varset($pref['user_new_period'], 0) > 0)) + { + $initClasses[] = e_UC_NEWUSER; // Probationary user class + } + if (count($initClasses)) + { // Update the user classes + if ($user['user_class']) + { + $initClasses = array_unique(array_merge($initClasses, explode(',',$user['user_class']))); + } + $user['user_class'] = $tp->toDB(implode(',',$initClasses)); + $ret = TRUE; + } + } + + } } + ?> \ No newline at end of file diff --git a/e107_handlers/validator_class.php b/e107_handlers/validator_class.php index 1ff6e4f59..5fe7fb952 100644 --- a/e107_handlers/validator_class.php +++ b/e107_handlers/validator_class.php @@ -9,8 +9,8 @@ * Handler - general purpose validation functions * * $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $ - * $Revision: 1.6 $ - * $Date: 2009-01-11 22:11:19 $ + * $Revision: 1.7 $ + * $Date: 2009-06-12 20:41:34 $ * $Author: e107steved $ * */ @@ -422,7 +422,7 @@ class validatorClass $ret = array(); foreach ($input as $k => $v) { - if (isset($refs[$k])) + if (array_key_exists($k, $refs)) { if ($refs[$k] != $v) { $ret[$k] = $v; } } diff --git a/e107_languages/English/lan_signup.php b/e107_languages/English/lan_signup.php index 627e31a1c..3cadf9792 100644 --- a/e107_languages/English/lan_signup.php +++ b/e107_languages/English/lan_signup.php @@ -9,9 +9,9 @@ * Language file - User signup * * $Source: /cvs_backup/e107_0.8/e107_languages/English/lan_signup.php,v $ - * $Revision: 1.17 $ - * $Date: 2009-03-22 21:07:33 $ - * $Author: e107coders $ + * $Revision: 1.18 $ + * $Date: 2009-06-12 20:41:34 $ + * $Author: e107steved $ * */ define("PAGE_NAME", "Register"); @@ -139,6 +139,7 @@ define('LAN_SIGNUP_97', 'Welcome to'); // LAN_403 (used in email) define("LAN_SIGNUP_98", "Confirm Your Email Address"); define("LAN_SIGNUP_99", "Problem Encountered"); define("LAN_SIGNUP_100", "Admin Approval Pending"); +define('LAN_SIGNUP_101', 'Update of records failed - please contact the site administrator'); define("LAN_LOGINNAME", "Username"); diff --git a/e107_plugins/alt_auth/alt_auth_adminmenu.php b/e107_plugins/alt_auth/alt_auth_adminmenu.php index d1536b1bd..83bc7af7f 100755 --- a/e107_plugins/alt_auth/alt_auth_adminmenu.php +++ b/e107_plugins/alt_auth/alt_auth_adminmenu.php @@ -40,24 +40,6 @@ function alt_auth_get_authlist() } -/* -// All user fields which might, just possibly, be transferred. The option name must be the corresponding field in the E107 user database, prefixed with 'xf_' -$alt_auth_user_fields = array( - 'user_email' => array('prompt' => LAN_ALT_12, 'optname' => 'xf_user_email', 'default' => 'user_email', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'mail'), - 'user_hideemail' => array('prompt' => LAN_ALT_13, 'optname' => 'xf_user_hideemail', 'default' => 'user_hideemail', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => '', method => 'bool1'), - 'user_name' => array('prompt' => LAN_ALT_14, 'optname' => 'xf_user_name', 'default' => 'user_name', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''), - 'user_login' => array('prompt' => LAN_ALT_15, 'optname' => 'xf_user_login', 'default' => 'user_login', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'sn'), - 'user_customtitle'=> array('prompt' => LAN_ALT_16, 'optname' => 'xf_user_customtitle', 'default' => 'user_customtitle', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE), - 'user_signature' => array('prompt' => LAN_ALT_17, 'optname' => 'xf_user_signature', 'default' => 'user_signature', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE), - 'user_image' => array('prompt' => LAN_ALT_18, 'optname' => 'xf_user_image', 'default' => 'user_image', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE), - 'user_sess' => array('prompt' => LAN_ALT_19, 'optname' => 'xf_user_sess', 'default' => 'user_sess', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE), - 'user_join' => array('prompt' => LAN_ALT_20, 'optname' => 'xf_user_join', 'default' => 'user_join', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''), - 'user_ban' => array('prompt' => LAN_ALT_21, 'optname' => 'xf_user_ban', 'default' => 'user_ban', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE), - 'user_class' => array('prompt' => LAN_ALT_22, 'optname' => 'xf_user_class', 'default' => 'user_class', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE), - 'user_xup' => array('prompt' => LAN_ALT_23, 'optname' => 'xf_user_xup', 'default' => 'user_xup', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE) -); - -*/ // All user fields which might, just possibly, be transferred. The array key is the corresponding field in the E107 user database; code prefixes it with 'xf_' to get the parameter // 'default' may be a single value to set the same for all connect methods, or an array to set different defaults. $alt_auth_user_fields = array( diff --git a/e107_plugins/alt_auth/alt_auth_conf.php b/e107_plugins/alt_auth/alt_auth_conf.php index 855a566a0..87e94158f 100755 --- a/e107_plugins/alt_auth/alt_auth_conf.php +++ b/e107_plugins/alt_auth/alt_auth_conf.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/alt_auth_conf.php,v $ -| $Revision: 1.3 $ -| $Date: 2008-12-23 20:31:30 $ +| $Revision: 1.4 $ +| $Date: 2009-06-12 20:41:34 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -142,10 +142,13 @@ $text .= " $ns -> tablerender("
".LAN_ALT_3."
", $text); -$extendedFields = $euf->user_extended_get_fields(); +//$extendedFields = $euf->user_extended_get_fields(); +//$extendedFields = &$euf->fieldDefinitions; //print_a($extendedFields); -if (count($extendedFields)) +if (count($euf->fieldDefinitions)) { + include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user_extended.php'); + $fl = &$euf->fieldDefinitions; $text = "
@@ -156,8 +159,6 @@ if (count($extendedFields)) \n"; - foreach ($extendedFields as $p => $fl ) - { $text .= " @@ -170,10 +171,9 @@ if (count($extendedFields)) $text .= " - + \n"; } - } $text .= "
".LAN_ALT_61." ".LAN_ALT_62."
{$f['user_extended_struct_name']}{$f['user_extended_struct_text']}".$tp->toHTML($f['user_extended_struct_text'],FALSE,'TITLE')." {$euf->user_extended_types[$f['user_extended_struct_type']]}
diff --git a/e107_plugins/alt_auth/alt_auth_login_class.php b/e107_plugins/alt_auth/alt_auth_login_class.php index b5bd09648..d35a75135 100755 --- a/e107_plugins/alt_auth/alt_auth_login_class.php +++ b/e107_plugins/alt_auth/alt_auth_login_class.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/alt_auth_login_class.php,v $ -| $Revision: 1.6 $ -| $Date: 2008-12-23 20:31:30 $ +| $Revision: 1.7 $ +| $Date: 2009-06-12 20:41:34 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -25,11 +25,11 @@ class alt_login { global $pref, $admin_log; $newvals=array(); - define("AUTH_SUCCESS", -1); - define("AUTH_NOUSER", 1); - define("AUTH_BADPASSWORD", 2); - define("AUTH_NOCONNECT", 3); - require_once(e_PLUGIN."alt_auth/".$method."_auth.php"); + define('AUTH_SUCCESS', -1); + define('AUTH_NOUSER', 1); + define('AUTH_BADPASSWORD', 2); + define('AUTH_NOCONNECT', 3); + require_once(e_PLUGIN.'alt_auth/'.$method.'_auth.php'); $_login = new auth_login; if(isset($_login->Available) && ($_login->Available === FALSE)) @@ -41,6 +41,9 @@ class alt_login if($login_result === AUTH_SUCCESS ) { + require_once (e_HANDLER.'user_handler.php'); + require_once(e_HANDLER.'validator_class.php'); + if (MAGIC_QUOTES_GPC == FALSE) { $username = mysql_real_escape_string($username); @@ -49,8 +52,8 @@ class alt_login $username = substr($username, 0, varset($pref['loginname_maxlength'],30)); $aa_sql = new db; - $uh = new UserHandler; - $db_vals = array('user_password' => $aa_sql->escape($uh->HashPassword($userpass,$username))); + $userMethods = new UserHandler; + $db_vals = array('user_password' => $aa_sql->escape($userMethods->HashPassword($userpass,$username))); $xFields = array(); // Possible extended user fields // See if any of the fields need processing before save @@ -79,7 +82,9 @@ class alt_login } } if (count($xFields)) - { + { // We're going to have to do something with extended fields as well - make sure there's an object + require_once (e_HANDLER.'user_extended_class.php'); + $ue = new e107_user_extended; $qry = "SELECT u.user_id,u.".implode(',u.',array_keys($db_vals)).", ue.user_extended_id, ue.".implode(',ue.',array_keys($xFields))." FROM `#user` AS u LEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = u.user_id WHERE u.user_loginname='{$username}' "; @@ -98,27 +103,36 @@ class alt_login } if (count($db_vals)) { - $aa_sql->db_UpdateArray('user',$db_vals," WHERE `user_id`=".$row['user_id']); + $newUser = array(); + $newUser['data'] = $db_vals; + validatorClass::addFieldTypes($userMethods->userVettingInfo,$allData); + $newUser['WHERE'] = '`user_id`='.$row['user_id']; + $aa_sql->db_Update('user',$db_vals); if (AA_DEBUG1) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User data update: ".print_r($db_vals,TRUE),FALSE,LOG_TO_ROLLING); } foreach ($xFields as $k => $v) { if ($row[$k] == $v) unset($xFields[$k]); } - if (AA_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User data read: ".print_r($row,TRUE)."[!br!]".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING); - if (AA_DEBUG1) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User xtnd read: ".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING); + if (AA_DEBUG1) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User data read: ".print_r($row,TRUE)."[!br!]".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING); + if (AA_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User xtnd read: ".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING); if (count($xFields)) { + $xArray = array(); + $xArray['data'] = $xFields; if ($row['user_extended_id']) { - if (AA_DEBUG1) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User xtnd update: ".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING); - $aa_sql->db_UpdateArray('user_extended',$xFields," WHERE `user_extended_id`=".intval($row['user_id'])); + $ue->addFieldTypes($xArray); // Add in the data types for storage + $xArray['WHERE'] = '`user_extended_id`='.intval($row['user_id']); + if (AA_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User xtnd update: ".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING); + $aa_sql->db_Update('user_extended',$xArray ); } else { // Never been an extended user fields record for this user - $xFields['user_extended_id'] = $row['user_id']; + $xArray['data']['user_extended_id'] = $row['user_id']; + $ue->addDefaultFields($xArray); // Add in the data types for storage, plus any default values if (AA_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","Write new extended record".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING); - $aa_sql->db_Insert('user_extended',$xFields); + $aa_sql->db_Insert('user_extended',$xArray); } } } @@ -132,11 +146,20 @@ class alt_login if (!isset($db_vals['user_signature'])) $db_vals['user_signature'] = ''; if (!isset($db_vals['user_prefs'])) $db_vals['user_prefs'] = ''; if (!isset($db_vals['user_perms'])) $db_vals['user_perms'] = ''; - $newID = $aa_sql->db_Insert('user',$db_vals); - if (($newID !== FALSE) && count($xfields)) + $userMethods->userClassUpdate($db_vals, 'userall'); + $newUser = array(); + $newUser['data'] = $db_vals; + $userMethods->addNonDefaulted($newUser); + validatorClass::addFieldTypes($userMethods->userVettingInfo,$newUser); + $newID = $aa_sql->db_Insert('user',$newUser); + if (($newID !== FALSE) && count($xFields)) { $xFields['user_extended_id'] = $newID; - $aa_sql->db_Insert('user_extended',$xFields); + $xArray = array(); + $xArray['data'] = $xFields; + $ue->addDefaultFields($xArray); // Add in the data types for storage, plus any default values + $result = $aa_sql->db_Insert('user_extended',$xArray); + if (AA_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","Add extended: UID={$newID} result={$result}",FALSE,LOG_TO_ROLLING); } } return LOGIN_CONTINUE; @@ -148,19 +171,19 @@ class alt_login case AUTH_NOUSER: if(!varset($pref['auth_nouser'],0)) { - $username=md5("xx_nouser_xx"); + $username=md5('xx_nouser_xx'); return LOGIN_ABORT; } break; case AUTH_NOCONNECT: if(!varset($pref['auth_noconn'])) { - $username=md5("xx_noconn_xx"); + $username=md5('xx_noconn_xx'); return LOGIN_ABORT; } break; case AUTH_BADPASSWORD: - $userpass=md5("xx_badpassword_xx"); + $userpass=md5('xx_badpassword_xx'); return LOGIN_ABORT; // Not going to magically be able to log in! break; } diff --git a/signup.php b/signup.php index e1a180549..d6f071c2a 100644 --- a/signup.php +++ b/signup.php @@ -9,8 +9,8 @@ * User signup * * $Source: /cvs_backup/e107_0.8/signup.php,v $ - * $Revision: 1.35 $ - * $Date: 2009-04-23 19:13:18 $ + * $Revision: 1.36 $ + * $Date: 2009-06-12 20:41:35 $ * $Author: e107steved $ * */ @@ -310,23 +310,32 @@ if (e_QUERY) { if ($row = $sql->db_Fetch()) { + $dbData = array(); + $dbData['WHERE'] = " user_sess='".$tp -> toDB($qs[2], true)."' "; + $dbData['data'] = array('user_ban'=>'0', 'user_sess'=>''); // Set initial classes, and any which the user can opt to join - $init_classes = ''; - if ($pref['init_class_stage'] == '2') + if ($userMethods->userClassUpdate($row, 'userveri')) { - $init_classes = explode(',',varset($pref['initial_user_classes'],'')); - if ($init_classes) - { // Update the user classes - $row['user_class'] = $tp->toDB(implode(',',array_unique(array_merge($init_classes, explode(',',$row['user_class']))))); - $init_classes = ", user_class='".$row['user_class']."' "; - } + $dbData['data']['user_class'] = $row['user_class']; } - $sql->db_Update("user", "user_ban='0', user_sess=''{$init_classes} WHERE user_sess='".$tp -> toDB($qs[2], true)."' "); + $userMethods->addNonDefaulted($dbData); + validatorClass::addFieldTypes($userMethods->userVettingInfo,$dbData); + $newID = $sql->db_Update('user',$dbData); + if ($newID === FALSE) + { + $admin_log->e_log_event(10,debug_backtrace(),'USER','Verification Fail',print_r($row,TRUE),FALSE,LOG_TO_ROLLING); + require_once(HEADERF); + $ns->tablerender(LAN_SIGNUP_75, LAN_SIGNUP_101); + require_once(FOOTERF); + exit; + } + // Log to user audit log if enabled $admin_log->user_audit(USER_AUDIT_EMAILACK,$row); - - $e_event->trigger("userveri", $row); + + $e_event->trigger('userveri', $row); // Legacy event + $e_event->trigger('userfull', $row); // 'New' event if (varset($pref['autologinpostsignup'])) { require_once(e_HANDLER.'login.php'); @@ -539,24 +548,7 @@ if (isset($_POST['register'])) $u_key = md5(uniqid(rand(), 1)); // Key for signup completion $allData['data']['user_sess'] = $u_key; // Validation key - // Work out all user classes - $intClasses = array(); - if (isset($pref['initial_user_classes'])) { $initClasses = explode(',',$pref['initial_user_classes']); } // Any initial user classes to be set at some stage - $classList = array(); - if (isset($allData['data']['user_class'])) { $classList = explode(',',$allData['data']['user_class']); } // Classes entered by user during signup - if (varsettrue($pref['user_new_period'])) - { - $classList[] = e_UC_NEWUSER; // Probationary user class - } - if (!$pref['user_reg_veri'] || ($pref['init_class_stage'] == '1')) - { // Set initial classes if no verification required, or if selected to add them now - $classList = array_merge($classList, $initClasses); - } - $classList = array_unique($classList); - if (count($classList)) - { - $allData['data']['user_class'] = implode(',',$classList); - } + $userMethods->userClassUpdate($allData['data'], 'usersup'); if ($pref['user_reg_veri']) { @@ -633,7 +625,8 @@ if (isset($_POST['register'])) $error_message = LAN_SIGNUP_42; // There was a problem, the registration mail was not sent, please contact the website administrator. } } - $e_event->trigger("usersup", $_POST); // send everything in the template, including extended fields. + $e_event->trigger('usersup', $_POST); // Old trigger - send everything in the template, including extended fields. + $e_event->trigger('userpartial', array_merge($allData['data'],$eufVals['data'])); // New trigger - send everything in the template, including extended fields. require_once(HEADERF); @@ -654,7 +647,8 @@ if (isset($_POST['register'])) exit; } - $e_event->trigger("usersup", $_POST); // send everything in the template, including extended fields. + $e_event->trigger('usersup', $_POST); // send everything in the template, including extended fields. + $e_event->trigger('userfull', array_merge($allData['data'],$eufVals['data'])); // New trigger - send everything in the template, including extended fields. if (isset($pref['signup_text_after']) && (strlen($pref['signup_text_after']) > 2)) { diff --git a/usersettings.php b/usersettings.php index f94d34130..97c6d76db 100644 --- a/usersettings.php +++ b/usersettings.php @@ -9,8 +9,8 @@ * User settings modify * * $Source: /cvs_backup/e107_0.8/usersettings.php,v $ - * $Revision: 1.34 $ - * $Date: 2009-02-22 14:21:08 $ + * $Revision: 1.35 $ + * $Date: 2009-06-12 20:41:35 $ * $Author: e107steved $ * */ @@ -226,6 +226,7 @@ if (isset($_POST['updatesettings'])) $changedEUFData['data'] = validatorClass::findChanges($eufVals['data'], $udata,FALSE); } + // Determine whether we have an error $error = ((isset($allData['errors']) && count($allData['errors'])) || (isset($eufVals['errors']) && count($eufVals['errors'])) || count($extraErrors)); @@ -335,6 +336,7 @@ unset($_POST['SaveValidatedInfo']); // At this point we know the error status. // $changedUserData has an array of core changed data, except password, which is in $savePassword if changed (or entered as confirmation). // $eufData has extended user field data +// $changedEUFData has any changes in extended user field data $dataToSave = !$error && (isset($changedUserData) && count($changedUserData)) || (isset($changedEUFData['data']) && count($changedEUFData['data'])) || $savePassword; if ($dataToSave) @@ -396,6 +398,8 @@ if ($dataToSave && !$promptPassword) } } + print_a($changedEUFData); + // Save extended field values if (isset($changedEUFData['data']) && count($changedEUFData['data'])) { @@ -551,9 +555,9 @@ if ($error) { $temp[] = validatorClass::makeErrorList($allData,'USER_ERR_','%n - %x - %t: %v', '
', $userMethods->userVettingInfo); } - if (varsettrue($eufData['errors'])) + if (varsettrue($eufVals['errors'])) { - $temp[] = '
'.validatorClass::makeErrorList($eufData,'USER_ERR_','%n - %x - %t: %v', '
', $userMethods->userVettingInfo); + $temp[] = '
'.validatorClass::makeErrorList($eufVals,'USER_ERR_','%n - %x - %t: %v', '
', NULL); } message_handler('P_ALERT', implode('
', $temp)); // $adref = $_POST['adminreturn'];