public function execute() { $action = ""; if (isset($_GET['action'])) { $action = $_GET['action']; } if (strcmp($action, 'save_info') == 0) { //save user info here //todo if (isset($_POST['first_name']) && isset($_POST['last_name'])) { $firstName = $_POST['first_name']; $lastName = $_POST['last_name']; $user = $this->user; $user->firstName = $firstName; $user->lastName = $lastName; DbUser::Update($user); } $this->addAlert(Alert::CreateSuccess('Success', 'Account information saved.')); $this->reloadUser(); } $this->accountPermissions = DbGroup::GetUserPermissions($this->user->id); $this->accountGroups = DbGroup::GetUserGroups($this->user->id); }
public function __construct($constraints = array()) { $this->alerts = array(); $this->alertRenderer = new AlertRenderer(); if (isset($_SESSION['alerts'])) { //fetching alerts //clearing them when they are show $this->alerts = $_SESSION['alerts']; } $this->constraints = $constraints; $this->user = new User(); //todo //do some methhods for getBoolConstraint, and other data type $no_redirect = $this->getConstraint('no_redirect'); if (is_int($no_redirect)) { $no_redirect = false; } else { $no_redirect = $no_redirect->value; } //loading settings $settings = DbSetting::GetAll(); $this->settings = new SettingContainer($settings); if ($this->settings->size() == 0) { $this->initSettings(); } if (isset($_SESSION['user_id'])) { $user_id = $_SESSION['user_id']; $this->user->id = $user_id; $user = DbUser::GetById($user_id); $perms = DbPermission::GetAll(); $this->permissions = new PermissionContainer($perms); if (!$user->isNull()) { $this->user = $user; //loading permissions $userPermissions = DbGroup::GetUserPermissions($this->user->id); $this->userPermissions = $userPermissions->getPermissionsInt(); if ($this->user->isClearPassword()) { //force a password change //todo $no_change = $this->getConstraint("no_change_password"); if (!is_int($no_change)) { if (!$no_change->value) { header('location: change_password.php'); } } else { header('location: change_password.php'); } } } else { //sending the user directly to the login if (!$no_redirect) { header('location: login.php'); } } } else { //sending the user directly to the login if (!$no_redirect) { header('location: login.php'); } } }