diff --git a/usersettings.php b/usersettings.php index b546c4173..9a7d07ffd 100644 --- a/usersettings.php +++ b/usersettings.php @@ -48,757 +48,901 @@ if ((!ADMIN || !getperms("4")) && e_QUERY && e_QUERY != "update" ) include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user.php'); // Generic user-related language defines include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_usersettings.php'); - +$ue = e107::getUserExt(); // needed by shortcodes for now. require_once (e_HANDLER.'ren_help.php'); -require_once (e_HANDLER.'user_extended_class.php'); // require_once (e_HANDLER.'user_handler.php'); require_once(e_HANDLER.'validator_class.php'); -$ue = new e107_user_extended; - -$userMethods = e107::getUserSession(); - -require_once (e_HANDLER.'ren_help.php'); -if(deftrue('BOOTSTRAP')===3) + + + +class usersettings_front // Begin Usersettings rewrite. { - $template = e107::getCoreTemplate('usersettings','', true, true); // always merge - - $USERSETTINGS_MESSAGE = "{MESSAGE}"; - $USERSETTINGS_MESSAGE_CAPTION = LAN_OK; - $USERSETTINGS_EDIT_CAPTION = LAN_USET_39; // 'Update User Settings' - $USERSETTINGS_EDIT = $template['edit']; - $usersettings_shortcodes = e107::getScBatch('usersettings'); - - $usersettings_shortcodes->wrapper('usersettings/edit'); -} -else -{ - include_once (e107::coreTemplatePath('usersettings')); //correct way to load a core template. - e107::scStyle($sc_style); - $usersettings_shortcodes = e107::getScBatch('usersettings'); -} + + private $template = array(); + private $sc = null; - - - - -e107::js('footer-inline'," - function addtext_us(sc) + /** + * usersettings_front constructor. + */ + function __construct() { - document.getElementById('dataform').image.value = sc; - } - "); - - - -$photo_to_delete = ''; -$avatar_to_delete = ''; -$ue_fields = ''; -$promptPassword = false; -$error = FALSE; -$extraErrors = array(); -$eufVals = array(); -$savePassword = ''; - - -$inp = USERID; // Initially assume that user is modifying their own data. -$_uid = false; // FALSE if user modifying their own data; otherwise ID of data being modified -$adminEdit = FALSE; // FALSE if editing own data. TRUE if admin edit - -if(is_numeric(e_QUERY)) -{ // Trying to edit specific user record - if (ADMIN) - { // Admin edit of specific record -/* -$_usersettings_matches = Array -( - [0] => /e107/usersettings.php?# OR /e107/edit/user/# - [1] => e107 - [2] => usersettings.php OR edit/user - [3] => ? OR / - [4] => # -) -*/ -$inp = intval(e_QUERY); - -$usersettings_form_action = strstr('?', $_usersettings_matches[3]) ? e_SELF.'?'.e_QUERY : e_SELF; - -$_uid = $inp; -$info = e107::user($inp); - //Only site admin is able to change setting for other admins -if(!is_array($info) || ($info['user_admin'] == 1 && (!defined('ADMINPERMS') || ADMINPERMS !== '0')) || ((!defined('ADMINPERMS') || ADMINPERMS !== '0') && !getperms('4'))) -{ - e107::redirect(); - exit(); -} - $adminEdit = TRUE; // Flag to indicate admin edit - } - else - { - //Non admin attempting to edit another user's ID - e107::redirect(); - exit(); - } - -} - - - -require_once (HEADERF); - - - -// Save user settings (changes only) -//----------------------------------- - -if (isset($_POST['updatesettings']) || isset($_POST['SaveValidatedInfo'])) -{ -// $udata = e107::user($inp); //@deprecated // Get all the existing user data, including any extended fields - - $udata = e107::user($inp); // Get all the existing user data, including any extended fields - $udata['user_classlist'] = $userMethods->addCommonClasses($udata, FALSE); -} - - -if (isset($_POST['updatesettings'])) -{ - if (!vartrue($pref['auth_method'])) - { - $pref['auth_method'] = 'e107'; - } - - if ($pref['auth_method'] != 'e107') - { - $_POST['password1'] = ''; - $_POST['password2'] = ''; - } - - // Uploaded avatar and/or photo - if (varset($file_userfile['error']) != 4) - { - require_once (e_HANDLER.'upload_handler.php'); - require_once (e_HANDLER.'resize_handler.php'); - - if ($uploaded = process_uploaded_files(e_AVATAR_UPLOAD, 'prefix+ap_'.$tp->leadingZeros($udata['user_id'],7).'_', array('overwrite' => TRUE, 'file_mask'=>'jpg,png,gif,jpeg', 'max_file_count' => 2))) + if(deftrue('BOOTSTRAP')===3) { - foreach ($uploaded as $upload) - { - if ($upload['name'] && ($upload['index'] == 'avatar') && $pref['avatar_upload']) - { - // avatar uploaded - give it a reference which identifies it as server-stored - // Vetting routines will do resizing and so on - $_POST['image'] = '-upload-'.$upload['name']; - } - elseif ($upload['name'] && ($upload['index'] == 'photo') && $pref['photo_upload']) - { - // photograph uploaded - $_POST['user_sess'] = '-upload-'.$upload['name']; - } - elseif (isset($upload['error']) && isset($upload['message'])) - { - $extraErrors[] = $upload['message']; - } - - } - } - - - } + $template = e107::getCoreTemplate('usersettings','', true, true); // always merge + $USERSETTINGS_MESSAGE = "{MESSAGE}"; + $USERSETTINGS_MESSAGE_CAPTION = LAN_OK; + $USERSETTINGS_EDIT_CAPTION = LAN_USET_39; // 'Update User Settings' + $USERSETTINGS_EDIT = $template['edit']; + $usersettings_shortcodes = e107::getScBatch('usersettings'); - // Now validate everything - just check everything that's been entered - $allData = validatorClass::validateFields($_POST,$userMethods->userVettingInfo, TRUE); // Do basic validation - validatorClass::dbValidateArray($allData, $userMethods->userVettingInfo, 'user', $inp); // Do basic DB-related checks - $userMethods->userValidation($allData); // Do user-specific DB checks - - $savePassword = ''; - - if (($_POST['password1'] != '') || ($_POST['password2'] != '')) - { // Need to validate new password here - if (!isset($allData['errors']['user_password'])) - { // No errors in password yet - may be valid - $savePassword = $allData['data']['user_password']; - unset($allData['data']['user_password']); // Delete the password value in the output array - } - } - else - { - unset($allData['errors']['user_password']); // Delete the error which an empty password field generates - } - - unset($_POST['password1']); - unset($_POST['password2']); - - - $changedUserData = validatorClass::findChanges($allData['data'], $udata,FALSE); - - -e107::getMessage()->addDebug("