blob: a3e9258ba9b04c22f631e7d1e94748dc49dd8da3 (
plain) (
tree)
|
|
<?php
require_once "model/master.mod.php";
require_once "class/form.class.php";
class CommonModel extends MasterModel
{
/*
* Get the glyphicon to use for the logged in user (user or admin)
*/
function getCurrentUserGlyphicon()
{
if (!$this->getCurrentUser())
return "";
if ($this->getCurrentUser()->admin == 1)
return "glyphicon glyphicon-sunglasses";
else
return "glyphicon glyphicon-user";
}
/*
* Save changes to user account settings
*/
function saveSettingUser($input)
{
$form = new Form();
$form->field_bool("setPasswd");
$form->field_text("curPasswd", null, false);
$form->field_text("newPasswd", null, false);
$form->field_text("confPasswd", null, false);
$form->field_text("alias", null, false);
$form->field_text("email", null, false);
$form->field_text("emailConfKey", null, false);
if (!$form->populate($input))
{
$this->logFormErrors($form);
return;
}
$user = $this->getCurrentUser();
if (!$user)
{
$this->logError("Not logged in");
return;
}
if ($form->setPasswd == "true")
{
if ($user->validatePassword($form->curPassword))
{
if ($form->newPasswd == $form->confPassword)
$user->setPassword($form->newPasswd);
else
$this->logWarning("Password not changed -- Passwords did not match");
}
else
$this->logWarning("Password not changed -- Current password was incorrect");
}
$user->alias = $form->alias;
if ($form->email != $user->email)
$user->setEmail($form->email);
else if ($form->emailConfKey != "")
{
if (!$user->confirmEmailKey($form->emailConfKey))
$this->logWarning("Email not confirmed -- Key was incorrect");
}
$user->saveObj();
}
}
?>
|