getCurrentUser()) return ""; if ($this->getCurrentUser()->admin == 1) return "glyphicon glyphicon-sunglasses"; else return "glyphicon glyphicon-user"; } /* * Default action */ function common_deflt() { global $_SCROTT; /* Admin settings tab */ if ($_SCROTT['settSSL'] != "neither") { $this->common_settingAdminSettSSLChecked[$_SCROTT['settSSL']] = "checked"; $this->common_settingAdminSettSSLDisabled = "disabled"; } else $this->common_settingAdminSettSSLChecked[Setting::settSSL()] = "checked"; if (Setting::allowPublicSignup()) $this->common_settingAdminAllowPublicSignupChecked = "checked"; } /* * Handle form submissions from common views */ function common_handleFormSubmissions($input) { switch ($input['action']) { case "common-setting-user": $this->saveSettingUser($input); break; case "common-setting-admin": $this->saveSettingAdmin($input); break; } } /* * 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", "", false); $form->field_text("email", "", 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) { if ($user->validatePassword($form->curPasswd)) { if ($form->newPasswd == $form->confPasswd) { $user->setPassword($form->newPasswd); $this->logNotice("Password updated successfully"); } 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(); } /* * Save changes to admin settings */ function saveSettingAdmin($input) { $form = new Form(); $form->field_enum("settSSL", array("force", "neither", "forbid")); $form->field_bool("allowPublicSignup"); if (!$form->populate($input)) { $this->logFormErrors($form); return; } $user = $this->getCurrentUser(); if (!$user || $user->admin == 0) { $this->logError("Admin permissions required"); return; } Setting::settSSL($form->settSSL); Setting::allowPublicSignup($form->allowPublicSignup); } } ?>