setVar("tpl_groups", array()); } } global $__TPLref; $__TPLref["autocomplete"] = "admin"; renderTPL("groups"); ?> </table> <?php if (!isset($customParameters) || empty($customParameters)) { $customParameters = array(''); } $cp = new MultipleInputTpl("customparameters", _("Custom parameters")); $cp->setRegexp('/^[a-z: _]+[ ]*=.*$/'); $cpf = new FormElement(_("Custom parameters"), $cp); $cpf->display($customParameters); ?> </div> <?php if ($_GET["action"] == "add") { ?> <input name="bcreate" type="submit" class="btnPrimary" value="<?php echo _T("Create"); ?> " /> <?php } else {
/** * 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; }
} } } $a = array("value" => $network, "required" => True); $a["zone"] = $zone; $a["ajaxurl"] = "ajaxDnsGetZoneFreeIp"; $formElt = new GetFreeIPInputTpl(); } else { if ($_GET["action"] == "addhost") { $a = array("value" => "", "required" => True); $formElt = new IPInputTpl("ipaddress"); } else { $a = array("value" => $ipaddress); $formElt = new HiddenTpl("ipaddress"); } } $f->add(new TrFormElement(_T("Network address"), $formElt), $a); $f->pop(); if ($_GET["action"] == "addhost") { $f->addButton("badd", _("Create")); } else { /* On edit mode, the user can setup host aliases */ $m = new MultipleInputTpl("hostalias", _T("Hostname alias")); $m->setRegexp('/^[a-z][a-z0-9-]*[a-z0-9]$/'); if (empty($cnames)) { $cnames = array(""); } $f->add(new FormElement(_T("Hostname alias"), $m), $cnames); $f->addValidateButton("bedit"); } $f->display();
$description = $zones[0][1]["tXTRecord"][0]; } $f = new ValidatingForm(); $f->push(new Table()); if ($_GET["action"] == "add") { $formElt1 = new DomainInputTpl("zonename"); $formElt2 = new HostnameInputTpl("nameserver"); $nameserver = "ns"; } else { $formElt1 = new HiddenTpl("zonename"); $formElt2 = new DomainInputTpl("nameserver"); $formElt3 = new MultipleInputTpl("nameservers", _T("Secondary name servers")); $formElt3->setRegexp($formElt2->regexp); $formElt4 = new MultipleInputTpl("mxservers", _T("MX records (SMTP servers)")); $tmp = new MXRecordInputTpl("mx"); $formElt4->setRegexp($tmp->regexp); } $f->add(new TrFormElement(_T("DNS zone FQDN"), $formElt1), array("value" => $zonename, "required" => True)); $f->add(new TrFormElement(_T("Description"), new IA5InputTpl("description")), array("value" => $description)); $f->add(new TrFormElement(_T("Primary name server host name"), $formElt2, array("tooltip" => _T("The primary name server for this zone. The host must exists in zone (A record)."))), array("value" => $nameserver, "required" => True)); if ($_GET["action"] == "add") { $f->add(new TrFormElement(_T("Name server IP"), new IPInputTpl("nameserverip")), array("value" => "")); $f->pop(); $f->push(new Table()); if (hasDHCP()) { $f->add(new TrFormElement(_T("The network address and mask fields must be filled in if you also want to create a reverse zone or a DHCP subnet linked to this DNS zone."), new HiddenTpl(""))); } else { $f->add(new TrFormElement(_T("The network address and mask fields must be filled in if you also want to create a reverse zone."), new HiddenTpl(""))); } $f->add(new TrFormElement(_T("Network address"), new IPInputTpl("netaddress")), array("value" => $netaddress)); $f->add(new TrFormElement(_T("Network mask"), new NetmaskInputTpl("netmask")), array("value" => $netmask, "extra" => _T("(e.g. 24 for a /24 network)")));
require_once "../FormGenerator.php"; if (isset($_POST[$name])) { $arr = $_POST[$name]; } else { $arr = array(); } if (isset($_POST['del'])) { if (count($arr) > 1) { unset($arr[$_POST['del']]); } else { if (count($arr) == 1) { $arr[$_POST['del']] = ''; } } } else { $arr[] = ''; } $arr = array_values($arr); global $aclArray; if (!isset($aclArray)) { /* * When this template is reloaded, we loose $aclArray, and this triggesr a PHP warning on some PHP version. * We can safely set it to an empty array. */ $aclArray = array(); } $mtpl = new MultipleInputTpl($name, urldecode($_POST['desc']), true); $mtpl->setRegexp(stripslashes(rawurldecode($_POST['regexp']))); $fe = new FormElement(_T($name), $mtpl); $fe->setCssError($name); $fe->display($arr);