// include_once "config.inc.php"; include_once APP_INC_PATH . "class.template.php"; include_once APP_INC_PATH . "class.auth.php"; include_once APP_INC_PATH . "class.prefs.php"; include_once APP_INC_PATH . "class.setup.php"; include_once APP_INC_PATH . "class.date.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("preferences.tpl.html"); Auth::checkAuthentication(APP_COOKIE); $usr_id = Auth::getUserID(); if (@$HTTP_POST_VARS["cat"] == "update_account") { $res = Prefs::set($usr_id); $tpl->assign('update_account_result', $res); User::updateSMS($usr_id, @$HTTP_POST_VARS['sms_email']); } elseif (@$HTTP_POST_VARS["cat"] == "update_name") { $res = User::updateFullName($usr_id); $tpl->assign('update_name_result', $res); } elseif (@$HTTP_POST_VARS["cat"] == "update_email") { $res = User::updateEmail($usr_id); $tpl->assign('update_email_result', $res); } elseif (@$HTTP_POST_VARS["cat"] == "update_password") { $res = User::updatePassword($usr_id); $tpl->assign('update_password_result', $res); } $prefs = Prefs::get($usr_id); $prefs['sms_email'] = User::getSMS($usr_id); // if the user has no preferences set yet, get it from the system-wide options if (empty($prefs)) { $prefs = Setup::load();
} $tpl = new Template_Helper(); $tpl->setTemplate('preferences.tpl.html'); Auth::checkAuthentication(APP_COOKIE); if (Auth::isAnonUser()) { Auth::redirect('index.php'); } $res = null; if ($cat == 'update_account') { $preferences = $_POST; // if the user is trying to upload a new signature, override any changes to the textarea if (!empty($_FILES['file_signature']['name'])) { $preferences['email_signature'] = file_get_contents($_FILES['file_signature']['tmp_name']); } $res = Prefs::set($usr_id, $preferences); User::updateSMS($usr_id, @$_POST['sms_email']); } elseif ($cat == 'update_name') { $res = User::updateFullName($usr_id); } elseif ($cat == 'update_email') { $res = User::updateEmail($usr_id); } elseif ($cat == 'update_password') { $res = Auth::updatePassword($usr_id, $_POST['new_password'], $_POST['confirm_password']); } if ($res == 1) { Misc::setMessage(ev_gettext('Your information has been updated')); } elseif ($res == -1) { Misc::setMessage(ev_gettext('Sorry, there was an error updating your information'), Misc::MSG_ERROR); } $prefs = Prefs::get($usr_id); $prefs['sms_email'] = User::getSMS($usr_id); $tpl->assign('user_prefs', $prefs);