/** * @covers Intacct\Xml\Response\ErrorMessage::__construct * @covers Intacct\Xml\Response\ErrorMessage::getErrors * @covers Intacct\Xml\Response\ErrorMessage::cleanse */ public function testGetErrors() { $errors = $this->object->getErrors(); $this->assertInternalType('array', $errors); $this->assertEquals('1234 description Object definition \'BADOBJECT\' not found. stripthesetags.', $errors[0]); $this->assertEquals('5678 stripthesetags. Object definition \'BADOBJECT\' not found. correct.', $errors[1]); }
/** * Verify that the constructor works properly and check all associated error message types. * * @param string $message The error message * @param array $params The array of substitution parameters * @param string $expectedLogMessage The expected output of ErrorMessage::getLogMessage() * * @return void * @dataProvider errorMessageConstructorDataProvider */ public function testConstructor($message, $params, $expectedLogMessage) { $errorMessage = new ErrorMessage($message, $params); $this->assertEquals($this->renderedMessage, $errorMessage->getMessage()); $this->assertEquals($message, $errorMessage->getRawMessage()); $this->assertEquals($expectedLogMessage, $errorMessage->getLogMessage()); $this->assertEquals($params, $errorMessage->getParameters()); }
public function get($key) { if (isset($this->vars[$key]) and isset($this->vars[$key][0])) { return $this->vars[$key][0]; } else { throw new \Exception(ErrorMessage::config(1, $key, $this->file)); } }
protected function protect() { $reflector = new \ReflectionClass($this); foreach ($reflector->getMethods() as $method) { if (!preg_match('#^(__).+#', $method->name) and !$method->isprotected()) { throw new \Exception(ErrorMessage::entity(0, $method->name, $reflector->name)); } } }
public function rules() { $method = 'rules' . ucFirst($this->action); if (method_exists($this, $method)) { $this->{$method}(); } elseif ($this->admin) { $this->rulesAdmin(); } else { throw new \Exception(ErrorMessage::controllers(1, $method, get_class($this))); } }
public function redirect_error($num) { $this->app->setError(true); $file = '../../Applications/Erreurs/' . $num . '.php'; $this->page = new Page($this->app()); if (file_exists($file)) { $this->page->setContentFile($file); $this->send(); } else { throw new \Exception(ErrorMessage::httpResponse(0, $file)); } }
public function crypt(User $utilisateur) { $file = file('../../Applications/' . $this->app()->name() . '/Config/key.ini'); if (sizeof($file) == 2) { $file[0] = str_replace("\n", "", $file[0]); $file[1] = str_replace("\n", "", $file[1]); $key1 = md5($utilisateur->id()) . $file[0] . md5($utilisateur->id()); $key2 = md5($utilisateur->id()) . $file[1] . md5($utilisateur->id()); return md5(sha1($key1 . $utilisateur->password() . $key2)); } else { throw new \Exception(ErrorMessage::cryptPassword(1)); } }
public static function menuIsActive() { if (!Session::getNested('active_menu', 'menu_id')) { // destroy session // Session::destroy(); // // create error message Session::add('feedback_errors', ErrorMessage::get('MENU_NOT_ACTIVE')); // redirect to menu selection screen header('Location: ' . URL_WITH_INDEX_FILE . 'menumanager/managemenus'); exit; } }
/** * Searches for error in the config errors array and returns the matching error description * Usage - ErrorMessage::get('ERROR_FIELD_IS_EMPTY'); * * @param [type] $key [description] * @return [type] [description] */ public static function get($key) { if (!$key) { return null; } // require Errors.php file which returns an array containing all possible error messages if (!self::$text) { self::$text = (require 'application/config/Errors.php'); } // check if array key exists if (!array_key_exists($key, self::$text)) { return null; } // return error message to requestor return self::$text[$key]; }
/** * Runs validation on login-form input fields * * @param array $postData * @return boolean */ public function validateLoginForm($postData) { if (empty($postData['username']) or empty($postData['password'])) { Session::add('feedback_errors', ErrorMessage::get('ERROR_FIELD_IS_EMPTY')); return false; } else { // attempt to retrieve username and password from database by selecting a row using client supplied username $dbResult = $this->retrieveCredentials($postData['username']); // a row containing client supplied username was found and the client supplied password matches the bcrypt hash of the password from the database if ($dbResult and password_verify($postData['password'], $dbResult['password'])) { // store account id to session Session::set('account_id', $dbResult['account_id']); return true; } else { Session::add('feedback_errors', ErrorMessage::get('ERROR_INVALID_CREDENTIALS')); return false; } } }
public function check($method, $array) { global $userManager; if ($this->check_exception($this->file, $method, $this->env)) { return true; } $token_is_valid = false; if (count($array) == 0) { $token_is_valid = true; } if (array_key_exists($this->token_name, $array)) { if ($array[$this->token_name] == $this->token) { $token_is_valid = true; } } if (!$token_is_valid && $userManager->loggedIn()) { echo ErrorMessage::setText('An error occured. Please reload this page.', true); //echo 'An error occured. Please reload this page.'; exit; } return false; }
public function getManagerOf($module) { //Si on n'a jamais instancié ce manager if (!isset($this->managers[$module])) { //Génère le nom de la classe à appeler $namespace = '\\' . $this->app()->name() . '\\Model\\' . ucFirst($module) . 'Manager'; //Génère le nom du fichier à inclure $file = '../../Applications' . str_replace('\\', '/', $namespace) . '.class.php'; if (file_exists($file)) { //Recupération de la configuration de la pdo $pdo = $this->app()->config()->get('pdo'); if (isset($pdo['dao'], $pdo['host'], $pdo['db'], $pdo['user'], $pdo['password'])) { $method = 'get' . ucFirst($pdo['dao']) . 'Connexion'; $this->managers[$module] = new $namespace(PDOFactory::$method($pdo['host'], $pdo['db'], $pdo['user'], $pdo['password'])); } else { throw new \Exception(ErrorMessage::managers(1, $this->app()->config()->file())); } } else { throw new \Exception(ErrorMessage::managers(0, $file)); } } return $this->managers[$module]; }
public function createSignage($parameter) { // store recipe id in the session of the recipe item that client wants to generate signage for Session::set('recipe_generate_signage', $parameter); // create message letting user know that they have been redirected Session::add('feedback_errors', ErrorMessage::get('GENERATE_SIGNAGE_FOR_RECIPE')); // redirect user to signage Helper::redirect('signagegenerator/premade'); }
/** @brief Composes a message in the format: <pre> file_name (line_no): message </pre> @developer Arnia Software @return @param $file @param $line_no @param $message @access */ public function __construct($file, $line_no, $message) { parent::__construct("{$file}({$line_no}):\n\t{$message}"); $this->xml_file = $file; $this->xml_line_no = $line_no; $this->xml_message = $message; }
/** * Form on user edit page * @param $FH FormHandler of the page * @param $mode add or edit mode */ function _mail_baseEdit($FH, $mode) { $attrs = getMailAttributes(); $f = new DivForModule(_T("Mail properties", "mail"), "#FFD"); // Show plugin details by default $show = true; // User has not mail attributes by default $hasMail = false; // User is not disabled by default $disabledMail = false; if ($mode == "edit") { // check user actual values $uid = $FH->getArrayOrPostValue('uid'); if (hasMailObjectClass($uid)) { $hasMail = true; } else { $show = false; } if ($FH->getArrayOrPostValue($attrs['mailenable']) == "NONE") { $disabledMail = true; // Display an error message on top of the page $em = new ErrorMessage(_T("Mail properties", "samba") . ' : ' . _T("Mail delivery is disabled", "samba")); $em->display(); } } if ($mode == "add" && $FH->getValue('mailaccess') == 'off') { $show = false; } $f->push(new Table()); $f->add(new TrFormElement(_T("Mail access", "mail"), new CheckboxTpl("mailaccess")), array("value" => $show ? "checked" : "", "extraArg" => 'onclick="toggleVisibility(\'maildiv\');"')); $f->pop(); $maildiv = new Div(array("id" => "maildiv")); $maildiv->setVisibility($show); $f->push($maildiv); $f->push(new Table()); $f->add(new TrFormElement(_T("Mail delivery is disabled, if checked", "mail"), new CheckboxTpl("maildisable")), array("value" => $disabledMail ? "checked" : "")); $f->add(new TrFormElement(_T("Mail quota (in kB)", "mail"), new QuotaTpl($attrs['mailuserquota'], '/^[0-9]*$/')), array("value" => $FH->getArrayOrPostValue($attrs['mailuserquota']))); $f->pop(); if (hasVDomainSupport()) { $m = new MultipleInputTpl("maildrop", _T("Forward to", "mail")); /* In virtual domain mode, maildrop must be an email address */ $m->setRegexp('/^[0-9a-zA-Z_.+\\-]+@[0-9a-zA-Z.\\-]+$/'); } else { $m = new MultipleInputTpl($attrs['maildrop'], _T("Mail drop", "mail")); $m->setRegexp('/^([0-9a-zA-Z_.+@\\-])+$/'); } $f->add(new FormElement(_T("Mail drop", "mail"), $m), $FH->getArrayOrPostValue($attrs['maildrop'], 'array')); $m = new MultipleInputTpl($attrs['mailalias'], _T("Mail alias", "mail")); $m->setRegexp('/^([0-9a-zA-Z@_.+\\-])+$/'); $f->add(new FormElement(_T("Mail alias", "mail"), $m), $FH->getArrayOrPostValue($attrs['mailalias'], 'array')); if (hasVDomainSupport()) { $f->push(new DivExpertMode()); $f->push(new Table()); $f->add(new TrFormElement(_T("Mail delivery path", "mail"), new InputTpl($attrs['mailbox'])), array("value" => $FH->getArrayOrPostValue($attrs['mailbox']))); $f->add(new TrFormElement(_T("Mail server host", "mail"), new IA5InputTpl($attrs['mailhost'])), array("value" => $FH->getArrayOrPostValue($attrs['mailhost']))); $f->pop(); $f->pop(); } if (hasZarafaSupport()) { $f->push(new DivForModule(_T("Zarafa properties", "mail"), "#FFD")); $f->push(new Table()); $checked = false; if ($FH->getArrayOrPostValue('zarafaAdmin') == "on" || $FH->getArrayOrPostValue('zarafaAdmin') == "1") { $checked = true; } $f->add(new TrFormElement(_T("Administrator of Zarafa", "mail"), new CheckboxTpl("zarafaAdmin")), array("value" => $checked ? "checked" : "")); $checked = false; if ($FH->getArrayOrPostValue('zarafaSharedStoreOnly') == "on" || $FH->getArrayOrPostValue('zarafaSharedStoreOnly') == "1") { $checked = true; } $f->add(new TrFormElement(_T("Shared store", "mail"), new CheckboxTpl("zarafaSharedStoreOnly")), array("value" => $checked ? "checked" : "")); $checked = false; if ($FH->getArrayOrPostValue('zarafaAccount') == "on" || $FH->getArrayOrPostValue('zarafaAccount') == "1") { $checked = true; } $f->add(new TrFormElement(_T("Zarafa account", "mail"), new CheckboxTpl("zarafaAccount")), array("value" => $checked == "on" ? "checked" : "")); $checked = false; if ($FH->getArrayOrPostValue('zarafaHidden') == "on" || $FH->getArrayOrPostValue('zarafaHidden') == "1") { $checked = true; } $f->add(new TrFormElement(_T("Hide from Zarafa address book", "mail"), new CheckboxTpl("zarafaHidden")), array("value" => $checked ? "checked" : "")); $f->pop(); $sendas = new MultipleInputTpl("zarafaSendAsPrivilege", _T("Zarafa send as user list", "mail")); $sendas->setRegexp('/^([0-9a-zA-Z@_.\\-])+$/'); $f->add(new FormElement("", $sendas), $FH->getArrayOrPostValue("zarafaSendAsPrivilege", "array")); $f->pop(); } $f->pop(); if ($mode == 'add' && !hasVDomainSupport()) { //suggest only on add user ?> <script type="text/javascript" language="javascript"> var autoCreate = function(e) { $('maildrop[0]').value = $F('uid').toLowerCase(); }; Event.observe(window, 'load', function() { $('uid').observe('keyup', autoCreate); }); </script> <?php } return $f; }
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Error Messages</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="bg-danger message-box"> <?php include './models/IMessage.php'; include './models/Message.php'; include './models/ErrorMessage.php'; $errorMessage = new ErrorMessage(); $errorMessage->addMessage('test', 'my test message'); var_dump($errorMessage->getAllMessages()); var_dump($errorMessage instanceof IMessage); var_dump($errorMessage->removeMessage('test')); var_dump($errorMessage->getAllMessages()); ?> </div> </body> </html>
<?php require 'base.php'; require LANGS . 'ForumT.php'; ForumT::init(); $topic = ForumTopic::fromID((int) $_GET['id']); if (!$topic instanceof ForumTopic) { echo ErrorMessage::setText(ForumT::get('topic_doesnt_exist'), true); } $forum = $topic->getForum(); $posts = $topic->getPosts(Config::get('max_posts_perpage'), max((int) $_GET['page'], 1)); Templates::assignVars(array('forum' => $forum, 'topic' => $topic, 'posts' => $posts['posts'], 'pages' => $posts['pages'])); PluginHelper::delegate('__onPageDisplay', array($page)); Templates::display('viewtopic');
/** * Sets the menu as active by storing menu name in session * @return [type] [description] */ public function activateMenu($parameter) { // instantiate model $MenuManagerModel = new MenuManagerModel(); // retrieve data $menuName = $MenuManagerModel->retrieveMenuName($parameter); // flatten array by one level $menuName = call_user_func_array('array_merge', $menuName); Session::set('active_menu', $menuName); Session::add('feedback_errors', ErrorMessage::get('MENU_ACTIVATED')); Helper::redirect('menumanager/managemenus'); }
function __toString() { return '!!!' . parent::__toString(); }
<?php require '../base.php'; ob_start(); require LANGS . 'ACPDashboardT.php'; ACPDashboardT::init(); require LIB . 'forum/Forum.php'; if (!$userManager->loggedIn() || !$user->isAdmin()) { echo ErrorMessage::setText('You are not allowed to view this page.', true); } include 'template/header.php'; echo ' <h1> Dashboard </h1> <section class="statistics"> <div class="row"> <div class="item"> <span>' . Forum::getTotalTopics() . '</span> ' . ACPDashboardT::get('topics') . ' </div> <div class="item"> <span>' . Forum::getTotalPosts() . '</span> ' . ACPDashboardT::get('posts') . ' </div> <div class="item"> <span>' . User::getTotalUsers() . '</span> ' . ACPDashboardT::get('members') . '
<?php Templates::display('header'); ?> <?php if ($errorMessage) { ?> <?php echo ErrorMessage::setText($errorMessage); ?> <?php } ?> <div id="login"> <h1>Welcome back!</h1> <form method="post" action=""> <input type="text" name="username" placeholder="Username" /> <input type="password" name="password" placeholder="Password" /> <input type="submit" name="submit" value="Login" /> </form> </div> <?php Templates::display('footer');
</div> </div>'; } else { $objprocess['process'] = $scriptmulticast; if (xmlrpc_check_process_multicast($objprocess)) { // if /tmp/multicast.sh is running then stoping $objprocess['process'] = $scriptmulticast; xmlrpc_stop_process_multicast($objprocess); $objprocess['process'] = $path . $scriptmulticast; xmlrpc_clear_script_multicast($objprocess); } } ?> <div class="spacer"></div> <h3 class="activity"><?php echo _T('Recent activity', 'imaging'); ?> </h3> <?php $ajax = new AjaxFilter("modules/imaging/manage/ajaxLogs.php", "container_logs", array(), "Logs"); //$ajax->setRefresh(10000); $ajax->display(); echo "<br/><br/><br/>"; $ajax->displayDivToUpdate(); } else { $e = new ErrorMessage(_T("Can't connect to the imaging server linked to the selected entity.", "imaging")); print $e->display(); } require "../includes/ajaxcommon_bottom.inc.php";
require_once "modules/base/includes/computers.inc.php"; $err = false; if (isset($_POST["bcreate"])) { if (checkComputerName($_POST["computername"])) { if (isComputerNameAvailable($_POST["location_uuid"], $_POST["computername"])) { addComputer($_POST); if (!isXMLRPCError()) { new NotifyWidgetSuccess(_("Computer successfully added")); header("Location: " . urlStrRedirect("base/computers/index")); exit; } } else { $err = new ErrorMessage(_("The computer name is already taken.")); } } else { $err = new ErrorMessage(_("Invalid computer name.")); } } $p = new PageGenerator(); if ($_GET["action"] == "add") { $title = _("Add a computer"); } else { $title = _("Edit a computer"); $sidemenu->forceActiveItem("index"); } $p->setTitle($title); $p->setSideMenu($sidemenu); $p->display(); if ($err) { $err->display(); }
/** * Form on user edit page * @param $FH FormHandler of the page * @param $mode add or edit mode */ function _samba_baseEdit($FH, $mode) { // default values $hasSmb = false; $show = true; // get smb config info $smbInfo = xmlCall("samba.getSmbInfo", null); // fetch ldap updated info if we can if ($mode == 'edit') { $uid = $FH->getArrayOrPostValue("uid"); if (hasSmbAttr($uid)) { $hasSmb = true; } else { $show = false; } // show Samba plugin in case of error if ($FH->getValue("isSamba") == "on") { $show = true; } } else { if ($FH->getValue("isSamba") == "off") { $show = false; } } if ($hasSmb && userPasswdHasExpired($uid)) { $em = new ErrorMessage(_T("Samba properties", "samba") . ' : ' . _T("The password of this account has expired.", "samba")); $em->display(); } if ($hasSmb && isLockedUser($uid)) { $em = new ErrorMessage(_T("Samba properties", "samba") . ' : ' . _T("This account is locked.", "samba")); $em->display(); } $f = new DivForModule(_T("Samba properties", "samba"), "#EFE"); $f->push(new Table()); $f->add(new TrFormElement(_T("Samba access", "samba"), new CheckboxTpl("isSamba")), array("value" => $show ? "checked" : "", "extraArg" => 'onclick="toggleVisibility(\'smbdiv\');"')); $f->pop(); $smbdiv = new Div(array("id" => "smbdiv")); $smbdiv->setVisibility($show); $f->push($smbdiv); $f->push(new Table()); $checked = ""; if ($hasSmb && !isEnabledUser($uid) || $FH->getArrayOrPostValue('isSmbDesactive') == 'on') { $checked = "checked"; // Display an error message on top of the page $em = new ErrorMessage(_T("Samba properties", "samba") . ' : ' . _T("This account is disabled", "samba")); $em->display(); } $f->add(new TrFormElement(_T("User is disabled, if checked", "samba"), new CheckboxTpl("isSmbDesactive"), array("tooltip" => _T("Disable samba user account", 'samba'))), array("value" => $checked)); $checked = ""; if ($hasSmb && isLockedUser($uid) || $FH->getArrayOrPostValue('isSmbLocked') == 'on') { $checked = "checked"; } $f->add(new TrFormElement(_T("User is locked, if checked", "samba"), new CheckboxTpl("isSmbLocked"), array("tooltip" => _T("Lock samba user access<p>User can be locked after too many failed log.</p>", 'samba'))), array("value" => $checked)); # display this options only if we are PDC if ($smbInfo["pdc"]) { # if no global profile set, we can set a roaming profile for this user if (!$smbInfo["logon path"]) { $hasProfile = false; $checked = ""; $value = ""; if ($FH->getArrayOrPostValue("sambaProfilePath")) { $hasProfile = true; $checked = "checked"; $value = $FH->getArrayOrPostValue('sambaProfilePath'); } $f->add(new TrFormElement(_T("Use network profile, if checked", "samba"), new CheckboxTpl("hasProfile")), array("value" => $checked, "extraArg" => 'onclick="toggleVisibility(\'pathdiv\')"')); $f->pop(); $pathdiv = new Div(array('id' => 'pathdiv')); $pathdiv->setVisibility($hasProfile); $f->push($pathdiv); $f->push(new Table()); $f->add(new TrFormElement(_T("Network path for user's profile", "samba"), new InputTpl("sambaProfilePath")), array("value" => $value)); $f->pop(); $f->pop(); $f->push(new Table()); } $checked = ""; if (($FH->getArrayOrPostValue('sambaPwdMustChange') == "0" || $FH->getArrayOrPostValue('sambaPwdMustChange') == "on") && $FH->getArrayOrPostValue('sambaPwdLastSet') == "0") { $checked = "checked"; } $f->add(new TrFormElement(_T("User must change password on next logon, <br/>if checked", "samba"), new CheckboxTpl("sambaPwdMustChange")), array("value" => $checked)); $value = ""; if ($FH->getArrayOrPostValue('sambaKickoffTime')) { $value = strftime("%Y-%m-%d %H:%M:%S", $FH->getArrayOrPostValue('sambaKickoffTime')); } $f->add(new TrFormElement(_T("Account expiration", "samba"), new DynamicDateTpl("sambaKickoffTime"), array("tooltip" => _T("Specifies the date when the user will be locked down and cannot login any longer. If this attribute is omitted, then the account will never expire.", 'samba'))), array("value" => $value, "ask_for_never" => 1)); $f->pop(); // Expert mode display $f->push(new DivExpertMode()); $f->push(new Table()); $d = array(_T("Opening script session", "samba") => "sambaLogonScript", _T("Base directory path", "samba") => "sambaHomePath", _T("Connect base directory on network drive", "samba") => "sambaHomeDrive"); foreach ($d as $description => $field) { $f->add(new TrFormElement($description, new InputTpl($field)), array("value" => $FH->getArrayOrPostValue($field))); } $f->pop(); } $f->pop(); $f->pop(); return $f; }
<html> <head> <meta charset="UTF-8"> <title></title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> </head> <body> <div class="bg-danger"> <?php include './models/IMessage.php'; include './models/Message.php'; include './models/ErrorMessage.php'; $errorMessage = new ErrorMessage(); $errorMessage->addMessage('test', 'this is my test msg!'); var_dump($errorMessage->getAllMessages()); echo '<br/>'; var_dump($errorMessage instanceof Imessage); echo '<br/>'; var_dump($errorMessage->removeMessage('test')); echo '<br/>'; var_dump($errorMessage->getAllMessages()); echo '<br/>'; ?> </div> </body> </html>
public function getUrl($module, $action, $vars = array()) { $found = false; $url = ""; foreach ($this->config->getList('route') as $route) { if (strtolower($module) == strtolower($route['module']) && strtolower($action) == strtolower($route['action'])) { $url = $route['url']; if (isset($route['vars'])) { $varsName = explode(',', $route['vars']); } else { $varsName = array(); } if (sizeof($varsName) == sizeof($vars)) { $url = preg_replace("#\\\\#", "", $url); foreach ($vars as $var) { $url = preg_replace("#\\(.+\\)#", $var, $url, 1); } $found = true; break; } //else // throw new \Exception(ErrorMessage::router(2)); } } if (!$found) { throw new \Exception(ErrorMessage::router(2)); } return $url; }
echo ' <h1>' . $plugin->getTitle() . ' Settings</h1> '; $pluginSettings = $plugin->__onCreateSettings(); if (!$pluginSettings instanceof SettingsContainer) { echo InfoMessage::setText('This plugin does not have any settings.'); } else { $pluginSettingsPreferences = $pluginSettings->__onCreate($plugin, $db); if (!is_array($pluginSettingsPreferences) || count($pluginSettingsPreferences) < 1) { echo InfoMessage::setText('This plugin does not have any settings.'); } else { if (isset($_POST['submit'])) { if ($pluginSettings->__onSave()) { echo SuccessMessage::setText('Settings saved.'); } else { echo ErrorMessage::setText('Could not save settings.'); } } echo ' <div class="preferences"> <form method="post" action=""> <ul> '; foreach ($pluginSettingsPreferences as $pref) { if (!$pref instanceof Preference) { continue; } if ($pref instanceof PreferenceCategory) { echo ' <li class="category"> <h3>' . $pref->getTitle() . '</h3>
/** * Form on user edit page * @param $FH FormHandler of the page * @param $mode add or edit mode */ function _ppolicy_baseEdit($FH, $mode) { $f = new DivForModule(_T("Password policy management", "ppolicy"), "#FDF"); // default values $hasPPolicy = false; $pwdReset = false; $ppolicyName = ""; $default = getDefaultPPolicyName(); if ($mode == "edit") { $uid = $FH->getArrayOrPostValue('uid'); if (hasUserPPolicy($uid)) { $hasPPolicy = true; $ppolicyName = getUserPPolicy($uid); } if (passwordHasBeenReset($uid)) { $pwdReset = true; } } $f->push(new Table()); if ($mode == "edit") { $pwdLock = false; if (isAccountLocked($uid) != "0") { $pwdLock = true; // Display an error message on top of the page $em = new ErrorMessage(_T("Password policy management", "ppolicy") . ' : ' . _T("This account is locked by the LDAP directory.", "ppolicy")); $em->display(); } $pwdExpired = isPasswordExpired($uid); $nbGraceLogins = isAccountInGraceLogin($uid); if ($pwdExpired && in_array($nbGraceLogins, array(0, 1))) { // Display an error message on top of the page $em = new ErrorMessage(_T("Password policy management", "ppolicy") . ' : ' . _T("The password of this account has expired. The user cannot change his password.", "ppolicy")); $em->display(); } if ($pwdExpired && ($nbGraceLogins == -1 || $nbGraceLogins > 1)) { if ($nbGraceLogins > 1) { // Display an error message on top of the page $em = new ErrorMessage(_T("Password policy management", "ppolicy") . ' : ' . sprintf(_T("The password of this account has expired. The user has %s login(s) left to change his password.", "ppolicy"), $nbGraceLogins)); } else { // Display an error message on top of the page $em = new ErrorMessage(_T("Password policy management", "ppolicy") . ' : ' . _T("The password of this account has expired. The user can change his password.", "ppolicy")); } $em->display(); } $f->add(new TrFormElement(_T("Lock account", "ppolicy"), new CheckboxTpl("pwdLock"), array("tooltip" => _T("If checked, permanently lock the user account", "ppolicy"))), array("value" => $pwdLock ? "checked" : "")); } $f->add(new TrFormElement(_T("Password reset flag", "ppolicy"), new CheckboxTpl("pwdReset"), array("tooltip" => _T("If checked, the user must change her password when she first binds to the LDAP directory after password is set or reset by a password administrator", "ppolicy"))), array("value" => $pwdReset ? "checked" : "")); $ppolicyList = listPPolicy(); if (count($ppolicyList) > 1) { $ppolicyTpl = new SelectItem("ppolicyname"); foreach ($ppolicyList as $pp) { $name = $pp[1]['cn'][0]; if (isset($pp[1]['description'][0])) { $desc = $pp[1]['description'][0]; } else { $desc = $name; } if ($name == $default) { $name = ""; $desc = _T($desc, "ppolicy"); } $values[$desc] = $name; } $ppolicyTpl->setElements(array_keys($values)); $ppolicyTpl->setElementsVal(array_values($values)); $f->add(new TrFormElement(_T("Enable a specific password policy for this user", "ppolicy"), $ppolicyTpl, array("tooltip" => _T("If not set the default password policy is enforced.", "ppolicy"))), array("value" => $ppolicyName)); } $f->pop(); return $f; }