<?php include '../../../inc/includes.php'; Session::checkRight("entity", UPDATE); Plugin::load('formcreator', true); $dropdown = new PluginFormcreatorCategory(); if (isset($_POST['add']) && isset($_POST['name'])) { $found = $dropdown->find("name LIKE '" . $_POST['name'] . "'"); if (!empty($found)) { Session::addMessageAfterRedirect(__('A category already exists with the same name! Category creation failed.', 'formcreator'), false, ERROR); Html::back(); } } include GLPI_ROOT . "/front/dropdown.common.form.php";
<?php include '../../../inc/includes.php'; Session::checkRight("config", "w"); Plugin::load('formcreator', true); $dropdown = new PluginFormcreatorCategory(); if (isset($_POST['add']) && isset($_POST['name'])) { $founded = $dropdown->find('name LIKE "' . $_POST['name'] . '"'); if (!empty($founded)) { Session::addMessageAfterRedirect(__('A category already exists with the same name! Category creation failed.', 'formcreator'), false, ERROR); Html::back(); } } include GLPI_ROOT . "/front/dropdown.common.form.php";
/** * 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); }
/** * 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(); }