Dropdown available languages
static public showLanguages ( $myname, $options = [] ) | ||
$myname | select name | |
$options | array of additionnal options: - display_emptychoice : allow selection of no language - emptylabel : specific string to empty label if display_emptychoice is true |
function choose_language() { echo "<form action='install.php' method='post'>"; echo "<p class='center'>"; Dropdown::showLanguages("language", array('value' => "en_GB")); echo "</p>"; echo ""; echo "<p class='submit'><input type='hidden' name='install' value='lang_select'>"; echo "<input type='submit' name='submit' class='submit' value='OK'></p>"; Html::closeForm(); }
function choose_language() { global $CFG_GLPI; echo "<form action='install.php' method='post'>"; echo "<p class='center'>"; // fix missing param for js drodpown $CFG_GLPI['ajax_limit_count'] = 15; Dropdown::showLanguages("language", array('value' => "en_GB")); echo "</p>"; echo ""; echo "<p class='submit'><input type='hidden' name='install' value='lang_select'>"; echo "<input type='submit' name='submit' class='submit' value='OK'></p>"; Html::closeForm(); }
/** * @covers Dropdown::showLanguages */ public function testShowLanguages() { $opt = ['display_emptychoice' => true, 'display' => false]; $out = Dropdown::showLanguages('dropfoo', $opt); $this->assertContains("name='dropfoo'", $out); $this->assertContains("value='' selected", $out); $this->assertNotContains("value='0'", $out); $this->assertContains("value='fr_FR'", $out); $opt = ['display' => false, 'value' => 'cs_CZ', 'rand' => '1234']; $out = Dropdown::showLanguages('language', $opt); $this->assertNotContains("value=''", $out); $this->assertNotContains("value='0'", $out); $this->assertContains("name='language' id='dropdown_language1234", $out); $this->assertContains("value='cs_CZ' selected", $out); $this->assertContains("value='fr_FR'", $out); }
function showForm($ID, $options = array()) { global $CFG_GLPI, $LANG; if ($ID > 0) { $this->check($ID, 'r'); } else { // Create item $this->check(-1, 'w'); } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Name'); echo " :</td>"; echo "<td>"; echo '<input type="text" name="name" value="' . $this->fields["name"] . '" size="54"/>'; echo "</td>"; echo "</td><td>"; echo __('Active'); echo " :</td><td>"; Dropdown::showYesNo("is_active", $this->fields["is_active"]); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Description'); echo " :</td>"; echo "<td>"; echo "<textarea name='content' cols='55' rows='6'>"; echo $this->fields["content"]; echo "</textarea>"; echo "</td></td>"; echo "<td>"; echo __('Select Language'); echo "</td><td>"; if ($this->fields["language"]) { Dropdown::showLanguages("language", array('value' => $this->fields["language"])); } else { Dropdown::showLanguages("language", array('value' => $_SESSION['glpilanguage'])); } echo "</td></tr>"; echo '<tr><td>' . $LANG['plugin_formcreator']["cat"][3] . '</td><td>'; PluginFormcreatorCat::getSelectCat($ID, $this->fields["cat"]); echo '</td></tr>'; $this->showFormButtons($options); $this->addDivForTabs(); }
/** * Print the config form for default user prefs * * @param $data array containing datas * (CFG_GLPI for global config / glpi_users fields for user prefs) * * @return Nothing (display) **/ function showFormUserPrefs($data = array()) { global $DB, $CFG_GLPI; $oncentral = $_SESSION["glpiactiveprofile"]["interface"] == "central"; $userpref = false; $url = Toolbox::getItemTypeFormURL(__CLASS__); if (array_key_exists('last_login', $data)) { $userpref = true; if ($data["id"] === Session::getLoginUserID()) { $url = $CFG_GLPI['root_doc'] . "/front/preference.php"; } else { $url = $CFG_GLPI['root_doc'] . "/front/user.form.php"; } } echo "<form name='form' action='{$url}' method='post'>"; // Only set id for user prefs if ($userpref) { echo "<input type='hidden' name='id' value='" . $data['id'] . "'>"; } echo "<div class='center' id='tabsbody'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . __('Personalization') . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td width='30%'>" . ($userpref ? __('Language') : __('Default language')) . "</td>"; echo "<td width='20%'>"; if (Config::canUpdate() || !GLPI_DEMO_MODE) { Dropdown::showLanguages("language", array('value' => $data["language"])); } else { echo " "; } echo "<td width='30%'>" . __('Date format') . "</td>"; echo "<td width='20%'>"; $date_formats = array(0 => __('YYYY-MM-DD'), 1 => __('DD-MM-YYYY'), 2 => __('MM-DD-YYYY')); Dropdown::showFromArray('date_format', $date_formats, array('value' => $data["date_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Results to display by page') . "</td><td>"; // Limit using global config $value = $data['list_limit'] < $CFG_GLPI['list_limit_max'] ? $data['list_limit'] : $CFG_GLPI['list_limit_max']; Dropdown::showNumber('list_limit', array('value' => $value, 'min' => 5, 'max' => $CFG_GLPI['list_limit_max'], 'step' => 5)); echo "</td>"; echo "<td>" . __('Number format') . "</td>"; $values = array(0 => '1 234.56', 1 => '1,234.56', 2 => '1 234,56', 3 => '1234.56', 4 => '1234,56'); echo "<td>"; Dropdown::showFromArray('number_format', $values, array('value' => $data["number_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Display order of surnames firstnames') . "</td><td>"; $values = array(User::REALNAME_BEFORE => __('Surname, First name'), User::FIRSTNAME_BEFORE => __('First name, Surname')); Dropdown::showFromArray('names_format', $values, array('value' => $data["names_format"])); echo "</td>"; echo "<td>" . __("Color palette") . "</td><td>"; $themes_files = scandir(GLPI_ROOT . "/css/palettes/"); echo "<select name='palette' id='theme-selector'>"; foreach ($themes_files as $key => $file) { if (strpos($file, ".css") !== false) { $name = substr($file, 0, -4); $selected = ""; if ($data["palette"] == $name) { $selected = "selected='selected'"; } echo "<option value='{$name}' {$selected}>" . ucfirst($name) . "</option>"; } } echo Html::scriptBlock("\n function formatThemes(theme) {\n return \" <img src='../css/palettes/previews/\" + theme.text.toLowerCase() + \".png'/>\"\n + \" \" + theme.text;\n }\n \$(\"#theme-selector\").select2({\n formatResult: formatThemes,\n formatSelection: formatThemes,\n width: '100%',\n escapeMarkup: function(m) { return m; }\n });\n "); echo "</select>"; echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . __('Display the complete name in tree dropdowns') . "</td><td>"; Dropdown::showYesNo('use_flat_dropdowntree', $data["use_flat_dropdowntree"]); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } if (!$userpref || $CFG_GLPI['show_count_on_tabs'] != -1) { echo "<td>" . __('Display counts in tabs') . "</td><td>"; $values = array(0 => __('No'), 1 => __('Yes')); if (!$userpref) { $values[-1] = __('Never'); } Dropdown::showFromArray('show_count_on_tabs', $values, array('value' => $data["show_count_on_tabs"])); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . __('Show GLPI ID') . "</td><td>"; Dropdown::showYesNo("is_ids_visible", $data["is_ids_visible"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "<td>" . __('CSV delimiter') . "</td><td>"; $values = array(';' => ';', ',' => ','); Dropdown::showFromArray('csv_delimiter', $values, array('value' => $data["csv_delimiter"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Notifications for my changes') . "</td><td>"; Dropdown::showYesNo("notification_to_myself", $data["notification_to_myself"]); echo "</td>"; if ($oncentral) { echo "<td>" . __('Results to display on home page') . "</td><td>"; Dropdown::showNumber('display_count_on_home', array('value' => $data['display_count_on_home'], 'min' => 0, 'max' => 30)); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('PDF export font') . "</td><td>"; Dropdown::showFromArray("pdffont", GLPIPDF::getFontList(), array('value' => $data["pdffont"], 'width' => 200)); echo "</td>"; echo "<td>" . __('Keep devices when purging an item') . "</td><td>"; Dropdown::showYesNo('keep_devices_when_purging_item', $data['keep_devices_when_purging_item']); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Go to created item after creation') . "</td>"; echo "<td>"; Dropdown::showYesNo("backcreated", $data["backcreated"]); echo "</td>"; echo "<td>" . __('Layout') . "</td><td>"; $layout_options = array('lefttab' => __("Tabs on left"), 'classic' => __("Classic view"), 'vsplit' => __("Vertical split")); echo "<select name='layout' id='layout-selector'>"; foreach ($layout_options as $key => $name) { $selected = ""; if ($data["layout"] == $key) { $selected = "selected='selected'"; } echo "<option value='{$key}' {$selected}>" . ucfirst($name) . "</option>"; } echo Html::scriptBlock("\n function formatLayout(layout) {\n return \" <img src='../pics/layout_\" + layout.id.toLowerCase() + \".png'/>\"\n + \" \" + layout.text;\n }\n \$(\"#layout-selector\").select2({\n formatResult: formatLayout,\n formatSelection: formatLayout,\n escapeMarkup: function(m) { return m; }\n });\n "); echo "</select>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'><td>" . __('Enable ticket timeline') . "</td>"; echo "<td>"; Dropdown::showYesNo('ticket_timeline', $data['ticket_timeline']); echo "</td>"; echo "<td>" . __('Keep tabs replaced by the ticket timeline') . "</td><td>"; Dropdown::showYesNo('ticket_timeline_keep_replaced_tabs', $data['ticket_timeline_keep_replaced_tabs']); echo "</td></tr>"; if ($oncentral) { echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Assistance') . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Private followups by default') . "</td><td>"; Dropdown::showYesNo("followup_private", $data["followup_private"]); echo "</td><td>" . __('Show new tickets on the home page') . "</td><td>"; if (Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READALL, Ticket::READASSIGN))) { Dropdown::showYesNo("show_jobs_at_login", $data["show_jobs_at_login"]); } else { echo Dropdown::getYesNo(0); } echo " </td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Private tasks by default') . "</td><td>"; Dropdown::showYesNo("task_private", $data["task_private"]); echo "</td><td> " . __('Request sources by default') . "</td><td>"; RequestType::dropdown(array('value' => $data["default_requesttypes_id"], 'name' => "default_requesttypes_id")); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Tasks state by default') . "</td><td>"; Planning::dropdownState("task_state", $data["task_state"]); echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Pre-select me as a technician when creating a ticket') . "</td><td>"; if (!$userpref || Session::haveRight('ticket', Ticket::OWN)) { Dropdown::showYesNo("set_default_tech", $data["set_default_tech"]); } else { echo Dropdown::getYesNo(0); } echo "</td><td>" . __('Automatically refresh the list of tickets (minutes)') . "</td><td>"; Dropdown::showNumber('refresh_ticket_list', array('value' => $data["refresh_ticket_list"], 'min' => 1, 'max' => 30, 'step' => 1, 'toadd' => array(0 => __('Never')))); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Priority colors') . "</td>"; echo "<td colspan='3'>"; echo "<table><tr>"; echo "<td>1 "; Html::showColorField('priority_1', array('value' => $data["priority_1"])); echo "</td>"; echo "<td>2 "; Html::showColorField('priority_2', array('value' => $data["priority_2"])); echo "</td>"; echo "<td>3 "; Html::showColorField('priority_3', array('value' => $data["priority_3"])); echo "</td>"; echo "<td>4 "; Html::showColorField('priority_4', array('value' => $data["priority_4"])); echo "</td>"; echo "<td>5 "; Html::showColorField('priority_5', array('value' => $data["priority_5"])); echo "</td>"; echo "<td>6 "; Html::showColorField('priority_6', array('value' => $data["priority_6"])); echo "</td>"; echo "</tr></table>"; echo "</td></tr>"; } // Only for user if (array_key_exists('personal_token', $data)) { echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Remote access key') . "</th></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Remote access key'); if (!empty($data["personal_token"])) { //TRANS: %s is the generation date echo "<br>" . sprintf(__('generated on %s'), Html::convDateTime($data["personal_token_date"])); } echo "</td><td colspan='3'>"; echo "<input type='checkbox' name='_reset_personal_token'> " . __('Regenerate'); echo "</td></tr>"; } echo "<tr><th colspan='4'>" . __('Due date progression') . "</th></tr>"; echo "<tr class='tab_bg_1'>" . "<td>" . __('OK state color') . "</td>"; echo "<td>"; Html::showColorField('duedateok_color', array('value' => $data["duedateok_color"])); echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Warning state color') . "</td>"; echo "<td>"; Html::showColorField('duedatewarning_color', array('value' => $data["duedatewarning_color"])); echo "</td>"; echo "<td>" . __('Warning state threshold') . "</td>"; echo "<td>"; Dropdown::showNumber("duedatewarning_less", array('value' => $data['duedatewarning_less'])); $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber())); echo " "; Dropdown::showFromArray("duedatewarning_unit", $elements, array('value' => $data['duedatewarning_unit'])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>" . "<td>" . __('Critical state color') . "</td>"; echo "<td>"; Html::showColorField('duedatecritical_color', array('value' => $data["duedatecritical_color"])); echo "</td>"; echo "<td>" . __('Critical state threshold') . "</td>"; echo "<td>"; Dropdown::showNumber("duedatecritical_less", array('value' => $data['duedatecritical_less'])); echo " "; $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber())); Dropdown::showFromArray("duedatecritical_unit", $elements, array('value' => $data['duedatecritical_unit'])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td colspan='4' class='center'>"; echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">"; echo "</td></tr>"; echo "</table></div>"; Html::closeForm(); }
function showForm($ID, $options) { global $DB, $CFG_GLPI; if (!Config::canUpdate()) { return false; } $notificationtemplates_id = -1; if (isset($options['notificationtemplates_id'])) { $notificationtemplates_id = $options['notificationtemplates_id']; } if ($this->getFromDB($ID)) { $notificationtemplates_id = $this->getField('notificationtemplates_id'); } $this->initForm($ID, $options); $template = new NotificationTemplate(); $template->getFromDB($notificationtemplates_id); Html::initEditorSystem('content_html'); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . NotificationTemplate::getTypeName() . "</td>"; echo "<td colspan='2'><a href='" . Toolbox::getItemTypeFormURL('NotificationTemplate') . "?id=" . $notificationtemplates_id . "'>" . $template->getField('name') . "</a>"; echo "</td><td>"; $rand = mt_rand(); Ajax::createIframeModalWindow("tags" . $rand, $CFG_GLPI['root_doc'] . "/front/notification.tags.php?sub_type=" . $template->getField('itemtype')); echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID("tags" . $rand) . ".dialog('open');\">" . __('Show list of available tags') . "</a>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Language') . "</td><td colspan='3'>"; //Get all used languages $used = self::getAllUsedLanguages($notificationtemplates_id); if ($ID > 0) { if (isset($used[$this->getField('language')])) { unset($used[$this->getField('language')]); } } Dropdown::showLanguages("language", array('display_emptychoice' => true, 'value' => $this->fields['language'], 'used' => $used)); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Subject') . "</td>"; echo "<td colspan='3'>"; Html::autocompletionTextField($this, 'subject', array('size' => 100)); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>"; _e('Email text body'); echo "<br>" . __('(leave the field empty for a generation from HTML)'); echo "</td><td colspan='3'>"; echo "<textarea cols='100' rows='15' name='content_text' >" . $this->fields["content_text"]; echo "</textarea></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; _e('Email HTML body'); echo "</td><td colspan='3'>"; echo "<textarea cols='100' rows='15' name='content_html'>" . $this->fields["content_html"]; echo "</textarea>"; echo "<input type='hidden' name='notificationtemplates_id' value='" . $template->getField('id') . "'>"; echo "</td></tr>"; $this->showFormButtons($options); return true; }
/** * Display translation form * * @param $ID field (default -1) * @param $options array */ function showForm($ID = -1, $options = array()) { global $CFG_GLPI; if (isset($options['parent']) && !empty($options['parent'])) { $item = $options['parent']; } if ($ID > 0) { $this->check($ID, READ); } else { $options['itemtype'] = get_class($item); $options['items_id'] = $item->getID(); // Create item $this->check(-1, CREATE, $options); } $rand = mt_rand(); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Language') . "</td>"; echo "<td>"; echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>"; echo "<input type='hidden' name='itemtype' value='" . get_class($item) . "'>"; if ($ID > 0) { echo "<input type='hidden' name='language' value='" . $this->fields['language'] . "'>"; echo Dropdown::getLanguageName($this->fields['language']); } else { $rand = Dropdown::showLanguages("language", array('display_none' => false, 'value' => $_SESSION['glpilanguage'])); $params = array('language' => '__VALUE__', 'itemtype' => get_class($item), 'items_id' => $item->getID()); Ajax::updateItemOnSelectEvent("dropdown_language{$rand}", "span_fields", $CFG_GLPI["root_doc"] . "/ajax/updateTranslationFields.php", $params); } echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Field') . "</td>"; echo "<td>"; if ($ID > 0) { echo "<input type='hidden' name='field' value='" . $this->fields['field'] . "'>"; $searchOption = $item->getSearchOptionByField('field', $this->fields['field']); echo $searchOption['name']; } else { echo "<span id='span_fields' name='span_fields'>"; self::dropdownFields($item, $_SESSION['glpilanguage']); echo "</span>"; } echo "</td>"; echo "<td>" . __('Value') . "</td>"; echo "<td><input type='text' name='value' value=\"" . $this->fields['value'] . "\" size='50'>"; echo "</td>"; echo "</tr>\n"; $this->showFormButtons($options); return true; }
/** * Show the Form edit form the the adminsitrator in the config page * * @param Array $options Optional options * * @return NULL Nothing, just display the form */ public function showForm($ID, $options = array()) { $this->initForm($ID, $options); $this->showFormHeader($options); echo '<tr class="tab_bg_1">'; echo '<td width="20%"><strong>' . __('Name') . ' <span class="red">*</span></strong></td>'; echo '<td width="30%"><input type="text" name="name" value="' . $this->fields["name"] . '" size="35"/></td>'; echo '<td width="20%"><strong>' . __('Active') . ' <span class="red">*</span></strong></td>'; echo '<td width="30%">'; Dropdown::showYesNo("is_active", $this->fields["is_active"]); echo '</td>'; echo '</tr>'; echo '<tr class="tab_bg_2">'; echo '<td><strong>' . __('Category') . ' <span class="red">*</span></strong></td>'; echo '<td>'; PluginFormcreatorCategory::dropdown(array('name' => 'plugin_formcreator_categories_id', 'value' => $ID != 0 ? $this->fields["plugin_formcreator_categories_id"] : 0)); echo '</td>'; echo '<td>' . __('Direct access on homepage', 'formcreator') . '</td>'; echo '<td>'; Dropdown::showYesNo("helpdesk_home", $this->fields["helpdesk_home"]); echo '</td>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td>' . __('Description') . '</td>'; echo '<td><input type="text" name="description" value="' . $this->fields['description'] . '" size="35" /></td>'; echo '<td>' . __('Language') . '</td>'; echo '<td>'; Dropdown::showLanguages('language', array('value' => $ID != 0 ? $this->fields['language'] : $_SESSION['glpilanguage'], 'display_emptychoice' => true, 'emptylabel' => '--- ' . __('All langages', 'formcreator') . ' ---')); echo '</td>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td>' . _n('Header', 'Headers', 1, 'formcreator') . '</td>'; echo '<td colspan="3"><textarea name="content" cols="124" rows="10">' . $this->fields["content"] . '</textarea></td>'; Html::initEditorSystem('content'); echo '</tr>'; echo '<tr class="tab_bg_2">'; echo '<td>' . __('Need to be validate?', 'formcreator') . '</td>'; echo '<td>'; Dropdown::showYesNo("validation_required", $this->fields["validation_required"], -1, array('on_change' => 'changeValidators(this.value)')); echo '</td>'; echo '<td><label for="validators" id="label_validators">' . __('Available validators', 'formcreator') . '</label></td>'; echo '<td>'; $validators = array(); $query = "SELECT `users_id`\n FROM `glpi_plugin_formcreator_formvalidators`\n WHERE `forms_id` = '" . $this->getID() . "'"; $result = $GLOBALS['DB']->query($query); while (list($id) = $GLOBALS['DB']->fetch_array($result)) { $validators[] = $id; } // Si le formulaire est récursif, on authorise les validateurs des sous-entités // Sinon uniquement les validateurs de l'entité du formulaire if ($this->isRecursive()) { $entites = getSonsOf('glpi_entities', $this->getEntityID()); } else { $entites = $this->getEntityID(); } $subentities = getEntitiesRestrictRequest("", 'pu', "", $entites, true, true); $query = "SELECT u.`id`, u.`name`, u.`realname`\n FROM `glpi_users` u\n INNER JOIN `glpi_profiles_users` pu ON u.`id` = pu.`users_id`\n INNER JOIN `glpi_profiles` p ON p.`id` = pu.`profiles_id`\n INNER JOIN `glpi_profilerights` pr ON p.`id` = pr.`profiles_id`\n WHERE pr.`name` = 'ticketvalidation'\n AND (\n pr.`rights` & " . TicketValidation::VALIDATEREQUEST . " = " . TicketValidation::VALIDATEREQUEST . "\n OR pr.`rights` & " . TicketValidation::VALIDATEINCIDENT . " = " . TicketValidation::VALIDATEINCIDENT . ")\n AND {$subentities}\n GROUP BY u.`id`\n ORDER BY u.`name`"; $result = $GLOBALS['DB']->query($query); echo '<div id="validators_block" style="width: 100%">'; echo '<select name="_validators[]" size="4" style="width: 100%" multiple id="validators">'; while ($user = $GLOBALS['DB']->fetch_assoc($result)) { echo '<option value="' . $user['id'] . '"'; if (in_array($user['id'], $validators)) { echo ' selected="selected"'; } echo '>' . $user['name'] . '</option>'; } echo '</select>'; echo '</div>'; echo '<script type="text/javascript"> function changeValidators(value) { if (value == 1) { document.getElementById("label_validators").style.display = "inline"; document.getElementById("validators_block").style.display = "block"; } else { document.getElementById("label_validators").style.display = "none"; document.getElementById("validators_block").style.display = "none"; } } changeValidators(' . $this->fields["validation_required"] . '); </script>'; echo '</td>'; echo '</tr>'; echo '</td>'; echo '</tr>'; $this->showFormButtons($options); }
/** * Print the config form for default user prefs * * @param $data array containing datas * (CFG_GLPI for global config / glpi_users fields for user prefs) * * @return Nothing (display) **/ function showFormUserPrefs($data = array()) { global $DB, $CFG_GLPI; $oncentral = $_SESSION["glpiactiveprofile"]["interface"] == "central"; $userpref = false; $url = Toolbox::getItemTypeFormURL(__CLASS__); if (array_key_exists('last_login', $data)) { $userpref = true; if ($data["id"] === Session::getLoginUserID()) { $url = $CFG_GLPI['root_doc'] . "/front/preference.php"; } else { $url = $CFG_GLPI['root_doc'] . "/front/user.form.php"; } } echo "<form name='form' action='{$url}' method='post'>"; echo "<div class='center' id='tabsbody'>"; echo "<input type='hidden' name='id' value='" . $data["id"] . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . __('Personalization') . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . ($userpref ? __('Language') : __('Default language')) . "</td>"; echo "<td>"; if (Session::haveRight("config", "w") || !GLPI_DEMO_MODE) { Dropdown::showLanguages("language", array('value' => $data["language"])); } else { echo " "; } echo "<td>" . __('Date format') . "</td>"; echo "<td>"; $date_formats = array(0 => __('YYYY-MM-DD'), 1 => __('DD-MM-YYYY'), 2 => __('MM-DD-YYYY')); Dropdown::showFromArray('date_format', $date_formats, array('value' => $data["date_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Results to display by page') . "</td><td>"; // Limit using global config Dropdown::showInteger('list_limit', $data['list_limit'] < $CFG_GLPI['list_limit_max'] ? $data['list_limit'] : $CFG_GLPI['list_limit_max'], 5, $CFG_GLPI['list_limit_max'], 5); echo "</td>"; echo "<td>" . __('Number format') . "</td>"; $values = array(0 => '1 234.56', 1 => '1,234.56', 2 => '1 234,56'); echo "<td>"; Dropdown::showFromArray('number_format', $values, array('value' => $data["number_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . __('Default characters limit in dropdowns') . "</td><td>"; Dropdown::showInteger('dropdown_chars_limit', $data["dropdown_chars_limit"], 20, 100); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "<td>" . __('Display order of surnames firstnames') . "</td><td>"; $values = array(User::REALNAME_BEFORE => __('Surname, First name'), User::FIRSTNAME_BEFORE => __('First name, Surname')); Dropdown::showFromArray('names_format', $values, array('value' => $data["names_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . __('Display the complete name in tree dropdowns') . "</td><td>"; Dropdown::showYesNo('use_flat_dropdowntree', $data["use_flat_dropdowntree"]); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } if (!$userpref || $CFG_GLPI['show_count_on_tabs'] != -1) { echo "<td>" . __('Display counts in tabs') . "</td><td>"; $values = array(0 => __('No'), 1 => __('Yes')); if (!$userpref) { $values[-1] = __('Never'); } Dropdown::showFromArray('show_count_on_tabs', $values, array('value' => $data["show_count_on_tabs"])); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . __('Show GLPI ID') . "</td><td>"; Dropdown::showYesNo("is_ids_visible", $data["is_ids_visible"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "<td>" . __('CSV delimiter') . "</td><td>"; $values = array(';' => ';', ',' => ','); Dropdown::showFromArray('csv_delimiter', $values, array('value' => $data["csv_delimiter"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Notifications for my changes') . "</td><td>"; Dropdown::showYesNo("notification_to_myself", $data["notification_to_myself"]); echo "</td>"; if ($oncentral) { echo "<td>" . __('Results to display on home page') . "</td><td>"; Dropdown::showInteger('display_count_on_home', $data['display_count_on_home'], 0, 30); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; if ($oncentral) { echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Assistance') . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Private followups by default') . "</td><td>"; Dropdown::showYesNo("followup_private", $data["followup_private"]); echo "</td><td> " . __('Show new tickets on the home page') . "</td><td>"; Dropdown::showYesNo("show_jobs_at_login", $data["show_jobs_at_login"]); echo " </td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Private tasks by default') . "</td><td>"; Dropdown::showYesNo("task_private", $data["task_private"]); echo "</td><td> " . __('Request sources by default') . "</td><td>"; RequestType::dropdown(array('value' => $data["default_requesttypes_id"], 'name' => "default_requesttypes_id")); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Pre-select me as a technician when creating a ticket') . "</td><td>"; if (!$userpref || Session::haveRight('own_ticket', 1)) { Dropdown::showYesNo("set_default_tech", $data["set_default_tech"]); } else { echo Dropdown::getYesNo(0); } echo "</td><td>" . __('Automatically refresh the list of tickets (minutes)') . "</td><td>"; Dropdown::showInteger('refresh_ticket_list', $data["refresh_ticket_list"], 1, 30, 1, array(0 => __('Never'))); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Priority colors') . "</td>"; echo "<td colspan='3'>"; echo "<table><tr>"; echo "<td bgcolor='" . $data["priority_1"] . "'>1 "; echo "<input type='text' name='priority_1' size='7' value='" . $data["priority_1"] . "'></td>"; echo "<td bgcolor='" . $data["priority_2"] . "'>2 "; echo "<input type='text' name='priority_2' size='7' value='" . $data["priority_2"] . "'></td>"; echo "<td bgcolor='" . $data["priority_3"] . "'>3 "; echo "<input type='text' name='priority_3' size='7' value='" . $data["priority_3"] . "'></td>"; echo "<td bgcolor='" . $data["priority_4"] . "'>4 "; echo "<input type='text' name='priority_4' size='7' value='" . $data["priority_4"] . "'></td>"; echo "<td bgcolor='" . $data["priority_5"] . "'>5 "; echo "<input type='text' name='priority_5' size='7' value='" . $data["priority_5"] . "'></td>"; echo "<td bgcolor='" . $data["priority_6"] . "'>6 "; echo "<input type='text' name='priority_6' size='7' value='" . $data["priority_6"] . "'></td>"; echo "</tr></table>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>" . "<th colspan='4'>" . _n('Software category', 'Software categories', 2) . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Unfold the software belonging to a category') . "</td><td>"; Dropdown::showYesNo("is_categorized_soft_expanded", $data["is_categorized_soft_expanded"]); echo "</td><td>" . __('Unfold the software without category') . "</td><td>"; Dropdown::showYesNo("is_not_categorized_soft_expanded", $data["is_not_categorized_soft_expanded"]); echo "</td></tr>"; } // Only for user if (array_key_exists('personal_token', $data)) { echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Remote access key') . "</th></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Remote access key'); if (!empty($data["personal_token"])) { //TRANS: %s is the generation date echo "<br>" . sprintf(__('generated on %s'), Html::convDateTime($data["personal_token_date"])); } echo "</td><td colspan='3'>"; echo "<input type='checkbox' name='_reset_personal_token'> " . __('Regenerate'); echo "</td></tr>"; } echo "<tr><th colspan='4'>" . __('Due date progression') . "</th></tr>"; echo "<tr class='tab_bg_1'>" . "<td>" . __('OK state color') . "</td>"; echo "<td bgcolor='" . $data['duedateok_color'] . "'>"; echo "<input name='duedateok_color' size='7' value='" . $data['duedateok_color'] . "'\n type='text'>"; echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Warning state color') . "</td>"; echo "<td bgcolor='" . $data['duedatewarning_color'] . "'>"; echo "<input name='duedatewarning_color' size='7' value='" . $data['duedatewarning_color'] . "'\n type='text'>"; echo "</td>"; echo "<td>" . __('Warning state threshold') . "</td>"; echo "<td>"; Dropdown::showNumber("duedatewarning_less", array('value' => $data['duedatewarning_less'])); $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', 2), 'days' => _n('Day', 'Days', 2)); echo " "; Dropdown::showFromArray("duedatewarning_unit", $elements, array('value' => $data['duedatewarning_unit'])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>" . "<td>" . __('Critical state color') . "</td>"; echo "<td bgcolor='" . $data['duedatecritical_color'] . "'>"; echo "<input name='duedatecritical_color' size='7' value='" . $data['duedatecritical_color'] . "'\n type='text'>"; echo "</td>"; echo "<td>" . __('Critical state threshold') . "</td>"; echo "<td>"; Dropdown::showNumber("duedatecritical_less", array('value' => $data['duedatecritical_less'])); echo " "; $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', 2), 'days' => _n('Day', 'Days', 2)); Dropdown::showFromArray("duedatecritical_unit", $elements, array('value' => $data['duedatecritical_unit'])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td colspan='4' class='center'>"; echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">"; echo "</td></tr>"; echo "</table></div>"; Html::closeForm(); }
/** * Select a field using standard system * * @since version 0.83 * * @param $field_id_or_search_options integer/string/array id of the search option field * or field name * or search option array * @param $name string name of the select (if empty use linkfield) * (default '') * @param $values mixed default value to display * (default '') * @param $options array of possible options: * Parameters which could be used in options array : * - comments : boolean / is the comments displayed near the value (default false) * - any others options passed to specific display method * * @return return the string to display **/ function getValueToSelect($field_id_or_search_options, $name = '', $values = '', $options = array()) { global $CFG_GLPI; $param['comments'] = false; $param['html'] = false; foreach ($param as $key => $val) { if (!isset($options[$key])) { $options[$key] = $val; } } $searchoptions = array(); if (is_array($field_id_or_search_options)) { $searchoptions = $field_id_or_search_options; } else { $searchopt = $this->getSearchOptions(); // Get if id of search option is passed if (is_numeric($field_id_or_search_options)) { if (isset($searchopt[$field_id_or_search_options])) { $searchoptions = $searchopt[$field_id_or_search_options]; } } else { // Get if field name is passed $searchoptions = $this->getSearchOptionByField('field', $field_id_or_search_options, $this->getTable()); } } if (count($searchoptions)) { $field = $searchoptions['field']; // Normalize option if (is_array($values)) { $value = $values[$field]; } else { $value = $values; $values = array($field => $value); } if (empty($name)) { $name = $searchoptions['linkfield']; } // If not set : set to specific if (!isset($searchoptions['datatype'])) { $searchoptions['datatype'] = 'specific'; } $options['display'] = false; $unit = ''; if (isset($searchoptions['unit'])) { $unit = $searchoptions['unit']; } if (isset($options[$searchoptions['table'] . '.' . $searchoptions['field']])) { $options = array_merge($options, $options[$searchoptions['table'] . '.' . $searchoptions['field']]); } switch ($searchoptions['datatype']) { case "count": case "number": case "integer": $copytooption = array('min', 'max', 'step', 'toadd', 'unit'); foreach ($copytooption as $key) { if (isset($searchoptions[$key]) && !isset($options[$key])) { $options[$key] = $searchoptions[$key]; } } $options['value'] = $value; return Dropdown::showNumber($name, $options); case "decimal": case "mac": case "ip": case "string": case "email": case "weblink": $this->fields[$name] = $value; return Html::autocompletionTextField($this, $name, $options); case "text": $out = ''; if (isset($searchoptions['htmltext']) && $searchoptions['htmltext']) { $out = Html::initEditorSystem($name, '', false); } return $out . "<textarea cols='45' rows='5' name='{$name}'>{$value}</textarea>"; case "bool": return Dropdown::showYesNo($name, $value, -1, $options); case "color": return Html::showColorField($name, $options); case "date": case "date_delay": if (isset($options['relative_dates']) && $options['relative_dates']) { if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) { $options['with_future'] = true; } return Html::showGenericDateTimeSearch($name, $value, $options); } $copytooption = array('min', 'max', 'maybeempty', 'showyear'); foreach ($copytooption as $key) { if (isset($searchoptions[$key]) && !isset($options[$key])) { $options[$key] = $searchoptions[$key]; } } $options['value'] = $value; return Html::showDateField($name, $options); case "datetime": if (isset($options['relative_dates']) && $options['relative_dates']) { if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) { $options['with_future'] = true; } $options['with_time'] = true; return Html::showGenericDateTimeSearch($name, $value, $options); } $copytooption = array('mindate', 'maxdate', 'mintime', 'maxtime', 'maybeempty', 'timestep'); foreach ($copytooption as $key) { if (isset($searchoptions[$key]) && !isset($options[$key])) { $options[$key] = $searchoptions[$key]; } } $options['value'] = $value; return Html::showDateTimeField($name, $options); case "timestamp": $copytooption = array('addfirstminutes', 'emptylabel', 'inhours', 'max', 'min', 'step', 'toadd', 'display_emptychoice'); foreach ($copytooption as $key) { if (isset($searchoptions[$key]) && !isset($options[$key])) { $options[$key] = $searchoptions[$key]; } } $options['value'] = $value; return Dropdown::showTimeStamp($name, $options); case "itemlink": // Do not use dropdown if wanted to select string value instead of ID if (isset($options['itemlink_as_string']) && $options['itemlink_as_string']) { break; } case "dropdown": $copytooption = array('condition', 'displaywith', 'emptylabel', 'right', 'toadd'); $options['name'] = $name; $options['value'] = $value; foreach ($copytooption as $key) { if (isset($searchoptions[$key]) && !isset($options[$key])) { $options[$key] = $searchoptions[$key]; } } if (!isset($options['entity'])) { $options['entity'] = $_SESSION['glpiactiveentities']; } $itemtype = getItemTypeForTable($searchoptions['table']); return $itemtype::dropdown($options); case "right": return Profile::dropdownRights(Profile::getRightsFor($searchoptions['rightclass']), $name, $value, array('multiple' => false, 'display' => false)); case "itemtypename": if (isset($searchoptions['itemtype_list'])) { $options['types'] = $CFG_GLPI[$searchoptions['itemtype_list']]; } $copytooption = array('types'); $options['value'] = $value; foreach ($copytooption as $key) { if (isset($searchoptions[$key]) && !isset($options[$key])) { $options[$key] = $searchoptions[$key]; } } if (isset($options['types'])) { return Dropdown::showItemTypes($name, $options['types'], $options); } return false; case "language": $copytooption = array('emptylabel', 'display_emptychoice'); foreach ($copytooption as $key) { if (isset($searchoptions[$key]) && !isset($options[$key])) { $options[$key] = $searchoptions[$key]; } } $options['value'] = $value; return Dropdown::showLanguages($name, $options); } // Get specific display if available $itemtype = getItemTypeForTable($searchoptions['table']); if ($item = getItemForItemtype($itemtype)) { $specific = $item->getSpecificValueToSelect($searchoptions['field'], $name, $values, $options); if (strlen($specific)) { return $specific; } } } // default case field text $this->fields[$name] = $value; return Html::autocompletionTextField($this, $name, $options); }
function showForm($ID, $options) { global $DB, $LANG, $CFG_GLPI; if (!haveRight("config", "w")) { return false; } if (empty($ID)) { if ($this->getEmpty()) { $notificationtemplates_id = $options['notificationtemplates_id']; } } else { if ($this->getFromDB($ID)) { $notificationtemplates_id = $this->getField('notificationtemplates_id'); } } $canedit = haveRight("config", "w"); $template = new NotificationTemplate(); $template->getFromDB($notificationtemplates_id); initEditorSystem('content_html'); $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . $template->getTypeName() . "</td>"; echo "<td colspan='2'><a href='" . getItemTypeFormURL('NotificationTemplate') . "?id=" . $notificationtemplates_id . "'>" . $template->getField('name') . "</a>"; echo "</td><td><a href='#' onClick=\"var w=window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=list_notificationtags&sub_type=" . $template->getField('itemtype') . "' ,\n 'glpipopup', 'height=400, width=1000, top=100, left=100," . " scrollbars=yes' );w.focus();\">" . $LANG['mailing'][138] . "</a></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['setup'][41] . " :</td><td colspan='3'>"; //Get all used languages $used = self::getAllUsedLanguages($notificationtemplates_id); if ($ID > 0) { if (isset($used[$this->getField('language')])) { unset($used[$this->getField('language')]); } } Dropdown::showLanguages("language", array('display_none' => true, 'value' => $this->fields['language'], 'used' => $used)); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['knowbase'][14] . " :</td>"; echo "<td colspan='3'>"; echo "<input type='text' name='subject'size='100' value='" . $this->fields["subject"] . "'>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>"; echo $LANG['mailing'][115] . ' ' . $LANG['mailing'][117] . " :<br>(" . $LANG['mailing'][128] . ")"; echo "</td><td colspan='3'>"; echo "<textarea cols='100' rows='15' name='content_text' >" . $this->fields["content_text"]; echo "</textarea></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['mailing'][115] . ' ' . $LANG['mailing'][116] . " :</td><td colspan='3'>"; echo "<textarea cols='100' rows='15' name='content_html'>" . $this->fields["content_html"]; echo "</textarea>"; echo "<input type='hidden' name='notificationtemplates_id' value='" . $template->getField('id') . "'>"; echo "</td></tr>"; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
function showForm($ID, $options) { global $DB, $CFG_GLPI; if (!Session::haveRight("config", "w")) { return false; } $notificationtemplates_id = -1; if (isset($options['notificationtemplates_id'])) { $notificationtemplates_id = $options['notificationtemplates_id']; } if ($this->getFromDB($ID)) { $notificationtemplates_id = $this->getField('notificationtemplates_id'); } $this->initForm($ID, $options); $template = new NotificationTemplate(); $template->getFromDB($notificationtemplates_id); Html::initEditorSystem('content_html'); $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . NotificationTemplate::getTypeName() . "</td>"; echo "<td colspan='2'><a href='" . Toolbox::getItemTypeFormURL('NotificationTemplate') . "?id=" . $notificationtemplates_id . "'>" . $template->getField('name') . "</a>"; echo "</td><td>" . "<a class='vsubmit' href='#' onClick=\"var w=window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=list_notificationtags&sub_type=" . $template->getField('itemtype') . "' ,'glpipopup', 'height=400, width=1000, top=100, " . "left=100, scrollbars=yes' );w.focus();\">" . __('Show list of available tags') . "</a>" . "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Language') . "</td><td colspan='3'>"; //Get all used languages $used = self::getAllUsedLanguages($notificationtemplates_id); if ($ID > 0) { if (isset($used[$this->getField('language')])) { unset($used[$this->getField('language')]); } } Dropdown::showLanguages("language", array('display_emptychoice' => true, 'value' => $this->fields['language'], 'used' => $used)); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Subject') . "</td>"; echo "<td colspan='3'>"; echo "<input type='text' name='subject'size='100' value='" . $this->fields["subject"] . "'>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>"; _e('Email text body'); echo "<br>" . __('(leave the field empty for a generation from HTML)'); echo "</td><td colspan='3'>"; echo "<textarea cols='100' rows='15' name='content_text' >" . $this->fields["content_text"]; echo "</textarea></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; _e('Email HTML body'); echo "</td><td colspan='3'>"; echo "<textarea cols='100' rows='15' name='content_html'>" . $this->fields["content_html"]; echo "</textarea>"; echo "<input type='hidden' name='notificationtemplates_id' value='" . $template->getField('id') . "'>"; echo "</td></tr>"; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
/** * Display translation form * * @param string $itemtype Item type * @param int $items_id Item ID * @param innt $id Translation ID (defaults to -1) */ function showForm($itemtype, $items_id, $id = -1) { global $CFG_GLPI; if ($id > 0) { $this->check($id, READ); } else { // Create item $this->check(-1, CREATE); } $this->showFormHeader(); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Language') . " :</td>"; echo "<td>"; echo "<input type='hidden' name='plugin_fields_itemtype' value='{$itemtype}'>"; echo "<input type='hidden' name='plugin_fields_items_id' value='{$items_id}'>"; if ($id > 0) { echo Dropdown::getLanguageName($this->fields['language']); } else { Dropdown::showLanguages("language", array('display_none' => false, 'value' => $_SESSION['glpilanguage'], 'used' => self::getAlreadyTranslatedForItem($itemtype, $items_id))); } echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td><label for='label'>" . __('Label') . "</label></td>"; echo "<td colspan='3'>"; echo "<input type='text' name='label' id='label' value='{$this->fields["label"]}'/>"; echo "</td></tr>\n"; $this->showFormButtons(); return true; }
/** * Show the Form edit form the the adminsitrator in the config page * * @param Array $options Optional options * * @return NULL Nothing, just display the form */ public function showForm($ID, $options = array()) { $this->initForm($ID, $options); $this->showTabs($options); $this->showFormHeader($options); echo '<tr class="tab_bg_1">'; echo '<td><strong>' . __('Name') . ' <span class="red">*</span></strong></td>'; echo '<td><input type="text" name="name" value="' . $this->fields["name"] . '" size="54"/></td>'; echo '<td><strong>' . __('Active') . ' <span class="red">*</span></strong></td>'; echo '<td>'; Dropdown::showYesNo("is_active", $this->fields["is_active"]); echo '</td>'; echo '</tr>'; echo '<tr class="tab_bg_2">'; echo '<td><strong>' . __('Category') . ' <span class="red">*</span></strong></td>'; echo '<td>'; PluginFormcreatorCategory::dropdown(array('name' => 'plugin_formcreator_categories_id', 'value' => $ID != 0 ? $this->fields["plugin_formcreator_categories_id"] : 1)); echo '</td>'; echo '<td>' . __('Direct access on homepage', 'formcreator') . '</td>'; echo '<td>'; Dropdown::showYesNo("helpdesk_home", $this->fields["helpdesk_home"]); echo '</td>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td>' . __('Description') . '</td>'; echo '<td><input type="text" name="description" value="' . $this->fields['description'] . '" size="54" /></td>'; echo '<td>' . __('Language') . '</td>'; echo '<td>'; Dropdown::showLanguages('language', array('value' => $ID != 0 ? $this->fields['language'] : $_SESSION['glpilanguage'], 'display_emptychoice' => true, 'emptylabel' => '--- ' . __('All langages', 'formcreator') . ' ---')); echo '</td>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td>' . _n('Header', 'Headers', 1, 'formcreator') . '</td>'; echo '<td colspan="3"><textarea name="content" cols="115" rows="10">' . $this->fields["content"] . '</textarea></td>'; Html::initEditorSystem('content'); echo '</tr>'; $this->showFormButtons($options); $this->addDivForTabs(); }
/** * Print the config form for default user prefs * * @param $data array containing datas * (CFG_GLPI for global config / glpi_users fields for user prefs) * * @return Nothing (display) **/ function showFormUserPrefs($data = array()) { global $DB, $LANG, $CFG_GLPI; $oncentral = $_SESSION["glpiactiveprofile"]["interface"] == "central"; $userpref = false; $url = getItemTypeFormURL(__CLASS__); if (array_key_exists('last_login', $data)) { $userpref = true; if ($data["id"] === getLoginUserID()) { $url = $CFG_GLPI['root_doc'] . "/front/preference.php"; } else { $url = $CFG_GLPI['root_doc'] . "/front/user.form.php"; } } echo "<form name='form' action='{$url}' method='post'>"; echo "<div class='center' id='tabsbody'>"; echo "<input type='hidden' name='id' value='" . $data["id"] . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . $LANG['setup'][6] . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][111] . " :</td><td>"; // Limit using global config Dropdown::showInteger('list_limit', $data['list_limit'] < $CFG_GLPI['list_limit_max'] ? $data['list_limit'] : $CFG_GLPI['list_limit_max'], 5, $CFG_GLPI['list_limit_max'], 5); echo "</td><td>" . $LANG['setup'][128] . " :</td>"; echo "<td>"; $date_formats = array(0 => $LANG['calendar'][0], 1 => $LANG['calendar'][1], 2 => $LANG['calendar'][2]); Dropdown::showFromArray('date_format', $date_formats, array('value' => $data["date_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . $LANG['setup'][112] . " :</td><td>"; Dropdown::showInteger('dropdown_chars_limit', $data["dropdown_chars_limit"], 20, 100); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "<td>" . $LANG['setup'][150] . " :</td>"; $values = array(0 => '1 234.56', 1 => '1,234.56', 2 => '1 234,56'); echo "<td>"; Dropdown::showFromArray('number_format', $values, array('value' => $data["number_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . $LANG['setup'][132] . " :</td><td>"; Dropdown::showYesNo('use_flat_dropdowntree', $data["use_flat_dropdowntree"]); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "<td>" . $LANG['setup'][10] . " :</td><td>"; $values = array(REALNAME_BEFORE => $LANG['common'][48] . " " . $LANG['common'][43], FIRSTNAME_BEFORE => $LANG['common'][43] . " " . $LANG['common'][48]); Dropdown::showFromArray('names_format', $values, array('value' => $data["names_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td colspan='2'></td>"; echo "<td>" . $LANG['setup'][7] . " :</td><td>"; $values = array(';' => ';', ',' => ','); Dropdown::showFromArray('csv_delimiter', $values, array('value' => $data["csv_delimiter"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . $LANG['setup'][129] . " :</td><td>"; Dropdown::showYesNo("is_ids_visible", $data["is_ids_visible"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "<td>" . ($userpref ? $LANG['setup'][41] : $LANG['setup'][113]) . " :</td><td>"; if (haveRight("config", "w") || !GLPI_DEMO_MODE) { Dropdown::showLanguages("language", array('value' => $data["language"])); } else { echo " "; } echo "</td></tr>"; if ($oncentral) { echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['title'][24] . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][39] . " :</td><td>"; Dropdown::showYesNo("followup_private", $data["followup_private"]); echo "</td><td> " . $LANG['setup'][110] . " :</td><td>"; Dropdown::showYesNo("show_jobs_at_login", $data["show_jobs_at_login"]); echo " </td></tr>"; echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][40] . " :</td><td>"; Dropdown::showYesNo("task_private", $data["task_private"]); echo "</td><td> " . $LANG['job'][44] . " :</td><td>"; Dropdown::show('RequestType', array('value' => $data["default_requesttypes_id"], 'name' => "default_requesttypes_id")); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][114] . " :</td>"; echo "<td colspan='3'>"; echo "<table><tr>"; echo "<td bgcolor='" . $data["priority_1"] . "'>1 : "; echo "<input type='text' name='priority_1' size='7' value='" . $data["priority_1"] . "'></td>"; echo "<td bgcolor='" . $data["priority_2"] . "'>2 : "; echo "<input type='text' name='priority_2' size='7' value='" . $data["priority_2"] . "'></td>"; echo "<td bgcolor='" . $data["priority_3"] . "'>3 : "; echo "<input type='text' name='priority_3' size='7' value='" . $data["priority_3"] . "'></td>"; echo "<td bgcolor='" . $data["priority_4"] . "'>4 : "; echo "<input type='text' name='priority_4' size='7' value='" . $data["priority_4"] . "'></td>"; echo "<td bgcolor='" . $data["priority_5"] . "'>5 : "; echo "<input type='text' name='priority_5' size='7' value='" . $data["priority_5"] . "'></td>"; echo "<td bgcolor='" . $data["priority_6"] . "'>6 : "; echo "<input type='text' name='priority_6' size='7' value='" . $data["priority_6"] . "'></td>"; echo "</tr></table>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['softwarecategories'][5] . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['softwarecategories'][4] . " :</td><td>"; Dropdown::showYesNo("is_categorized_soft_expanded", $data["is_categorized_soft_expanded"]); echo "</td><td>" . $LANG['softwarecategories'][3] . " :</td><td>"; Dropdown::showYesNo("is_not_categorized_soft_expanded", $data["is_not_categorized_soft_expanded"]); echo "</td></tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td colspan='4' class='center'>"; echo "<input type='submit' name='update' class='submit' value=\"" . $LANG['buttons'][2] . "\">"; echo "</td></tr>"; echo "</table></div>"; echo "</form>"; }
function showFormEdit($params, $options = array()) { global $LANG, $CFG_GLPI; if ($params['id'] > 0) { $this->check($params['id'], 'r'); } else { // Create item $this->check(-1, 'w'); } echo "<form method='POST' \n action='" . $CFG_GLPI["root_doc"] . "/plugins/formcreator/front/title.form.php'>"; echo "<input type='hidden' name='id' \n value='" . $this->fields['id'] . "' />"; echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe fix_tab_height'>"; echo "<tr>"; echo "<th colspan='1'>" . $LANG['plugin_formcreator']["title"][1] . "</th>"; echo "<th colspan='1'>" . $LANG['plugin_formcreator']["title"][2] . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo '<td>' . $LANG['plugin_formcreator']["title"][1] . ' : <textarea name="name" rows="10" cols="100">' . $this->fields['name'] . '</textarea></td>'; echo "<td>"; Dropdown::showLanguages("language", array('value' => $this->fields["language"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo '<td class="center" colspan="2">' . $LANG['plugin_formcreator']["title"][3] . '</td>'; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo '<td colspan="2">' . self::bbCode($this->fields['name']) . '</td>'; echo "</tr>"; echo "<tr>"; echo "<td class='center' colspan='1'>"; echo "<input class='submit' type='submit' value='"; echo __('Update'); echo "' name='update'>"; echo "</td>"; echo "<td class='center' colspan='1'>"; echo "<input class='submit' type='submit' value='"; echo __('Purge'); echo "' name='delete'>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; Html::closeForm(); }
/** * Display translation form * * @param $ID field (default -1) * @param $options array */ function showForm($ID = -1, $options = array()) { global $CFG_GLPI; if (isset($options['parent']) && !empty($options['parent'])) { $item = $options['parent']; } if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options['itemtype'] = get_class($item); $options['knowbaseitems_id'] = $item->getID(); $this->check(-1, CREATE, $options); } Html::initEditorSystem('answer'); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Language') . " :</td>"; echo "<td>"; echo "<input type='hidden' name='knowbaseitems_id' value='" . $item->getID() . "'>"; if ($ID > 0) { echo Dropdown::getLanguageName($this->fields['language']); } else { Dropdown::showLanguages("language", array('display_none' => false, 'value' => $_SESSION['glpilanguage'], 'used' => self::getAlreadyTranslatedForItem($item))); } echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Subject') . "</td>"; echo "<td colspan='3'>"; echo "<textarea cols='100' rows='1' name='name'>" . $this->fields["name"] . "</textarea>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Content') . "</td>"; echo "<td colspan='3'>"; echo "<textarea cols='100' rows='30' id='answer' name='answer'>" . $this->fields["answer"]; echo "</textarea>"; echo "</td></tr>\n"; $this->showFormButtons($options); return true; }
/** * Print the user preference form * * @param $target form target * @param $ID integer Id of the user * * @return boolean : user found **/ function showMyForm($target, $ID) { global $CFG_GLPI, $PLUGIN_HOOKS; // Affiche un formulaire User if ($ID != Session::getLoginUserID() && !$this->currentUserHaveMoreRightThan($ID)) { return false; } if ($this->getFromDB($ID)) { $authtype = $this->getAuthMethodsByID(); $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"])); // No autocopletion : $save_autocompletion = $CFG_GLPI["use_ajax_autocompletion"]; $CFG_GLPI["use_ajax_autocompletion"] = false; echo "<div class='center'>"; echo "<form method='post' name='user_manager' action='" . $target . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . sprintf(__('%1$s: %2$s'), __('Login'), $this->fields["name"]); echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>"; echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>"; echo "</th></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>"; if ($extauth && isset($authtype['realname_field']) && !empty($authtype['realname_field'])) { echo $this->fields["realname"]; } else { Html::autocompletionTextField($this, "realname"); } echo "</td>"; //do some rights verification if (!$extauth && Session::haveRight("password_update", "1")) { echo "<td>" . __('Password') . "</td>"; echo "<td><input id='password' type='password' name='password' value='' size='30' autocomplete='off' onkeyup=\"return passwordCheck();\">"; echo "</td></tr>"; } else { echo "<td colspan='2'></tr>"; } echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>"; if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) { echo $this->fields["firstname"]; } else { Html::autocompletionTextField($this, "firstname"); } echo "</td>"; if (!$extauth && Session::haveRight("password_update", "1")) { echo "<td>" . __('Password confirmation') . "</td>"; echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>"; echo "</td></tr>"; } else { echo "<td colspan='2'></tr>"; } echo "<tr class='tab_bg_1'><td class='top'>" . _n('Email', 'Emails', 2); UserEmail::showAddEmailButton($this); echo "</td><td>"; UserEmail::showForUser($this); echo "</td>"; if (!$extauth && Session::haveRight("password_update", "1")) { echo "<td>" . __('Password security policy') . "</td>"; echo "<td>"; Config::displayPasswordSecurityChecks(); echo "</td>"; } else { echo "<td colspan='2'>"; } echo "</tr>"; echo "<tr class='tab_bg_1'><td>" . __('Mobile phone') . " :</td><td>"; if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) { echo $this->fields["mobile"]; } else { Html::autocompletionTextField($this, "mobile"); } echo "</td>"; if (!GLPI_DEMO_MODE) { echo "<td>" . __('Language') . "</td><td>"; // Use session variable because field in table may be null if same of the global config Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"])); } else { echo "<td colspan='2'> "; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Phone') . "</td><td>"; if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) { echo $this->fields["phone"]; } else { Html::autocompletionTextField($this, "phone"); } echo "</td>"; if (count($_SESSION['glpiprofiles']) > 1) { echo "<td>" . __('Default profile') . "</td><td>"; $options = array(0 => Dropdown::EMPTY_VALUE); $options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id'])); Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"])); } else { echo "<td colspan='2'> "; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Phone 2') . "</td><td>"; if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) { echo $this->fields["phone2"]; } else { Html::autocompletionTextField($this, "phone2"); } echo "</td>"; $entities = Profile_User::getUserEntities($this->fields['id'], 1); if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) { echo "<td>" . __('Default entity') . "</td><td>"; Entity::dropdown(array('value' => $this->fields['entities_id'], 'entity' => $entities)); } else { echo "<td colspan='2'> "; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>"; $entities = Profile_User::getUserEntities($ID, true); Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $entities)); if (Session::haveRight("config", "w")) { echo "<td>" . __('Use GLPI in mode') . "</td><td>"; $modes[Session::NORMAL_MODE] = __('Normal'); //$modes[Session::TRANSLATION_MODE] = __('Translation'); $modes[Session::DEBUG_MODE] = __('Debug'); Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"])); } else { echo "<td colspan='2'> "; } echo "</td></tr>"; echo "<tr><td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; $CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion; return true; } return false; }
/** * Print the user preference form * * @param $target form target * @param $ID Integer : Id of the user * * @return boolean : user found **/ function showMyForm($target, $ID) { global $CFG_GLPI, $LANG, $PLUGIN_HOOKS; // Affiche un formulaire User if ($ID != getLoginUserID() && !$this->currentUserHaveMoreRightThan($ID)) { return false; } if ($this->getFromDB($ID)) { $authtype = $this->getAuthMethodsByID(); $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"])); // No autocopletion : $save_autocompletion = $CFG_GLPI["use_ajax_autocompletion"]; $CFG_GLPI["use_ajax_autocompletion"] = false; echo "<div class='center'>"; echo "<form method='post' name='user_manager' action='" . $target . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . $LANG['setup'][18] . " : " . $this->fields["name"]; echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>"; echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>"; echo "</th></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['common'][48] . " :</td><td>"; if ($extauth && isset($authtype['realname_field']) && !empty($authtype['realname_field'])) { echo $this->fields["realname"]; } else { autocompletionTextField($this, "realname"); } echo "</td>"; //do some rights verification if (!$extauth && haveRight("password_update", "1")) { echo "<td>" . $LANG['setup'][19] . " :</td>"; echo "<td><input type='password' name='password' value='' size='30' autocomplete='off'>"; echo "</td></tr>"; } else { echo "<td colspan='2'></tr>"; } echo "<tr class='tab_bg_1'><td>" . $LANG['common'][43] . " :</td><td>"; if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) { echo $this->fields["firstname"]; } else { autocompletionTextField($this, "firstname"); } echo "</td>"; if (!$extauth && haveRight("password_update", "1")) { echo "<td>" . $LANG['setup'][20] . " :</td>"; echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>"; echo "</td></tr>"; } else { echo "<td colspan='2'></tr>"; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['setup'][14] . " :</td><td>"; if ($extauth && isset($authtype['email_field']) && !empty($authtype['email_field'])) { echo $this->fields["email"]; } else { autocompletionTextField($this, "email", array('name' => "email_form")); if (!NotificationMail::isUserAddressValid($this->fields["email"])) { echo "<br><span class='red'>" . $LANG['mailing'][110] . "</span>"; } } echo "</td>"; if (!GLPI_DEMO_MODE) { echo "<td>" . $LANG['setup'][41] . " :</td><td>"; /// Use sesion variable because field in table may be null if same of the global config Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"])); } else { echo "<td colspan='2'> "; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['common'][42] . " :</td><td>"; if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) { echo $this->fields["mobile"]; } else { autocompletionTextField($this, "mobile"); } echo "</td>"; if (count($_SESSION['glpiprofiles']) > 1) { echo "<td>" . $LANG['profiles'][13] . " :</td><td>"; $options = array(0 => DROPDOWN_EMPTY_VALUE); $options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id'])); Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"])); } else { echo "<td colspan='2'> "; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['help'][35] . " :</td><td>"; if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) { echo $this->fields["phone"]; } else { autocompletionTextField($this, "phone"); } echo "</td>"; if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) { $entities = Profile_User::getUserEntities($this->fields['id'], 1); echo "<td>" . $LANG['profiles'][37] . " :</td><td>"; Dropdown::show('Entity', array('value' => $this->fields['entities_id'], 'entity' => $entities)); } else { echo "<td colspan='2'> "; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['help'][35] . " 2 : </td><td>"; if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) { echo $this->fields["phone2"]; } else { autocompletionTextField($this, "phone2"); } echo "</td>"; if (haveRight("config", "w")) { echo "<td>" . $LANG['setup'][138] . " :</td><td>"; $modes[NORMAL_MODE] = $LANG['setup'][135]; $modes[TRANSLATION_MODE] = $LANG['setup'][136]; $modes[DEBUG_MODE] = $LANG['setup'][137]; Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"])); } else { echo "<td colspan='2'> "; } echo "</td></tr>"; echo "<tr><td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>"; echo "</td></tr>"; echo "</table></form></div>"; $CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion; return true; } return false; }