function _inventory_baseEdit($FH, $mode) { $username = $FH->getArrayOrPostValue("uid"); $d = new DivForModule(_T("Entity right", "inventory"), "#DDF"); $entities = getLocationAll(['min' => 0, 'filters' => array()]); $default_user_locations = array("1"); $f = new Table(); $d->push($f); if ($mode == 'edit') { $user_locations = getLocationsForUser($username); if (!count($user_locations)) { $user_locations = $default_user_locations; } } else { $user_locations = $default_user_locations; } $entities_select = new SelectItem("entitie[]"); $entity_val = array(); $entity_list = array(); foreach ($entities['data'] as $entity) { $entity_list[$entity['id']] = $entity['Labelval']; $entity_val[$entity['id']] = $entity['id']; } $entities_select->setElements($entity_list); $entities_select->setElementsVal($entity_val); $entity_valT = array(); foreach ($user_locations as $attr) { $fields = array($entities_select, new inventorybuttonTpl2('removeLine', _T('Remove', 'inventory'), 'removeLine', _T('Remove entity for user', 'inventory') . " : [" . $username . "]")); $values = array(strval($attr), ''); $f->add(new TrFormElement(_T('Entity right', 'inventory'), new multifieldTpl($fields)), array("value" => $values, "required" => True)); } // Add line button $addEntityRightBtn = new inventorybuttonTpl2('addLine', _T('Add entity right', 'inventory'), '', _T('Add entity right for user', 'inventory') . " : [" . $username . "]"); $addEntityRightBtn->setClass('btnPrimary'); $f->add(new TrFormElement('', $addEntityRightBtn), array()); print <<<EOF <script type="text/javascript"> jQuery(function(){ modelLine = jQuery('.removeLine:first').parents('tr:first').clone(); // Remove line button jQuery('.removeLine').click(function(){ if (jQuery('.removeLine').length > 1) jQuery(this).parents('tr:first').remove(); else jQuery('#entitie option[value="1"]').prop('selected', true); }); // Add line button jQuery('#addLine').click(function(){ var newline = modelLine.clone().insertBefore(jQuery(this).parents('tr:first')); newline.find('.removeLine').click(function(){ if (jQuery('.removeLine').length > 1) jQuery(this).parents('tr:first').remove(); }); }); }); </script> EOF; return $d; }
function select_locations($selected, $name = 'locations') { $sel = new SelectItem($name); list($list, $values) = getEntitiesSelectableElements(); $sel->setElements($list); $sel->setElementsVal($values); $sel->setSelected($selected); return $sel; }
function select_locations($selected, $name = 'locations') { $sel = new SelectItem($name); $list = array(); $locations = getUserLocations(); if (is_array($locations)) { foreach ($locations as $loc) { $list[$loc['uuid']] = $loc['altname']; } } else { $locations = array(); } $sel->setElements(array_values($list)); $sel->setElementsVal(array_keys($list)); $sel->setSelected($selected); return $sel; }
/** * 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; }
if ($ID && $ID < 1000) { new NotifyWidgetWarning(_T("Default profiles can't be modified. Your changes will be saved as a new profile.", 'backuppc')); $profile['profilename'] = ''; } $p->setSideMenu($sidemenu); $p->display(); // display an edit config form $f = new ValidatingForm(); $f->push(new Table()); // Profile name $f->add(new TrFormElement(_T('Name', 'backuppc'), new InputTpl('profilename')), array("value" => $profile['profilename'], "required" => True)); // Client host encoding $sel = new SelectItem("encoding"); $list = array("utf8" => 'UTF8', "cp1252" => _T('Windows-1252 - Western Europe', 'backuppc'), "cp874" => _T('Windows-874 - Thai', 'backuppc'), "cp932" => _T('Windows-932 - Japanese', 'backuppc'), "cp936" => _T('Windows-936 - Chinese (simplified)', 'backuppc'), "cp949" => _T('Windows-949 - Korean', 'backuppc'), "cp950" => _T('Windows-950 - Chinese (traditional)', 'backuppc'), "cp1250" => _T('Windows-1250 - Latin (Central Europe)', 'backuppc'), "cp1251" => _T('Windows-1251 - Cyrillic', 'backuppc'), "cp1253" => _T('Windows-1253 - Greek', 'backuppc'), "cp1254" => _T('Windows-1254 - Turkish', 'backuppc'), "cp1255" => _T('Windows-1255 - Hebrew', 'backuppc'), "cp1256" => _T('Windows-1256 - Arabic', 'backuppc'), "cp1257" => _T('Windows-1257 - Latin (Baltic languages)', 'backuppc'), "cp1258" => _T('Windows-1258 - Vietnamese', 'backuppc')); $sel->setElements(array_values($list)); $sel->setElementsVal(array_keys($list)); $sel->setSelected($profile['encoding']); $f->add(new TrFormElement(_T("Client encoding", "backuppc"), $sel, array())); // Exclude lists $sharenames = explode("\n", $profile['sharenames']); $i = 0; $profile['excludes'] = explode('||', $profile['excludes']); for ($i = 0; $i < count($sharenames); $i++) { // Fields $fields = array(new InputTpl('sharenames[]'), new textTpl(_T('Excluded files', 'backuppc')), new TextareaTpl('excludes[]'), new buttonTpl('removeShare', _T('Remove'), 'removeShare')); $values = array($sharenames[$i], '', $profile['excludes'][$i], ''); $f->add(new TrFormElement(_T('Folder', 'backuppc'), new multifieldTpl($fields)), array("value" => $values, "required" => True)); } // Add Share button $addShareBtn = new buttonTpl('addShare', _T('Add folder', 'backuppc')); $addShareBtn->setClass('btnPrimary');
$imaging_server = $config[0]; $default_menu = $config[1]; $f = new ValidatingForm(array("action" => urlStrRedirect("imaging/manage/save_configuration"))); $f->add(new HiddenTpl("is_uuid"), array("value" => $imaging_server['imaging_uuid'], "hide" => True)); $lang = xmlrpc_getAllKnownLanguages(); $lang_choices = array(); $lang_values = array(); $lang_id2uuid = array(); foreach ($lang as $l) { $lang_choices[$l['imaging_uuid']] = $l['label']; $lang_values[$l['imaging_uuid']] = $l['imaging_uuid']; $lang_id2uuid[$l['id']] = $l['imaging_uuid']; } $language = new SelectItem("language"); $language->setElements($lang_choices); $language->setElementsVal($lang_values); if ($imaging_server['fk_language']) { $language->setSelected($lang_id2uuid[$imaging_server['fk_language']]); } $f->push(new Table()); $f->add(new TrFormElement(_T("Menu language", "imaging"), $language)); $pxe_password_label = _T('PXE Password', 'imaging'); $pxe_password_label_desc = _T('Leave this field empty to unset PXE Password', 'imaging'); $pxe_password_label = <<<EOS <a href="#" class="tooltip"> {$pxe_password_label} <span><p> {$pxe_password_label_desc} </p></span> </a>
} $langLabelList = array(); $langDescList = array(); $languages = list_system_locales(realpath("modules/base/locale/")); $langDesc = getArrLocale(); foreach ($languages as $value) { if ($langDesc[$value]) { $langDescList[] = $langDesc[$value]; } else { $langDescList[] = $value; } $langLabelList[] = $value; } $langList = new SelectItem("lang", "changeServerLang"); $langList->setElements($langDescList); $langList->setElementsVal($langLabelList); if (!isset($_GET['lang'])) { // Get browser lang $lang_1 = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $lang_2 = str_replace('-', '_', substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5)); // If lang1 = en => LANG = C if ($lang_1 == 'en') { $_SESSION['lang'] = 'C'; } else { // We check other languages // Searching with xx_XX pattern if (in_array($lang_2, $languages)) { $_SESSION['lang'] = $lang_2; } else { // Searching with xx pattern foreach ($languages as $lang) {
if ($dst != array("fw")) { $tr = new TrFormElement(_T("Limit destination IP(s)"), new InputTpl("destination_ip"), array("tooltip" => "Specify destination IP(s), IP range(s), network for this rule separated by commas. (eg: 155.186.235.0/24,155.186.233.23)")); $f->add($tr, array("value" => fromPOST("destination_ip"))); } $macros = getServices(); $services = array("", "Custom rule...") + $macros; $servicesVals = array("", "custom") + $macros; $serviceTpl = new SelectItem("service", "toggleCustom"); $serviceTpl->setElements($services); $serviceTpl->setElementsVal($servicesVals); $f->add(new TrFormElement(_T("Service"), $serviceTpl), array("value" => fromPOST('service'))); $f->pop(); $customDiv = new Div(array("id" => "custom")); $customDiv->setVisibility(false); $f->push($customDiv); $f->push(new Table()); $protoTpl = new SelectItem("proto"); $protoTpl->setElements(array("", "TCP", "UDP")); $protoTpl->setElementsVal(array("", "tcp", "udp")); $f->add(new TrFormElement(_T("Protocol"), $protoTpl), array("value" => fromPOST('proto'))); $f->add(new TrFormElement(_T("Port(s)"), new InputTpl("port", "/^([0-9:,]{1,4}|[1-5][0-9:,]{4}|6[0-4][0-9:,]{3}|65[0-4][0-9:,]{2}|655[0-2][0-9:,]|6553[0-5:,])+\$/"), array("tooltip" => _T("You can specify multiple ports using ',' as separator (eg: 22,34,56). Port ranges can be defined with ':' (eg: 3400:3500 - from port 3400 to port 3500)."))), array("value" => fromPOST('ports'))); $f->pop(); $f->pop(); $f->addButton("brule", _T("Add rule")); $f->display(); if (!servicesModuleEnabled()) { echo '<br/>'; $f = new ValidatingForm(array("id" => "service")); $f->addButton("brestart", _T("Restart service")); $f->display(); }
//TODO put in class if (quickGet('add_param')) { print "<form action='" . urlStr("base/computers/{$target}", array()) . "' method='POST'><table>"; print "<input type='hidden' name='imaging_server' value='{$imaging_server}'/>"; // need to be changed in getCriterionType (we don't use the second part of the array... $type = getTypeForCriterionInModule(quickGet('req'), quickGet('add_param')); $extended = getExtended(quickGet('req'), quickGet('add_param')); print "<tr><td>" . quickGet('req') . " > " . quickGet('add_param') . "</td><td>"; if (strlen($extended)) { // Insert a hidden input which contains the type of data print "<input type='hidden' name='type_extended' value='" . $extended . "' />"; // Display an option list to chose the comparison operator $operators = array('=', '<', '>', '!='); $listbox = new SelectItem("operator"); $listbox->setElements($operators); $listbox->setElementsVal($operators); print _T("Comparison operator : "); $listbox->display(); print "</td><td>"; switch ($extended) { // Execute a regexp that checks the right type case 'int': // Nothing to do for the moment. break; // Display a calendar widget instead of an input // Display a calendar widget instead of an input case 'date': include "modules/base/includes/AjaxFilterLog.inc.php"; $dateWidget = new LogDynamicDateTpl("value", _("Date")); $dateWidget->display(); print "</td><td>";
$f->push(new Table()); # default value for profile path $value = "\\\\%N\\profiles\\%U"; if ($hasProfiles) { $value = $smb['logon path']; } $f->add(new TrFormElement(_T("Network path for profiles"), new InputTpl("logon path"), array("tooltip" => _T("The share must exist and be world-writable.", "samba"))), array("value" => $value)); $f->pop(); $f->pop(); $f->push(new DivExpertMode()); $f->push(new Table()); $syncTpl = new SelectItem("ldap passwd sync"); $labels = array(_T('Yes'), _T('No'), _T('Only (for smbk5pwd)')); $values = array('yes', 'no', 'only'); $syncTpl->setElements($labels); $syncTpl->setElementsVal($values); // $f->add( // new TrFormElement(_T("LDAP password sync"), $syncTpl), // array("value" => $smb["ldap passwd sync"]) // ); $d = array(_T("Opening script session") => "logon script", _T("Base directory path") => "logon home", _T("Connect base directory on network drive") => "logon drive"); // foreach ($d as $description => $field) { // $f->add( // new TrFormElement($description, new IA5InputTpl($field)), // array("value"=>$smb[$field]) // ); // } $f->pop(); $f->pop(); #$f->addValidateButton("bsave"); #$f->addExpertButton("brestart", _T("Restart SAMBA"));
$f->add(new TrFormElement(_T('Version', 'pkgs'), new InputTpl('version')), array("value" => $package['version'], "required" => True)); // Bundle description $f->add(new TrFormElement(_T('Description', 'pkgs'), new InputTpl('description')), array("value" => $package['description'], "required" => True)); // Need reboot $f->add(new TrFormElement(_T('Need a reboot', 'pkgs'), new CheckboxTpl('do_reboot')), array("value" => $package['reboot'] == 1 ? 'checked' : '')); // Associate inventory $f->add(new TrFormElement(_T('Associate inventory', 'pkgs'), new CheckboxTpl('do_associateinventory')), array("value" => $package['associateinventory'] == 1 ? 'checked' : '')); // If sub_packages is empty (new bundle, we init it with the first package) if (!$package['sub_packages']) { $package['sub_packages'] = array(array('pid' => $papi_packages_pids[0], 'condition' => '')); } // SubPackages lists for ($i = 0; $i < count($package['sub_packages']); $i++) { $package_select = new SelectItem('sub_packages[pids][]'); $package_select->setElements($papi_packages_labels); $package_select->setElementsVal($papi_packages_pids); // Fields $fields = array($package_select, new InputTpl('sub_packages[conditions][]'), new buttonTpl('removeShare', _T('Remove'), 'removeShare')); $values = array($package['sub_packages'][$i]['pid'], $package['sub_packages'][$i]['condition'], ''); $f->add(new TrFormElement(_T('Package', 'pkgs') . " (" . ($i + 1) . ')', new multifieldTpl($fields)), array("value" => $values, "required" => True)); } print '<script type="text/javascript">window.pkg_count = ' . $i . ';</script>'; // Add Share button $addShareBtn = new buttonTpl('addShare', _T('Add bundle', 'pkgs')); $addShareBtn->setClass('btnPrimary'); $f->add(new TrFormElement('', $addShareBtn), array()); // If BackupProfile id is transmitten, we write it into the form if ($ID) { $f->add(new HiddenTpl("id"), array("value" => $ID, "hide" => True)); } elseif (isset($profile['id'])) { $f->add(new HiddenTpl("id"), array("value" => $profile['id'], "hide" => True));
} else { $sel->setSelected(-1); } $f->add(new TrFormElement(_T("Folder", "backuppc"), $sel, array())); // ===================================================================== // MIN AND MAX FILESIZE // ===================================================================== $f->add(new HiddenTpl("minsize"), array("value" => isset($_POST['minsize']) ? $_POST['minsize'] : '-1', "hide" => True)); $f->add(new HiddenTpl("maxsize"), array("value" => isset($_POST['maxsize']) ? $_POST['maxsize'] : '-1', "hide" => True)); // ============================================================================= // SHARENAME SELECT FIELD ===================================================== // ============================================================================= $sel = new SelectItem("filesize"); $sizes = array('0' => _T('Any size', 'backuppc'), '1' => _T('Less than 1 Mb', 'backuppc'), '2' => _T('1 Mb to 10 Mb', 'backuppc'), '3' => _T('10 Mb to 100 Mb', 'backuppc'), '4' => _T('Greater than 100 Mb', 'backuppc')); $sel->setElements(array_values($sizes)); $sel->setElementsVal(array_keys($sizes)); if (isset($_POST['filesize'])) { $sel->setSelected($_POST['filesize']); } else { $sel->setSelected(0); } $f->add(new TrFormElement(_T("File size", "backuppc"), $sel, array())); /* $f->add( new TrFormElement(_T('Minimum file size','backuppc'), new InputTpl('minsize')), array("value" => isset($_POST['minsize'])?$_POST['minsize']:'',"required" => True) ); $f->add( new TrFormElement(_T('Maximum file size','backuppc'), new InputTpl('maxsize')), array("value" => isset($_POST['maxsize'])?$_POST['maxsize']:'',"required" => True)
$params = array(); $params['filters']['id'] = $_GET["id"]; $result = getAllLocationsPowered($params); if ($result['count'] != 1) { die('Unexpected error'); } $location = $result['data'][0]; $location_name = $location['name']; $parent = $location['locations_id']; $description = $location['comment']; } $p = new PageGenerator($page_title); $p->setSideMenu($sidemenu); $p->display(); $f = new ValidatingForm(); $f->push(new Table()); $f->add(new TrFormElement(_T('Name', 'glpi'), new InputTpl('name')), array("value" => $location_name, "required" => True)); // Location list $locations_select = new SelectItem("parent"); $locations = getAllLocationsPowered(array()); $location_list = array(); foreach ($locations['data'] as $location) { $location_list[$location['id']] = $location['completename']; } $locations_select->setElements(array_values($location_list)); $locations_select->setElementsVal(array_keys($location_list)); $f->add(new TrFormElement(_T('Parent location', 'glpi'), $locations_select), array("value" => $parent, "required" => True)); $f->add(new TrFormElement(_T('Description', 'glpi'), new InputTpl('description')), array("value" => $description, "required" => True)); $f->pop(); $f->addValidateButton("bconfirm"); $f->display();
require "modules/base/computers/localSidebar.php"; require "graph/navbar.inc.php"; $params = array('min' => 0, 'filters' => array()); //Receiving form data if (isset($_POST['name'], $_POST['parent'])) { //Le champ name ne doit pas contenir d'espaces ni de virgules ni de slash (/) '^[a-zA-Z0-9]{3,64}$' createLocation($_POST['name'], $_POST['parent']); if (!isXMLRPCError()) { header('location: main.php?module=base&submod=computers&action=entityList&filter=' . $_POST['name']); } } $p = new PageGenerator(_T("Add entity", 'inventory')); $p->setSideMenu($sidemenu); $p->display(); $f = new ValidatingForm(); $f->push(new Table()); $f->add(new TrFormElement(_T('Name', 'inventory'), new InputTpl('name')), array("value" => $profile['profilename'], "required" => True)); $entities_select = new SelectItem("parent"); $entities = getLocationAll($params); $entity_val = array(); $entity_list = array(); foreach ($entities['data'] as $entity) { $entity_list[$entity['id']] = $entity['Labelval']; $entity_val[$entity['id']] = $entity['id']; } $entities_select->setElements($entity_list); $entities_select->setElementsVal($entity_val); $f->add(new TrFormElement(_T('Parent entity', 'inventory'), $entities_select), array("value" => 1, "required" => True)); $f->pop(); $f->addValidateButton("bconfirm"); $f->display();
$str = "<h2>" . _T("Share backup") . "</h2>"; $str .= '<p>'; $str .= sprintf(_T("Backup of share <b>%s</b> has been launched in background."), $share); $str .= "</p><p>"; $str .= sprintf(_("The files will be stored in the directory %s of the server at the end of the backup."), $backuppath); $str .= "</p><p>"; $str .= _T("Please go to the status page to check the backup status."); $str .= "</p><p>"; $str .= _T("This operation will last according to the amount of data to backup."); $str .= "</p>"; new NotifyWidgetSuccess($str); } else { new NotifyWidgetFailure(_T("Can't launch backup")); } header("Location: " . urlStrRedirect("samba/shares/index")); exit; } else { $share = urldecode($_GET["share"]); $f = new PopupForm(_T("Share backup")); $f->addText(sprintf(_T("The share %s will be archived."), $share)); $f->addText(_T("Please select media size. If your data exceed volume size, several files with your media size will be created.")); $select = new SelectItem("media"); $select->setElements(array("CD (650 Mo)", "DVD (4.7 Go)")); $select->setElementsVal(array(600, 4200)); $f->add($select); $hidden = new HiddenTpl("share"); $f->add($hidden, array("value" => $share, "hide" => True)); $f->addValidateButton("bgo"); $f->addCancelButton("bback"); $f->display(); }
header("Location: " . urlStrRedirect("imaging/manage/computersprofilecreator", $params)); } $p->addTab("tabsta", _T("Static imaging group", "dyngroup"), "", "modules/dyngroup/dyngroup/add_groups.php", $params); $p->display(); } else { $p = new PageGenerator(_T('Imaging server selection', 'dyngroup')); $p->setSideMenu($sidemenu); require_once "modules/pulse2/includes/profiles_xmlrpc.inc.php"; $f = new ValidatingForm(); $f->add(new HiddenTpl("id"), array("value" => $gid, "hide" => True)); $f->push(new Table()); $imss = xmlrpc_getAllImagingServersForProfiles(true); $elt = array(); $elt_values = array(); foreach ($imss as $uuid => $imaging_server) { $elt[$uuid] = $imaging_server['name']; $elt_values[$uuid] = $uuid; } $imss = new SelectItem("imaging_server"); $imss->setElements($elt); $imss->setElementsVal($elt_values); $f->add(new TrFormElement(_T("Select an imaging server for this group", "dyngroup"), $imss)); $f->pop(); $f->addValidateButton("bvalid"); $p->display(); $f->display(); } } ?>
function _glpi_baseEdit($FH, $mode) { $username = $FH->getArrayOrPostValue("uid"); // Default profile is SuperAdmin on root entity // with recursive rights $default_user_locations = array(array('entity_id' => 1, 'is_dynamic' => 0, 'is_recursive' => 1, 'profile' => 4)); if ($mode == 'edit') { $user_locations = getLocationsForUser($username); // If not user profile, switching to default if (!count($user_locations)) { $user_locations = $default_user_locations; } } else { // Default profile is SuperAdmin on root entity // with recursive rights $user_locations = $default_user_locations; } $d = new DivForModule(_T("Entity attributes", "glpi"), "#DDF"); $f = new Table(); $d->push($f); // ================================= // Entity select // ================================= $entities_select = new SelectItem("entities[]"); $entities = getUserLocations(); $entity_list = array(); foreach ($entities as $entity) { $id = str_replace('UUID', '', $entity['uuid']); $entity_list[$id] = $entity['name']; } $entities_select->setElements(array_values($entity_list)); $entities_select->setElementsVal(array_keys($entity_list)); // ================================= // Profiles select // ================================= $profiles_select = new SelectItem("profiles[]"); $profiles = getAllUserProfiles(); $profiles_select->setElements(array_values($profiles)); $profiles_select->setElementsVal(array_keys($profiles)); // ================================= // Recursive select // ================================= $recursive_select = new SelectItem("is_recursive[]"); $recursive_select->setElements(array('Recursive', 'Not recursive')); $recursive_select->setElementsVal(array('1', '0')); // ================================= // Recursive select // ================================= $dynamic_select = new SelectItem("is_dynamic[]"); $dynamic_select->setElements(array('Dynamic', 'Not dynamic')); $dynamic_select->setElementsVal(array('1', '0')); foreach ($user_locations as $attr) { // Fields $fields = array($entities_select, $profiles_select, $recursive_select, $dynamic_select, new buttonTpl2('removeLine', _T('Remove', 'glpi'), 'removeLine')); $values = array($attr['entity_id'], $attr['profile'], $attr['is_recursive'], $attr['is_dynamic'], ''); $f->add(new TrFormElement(_T('Entity right', 'glpi'), new multifieldTpl($fields)), array("value" => $values, "required" => True)); } // Add line button $addEntityRightBtn = new buttonTpl2('addLine', _T('Add entity right', 'backuppc')); $addEntityRightBtn->setClass('btnPrimary'); $f->add(new TrFormElement('', $addEntityRightBtn), array()); print <<<EOF <script type="text/javascript"> jQuery(function(){ modelLine = jQuery('.removeLine:first').parents('tr:first').clone(); // Remove line button jQuery('.removeLine').click(function(){ if (jQuery('.removeLine').length > 1) jQuery(this).parents('tr:first').remove(); }); // Add line button jQuery('#addLine').click(function(){ var newline = modelLine.clone().insertBefore(jQuery(this).parents('tr:first')); newline.find('input[type=text]').val(''); newline.find('textarea').val(''); newline.find('.removeLine').click(function(){ if (jQuery('.removeLine').length > 1) jQuery(this).parents('tr:first').remove(); }); }); }); window.toto=1; </script> EOF; return $f; }
$res = getUserPackageApi(); // set first Package Api found as default Package API $p_api_id = $res[0]['uuid']; $list_val = $list = array(); if (!isset($_SESSION['PACKAGEAPI'])) { $_SESSION['PACKAGEAPI'] = array(); } foreach ($res as $mirror) { $list_val[$mirror['uuid']] = $mirror['uuid']; $list[$mirror['uuid']] = $mirror['mountpoint']; $_SESSION['PACKAGEAPI'][$mirror['uuid']] = $mirror; } $span = new SpanElement(_T("Choose package source", "pkgs"), "pkgs-title"); $selectpapi = new SelectItem('p_api'); $selectpapi->setElements($list); $selectpapi->setElementsVal($list_val); $_SESSION['pkgs_selected'] = array_values($list_val)[0]; $f = new ValidatingForm(); $f->push(new Table()); // Step title $f->add(new TrFormElement("", $span), array()); $r = new RadioTpl("package-method"); $vals = array("package", "upload", "empty"); $keys = array(_T("Already uploaded on the server", "pkgs"), _T("Upload from this web page", "pkgs"), _T("Make an empty package", "pkgs")); $r->setValues($vals); $r->setChoices($keys); // Package API $f->add(new TrFormElement("<div id=\"p_api_label\">" . _T("Package API", "pkgs") . "</div>", $selectpapi), array("value" => $p_api_id, "required" => True)); $f->add(new TrFormElement(_T("Package source", "pkgs"), $r), array()); $f->add(new TrFormElement("<div id='directory-label'>" . _T("Files directory", "pkgs") . "</div>", new Div(array("id" => "package-temp-directory"))), array()); $f->add(new HiddenTpl("mode"), array("value" => "creation", "hide" => True));
// Create the page with its title and sidemenu $p = new PageGenerator(_T("Incoming Inventories")); $p->setSideMenu($sidemenu); // Display the PageGenerator $p->display(); // Create a form with a list of options and a checkbox $form = new ValidatingForm(); $form->push(new Table()); // The list of options is put in an array, and the listbox is configured with this array $periodList = array(_T("Last week") => 7, _T("Last month")=>30, _T("Last quarter")=>90, _T("Last semester")=>180, _T("Last year")=>356); $listbox = new SelectItem("period", "validateForm"); $listbox->setElements(array_keys($periodList)); $listbox->setElementsVal(array_values($periodList)); // Check the value to put by default in the list if(isset($_POST['period'])) $listbox->setSelected($_POST['period']); else $listbox->setSelected(7); // must match with the default value in ajaxIncoming.php (7 for a week here) // Put the element in a Tr elemet to align it $listboxTr = new TrFormElement(_T("Period"), $listbox); // Create a checkbox element $checkbox = new CheckboxTpl("only_new", null, "validateForm"); $checkboxTr = new TrFormElement(_T("Only new computers"), $checkbox, array("tooltip"=>_T("Load only the computers which were new when the inventory was made")));
function display_ordered($orders) { $f = new ValidatingForm(); $f->push(new Table()); foreach ($this->members as $pid => $plabel) { $select = new SelectItem($this->input_pre . base64_encode($pid)); $select->setElements($this->c); $select->setElementsVal($this->c); $select->setSelected($orders[$pid]); $f->add(new TrFormElement($plabel, $select, array())); } foreach ($this->getHidden() as $w) { $f->add($w[0], $w[1]); } $this->display_options($f); $f->pop(); foreach ($this->buttons as $b) { $f->addButton($b[0], $b[1], $b[2]); } $f->display(); }
/** * 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(); }
$f->push(new Table()); $zones_types = getZonesTypes(); $external = array(); $externalVals = array(); foreach (getZonesInterfaces($zones_types["external"]) as $zone) { $external[] = sprintf("%s (%s)", $zone[0], $zone[1]); $externalVals[] = $zone[1]; } $externalTpl = new SelectItem("external_if"); $externalTpl->setElements($external); $externalTpl->setElementsVal($externalVals); $f->add(new TrFormElement(_T("External network (Internet)"), $externalTpl)); $internal = array(); $internalVals = array(); foreach (getZonesInterfaces($zones_types["internal"]) as $zone) { $internal[] = sprintf("%s (%s)", $zone[0], $zone[1]); $internalVals[] = $zone[1]; } $internalTpl = new SelectItem("internal_if"); $internalTpl->setElements($internal); $internalTpl->setElementsVal($internalVals); $f->add(new TrFormElement(_T("Internal network"), $internalTpl)); $f->pop(); $f->addButton("badd", _T("Add NAT rule")); $f->display(); if (!servicesModuleEnabled()) { echo '<br/>'; $f = new ValidatingForm(array("id" => "service")); $f->addButton("brestart", _T("Restart service")); $f->display(); }
} else { $_SESSION['pkgs-add-reloaded'][$_GET['papi']] = 0; } $_SESSION['p_api_id'] = $_GET['papi']; $files = getTemporaryFiles($_GET['papi']); if (count($files)) { $r = new SelectItem("rdo_files"); $vals = array(); $keys = array(); foreach ($files as $fi) { if ($fi[1] == True) { $vals[] = $fi[0]; $keys[] = $fi[0]; } } $r->setElementsVal($vals); $r->setElements($keys); $r->display(); ?> <script type="text/javascript"> /* * Auto fill fields of form * if tempdir is empty (when changing packageAPI) * default tempdir will be chosen in ajaxGetSuggestedCommand * php file. */ // FIXME: duplicated fillForm function function fillForm(selectedPapi, tempdir) { url = '<?php echo urlStrRedirect("pkgs/pkgs/ajaxGetSuggestedCommand"); ?>
$f->add(new TrFormElement(_T("Description"), new IA5InputTpl("description")), array("value" => $description)); $f->add(new TrFormElement(_T("Authoritative"), new CheckboxTpl("authoritative")), array("value" => $authoritative)); $f->pop(); $f->push(new Table()); $f->add(new TrFormElement(_T("DHCP options related to clients network parameters"), new HiddenTpl(""))); $f->add(new TrFormElement(_T("Broadcast address"), new IPInputTpl("broadcast-address")), array("value" => $options["broadcast-address"])); $f->add(new TrFormElement(_T("Domain name"), new IA5InputTpl("domain-name"), array("tooltip" => _T("Domain name that will be appended to the client's hostname to form a fully-qualified domain-name (FQDN).") . "<br/>" . _T("If the domain name is a registered DNS domain, the subnet will be associated to the DNS domain.") . "<br/>" . _T("You can set more than one domain, separated by spaces. They will be added to the DHCP client DNS domain search path."))), array("value" => $options["domain-name"], "extra" => _T("Links the subnet to a DNS zone"))); $f->add(new TrFormElement(_T("Routers"), new HostIpListInputTpl("routers"), array("tooltip" => _T("List of routers (gateways) on client's subnet."))), array("value" => $options["routers"])); $f->add(new TrFormElement(_T("Domain name servers"), new HostIpListInputTpl("domain-name-servers"), array("tooltip" => _T("DNS name servers available to the client. Separate servers addresses with ','."))), array("value" => $options["domain-name-servers"])); $f->add(new TrFormElement(_T("NTP servers"), new HostIpListInputTpl("ntp-servers"), array("tooltip" => _T("Network Time Protocol servers available to the client. Separate servers addresses with ','."))), array("value" => $options["ntp-servers"])); $f->add(new TrFormElement(_T("Proxy auto config URL"), new IA5InputTpl("local-pac-server"), array("tooltip" => _T("Automatic proxy configuration URL (PAC)."))), array("value" => $options["local-pac-server"])); $f->add(new TrFormElement(_T("WINS servers"), new HostIpListInputTpl("netbios-name-servers"), array("tooltip" => _T("Netbios name servers available to Windows clients, listed in order of preference. Separate servers addresses with ','."))), array("value" => $options["netbios-name-servers"])); $winsclient = new SelectItem("netbios-node-type"); $types = array("" => "Auto", "1" => _T("Broadcast only"), "2" => _T("WINS only"), "4" => _T("Broadcast, then WINS"), "8" => _T("WINS, then broadcast")); $winsclient->setElements(array_values($types)); $winsclient->setElementsVal(array_keys($types)); $f->add(new TrFormElement(_T("WINS resolution and registration method"), $winsclient, array("tooltip" => _T("Specify how NetBIOS name resolution is performed. Auto: the client OS will automatically select a method. Broadcast only (B-node): use broadcast for name resolution and registration. Peer node (P-node): use the specified WINS servers. Mixed node (M-node): use broadcast, then the specified WINS servers. Hybrid node (H-node): use the specified WINS server, then broadcast."))), array("value" => $options["netbios-node-type"])); $f->pop(); $f->push(new Table()); $f->add(new TrFormElement(_T("Other DHCP options"), new HiddenTpl(""))); $tooltip = _T("Specify the name of the initial boot file which is to be loaded by a client."); $tooltip .= "%s"; $tooltip .= _T("The filename should be a filename recognizable to whatever file transfer protocol the client can be expected to use to load the file."); $tooltip .= "%s"; $tooltip .= _T("(DHCP option number 67)"); $tooltip = sprintf($tooltip, "<br/>", "<br/>"); $f->add(new TrFormElement(_T("Initial boot file name"), new IA5InputTpl("filename"), array("tooltip" => $tooltip)), array("value" => $statements["filename"])); $tooltip = _T("Path-name that contains the client's root disk."); $tooltip .= "%s"; $tooltip .= _T("(DHCP option number 17)"); $tooltip = sprintf($tooltip, "<br/>");
* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MMC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MMC; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ include_once "modules/msc/includes/commands_xmlrpc.inc.php"; if (!empty($_GET["commands"])) { setCommandsFilter($_GET["commands"]); } $paramname2 = $_GET['paramname2']; $res = get_all_commandsonhost_currentstate(); $states = new SelectItem($paramname2, 'pushSearch', 'searchfieldreal noborder'); $list = array(); $labels = array(); foreach ($res as $name) { $labels[$name] = _T(preg_replace("[_]", ' ', ucfirst($name)), 'msc'); $list[$name] = $name; } $states->setElements($labels); $states->setElementsVal($list); if (in_array($_GET['selected'], array_keys($labels))) { $states->setSelected($_GET['selected']); } $states->displayContent();
$tr = new TrFormElement(_T("Source zone"), new HiddenTpl("source")); $tr->setStyle("display: none"); $f->add($tr, array("value" => $zones[0][0])); } $f->add(new TrFormElement(_T("Source IP(s)"), new InputTpl("src_ip"), array("tooltip" => _T("Allow connection from IP(s) address(es) (separate IPs with ',')."))), array("value" => "")); $zones = getZonesInterfaces($dst); if (count($zones) > 1) { $destinations = array(); $destinationsVals = array(); foreach ($zones as $zone) { $destinations[] = sprintf("%s (%s)", $zone[0], $zone[1]); $destinationsVals[] = $zone[0]; } $destinationsTpl = new SelectItem("destination"); $destinationsTpl->setElements($destinations); $destinationsTpl->setElementsVal($destinationsVals); $f->add(new TrFormElement(_T("Destination zone"), $destinationsTpl)); } else { $tr = new TrFormElement(_T("Destination zone"), new HiddenTpl("destination")); $tr->setStyle("display: none"); $f->add($tr, array("value" => $zones[0][0])); } $f->add(new TrFormElement(_T("Destination IP"), new InputTpl("dest_ip"), array("tooltip" => _T("The computer IP in the internal network where the request will be transfered."))), array("value" => "", "required" => true)); $f->add(new TrFormElement(_T("Destination port(s)"), new InputTpl("dest_port", "/^[0-9]+\$/"), array("tooltip" => _T("If not specified, destination port(s) will be the same as the incoming port(s)"))), array("value" => "")); $f->pop(); $f->addButton("brule", _T("Add rule")); $f->display(); if (!servicesModuleEnabled()) { echo '<br/>'; $f = new ValidatingForm(array("id" => "service")); $f->addButton("brestart", _T("Restart service"));
$params = array(); $params['filters']['id'] = $_GET["id"]; $result = getAllEntitiesPowered($params); if ($result['count'] != 1) { die('Unexpected error'); } $entity = $result['data'][0]; $entity_name = $entity['name']; $parent = $entity['entities_id']; $description = $entity['comment']; } $p = new PageGenerator($page_title); $p->setSideMenu($sidemenu); $p->display(); $f = new ValidatingForm(); $f->push(new Table()); $f->add(new TrFormElement(_T('Name', 'glpi'), new InputTpl('name')), array("value" => $entity_name, "required" => True)); $entities_select = new SelectItem("parent"); $entities = getUserLocations(); $entity_list = array(); foreach ($entities as $entity) { $id = str_replace('UUID', '', $entity['uuid']); $entity_list[$id] = $entity['completename']; } $entities_select->setElements(array_values($entity_list)); $entities_select->setElementsVal(array_keys($entity_list)); $f->add(new TrFormElement(_T('Parent entity', 'glpi'), $entities_select), array("value" => $parent, "required" => True)); $f->add(new TrFormElement(_T('Description', 'glpi'), new InputTpl('description')), array("value" => $description, "required" => True)); $f->pop(); $f->addValidateButton("bconfirm"); $f->display();