1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-29 10:38:08 +01:00

Modify user-related stuff to use new db_Update() structure - hopefully nothing broken

This commit is contained in:
e107steved 2009-01-11 21:06:52 +00:00
parent 4035c47288
commit 540146be8f
7 changed files with 234 additions and 147 deletions

View File

@ -9,9 +9,9 @@
* Administration Area - Users
*
* $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $
* $Revision: 1.25 $
* $Date: 2009-01-11 04:13:01 $
* $Author: mcfly_e107 $
* $Revision: 1.26 $
* $Date: 2009-01-11 21:06:46 $
* $Author: e107steved $
*
*/
require_once('../class2.php');
@ -229,14 +229,14 @@ if (isset($_POST['adduser']))
$userMethods->userValidation($allData); // Do user-specific DB checks
if (!isset($allData['errors']['user_password']))
{ // No errors in password - keep it outside the main data array
$savePassword = $allData['validate']['user_password'];
unset($allData['validate']['user_password']); // Delete the password value in the output array
$savePassword = $allData['data']['user_password'];
unset($allData['data']['user_password']); // Delete the password value in the output array
}
unset($_POST['password1']); // Restrict the scope of this
unset($_POST['password2']);
if (!check_class($pref['displayname_class'], $allData['validate']['user_class']))
if (!check_class($pref['displayname_class'], $allData['data']['user_class']))
{
if ($allData['validate']['user_name'] != $allData['validate']['user_loginname'])
if ($allData['data']['user_name'] != $allData['data']['user_loginname'])
{
$allData['errors']['user_name'] = ERR_FIELDS_DIFFERENT;
}
@ -251,7 +251,7 @@ if (isset($_POST['adduser']))
}
// Always save some of the entered data - then we can redisplay on error
$user_data = $allData['validate'];
$user_data = &$allData['data'];
if (!$error)
{
@ -267,7 +267,8 @@ if (isset($_POST['adduser']))
$user_data['user_class'] = user_class::ucAdd(e_UC_NEWUSER, $user_data['user_class']); // Probationary user class
}
$userMethods->addNonDefaulted($user_data);
if (admin_update($sql -> db_Insert("user", $user_data), 'insert', USRLAN_70))
validatorClass::addFieldTypes($userMethods->userVettingInfo,$allData);
if ($sql -> db_Insert('user', $allData))
{
// Add to admin log
$admin_log->log_event('USET_02',"UName: {$user_data['user_name']}; Email: {$user_data['user_email']}",E_LOG_INFORMATIVE);

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/user_extended_class.php,v $
| $Revision: 1.21 $
| $Date: 2008-12-28 22:37:43 $
| $Revision: 1.22 $
| $Date: 2009-01-11 21:06:46 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@ -20,17 +20,15 @@
if (!defined('e107_INIT')) { exit; }
/*
User_extended rewrite for version 0.7
this code uses two tables,
user_extended
user_extended_struct
to store its data and structural information.
Code uses two tables:
user_extended_struct - individual field definitions, one record per field
user_extended - actual field data, one record per user
//TODO: Should user_extended_validate_entry() ckech DB for DB-type fields?
*/
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_user_extended.php");
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user_extended.php');
class e107_user_extended
{
@ -38,20 +36,22 @@ class e107_user_extended
var $extended_xml;
var $typeArray;
var $reserved_names;
var $fieldDefinitions; // Array initialised from DB by constructor
var $nameIndex; // Array for field name lookup - initialised by constructor
function e107_user_extended()
{
define('EUF_TEXT',1);
define('EUF_RADIO',2);
define('EUF_DROPDOWN',3);
define('EUF_DB_FIELD',4);
define('EUF_TEXTAREA',5);
define('EUF_INTEGER',6);
define('EUF_DATE',7);
define('EUF_LANGUAGE',8);
define('EUF_PREDEFINED',9);
define('EUF_TEXT',1);
define('EUF_RADIO',2);
define('EUF_DROPDOWN',3);
define('EUF_DB_FIELD',4);
define('EUF_TEXTAREA',5);
define('EUF_INTEGER',6);
define('EUF_DATE',7);
define('EUF_LANGUAGE',8);
define('EUF_PREDEFINED',9);
$this->typeArray = array(
$this->typeArray = array(
'text' => 1,
'radio' => 2,
'dropdown' => 3,
@ -61,19 +61,19 @@ class e107_user_extended
'date' => 7,
'language' => 8,
'list' => 9
);
);
$this->user_extended_types = array(
1 => UE_LAN_1,
2 => UE_LAN_2,
3 => UE_LAN_3,
4 => UE_LAN_4,
5 => UE_LAN_5,
6 => UE_LAN_6,
7 => UE_LAN_7,
8 => UE_LAN_8,
9 => UE_LAN_9
);
$this->user_extended_types = array(
1 => UE_LAN_1,
2 => UE_LAN_2,
3 => UE_LAN_3,
4 => UE_LAN_4,
5 => UE_LAN_5,
6 => UE_LAN_6,
7 => UE_LAN_7,
8 => UE_LAN_8,
9 => UE_LAN_9
);
//load array with field names from main user table, so we can disallow these
// user_new, user_timezone deleted for 0.8
@ -86,6 +86,12 @@ class e107_user_extended
'xup'
);
$this->fieldDefinitions = $this->user_extended_get_fieldList(); // Assume that we'll need these if an object has been instantiated
$this->nameIndex = array();
foreach ($this->fieldDefinitions as $k => $v)
{
$this->nameIndex['user_'.$v['user_extended_struct_name']] = $k; // Create name to ID index
}
}
function user_extended_reserved($name)
@ -94,6 +100,69 @@ class e107_user_extended
}
// Adds the _FIELD_TYPES array to the data, ready for saving in the DB.
function addFieldTypes(&$target)
{
$target['_FIELD_TYPES'] = array(); // We should always want to recreate the array, even if it exists
foreach ($target['data'] as $k => $v)
{
if (isset($this->nameIndex[$k]))
{
switch ($this->fieldDefinitions[$this->nameIndex[$k]]['user_extended_struct_type'])
{
case EUF_TEXT :
case EUF_DB_FIELD :
case EUF_TEXTAREA :
case EUF_DROPDOWN :
case EUF_DATE :
case EUF_LANGUAGE :
case EUF_PREDEFINED :
$target['_FIELD_TYPES'][$k] = 'todb';
break;
case EUF_RADIO :
case EUF_INTEGER :
$target['_FIELD_TYPES'][$k] = 'int';
break;
}
}
}
}
// For all UEFs not in the target array, adds the default value
// Also updates the _FIELD_TYPES array, so call this last thing before writing to the DB
function addDefaultFields(&$target)
{
$target['_FIELD_TYPES'] = array(); // We should always want to recreate the array, even if it exists
foreach ($this->fieldDefinitions as $k => $defs)
{
$f = 'user_'.$defs['user_extended_struct_name'];
if (!isset($target['data'][$f]))
{
switch ($this->fieldDefinitions[$k]['user_extended_struct_type'])
{
case EUF_TEXT :
case EUF_DB_FIELD :
case EUF_TEXTAREA :
case EUF_DROPDOWN :
case EUF_DATE :
case EUF_LANGUAGE :
case EUF_PREDEFINED :
$target['data'][$f] = $this->fieldDefinitions[$k]['user_extended_struct_default'];
$target['_FIELD_TYPES'][$f] = 'todb';
break;
case EUF_RADIO :
case EUF_INTEGER :
$target['data'][$f] = $this->fieldDefinitions[$k]['user_extended_struct_default'];
$target['_FIELD_TYPES'][$f] = 'int';
break;
}
}
}
}
// Validate a single extended user field
// $val is whatever the user entered.
// $params is the field definition
@ -101,7 +170,7 @@ class e107_user_extended
function user_extended_validate_entry($val, $params)
{
global $tp;
$parms = explode("^,^", $params['user_extended_struct_parms']);
$parms = explode('^,^', $params['user_extended_struct_parms']);
$requiredField = $params['user_extended_struct_required'] == 1;
$regex = $tp->toText($parms[1]);
$regexfail = $tp->toText($parms[2]);
@ -127,10 +196,9 @@ class e107_user_extended
function userExtendedValidateAll($inArray, $hideArray)
{
global $tp;
$extList = $this->user_extended_get_fieldList(); // Filter this more later
$eufVals = array(); // 'Answer' array
$hideFlags = array();
foreach ($extList as $k => $defs)
foreach ($this->fieldDefinitions as $k => $defs)
{
$f = 'user_'.$defs['user_extended_struct_name'];
if (isset($inArray[$f]))
@ -149,7 +217,7 @@ class e107_user_extended
}
elseif (!$err)
{
$eufVals['validate'][$f] = $tp->toDB($val);
$eufVals['data'][$f] = $tp->toDB($val);
}
if (isset($hideArray[$f]))
{
@ -162,7 +230,7 @@ class e107_user_extended
{
$hidden_fields = "^".$hidden_fields."^";
}
$eufVals['validate']['user_hidden_fields'] = $hidden_fields;
$eufVals['data']['user_hidden_fields'] = $hidden_fields;
return $eufVals;
}
@ -205,7 +273,7 @@ class e107_user_extended
return $ret;
}
// Get the definition of all fields, or those in a specific category, indexed by field ID
// Get the definition of all fields, or those in a specific category, indexed by field ID (or some other field by specifying $indexField)
function user_extended_get_fieldList($cat = "", $indexField = 'user_extended_struct_id')
{
global $sql;
@ -221,6 +289,7 @@ class e107_user_extended
}
// Return the field creation text for a definition
function user_extended_type_text($type, $default)
{
global $tp;
@ -393,17 +462,6 @@ class e107_user_extended
}
/*
define('EUF_TEXT',1);
define('EUF_RADIO',2);
define('EUF_DROPDOWN',3);
define('EUF_DB_FIELD',4);
define('EUF_TEXTAREA',5);
define('EUF_INTEGER',6);
define('EUF_DATE',7);
define('EUF_LANGUAGE',8);
define('EUF_PREDEFINED',9);
*/
switch($struct['user_extended_struct_type'])
{
case EUF_TEXT : //textbox
@ -562,19 +620,19 @@ class e107_user_extended
$item['include_text'] = '';
}
$info = array(
"name" => $item['@attributes']['name'],
"text" => "UE_LAN_".strtoupper($item['@attributes']['name']),
"type" => $item['type'],
"values" => $item['values'],
"default" => $item['default'],
"required" => $item['required'],
"read" => $item['read'],
"write" => $item['write'],
"applicable" => $item['applicable'],
"include_text" => $item['include_text'],
"parms" => $item['include_text'],
"regex" => $item['regex']
);
"name" => $item['@attributes']['name'],
"text" => "UE_LAN_".strtoupper($item['@attributes']['name']),
"type" => $item['type'],
"values" => $item['values'],
"default" => $item['default'],
"required" => $item['required'],
"read" => $item['read'],
"write" => $item['write'],
"applicable" => $item['applicable'],
"include_text" => $item['include_text'],
"parms" => $item['include_text'],
"regex" => $item['regex']
);
if(is_array($item['default']) && $item['default'] == '')
{
$info['default'] = 0;

View File

@ -9,9 +9,9 @@
* Handler - user-related functions
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/user_handler.php,v $
* $Revision: 1.6 $
* $Date: 2008-12-30 14:05:44 $
* $Author: secretr $
* $Revision: 1.7 $
* $Date: 2009-01-11 21:06:46 $
* $Author: e107steved $
*
*/
@ -86,18 +86,18 @@ class UserHandler
'enablePref' - value is processed only if the named $pref evaluates to true; otherwise any input is discarded without error
*/
$this->userVettingInfo = array(
'user_name' => array('niceName'=> LAN_USER_01, 'vetMethod' => '1,2', 'vetParam' => 'signup_disallow_text', 'srcName' => 'username', 'stripTags' => TRUE, 'stripChars' => '/ |\#|\=|\$/', fixedBlock => 'anonymous', 'minLength' => 2, 'maxLength' => varset($pref['displayname_maxlength'],15)), // Display name
'user_loginname' => array('niceName'=> LAN_USER_02, 'vetMethod' => '1', 'vetParam' => '', 'srcName' => 'loginname', 'stripTags' => TRUE, 'stripChars' => '/ |\#|\=|\$/', 'minLength' => 2, 'maxLength' => varset($pref['loginname_maxlength'],30)), // User name
'user_login' => array('niceName'=> LAN_USER_03, 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'realname', 'dbClean' => 'toDB'), // Real name (no real vetting)
'user_customtitle' => array('niceName'=> LAN_USER_04, 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'customtitle', 'dbClean' => 'toDB', 'enablePref' => 'signup_option_customtitle'), // No real vetting
'user_password' => array('niceName'=> LAN_USER_05, 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'password1', 'dataType' => 2, 'minLength' => varset($pref['signup_pass_len'],1)),
'user_sess' => array('niceName'=> LAN_USER_06, 'vetMethod' => '0', 'vetParam' => '', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'image', 'imagePath' => e_FILE.'public/avatars/', 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Photo
'user_image' => array('niceName'=> LAN_USER_07, 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'image', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'avatar', 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Avatar
'user_email' => array('niceName'=> LAN_USER_08, 'vetMethod' => '1,3', 'vetParam' => '', 'srcName' => 'email', 'dbClean' => 'toDB'),
'user_signature' => array('niceName'=> LAN_USER_09, 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'signature', 'dbClean' => 'toDB'),
'user_hideemail' => array('niceName'=> LAN_USER_10, 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'hideemail', 'dbClean' => 'intval'),
'user_xup' => array('niceName'=> LAN_USER_11, 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'user_xup', 'dbClean' => 'toDB'),
'user_class' => array('niceName'=> LAN_USER_12, 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'class', 'dataType' => '1')
'user_name' => array('niceName'=> LAN_USER_01, 'fieldType' => 'string', 'vetMethod' => '1,2', 'vetParam' => 'signup_disallow_text', 'srcName' => 'username', 'stripTags' => TRUE, 'stripChars' => '/ |\#|\=|\$/', fixedBlock => 'anonymous', 'minLength' => 2, 'maxLength' => varset($pref['displayname_maxlength'],15)), // Display name
'user_loginname' => array('niceName'=> LAN_USER_02, 'fieldType' => 'string', 'vetMethod' => '1', 'vetParam' => '', 'srcName' => 'loginname', 'stripTags' => TRUE, 'stripChars' => '/ |\#|\=|\$/', 'minLength' => 2, 'maxLength' => varset($pref['loginname_maxlength'],30)), // User name
'user_login' => array('niceName'=> LAN_USER_03, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'realname', 'dbClean' => 'toDB'), // Real name (no real vetting)
'user_customtitle' => array('niceName'=> LAN_USER_04, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'customtitle', 'dbClean' => 'toDB', 'enablePref' => 'signup_option_customtitle'), // No real vetting
'user_password' => array('niceName'=> LAN_USER_05, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'password1', 'dataType' => 2, 'minLength' => varset($pref['signup_pass_len'],1)),
'user_sess' => array('niceName'=> LAN_USER_06, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'image', 'imagePath' => e_FILE.'public/avatars/', 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Photo
'user_image' => array('niceName'=> LAN_USER_07, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'image', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'avatar', 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Avatar
'user_email' => array('niceName'=> LAN_USER_08, 'fieldType' => 'string', 'vetMethod' => '1,3', 'vetParam' => '', 'srcName' => 'email', 'dbClean' => 'toDB'),
'user_signature' => array('niceName'=> LAN_USER_09, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'signature', 'dbClean' => 'toDB'),
'user_hideemail' => array('niceName'=> LAN_USER_10, 'fieldType' => 'int', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'hideemail', 'dbClean' => 'intval'),
'user_xup' => array('niceName'=> LAN_USER_11, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'user_xup', 'dbClean' => 'toDB'),
'user_class' => array('niceName'=> LAN_USER_12, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'class', 'dataType' => '1')
);
$this->otherFields = array(
@ -461,9 +461,9 @@ Following fields auto-filled in code as required:
global $e107, $pref;
$u_sql = new db;
$ret = TRUE;
if (isset($targetData['validate']['user_email']))
if (isset($targetData['data']['user_email']))
{
$v = trim($targetData['validate']['user_email']); // Always check email address if its entered
$v = trim($targetData['data']['user_email']); // Always check email address if its entered
if ($v == '')
{
$errMsg = ERR_MISSING_VALUE;
@ -488,7 +488,7 @@ Following fields auto-filled in code as required:
}
if ($errMsg)
{
unset($targetData['validate']['user_email']); // Remove the valid entry
unset($targetData['data']['user_email']); // Remove the valid entry
}
}
else

View File

@ -9,9 +9,9 @@
* Handler - general purpose validation functions
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
* $Revision: 1.4 $
* $Date: 2008-12-30 14:05:44 $
* $Author: secretr $
* $Revision: 1.5 $
* $Date: 2009-01-11 21:06:46 $
* $Author: e107steved $
*
*/
@ -74,7 +74,7 @@ class validatorClass
function validateFields(&$sourceFields, &$definitions, $addDefaults = FALSE)
{
global $tp, $pref;
$ret = array('validate' => array(), 'failed' => array(), 'errors' => array());
$ret = array('data' => array(), 'failed' => array(), 'errors' => array());
foreach ($definitions as $dest => $defs)
{
$errNum = 0; // Start with no error
@ -85,7 +85,7 @@ class validatorClass
{
if (isset($defs['default']))
{
$ret['validate'] = $defs['default']; // Set default value if one is specified
$ret['data'] = $defs['default']; // Set default value if one is specified
} //...otherwise don't add the value at all
}
else
@ -175,7 +175,7 @@ class validatorClass
$temp = array();
foreach ($value as $v)
{
$temp[] = intval($v);
if (ctype_digit(trim($v))) { $temp[] = intval($v); }
}
$value = implode(',',array_unique($temp));
}
@ -248,7 +248,7 @@ class validatorClass
echo "Invalid dbClean method: {$defs['dbClean']}<br />"; // Debug message
}
}
$ret['validate'][$dest] = $value; // Success!!
$ret['data'][$dest] = $value; // Success!!
}
}
if ($errNum)
@ -272,7 +272,7 @@ class validatorClass
// Validate data against a DB table
// Inspects the passed array of user data (not necessarily containing all possible fields) and validates against the DB where appropriate.
// Just skips over fields for which we don't have a validation routine without an error
// The target array is as returned from validateFields(), so has 'validate', 'failed' and 'errors' first-level sub-arrays
// The target array is as returned from validateFields(), so has 'data', 'failed' and 'errors' first-level sub-arrays
// All the 'vetting methods' begin 'vet', and don't overlap with validateFields(), so the same definition array may be used for both
// Similarly, error numbers don't overlap with validateFields()
// Typically checks for unacceptable duplicates, banned users etc
@ -298,7 +298,7 @@ class validatorClass
$allOK = TRUE;
$userID = intval($userID); // Precautionary
if (!$targetTable) return FALSE;
foreach ($targetData['validate'] as $f => $v)
foreach ($targetData['data'] as $f => $v)
{
$errMsg = '';
if (isset($definitions[$f]))
@ -369,7 +369,7 @@ class validatorClass
{ // Update the error
$targetData['errors'][$f] = $errMsg;
$targetData['failed'][$f] = $v;
unset($targetData['validate'][$f]); // Remove the valid entry
unset($targetData['data'][$f]); // Remove the valid entry
$allOK = FALSE;
}
}
@ -385,7 +385,7 @@ class validatorClass
$allOK = TRUE;
foreach ($fields as $f)
{
if (!isset($target['validate'][$f]) && !isset($target['errors'][$f]))
if (!isset($target['data'][$f]) && !isset($target['errors'][$f]))
{
$allOK = FALSE;
$targetData['errors'][$f] = ERR_MISSING_VALUE;
@ -395,6 +395,22 @@ class validatorClass
}
// Adds the _FIELD_TYPES array to the data, ready for saving in the DB.
// $fieldList is the standard definition array
function addFieldTypes($fieldList, &$target)
{
$target['_FIELD_TYPES'] = array(); // We should always want to recreate the array, even if it exists
foreach ($target['data'] as $k => $v)
{
if (isset($fieldList[$k]) && isset($fieldList[$k]['fieldType']))
{
$target['_FIELD_TYPES'][$k] = $fieldList[$k]['fieldType'];
}
}
}
// Given two arrays, returns an array of those elements in $input which are different from the corresponding element in $refs.
// If $addMissing == TRUE, includes any element in $input for which there isn't a corresponding element in $refs
function findChanges(&$input, &$refs, $addMissing = FALSE)

View File

@ -9,9 +9,9 @@
* Language file - user admin
*
* $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_users.php,v $
* $Revision: 1.13 $
* $Date: 2008-12-22 03:15:04 $
* $Author: mcfly_e107 $
* $Revision: 1.14 $
* $Date: 2009-01-11 21:06:52 $
* $Author: e107steved $
*
*/
define("USRLAN_1", "Options Saved.");
@ -80,7 +80,7 @@ define("USRLAN_66", "That display name already exists in the database, please ch
define("USRLAN_67", "The two passwords do not match");
define("USRLAN_68", "You left required field(s) blank");
define("USRLAN_69", "That doesn't appear to be a valid email address");
define("USRLAN_70", "User created");
//define("USRLAN_70", "User created");
define("USRLAN_71", "Users Front Page");
define("USRLAN_72", "Quick Add User");
define("USRLAN_73", "Prune Users");

View File

@ -9,8 +9,8 @@
* User signup
*
* $Source: /cvs_backup/e107_0.8/signup.php,v $
* $Revision: 1.31 $
* $Date: 2009-01-04 16:00:19 $
* $Revision: 1.32 $
* $Date: 2009-01-11 21:06:46 $
* $Author: e107steved $
*
*/
@ -444,8 +444,8 @@ if (isset($_POST['register']))
$userMethods->userValidation($allData); // Do user-specific DB checks
if (!isset($allData['errors']['user_password']))
{ // No errors in password - keep it outside the main data array
$savePassword = $allData['validate']['user_password'];
unset($allData['validate']['user_password']); // Delete the password value in the output array
$savePassword = $allData['data']['user_password'];
unset($allData['data']['user_password']); // Delete the password value in the output array
}
unset($_POST['password1']); // Restrict the scope of this
unset($_POST['password2']);
@ -470,7 +470,7 @@ if (isset($_POST['register']))
{
$allData['errors']['user_email'] = ERR_GENERIC;
$allData['errortext']['user_email'] = LAN_SIGNUP_38;
unset($allData['validate']['user_email']);
unset($allData['data']['user_email']);
}
}
@ -481,7 +481,7 @@ if (isset($_POST['register']))
foreach($signup_option_names as $key => $value)
{
if ($pref['signup_option_'.$value] == 2 && !isset($alldata['validate']['user_'.$value]) && !isset($alldata['errors']['user_'.$value]))
if ($pref['signup_option_'.$value] == 2 && !isset($alldata['data']['user_'.$value]) && !isset($alldata['errors']['user_'.$value]))
{
$alldata['errors']['user_'.$value] = ERR_GENERIC;
$alldata['errortext']['user_'.$value] = str_replace('--SOMETHING--',$signup_option_title[$key],LAN_USER_75);
@ -526,8 +526,8 @@ if (isset($_POST['register']))
// ========== End of verification.. ==============
// If no errors, we can enter the new member in the DB
// At this point we have two data arrays:
// $allData['validate'] - the 'core' user data
// $eufVals['validate'] - any extended user fields
// $allData['data'] - the 'core' user data
// $eufVals['data'] - any extended user fields
if (!$error)
{
@ -546,13 +546,13 @@ if (isset($_POST['register']))
$u_key = md5(uniqid(rand(), 1)); // Key for signup completion
$allData['validate']['user_sess'] = $u_key; // Validation key
$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['validate']['user_class'])) { $classList = explode(',',$allData['validate']['user_class']); } // Classes entered by user during signup
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
@ -564,40 +564,44 @@ if (isset($_POST['register']))
$classList = array_unique($classList);
if (count($classList))
{
$allData['validate']['user_class'] = implode(',',$classList);
$allData['data']['user_class'] = implode(',',$classList);
}
if ($pref['user_reg_veri'])
{
$allData['validate']['user_ban'] = USER_REGISTERED_NOT_VALIDATED;
$allData['data']['user_ban'] = USER_REGISTERED_NOT_VALIDATED;
}
else
{
$allData['validate']['user_ban'] = USER_VALIDATED;
$allData['data']['user_ban'] = USER_VALIDATED;
}
// Work out data to be written to user audit trail
$signup_data = array('user_name', 'user_loginname', 'user_email', 'user_ip');
foreach (array() as $f)
{
$signup_data[$f] = $allData['validate'][$f]; // Just copy across selected fields
$signup_data[$f] = $allData['data'][$f]; // Just copy across selected fields
}
$allData['validate']['user_password'] = $userMethods->HashPassword($savePassword,$allData['validate']['user_loginname']);
$allData['data']['user_password'] = $userMethods->HashPassword($savePassword,$allData['data']['user_loginname']);
if (varsettrue($pref['allowEmailLogin']))
{ // Need to create separate password for email login
$allData['validate']['user_prefs'] = serialize(array('email_password' => $userMethods->HashPassword($savePassword, $allData['validate']['user_email'])));
$allData['data']['user_prefs'] = serialize(array('email_password' => $userMethods->HashPassword($savePassword, $allData['data']['user_email'])));
}
$allData['validate']['user_join'] = time();
$allData['data']['user_join'] = time();
// Actually write data to DB
$nid = $sql->db_Insert("user", $allData['validate']);
if (isset($eufVals['validate']) && count($eufVals['validate']))
validatorClass::addFieldTypes($userMethods->userVettingInfo,$allData);
$nid = $sql->db_Insert('user', $allData);
if (isset($eufVals['data']) && count($eufVals['data']))
{
$usere->addFieldTypes($eufVals); // Add in the data types for storage
$eufVals['WHERE'] = '`user_extended_id` = '.intval($nid);
//$usere->addDefaultFields($eufVals); // Add in defaults for anything not explicitly set (commented out for now - will slightly modify behaviour)
$sql->db_Select_gen("INSERT INTO `#user_extended` (user_extended_id) values ('{$nid}')");
$sql->db_UpdateArray("user_extended", $eufVals['validate']." WHERE `user_extended_id` = ".intval($nid));
$sql->db_Update('user_extended', $eufVals);
}
if (SIGNUP_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Signup new user",array_merge($allData['validate'],$eufVals) ,FALSE,LOG_TO_ROLLING);
if (SIGNUP_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Signup new user",array_merge($allData['data'],$eufVals) ,FALSE,LOG_TO_ROLLING);
// Log to user audit log if enabled
$signup_data['user_id'] = $nid;
@ -616,7 +620,7 @@ if (isset($_POST['register']))
$adviseLoginName = '';
if (varsettrue($pref['predefinedLoginName']))
{
$adviseLoginName = LAN_SIGNUP_65.': '.$allData['validate']['user_loginname'].'<br />'.LAN_SIGNUP_66.'<br />';
$adviseLoginName = LAN_SIGNUP_65.': '.$allData['data']['user_loginname'].'<br />'.LAN_SIGNUP_66.'<br />';
}
@ -624,11 +628,11 @@ if (isset($_POST['register']))
{ // Verification required (may be by email or by admin)
// ========== Send Email =========>
if (($pref['user_reg_veri'] != 2) && $allData['validate']['user_email']) // Don't send if email address blank - means that its not compulsory
if (($pref['user_reg_veri'] != 2) && $allData['data']['user_email']) // Don't send if email address blank - means that its not compulsory
{
$allData['validate']['user_id'] = $nid; // User ID
$allData['validate']['user_password'] = $savePassword; // Might need to send plaintext password in the email
$eml = render_email($allData['validate']);
$allData['data']['user_id'] = $nid; // User ID
$allData['data']['user_password'] = $savePassword; // Might need to send plaintext password in the email
$eml = render_email($allData['data']);
$mailheader_e107id = $eml['userid'];
require_once(e_HANDLER."mail.php");
@ -643,7 +647,7 @@ if (isset($_POST['register']))
require_once(HEADERF);
if (isset($pref['signup_text_after']) && (strlen($pref['signup_text_after']) > 2))
{
$text = $tp->toHTML(str_replace('{NEWLOGINNAME}', $allData['validate']['user_loginname'], $pref['signup_text_after']), TRUE, 'parse_sc,defs')."<br />";
$text = $tp->toHTML(str_replace('{NEWLOGINNAME}', $allData['data']['user_loginname'], $pref['signup_text_after']), TRUE, 'parse_sc,defs')."<br />";
}
else
{
@ -668,7 +672,7 @@ if (isset($_POST['register']))
{ // User can be signed up immediately
require_once(HEADERF);
if(!$sql -> db_Select("user", "user_id", "user_loginname='".$allData['validate']['user_loginname']."' AND user_password='".$allData['validate']['user_password']."'"))
if(!$sql -> db_Select("user", "user_id", "user_loginname='".$allData['data']['user_loginname']."' AND user_password='".$allData['data']['user_password']."'"))
{ // Error looking up newly created user
$ns->tablerender("", LAN_SIGNUP_36);
require_once(FOOTERF);
@ -694,7 +698,7 @@ if (isset($_POST['register']))
{ // 'Recirculate' selected values so they are retained on the form when an error occurs
foreach (array('user_class') as $a)
{
$signupData[$a] = $tp->toForm(varset($allData['validate'][$a],''));
$signupData[$a] = $tp->toForm(varset($allData['data'][$a],''));
}
}
}

View File

@ -9,8 +9,8 @@
* User settings modify
*
* $Source: /cvs_backup/e107_0.8/usersettings.php,v $
* $Revision: 1.32 $
* $Date: 2008-12-29 11:00:16 $
* $Revision: 1.33 $
* $Date: 2009-01-11 21:06:46 $
* $Author: e107steved $
*
*/
@ -167,8 +167,8 @@ if (isset($_POST['updatesettings']))
{ // Need to validate new password here
if (!isset($allData['errors']['user_password']))
{ // No errors in password yet - may be valid
$savePassword = $allData['validate']['user_password'];
unset($allData['validate']['user_password']); // Delete the password value in the output array
$savePassword = $allData['data']['user_password'];
unset($allData['data']['user_password']); // Delete the password value in the output array
}
}
else
@ -180,7 +180,7 @@ if (isset($_POST['updatesettings']))
unset($_POST['password2']);
$changedUserData = validatorClass::findChanges($allData['validate'], $udata,FALSE);
$changedUserData = validatorClass::findChanges($allData['data'], $udata,FALSE);
// Login Name checks - only admin can change login name
@ -223,7 +223,7 @@ if (isset($_POST['updatesettings']))
if (isset($_POST['ue']))
{
$eufVals = $ue->userExtendedValidateAll($_POST['ue'], varset($_POST['hide'],array())); // Validate the extended user fields
$changedEUFData = validatorClass::findChanges($eufVals['validate'], $udata,FALSE);
$changedEUFData['data'] = validatorClass::findChanges($eufVals['data'], $udata,FALSE);
}
// Determine whether we have an error
@ -231,7 +231,7 @@ if (isset($_POST['updatesettings']))
// Update Userclass - only if its the user changing their own data (admins can do it another way)
if (isset($allData['validate']['user_class']))
if (isset($allData['data']['user_class']))
{
unset($changedUserData['user_class']); // We always recalculate this
if (FALSE === $adminEdit)
@ -243,10 +243,10 @@ if (isset($_POST['updatesettings']))
$ucList = $e_userclass->get_editable_classes(USERCLASS_LIST,TRUE); // List of classes which this user can edit
if (count($ucList))
{
$nid = $e_userclass->mergeClassLists($udata['user_class'], $ucList, $allData['validate']['user_class'], TRUE);
$nid = $e_userclass->mergeClassLists($udata['user_class'], $ucList, $allData['data']['user_class'], TRUE);
$nid = $e_userclass->stripFixedClasses($nid);
$nid = implode(',',$nid);
// echo "Userclass data - new: {$nid}, old: {$udata['user_baseclasslist']}, editable: ".implode(',',$ucList).", entered: {$allData['validate']['user_class']}<br />";
// echo "Userclass data - new: {$nid}, old: {$udata['user_baseclasslist']}, editable: ".implode(',',$ucList).", entered: {$allData['data']['user_class']}<br />";
if ($nid != $udata['user_baseclasslist'])
{
if (US_DEBUG)
@ -335,7 +335,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
$dataToSave = !$error && (isset($changedUserData) && count($changedUserData)) || (isset($changedEUFData) && count($changedEUFData)) || $savePassword;
$dataToSave = !$error && (isset($changedUserData) && count($changedUserData)) || (isset($changedEUFData['data']) && count($changedEUFData['data'])) || $savePassword;
if ($dataToSave)
{
@ -377,8 +377,12 @@ if ($dataToSave && !$promptPassword)
if (US_DEBUG) { $admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Usersettings test", "Changed data:<br /> ".var_export($changedUserData, true), false, LOG_TO_ROLLING); }
if (isset($changedUserData) && count($changedUserData))
{
//print_a($changedUserData);
if (FALSE === $sql->db_UpdateArray('user', $changedUserData, ' WHERE user_id='.intval($inp)))
$changedData['data'] = $changedUserData;
$changedData['WHERE'] = 'user_id='.intval($inp);
validatorClass::addFieldTypes($userMethods->userVettingInfo,$changedData);
//print_a($changedData);
if (FALSE === $sql->db_Update('user', $changedData))
{
$message .= '<br />Error updating user data';
}
@ -393,11 +397,15 @@ if ($dataToSave && !$promptPassword)
}
// Save extended field values
if (isset($changedEUFData) && count($changedEUFData))
if (isset($changedEUFData['data']) && count($changedEUFData['data']))
{
$ue->addFieldTypes($changedEUFData); // Add in the data types for storage
$changedEUFData['WHERE'] = '`user_extended_id` = '.intval($inp);
//print_a($changedEUFData);
// ***** Next line creates a record which presumably should be there anyway, so could generate an error
$sql->db_Select_gen("INSERT INTO #user_extended (user_extended_id, user_hidden_fields) values ('".intval($inp)."', '')");
if (!$sql->db_UpdateArray('user_extended', $changedEUFData,' WHERE user_extended_id = '.$inp))
if (!$sql->db_Update('user_extended', $changedEUFData))
{
$message .= '<br />Error updating EUF';
}