/** * Form on user edit page * @param $FH FormHandler of the page * @param $mode add or edit mode */ function _sshlpk_baseEdit($FH, $mode) { // default value $show = false; if ($mode == 'edit' && hasSshKeyObjectClass($FH->getArrayOrPostValue("uid"))) { $show = true; } else { if ($FH->getValue("showsshkey") == "on") { $show = true; } } $f = new DivForModule(_T("Public SSH keys management", "sshlpk"), "#DDF"); $f->push(new Table()); $f->add(new TrFormElement(_T("Enable SSH keys management", "sshlpk"), new CheckboxTpl("showsshkey")), array("value" => $show ? "checked" : "", "extraArg" => 'onclick="toggleVisibility(\'sshkeydiv\');"')); $f->pop(); $sshkeydiv = new Div(array("id" => "sshkeydiv")); $sshkeydiv->setVisibility($show); $f->push($sshkeydiv); $sshkeylist = array(); if ($FH->getArrayOrPostValue("uid")) { if ($show && $mode == "edit") { $sshkeylist = getAllSshKey($FH->getArrayOrPostValue("uid")); } } if (count($sshkeylist) == 0) { $sshkeylist = array("0" => ""); } $f->add(new TrFormElement('', new MultipleInputTpl("sshkeylist", _T("Public SSH Key", "sshlpk"))), $sshkeylist); $f->pop(); return $f; }
/** * Form on user edit page * @param $FH FormHandler of the page * @param $mode add or edit mode */ function _radius_baseEdit($FH, $mode) { // default value $show = false; if ($mode == 'edit' && hasRadiusObjectClass($FH->getArrayOrPostValue("uid"))) { $show = true; } else { if ($FH->getValue("showradius") == "on") { $show = true; } } $f = new DivForModule(_T("Radius management", "radius"), "#E0FFDF"); $f->push(new Table()); $f->add(new TrFormElement(_T("Enable Radius management", "radius"), new CheckboxTpl("showradius")), array("value" => $show ? "checked" : "", "extraArg" => 'onclick="toggleVisibility(\'radiusdiv\');"')); $f->pop(); $radiusdiv = new Div(array("id" => "radiusdiv")); $radiusdiv->setVisibility($show); $f->push($radiusdiv); $radiusCallingStationId = $FH->getArrayOrPostValue('radiusCallingStationId', 'array'); $f->add(new TrFormElement('', new MultipleInputTpl("radiusCallingStationId", _T("Calling Station ID", "radius"))), $radiusCallingStationId); $f->pop(); return $f; }
/** * Form on user edit page * @param $FH FormHandler of the page * @param $mode add or edit mode */ function _base_baseEdit($FH, $mode) { $uid = $FH->getArrayOrPostValue("uid"); $f = new DivForModule(_("User attributes"), "#F4F4F4"); $f->push(new Table()); if ($mode == "add") { $loginTpl = new InputTpl("uid", '/^[a-zA-Z0-9][A-Za-z0-9_.\\-]*$/'); } else { $loginTpl = new HiddenTpl("uid"); } $f->add(new TrFormElement(_("Login") . "*", $loginTpl), array("value" => $uid)); /*if($mode == "edit") { $lastlog = get_last_log_user($uid); if ($lastlog[0] != 0) { $f->add( new LinkTrFormElement(_("Last action"), new HiddenTpl("lastaction")), array("value" => urlStr("base/users/loguser", array("user" => $uid)), "name" => $lastlog[1][0]["date"]) ); } }*/ $f->add(new TrFormElement(_("Password") . "*", new PasswordTpl("pass")), array("value" => "")); $f->add(new TrFormElement(_("Confirm password") . "*", new PasswordTpl("confpass")), array("value" => "")); $f->add(new TrFormElement(_("Photo"), new ImageTpl("jpegPhoto")), array("value" => $FH->getArrayOrPostValue("jpegPhoto"), "action" => $mode)); $f->add(new TrFormElement(_("Last name") . "*", new InputTpl("sn")), array("value" => $FH->getArrayOrPostValue("sn"))); $f->add(new TrFormElement(_("First name") . "*", new InputTpl("givenName")), array("value" => $FH->getArrayOrPostValue("givenName"))); $f->add(new TrFormElement(_("Title") . "*", new InputTpl("title")), array("value" => $FH->getArrayOrPostValue("title"))); $f->add(new TrFormElement(_("Email address"), new MailInputTpl("mail")), array("value" => $FH->getArrayOrPostValue("mail"))); $f->pop(); $phoneregexp = "/^[a-zA-Z0-9(/ +\\-]*\$/"; $tn = new MultipleInputTpl("telephoneNumber", _("Telephone number")); $tn->setRegexp($phoneregexp); $f->add(new FormElement(_("Telephone number"), $tn), $FH->getArrayOrPostValue("telephoneNumber", "array")); $f->push(new Table()); $f->add(new TrFormElement(_("Mobile number"), new InputTpl("mobile", $phoneregexp)), array("value" => $FH->getArrayOrPostValue("mobile"))); $f->add(new TrFormElement(_("Fax number"), new InputTpl("facsimileTelephoneNumber", $phoneregexp)), array("value" => $FH->getArrayOrPostValue("facsimileTelephoneNumber"))); $f->add(new TrFormElement(_("Home phone number"), new InputTpl("homePhone", $phoneregexp)), array("value" => $FH->getArrayOrPostValue("homePhone"))); $languages = new SelectItem("preferredLanguage"); $labels = array(_("Choose language")) + array_values(getLanguages()); $values = array("") + array_keys(getLanguages()); $languages->setElements($labels); $languages->setElementsVal($values); $f->add(new TrFormElement(_("Preferred language"), $languages), array("value" => $FH->getArrayOrPostValue("preferredLanguage"))); $checked = "checked"; if ($FH->getArrayOrPostValue("loginShell") != '/bin/false') { $checked = ""; } $f->add(new TrFormElement(_("Disable user's shell"), new CheckboxTpl("isBaseDesactive"), array("tooltip" => _("A disabled user can't log in any UNIX services.<br/>\n His login shell command is replaced by /bin/false"))), array("value" => $checked)); /* Primary group */ $groupsTpl = new SelectItem("primary"); $all_groups = search_groups(); $groups = array(); foreach ($all_groups as $key => $infos) { $groups[] = $infos[0]; } $groupsTpl->setElements($groups); if ($mode == "add") { $primary = getUserDefaultPrimaryGroup(); } else { if ($mode == "edit") { /* In case of error, display the POST values */ if ($FH->isUpdated("primary")) { $primary = $FH->getValue("primary"); } else { $primary = getUserPrimaryGroup($uid); /* If the group is not an LDAP group */ if (!in_array($primary, $groups)) { $primaryGroups = $groups; $primaryGroups[] = $primary; $groupsTpl->setElements($primaryGroups); } } } } $f->add(new TrFormElement(_("Primary group"), $groupsTpl), array("value" => $primary)); /* Secondary groups */ $groupsTpl = new MembersTpl("secondary"); $groupsTpl->setTitle(_("User's groups"), _("All groups")); // get the user's groups /* In case of error, display the POST values */ if ($FH->getPostValue("secondary")) { $user_groups = $FH->getPostValue("secondary"); } else { if ($mode == 'edit') { $user_groups = getUserSecondaryGroups($uid); } else { $user_groups = array(); } } $member = array(); foreach ($user_groups as $group) { $member[$group] = $group; } // get all groups $available = array(); foreach ($groups as $group) { if (!in_array($group, $member)) { $available[$group] = $group; } } $f->add(new TrFormElement(_("Secondary groups"), $groupsTpl), array("member" => $member, "available" => $available)); $f->pop(); $f->push(new DivExpertMode()); $f->push(new Table()); $f->add(new TrFormElement(_("Home directory"), new InputTpl("homeDirectory")), array("value" => $FH->getArrayOrPostValue("homeDirectory"))); if ($mode == "add") { $f->add(new TrFormElement(_("Create home directory on filesystem"), new CheckboxTpl("createHomeDir")), array("value" => "checked")); $f->add(new TrFormElement(_("Force to use the home directory if it exists"), new CheckboxTpl("ownHomeDir"), array("tooltip" => _("Warning: an existing directory may belong to another user !"))), array("value" => "")); } $f->add(new TrFormElement(_("Login shell"), new InputTpl("loginShell")), array("value" => $FH->getArrayOrPostValue("loginShell"))); $f->add(new TrFormElement(_("Common name"), new InputTpl("cn"), array("tooltip" => _("This field is used by some LDAP clients (for example Thunderbird address book) to display user entries."))), array("value" => $FH->getArrayOrPostValue("cn"))); $f->add(new TrFormElement(_("Preferred name to be used"), new InputTpl("displayName"), array("tooltip" => _("This field is used by SAMBA (and other LDAP clients) to display user name."))), array("value" => $FH->getArrayOrPostValue("displayName"))); if ($mode == "edit") { $f->add(new TrFormElement(_("UID"), new HiddenTpl("uidNumber")), array("value" => $FH->getArrayOrPostValue("uidNumber"))); $f->add(new TrFormElement(_("GID"), new HiddenTpl("gidNumber")), array("value" => $FH->getArrayOrPostValue("gidNumber"))); } $f->pop(); $f->pop(); return $f; }
/** * 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; }
/** * 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; }
/** * Function called when editing a group */ function _ppolicy_baseGroupEdit($ldapArr, $postArr) { if (!isset($ldapArr["cn"][0])) { return; } $default = getDefaultPPolicyName(); $f = new DivForModule(_T("Password policy management", "ppolicy"), "#FDF"); $f->push(new Table()); $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("Apply a password policy for all group users", "ppolicy"), $ppolicyTpl, array("tooltip" => _T("If not set the default password policy is enforced.", "ppolicy"))), array("value" => $ppolicyName)); } $f->pop(); $f->display(); }
function _samba4_baseEdit($FH, $mode) { $form = new DivForModule(_T("Samba4 properties", "samba4"), "#F3E2F2"); if (!isSamba4Provisioned()) { $form->setVisibility(False); } $username = $FH->getArrayOrPostValue("uid"); if (!$username) { $form->setVisibility(False); } $form->push(new Table()); $tr = new TrFormElement(_T("Samba access", "samba"), new CheckboxTpl("isSamba4")); $form->add($tr, array("value" => userHasSambaEnabled($username) ? "checked" : "")); $form->pop(); return $form; }