Init the Editor System to a textarea
static public initEditorSystem ( $name, $rand = '', $display = true ) : nothing | ||
$name | name of the html textarea to use | |
$rand | rand of the html textarea to use (if empty no image paste system)(default '') | |
$display | boolean display or get js script (true by default) | |
return | nothing |
public function showForm($ID, $options = array()) { if (!$this->isNewID($ID)) { $this->check($ID, READ); } else { $this->check(-1, UPDATE); } $options['colspan'] = 2; $options['target'] = Toolbox::getItemTypeFormURL(__CLASS__); $this->showFormHeader($options); echo '<table class="tab_cadre_fixe">'; echo "<tr class='line0'><td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name"); echo "</td>"; echo "</tr>"; echo "<tr class='line1'><td>" . __('Content') . "</td>"; echo "<td>"; echo "<textarea name='comment' id ='comment' >" . $this->fields['comment'] . "</textarea>"; Html::initEditorSystem('comment'); echo "</td>"; echo "</tr>"; $this->showFormButtons($options); return true; }
/** * @see CommonDropdown::displaySpecificTypeField() **/ function displaySpecificTypeField($ID, $field = array()) { switch ($field['type']) { case 'tinymce': // Display empty field echo " </td></tr>"; // And a new line to have a complete display echo "<tr class='center'><td colspan='5'>"; $rand = mt_rand(); Html::initEditorSystem($field['name'] . $rand); echo "<textarea id='" . $field['name'] . "{$rand}' name='" . $field['name'] . "' rows='3'>" . $this->fields[$field['name']] . "</textarea>"; break; } }
public function displayField($canEdit = true) { if ($canEdit) { $required = $this->fields['required'] ? ' required' : ''; echo '<textarea class="form-control" rows="5" name="formcreator_field_' . $this->fields['id'] . '" id="formcreator_field_' . $this->fields['id'] . '" onchange="formcreatorChangeValueOf(' . $this->fields['id'] . ', this.value);">' . str_replace('\\r\\n', PHP_EOL, $this->getValue()) . '</textarea>'; if ($GLOBALS['CFG_GLPI']["use_rich_text"]) { Html::initEditorSystem('formcreator_field_' . $this->fields['id']); } } else { if ($GLOBALS['CFG_GLPI']["use_rich_text"]) { echo plugin_formcreator_decode($this->getAnswer()); } else { echo nl2br($this->getAnswer()); } } }
/** * Print out an HTML "<form>" for knowbase item * * @param $ID * @param $options array * - target for the Form * * @return nothing (display the form) **/ function showForm($ID, $options = array()) { // show kb item form if (!Session::haveRight("knowbase", "w") && !Session::haveRight("faq", "w")) { return false; } $this->initForm($ID, $options); $canedit = $this->can($ID, 'w'); $canrecu = $this->can($ID, 'recursive'); if ($canedit) { // Load ticket solution if (empty($ID) && isset($options['item_itemtype']) && !empty($options['item_itemtype']) && isset($options['item_items_id']) && !empty($options['item_items_id'])) { if ($item = getItemForItemtype($options['item_itemtype'])) { if ($item->getFromDB($options['item_items_id'])) { $this->fields['name'] = $item->getField('name'); $this->fields['answer'] = $item->getField('solution'); if ($item->isField('itilcategories_id')) { $ic = new ItilCategory(); if ($ic->getFromDB($item->getField('itilcategories_id'))) { $this->fields['knowbaseitemcategories_id'] = $ic->getField('knowbaseitemcategories_id'); } } } } } echo "<div id='contenukb'>"; Html::initEditorSystem('answer'); echo "<form method='post' id='form_kb' name='form_kb' action=\"" . $this->getFormUrl() . "\">"; if (!empty($ID)) { echo "<input type='hidden' name='id' value='{$ID}'>\n"; } echo "<fieldset>"; echo "<legend>" . __('Category name') . "</legend>"; echo "<div class='center'>" . __('Select a category for this item') . " "; KnowbaseItemCategory::dropdown(array('value' => $this->fields["knowbaseitemcategories_id"])); echo "</div></fieldset>"; echo "<fieldset>"; echo "<legend>" . __('Subject') . "</legend>"; echo "<div class='center'>"; echo "<textarea cols='80' rows='2' name='name'>" . $this->fields["name"] . "</textarea>"; echo "</div></fieldset>"; echo "<fieldset>"; echo "<legend>" . __('Content') . "</legend>"; echo "<div class='center spaced'>"; echo "<textarea cols='80' rows='30' id='answer' name='answer'>" . $this->fields["answer"]; echo "</textarea></div></fieldset>"; if (!empty($ID)) { echo "<fieldset>"; echo "<legend></legend>"; echo "<div class='baskb'>"; if ($this->fields["users_id"]) { //TRANS: %s is the writer name printf(__('%1$s: %2$s'), __('Writer'), getUserName($this->fields["users_id"], "1")); } echo "<span class='baskb_right'>"; if ($this->fields["date_mod"]) { //TRANS: %s is the datetime of update printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"])); } echo "</span><br>"; if ($this->fields["date"]) { //TRANS: %s is the datetime of insertion printf(__('Created on %s'), Html::convDateTime($this->fields["date"])); } echo "<span class='baskb_right'>"; //TRANS: %d is the number of view printf(_n('%d view', '%d views', $this->fields["view"]), $this->fields["view"]); echo "</span></div>"; echo "</fieldset>"; } echo "<p class='center'>"; // if (Session::isMultiEntitiesMode()) { // _e('Entity'); // Entity::dropdown(array('value' => $this->fields["entities_id"], // 'comments' => 0 )); // _e('Child entities: '); // if ($canrecu) { // Dropdown::showYesNo("is_recursive", $this->fields["is_recursive"]); // } else { // echo Dropdown::getYesNo($this->fields["is_recursive"]); // } // } // echo "<br><br>" . echo __('Put this item in the FAQ') . " "; if (Session::haveRight("faq", "w") && Session::haveRight("knowbase", "w")) { Dropdown::showYesNo('is_faq', $this->fields["is_faq"]); } else { echo Dropdown::getYesNo($this->fields["is_faq"]); } echo "<br><br>"; if ($ID > 0) { echo "<input type='submit' class='submit' name='update' value=\"" . _sx('button', 'Save') . "\">"; } else { echo "<input type='hidden' name='users_id' value=\"" . Session::getLoginUserID() . "\">"; echo "<input type='submit' class='submit' name='add' value=\"" . _sx('button', 'Add') . "\">"; } echo "<span class='big_space'>"; echo "<input type='reset' class='submit' value=\"" . _sx('button', 'Blank') . "\"></span>"; echo "</p>"; Html::closeForm(); echo "</div>"; return true; } // ELSE Cannot edit return false; }
/** * Convert simple text content to rich text content, init html editor * * @since version 0.85 * * @param $name name of textarea * @param $content content to convert in html * @param $rand * * @return $content **/ function setRichTextContent($name, $content, $rand) { // Init html editor Html::initEditorSystem($name, $rand); // If no html if ($content == strip_tags($content)) { $content = $this->convertTagToImage($content); } // If content does not contain <br> or <p> html tag, use nl2br $content = Html::entity_decode_deep($content); if (!preg_match("/<br\\s?\\/?>/", $content) && !preg_match("/<p>/", $content)) { $content = nl2br($content); } return Toolbox::clean_cross_side_scripting_deep($content); }
/** * 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(); }
/** * Convert simple text content to rich text content, init html editor * * @since version 0.85 * * @param $name name of textarea * @param $content content to convert in html * @param $rand * * @return $content **/ function setRichTextContent($name, $content, $rand) { // Init html editor Html::initEditorSystem($name, $rand); // If no html if ($content == strip_tags($content)) { $content = $this->convertTagToImage($content); } // Neutralize non valid HTML tags $content = html::clean($content, false, 1); // If content does not contain <br> or <p> html tag, use nl2br if (!preg_match("/<br\\s?\\/?>/", $content) && !preg_match("/<p>/", $content)) { $content = nl2br($content); } return $content; }
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; }
/** * 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($options = array()) { $rand = mt_rand(); $obj = new PluginFormcreatorTarget(); $found = $obj->find("itemtype = '" . __CLASS__ . "' AND items_id = " . (int) $this->getID()); $target = array_shift($found); $form = new PluginFormcreatorForm(); $form->getFromDB($target['plugin_formcreator_forms_id']); echo '<div class="center" style="width: 950px; margin: 0 auto;">'; echo '<form name="form_target" method="post" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/targetticket.form.php">'; // General information : name echo '<table class="tab_cadre_fixe">'; echo '<tr><th colspan="2">' . __('Edit a destination', 'formcreator') . '</th></tr>'; echo '<tr class="line1">'; echo '<td width="15%"><strong>' . __('Name') . ' <span style="color:red;">*</span></strong></td>'; echo '<td width="85%"><input type="text" name="name" style="width:704px;" value="' . $target['name'] . '"></textarea</td>'; echo '</tr>'; echo '</table>'; // Ticket information : title, template... echo '<table class="tab_cadre_fixe">'; echo '<tr><th colspan="4">' . _n('Target ticket', 'Target tickets', 1, 'formcreator') . '</th></tr>'; echo '<tr class="line1">'; echo '<td><strong>' . __('Ticket title', 'formcreator') . ' <span style="color:red;">*</span></strong></td>'; echo '<td colspan="3"><input type="text" name="title" style="width:704px;" value="' . $this->fields['name'] . '"></textarea</td>'; echo '</tr>'; echo '<tr class="line0">'; echo '<td><strong>' . __('Description') . ' <span style="color:red;">*</span></strong></td>'; echo '<td colspan="3">'; echo '<textarea name="comment" style="width:700px;" rows="15">' . $this->fields['comment'] . '</textarea>'; if ($GLOBALS['CFG_GLPI']["use_rich_text"]) { Html::initEditorSystem('comment'); } echo '</td>'; echo '</tr>'; // Ticket Template echo '<tr class="line1">'; echo '<td width="15%">' . _n('Ticket template', 'Ticket templates', 1) . '</td>'; echo '<td width="25%">'; Dropdown::show('TicketTemplate', array('name' => 'tickettemplates_id', 'value' => $this->fields['tickettemplates_id'])); echo '</td>'; echo '<td width="15%">' . __('Due date') . '</td>'; echo '<td width="45%">'; // ------------------------------------------------------------------------------------------- // Due date type selection // ------------------------------------------------------------------------------------------- Dropdown::showFromArray('due_date_rule', array('' => Dropdown::EMPTY_VALUE, 'answer' => __('equals to the answer to the question', 'formcreator'), 'ticket' => __('calculated from the ticket creation date', 'formcreator'), 'calcul' => __('calculated from the answer to the question', 'formcreator')), array('value' => $this->fields['due_date_rule'], 'on_change' => 'formcreatorChangeDueDate(this.value)')); // for each section ... $questions_list = array(Dropdown::EMPTY_VALUE); $query = "SELECT s.id, s.name\n FROM glpi_plugin_formcreator_targets t\n INNER JOIN glpi_plugin_formcreator_sections s ON s.plugin_formcreator_forms_id = t.plugin_formcreator_forms_id\n WHERE t.items_id = " . (int) $this->getID() . "\n ORDER BY s.order"; $result = $GLOBALS['DB']->query($query); while ($section = $GLOBALS['DB']->fetch_array($result)) { // select all date and datetime questions $query2 = "SELECT q.id, q.name\n FROM glpi_plugin_formcreator_questions q\n INNER JOIN glpi_plugin_formcreator_sections s ON s.id = q.plugin_formcreator_sections_id\n WHERE s.id = {$section['id']}\n AND q.fieldtype IN ('date', 'datetime')"; $result2 = $GLOBALS['DB']->query($query2); $section_questions = array(); while ($question = $GLOBALS['DB']->fetch_array($result2)) { $section_questions[$question['id']] = $question['name']; } if (count($section_questions) > 0) { $questions_list[$section['name']] = $section_questions; } } // List questions if ($this->fields['due_date_rule'] != 'answer' && $this->fields['due_date_rule'] != 'calcul') { echo '<div id="due_date_questions" style="display:none">'; } else { echo '<div id="due_date_questions">'; } Dropdown::showFromArray('due_date_question', $questions_list, array('value' => $this->fields['due_date_question'])); echo '</div>'; if ($this->fields['due_date_rule'] != 'ticket' && $this->fields['due_date_rule'] != 'calcul') { echo '<div id="due_date_time" style="display:none">'; } else { echo '<div id="due_date_time">'; } Dropdown::showNumber("due_date_value", array('value' => $this->fields['due_date_value'], 'min' => -30, 'max' => 30)); Dropdown::showFromArray('due_date_period', array('minute' => _n('Minute', 'Minutes', 2), 'hour' => _n('Hour', 'Hours', 2), 'day' => _n('Day', 'Days', 2), 'month' => __('Month')), array('value' => $this->fields['due_date_period'])); echo '</div>'; echo '</td>'; echo '</tr>'; // ------------------------------------------------------------------------------------------- // Due date type selection end // ------------------------------------------------------------------------------------------- if ($form->fields['validation_required']) { echo '<tr class="line0">'; echo '<td colspan="4">'; echo '<input type="hidden" name="validation_followup" value="0" />'; echo '<input type="checkbox" name="validation_followup" id="validation_followup" value="1" '; if (!isset($this->fields['validation_followup']) || $this->fields['validation_followup'] == 1) { echo ' checked="checked"'; } echo '/>'; echo ' <label for="validation_followup">'; echo __('Add validation message as first ticket followup', 'formcreator'); echo '</label>'; echo '</td>'; echo '</tr>'; } echo '</table>'; // Buttons echo '<table class="tab_cadre_fixe">'; echo '<tr class="line1">'; echo '<td colspan="5" class="center">'; echo '<input type="reset" name="reset" class="submit_button" value="' . __('Cancel', 'formcreator') . '" onclick="document.location = \'form.form.php?id=' . $target['plugin_formcreator_forms_id'] . '\'" /> '; echo '<input type="hidden" name="id" value="' . $this->getID() . '" />'; echo '<input type="submit" name="update" class="submit_button" value="' . __('Save') . '" />'; echo '</td>'; echo '</tr>'; echo '</table>'; Html::closeForm(); // Get available questions for actors lists $questions_user_list = array(Dropdown::EMPTY_VALUE); $questions_group_list = array(Dropdown::EMPTY_VALUE); $questions_supplier_list = array(Dropdown::EMPTY_VALUE); $query = "SELECT s.id, s.name\n FROM glpi_plugin_formcreator_targets t\n INNER JOIN glpi_plugin_formcreator_sections s ON s.plugin_formcreator_forms_id = t.plugin_formcreator_forms_id\n WHERE t.items_id = " . (int) $this->getID() . "\n ORDER BY s.order"; $result = $GLOBALS['DB']->query($query); while ($section = $GLOBALS['DB']->fetch_array($result)) { // select all user, group or supplier questions (GLPI Object) $query2 = "SELECT q.id, q.name, q.values\n FROM glpi_plugin_formcreator_questions q\n INNER JOIN glpi_plugin_formcreator_sections s ON s.id = q.plugin_formcreator_sections_id\n WHERE s.id = {$section['id']}\n AND q.fieldtype = 'glpiselect'\n AND q.values IN ('User', 'Group', 'Supplier')"; $result2 = $GLOBALS['DB']->query($query2); $section_questions_user = array(); $section_questions_group = array(); $section_questions_supplier = array(); while ($question = $GLOBALS['DB']->fetch_array($result2)) { switch ($question['values']) { case 'User': $section_questions_user[$question['id']] = $question['name']; break; case 'Group': $section_questions_group[$question['id']] = $question['name']; break; case 'Supplier': $section_questions_supplier[$question['id']] = $question['name']; break; } } $questions_user_list[$section['name']] = $section_questions_user; $questions_group_list[$section['name']] = $section_questions_group; $questions_supplier_list[$section['name']] = $section_questions_supplier; } // Get available questions for actors lists $actors = array('requester' => array(), 'observer' => array(), 'assigned' => array()); $query = "SELECT id, actor_role, actor_type, actor_value, use_notification\n FROM glpi_plugin_formcreator_targettickets_actors\n WHERE plugin_formcreator_targettickets_id = " . $this->getID(); $result = $GLOBALS['DB']->query($query); while ($actor = $GLOBALS['DB']->fetch_array($result)) { $actors[$actor['actor_role']][$actor['id']] = array('actor_type' => $actor['actor_type'], 'actor_value' => $actor['actor_value'], 'use_notification' => $actor['use_notification']); } $img_user = '******' . __('User') . '" title="' . __('User') . '" width="20" />'; $img_group = '<img src="../../../pics/groupes.png" alt="' . __('Group') . '" title="' . __('Group') . '" width="20" />'; $img_supplier = '<img src="../../../pics/supplier.png" alt="' . __('Supplier') . '" title="' . __('Supplier') . '" width="20" />'; $img_mail = '<img src="../pics/email.png" alt="' . __('Yes') . '" title="' . __('Email followup') . ' ' . __('Yes') . '" />'; $img_nomail = '<img src="../pics/email-no.png" alt="' . __('No') . '" title="' . __('Email followup') . ' ' . __('No') . '" />'; echo '<table class="tab_cadre_fixe">'; echo '<tr><th colspan="3">' . __('Ticket actors', 'formcreator') . '</th></tr>'; echo '<tr>'; echo '<th width="33%">'; echo _n('Requester', 'Requesters', 1) . ' '; echo '<img title="Ajouter" alt="Ajouter" onclick="displayRequesterForm()" class="pointer" id="btn_add_requester" src="../../../pics/add_dropdown.png">'; echo '<img title="Annuler" alt="Annuler" onclick="hideRequesterForm()" class="pointer" id="btn_cancel_requester" src="../../../pics/delete.png" style="display:none">'; echo '</th>'; echo '<th width="34%">'; echo _n('Watcher', 'Watchers', 1) . ' '; echo '<img title="Ajouter" alt="Ajouter" onclick="displayWatcherForm()" class="pointer" id="btn_add_watcher" src="../../../pics/add_dropdown.png">'; echo '<img title="Annuler" alt="Annuler" onclick="hideWatcherForm()" class="pointer" id="btn_cancel_watcher" src="../../../pics/delete.png" style="display:none">'; echo '</th>'; echo '<th width="33%">'; echo __('Assigned to') . ' '; echo '<img title="Ajouter" alt="Ajouter" onclick="displayAssignedForm()" class="pointer" id="btn_add_assigned" src="../../../pics/add_dropdown.png">'; echo '<img title="Annuler" alt="Annuler" onclick="hideAssignedForm()" class="pointer" id="btn_cancel_assigned" src="../../../pics/delete.png" style="display:none">'; echo '</th>'; echo '</tr>'; echo '<tr>'; // Requester echo '<td valign="top">'; // => Add requester form echo '<form name="form_target" id="form_add_requester" method="post" style="display:none" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/targetticket.form.php">'; Dropdown::showFromArray('actor_type', array('' => Dropdown::EMPTY_VALUE, 'creator' => __('Form requester', 'formcreator'), 'validator' => __('Form validator', 'formcreator'), 'person' => __('Specific person', 'formcreator'), 'question_person' => __('Person from the question', 'formcreator'), 'group' => __('Specific group', 'formcreator'), 'question_group' => __('Group from the question', 'formcreator')), array('on_change' => 'formcreatorChangeActorRequester(this.value)')); echo '<div id="block_requester_user" style="display:none">'; User::dropdown(array('name' => 'actor_value_person', 'right' => 'all', 'all' => 0)); echo '</div>'; echo '<div id="block_requester_group" style="display:none">'; Group::dropdown(array('name' => 'actor_value_group')); echo '</div>'; echo '<div id="block_requester_question_user" style="display:none">'; Dropdown::showFromArray('actor_value_question_person', $questions_user_list, array('value' => $this->fields['due_date_question'])); echo '</div>'; echo '<div id="block_requester_question_group" style="display:none">'; Dropdown::showFromArray('actor_value_question_group', $questions_group_list, array('value' => $this->fields['due_date_question'])); echo '</div>'; echo '<div>'; echo __('Email followup'); Dropdown::showYesNo('use_notification', 1); echo '</div>'; echo '<p align="center">'; echo '<input type="hidden" name="id" value="' . $this->getID() . '" />'; echo '<input type="hidden" name="actor_role" value="requester" />'; echo '<input type="submit" value="' . __('Add') . '" class="submit_button" />'; echo '</p>'; echo "<hr>"; Html::closeForm(); // => List of saved requesters foreach ($actors['requester'] as $id => $values) { echo '<div>'; switch ($values['actor_type']) { case 'creator': echo $img_user . ' <b>' . __('Form requester', 'formcreator') . '</b>'; break; case 'validator': echo $img_user . ' <b>' . __('Form validator', 'formcreator') . '</b>'; break; case 'person': $user = new User(); $user->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('User') . ' </b> "' . $user->getName() . '"'; break; case 'question_person': $question = new PluginFormcreatorQuestion(); $question->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('Person from the question', 'formcreator') . '</b> "' . $question->getName() . '"'; break; case 'group': $group = new Group(); $group->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('Group') . ' </b> "' . $group->getName() . '"'; break; case 'question_group': $question = new PluginFormcreatorQuestion(); $question->getFromDB($values['actor_value']); echo $img_group . ' <b>' . __('Group from the question', 'formcreator') . '</b> "' . $question->getName() . '"'; break; } echo $values['use_notification'] ? ' ' . $img_mail . ' ' : ' ' . $img_nomail . ' '; echo self::getDeleteImage($id); echo '</div>'; } echo '</td>'; // Observer echo '<td valign="top">'; // => Add observer form echo '<form name="form_target" id="form_add_watcher" method="post" style="display:none" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/targetticket.form.php">'; Dropdown::showFromArray('actor_type', array('' => Dropdown::EMPTY_VALUE, 'creator' => __('Form requester', 'formcreator'), 'validator' => __('Form validator', 'formcreator'), 'person' => __('Specific person', 'formcreator'), 'question_person' => __('Person from the question', 'formcreator'), 'group' => __('Specific group', 'formcreator'), 'question_group' => __('Group from the question', 'formcreator')), array('on_change' => 'formcreatorChangeActorWatcher(this.value)')); echo '<div id="block_watcher_user" style="display:none">'; User::dropdown(array('name' => 'actor_value_person', 'right' => 'all', 'all' => 0)); echo '</div>'; echo '<div id="block_watcher_group" style="display:none">'; Group::dropdown(array('name' => 'actor_value_group')); echo '</div>'; echo '<div id="block_watcher_question_user" style="display:none">'; Dropdown::showFromArray('actor_value_question_person', $questions_user_list, array('value' => $this->fields['due_date_question'])); echo '</div>'; echo '<div id="block_watcher_question_group" style="display:none">'; Dropdown::showFromArray('actor_value_question_group', $questions_group_list, array('value' => $this->fields['due_date_question'])); echo '</div>'; echo '<div>'; echo __('Email followup'); Dropdown::showYesNo('use_notification', 1); echo '</div>'; echo '<p align="center">'; echo '<input type="hidden" name="id" value="' . $this->getID() . '" />'; echo '<input type="hidden" name="actor_role" value="observer" />'; echo '<input type="submit" value="' . __('Add') . '" class="submit_button" />'; echo '</p>'; echo "<hr>"; Html::closeForm(); // => List of saved observers foreach ($actors['observer'] as $id => $values) { echo '<div>'; switch ($values['actor_type']) { case 'creator': echo $img_user . ' <b>' . __('Form requester', 'formcreator') . '</b>'; break; case 'validator': echo $img_user . ' <b>' . __('Form validator', 'formcreator') . '</b>'; break; case 'person': $user = new User(); $user->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('User') . ' </b> "' . $user->getName() . '"'; break; case 'question_person': $question = new PluginFormcreatorQuestion(); $question->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('Person from the question', 'formcreator') . '</b> "' . $question->getName() . '"'; break; case 'group': $group = new Group(); $group->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('Group') . ' </b> "' . $group->getName() . '"'; break; case 'question_group': $question = new PluginFormcreatorQuestion(); $question->getFromDB($values['actor_value']); echo $img_group . ' <b>' . __('Group from the question', 'formcreator') . '</b> "' . $question->getName() . '"'; break; } echo $values['use_notification'] ? ' ' . $img_mail . ' ' : ' ' . $img_nomail . ' '; echo self::getDeleteImage($id); echo '</div>'; } echo '</td>'; // Assigned to echo '<td valign="top">'; // => Add assigned to form echo '<form name="form_target" id="form_add_assigned" method="post" style="display:none" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/targetticket.form.php">'; Dropdown::showFromArray('actor_type', array('' => Dropdown::EMPTY_VALUE, 'creator' => __('Form requester', 'formcreator'), 'validator' => __('Form validator', 'formcreator'), 'person' => __('Specific person', 'formcreator'), 'question_person' => __('Person from the question', 'formcreator'), 'group' => __('Specific group', 'formcreator'), 'question_group' => __('Group from the question', 'formcreator'), 'supplier' => __('Specific supplier', 'formcreator'), 'question_supplier' => __('Supplier from the question', 'formcreator')), array('on_change' => 'formcreatorChangeActorAssigned(this.value)')); echo '<div id="block_assigned_user" style="display:none">'; User::dropdown(array('name' => 'actor_value_person', 'right' => 'all', 'all' => 0)); echo '</div>'; echo '<div id="block_assigned_group" style="display:none">'; Group::dropdown(array('name' => 'actor_value_group')); echo '</div>'; echo '<div id="block_assigned_supplier" style="display:none">'; Supplier::dropdown(array('name' => 'actor_value_supplier')); echo '</div>'; echo '<div id="block_assigned_question_user" style="display:none">'; Dropdown::showFromArray('actor_value_question_person', $questions_user_list, array('value' => $this->fields['due_date_question'])); echo '</div>'; echo '<div id="block_assigned_question_group" style="display:none">'; Dropdown::showFromArray('actor_value_question_group', $questions_group_list, array('value' => $this->fields['due_date_question'])); echo '</div>'; echo '<div id="block_assigned_question_supplier" style="display:none">'; Dropdown::showFromArray('actor_value_question_supplier', $questions_supplier_list, array('value' => $this->fields['due_date_question'])); echo '</div>'; echo '<div>'; echo __('Email followup'); Dropdown::showYesNo('use_notification', 1); echo '</div>'; echo '<p align="center">'; echo '<input type="hidden" name="id" value="' . $this->getID() . '" />'; echo '<input type="hidden" name="actor_role" value="assigned" />'; echo '<input type="submit" value="' . __('Add') . '" class="submit_button" />'; echo '</p>'; echo "<hr>"; Html::closeForm(); // => List of saved assigned to foreach ($actors['assigned'] as $id => $values) { echo '<div>'; switch ($values['actor_type']) { case 'creator': echo $img_user . ' <b>' . __('Form requester', 'formcreator') . '</b>'; break; case 'validator': echo $img_user . ' <b>' . __('Form validator', 'formcreator') . '</b>'; break; case 'person': $user = new User(); $user->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('User') . ' </b> "' . $user->getName() . '"'; break; case 'question_person': $question = new PluginFormcreatorQuestion(); $question->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('Person from the question', 'formcreator') . '</b> "' . $question->getName() . '"'; break; case 'group': $group = new Group(); $group->getFromDB($values['actor_value']); echo $img_user . ' <b>' . __('Group') . ' </b> "' . $group->getName() . '"'; break; case 'question_group': $question = new PluginFormcreatorQuestion(); $question->getFromDB($values['actor_value']); echo $img_group . ' <b>' . __('Group from the question', 'formcreator') . '</b> "' . $question->getName() . '"'; break; case 'supplier': $group = new Group(); $group->getFromDB($values['actor_value']); echo $img_supplier . ' <b>' . __('Supplier') . ' </b> "' . $group->getName() . '"'; break; case 'question_supplier': $question = new PluginFormcreatorQuestion(); $question->getFromDB($values['actor_value']); echo $img_supplier . ' <b>' . __('Supplier from the question', 'formcreator') . '</b> "' . $question->getName() . '"'; break; } echo $values['use_notification'] ? ' ' . $img_mail . ' ' : ' ' . $img_nomail . ' '; echo self::getDeleteImage($id); echo '</div>'; } echo '</td>'; echo '</tr>'; echo '</table>'; // List of available tags echo '<table class="tab_cadre_fixe">'; echo '<tr><th colspan="5">' . __('List of available tags') . '</th></tr>'; echo '<tr>'; echo '<th width="40%" colspan="2">' . _n('Question', 'Questions', 1, 'formcreator') . '</th>'; echo '<th width="20%">' . __('Title') . '</th>'; echo '<th width="20%">' . _n('Answer', 'Answers', 1, 'formcreator') . '</th>'; echo '<th width="20%">' . _n('Section', 'Sections', 1, 'formcreator') . '</th>'; echo '</tr>'; echo '<tr class="line0">'; echo '<td colspan="2"><strong>' . __('Full form', 'formcreator') . '</strong></td>'; echo '<td align="center"><code>-</code></td>'; echo '<td align="center"><code><strong>##FULLFORM##</strong></code></td>'; echo '<td align="center">-</td>'; echo '</tr>'; $table_questions = getTableForItemType('PluginFormcreatorQuestion'); $table_sections = getTableForItemType('PluginFormcreatorSection'); $query = "SELECT q.`id`, q.`name` AS question, s.`name` AS section\n FROM {$table_questions} q\n LEFT JOIN {$table_sections} s ON q.`plugin_formcreator_sections_id` = s.`id`\n WHERE s.`plugin_formcreator_forms_id` = " . $target['plugin_formcreator_forms_id'] . "\n ORDER BY s.`order`, q.`order`"; $result = $GLOBALS['DB']->query($query); $i = 0; while ($question = $GLOBALS['DB']->fetch_array($result)) { $i++; echo '<tr class="line' . $i % 2 . '">'; echo '<td colspan="2">' . $question['question'] . '</td>'; echo '<td align="center"><code>##question_' . $question['id'] . '##</code></td>'; echo '<td align="center"><code>##answer_' . $question['id'] . '##</code></td>'; echo '<td align="center">' . $question['section'] . '</td>'; echo '</tr>'; } echo '</table>'; echo '</div>'; }
/** * 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; }
/** * 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, $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; }
/** * Print out an HTML "<form>" for knowbase item * * @param $ID * @param $options array * - target for the Form * * @return nothing (display the form) **/ function showForm($ID, $options = array()) { global $CFG_GLPI; // show kb item form if (!Session::haveRightsOr(self::$rightname, array(UPDATE, self::PUBLISHFAQ, self::KNOWBASEADMIN))) { return false; } $this->initForm($ID, $options); $canedit = $this->can($ID, UPDATE); // Load ticket solution if (empty($ID) && isset($options['item_itemtype']) && !empty($options['item_itemtype']) && isset($options['item_items_id']) && !empty($options['item_items_id'])) { if ($item = getItemForItemtype($options['item_itemtype'])) { if ($item->getFromDB($options['item_items_id'])) { $this->fields['name'] = $item->getField('name'); $this->fields['answer'] = $item->getField('solution'); if ($item->isField('itilcategories_id')) { $ic = new ItilCategory(); if ($ic->getFromDB($item->getField('itilcategories_id'))) { $this->fields['knowbaseitemcategories_id'] = $ic->getField('knowbaseitemcategories_id'); } } } } } $rand = mt_rand(); Html::initEditorSystem('answer'); $this->initForm($ID, $options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Category name') . "</td>"; echo "<td>"; echo "<input type='hidden' name='users_id' value=\"" . Session::getLoginUserID() . "\">"; KnowbaseItemCategory::dropdown(array('value' => $this->fields["knowbaseitemcategories_id"])); echo "</td>"; echo "<td>"; if ($this->fields["date"]) { //TRANS: %s is the datetime of insertion printf(__('Created on %s'), Html::convDateTime($this->fields["date"])); } echo "</td><td>"; if ($this->fields["date_mod"]) { //TRANS: %s is the datetime of update printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"])); } echo "</td>"; echo "</tr>\n"; echo "<tr class='tab_bg_1'>"; if (Session::haveRight(self::$rightname, self::PUBLISHFAQ)) { echo "<td>" . __('Put this item in the FAQ') . "</td>"; echo "<td>"; Dropdown::showYesNo('is_faq', $this->fields["is_faq"]); echo "</td>"; } else { echo "<td colspan='2'>"; if ($this->fields["is_faq"]) { _e('This item is part of the FAQ'); } else { _e('This item is not part of the FAQ'); } echo "</td>"; } echo "<td>"; $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } if ($this->fields["users_id"]) { //TRANS: %s is the writer name printf(__('%1$s: %2$s'), __('Writer'), getUserName($this->fields["users_id"], $showuserlink)); } echo "</td><td>"; //TRANS: %d is the number of view if ($ID) { printf(_n('%d view', '%d views', $this->fields["view"]), $this->fields["view"]); } echo "</td>"; echo "</tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Visible since') . "</td><td>"; Html::showDateTimeField("begin_date", array('value' => $this->fields["begin_date"], 'timestep' => 1, 'maybeempty' => true, 'canedit' => $canedit)); echo "</td>"; echo "<td>" . __('Visible until') . "</td><td>"; Html::showDateTimeField("end_date", array('value' => $this->fields["end_date"], 'timestep' => 1, 'maybeempty' => true, 'canedit' => $canedit)); echo "</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>"; echo "</tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Content') . "</td>"; echo "<td colspan='3'>"; $cols = 100; $rows = 30; if (isset($options['_in_modal']) && $options['_in_modal']) { $rows = 15; echo Html::hidden('_in_modal', array('value' => 1)); } echo "<textarea cols='{$cols}' rows='{$rows}' id='answer' name='answer'>" . $this->fields["answer"]; echo "</textarea>"; echo "</td>"; echo "</tr>\n"; if ($this->isNewID($ID)) { echo "<tr class='tab_bg_1'>"; echo "<td>" . _n('Target', 'Targets', 1) . "</td>"; echo "<td>"; $types = array('Entity', 'Group', 'Profile', 'User'); $addrand = Dropdown::showItemTypes('_visibility[_type]', $types); echo "</td><td colspan='2'>"; $params = array('type' => '__VALUE__', 'right' => 'knowbase', 'prefix' => '_visibility', 'nobutton' => 1); Ajax::updateItemOnSelectEvent("dropdown__visibility__type_" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params); echo "<span id='visibility{$rand}'></span>"; echo "</td></tr>\n"; } $this->showFormButtons($options); return true; }
/** * Print the wainting ticket form * * @param $ID integer ID of the item * @param $options array * - target filename : where to go when done. * - withtemplate boolean : template or basic item * * @return Nothing (display) * */ function showForm($ID, $options = array()) { global $CFG_GLPI; // validation des droits if (!$this->canview()) { return false; } $ticket = new Ticket(); if ($ID > 0) { if (!$ticket->getFromDB($ID)) { $ticket->getEmpty(); } } else { // Create item $ticket->getEmpty(); } // If values are saved in session we retrieve it if (isset($_SESSION['glpi_plugin_moreticket_close'])) { foreach ($_SESSION['glpi_plugin_moreticket_close'] as $key => $value) { $ticket->fields[$key] = str_replace(array('\\r\\n', '\\r', '\\n'), '', $value); } } unset($_SESSION['glpi_plugin_moreticket_close']); echo "<div class='spaced' id='moreticket_close_ticket'>"; echo "</br>"; echo "<table class='moreticket_close_ticket' id='cl_menu'>"; echo "<tr><td>"; echo _n('Solution template', 'Solution templates', 1) . " : "; $rand_template = mt_rand(); $rand_type = 0; $rand_text = mt_rand(); $rand_type = mt_rand(); SolutionTemplate::dropdown(array('value' => 0, 'entity' => $ticket->getEntityID(), 'rand' => $rand_template, 'toupdate' => array('value_fieldname' => 'value', 'to_update' => 'solution' . $rand_text, 'url' => $CFG_GLPI["root_doc"] . "/ajax/solution.php", 'moreparams' => array('type_id' => 'dropdown_solutiontypes_id' . $rand_type)))); echo "</td></tr>"; echo "<tr><td>"; echo _n('Solution type', 'Solution types', 1); $config = new PluginMoreticketConfig(); if ($config->mandatorySolutionType() == true) { echo " : <span class='red'>*</span> "; } Dropdown::show('SolutionType', array('value' => $ticket->getField('solutiontypes_id'), 'rand' => $rand_type, 'entity' => $ticket->getEntityID())); echo "</td></tr>"; echo "<tr><td>"; echo __('Solution description', 'moreticket') . " : <span class='red'>*</span> "; $rand = mt_rand(); Html::initEditorSystem("solution" . $rand); echo "<div id='solution{$rand_text}'>"; echo "<textarea id='solution{$rand}' name='solution' rows='3'>" . stripslashes($ticket->fields['solution']) . "</textarea></div>"; echo "</td></tr>"; echo "</table>"; echo "</div>"; }
<tr class="line1" id="description_tr"> <td> <label for="description" id="label_description"> <?php echo __('Description'); ?> </label> </td> <td width="80%" colspan="3"> <textarea name="description" id="description" rows="6" cols="108" style="width: 97%"><?php echo $question->fields['description']; ?> </textarea> <?php Html::initEditorSystem('description'); ?> </td> </tr> <tr class="line0" id="regex_tr"> <td> <label for="regex" id="label_regex"> <?php echo __('Additional validation', 'formcreator'); ?> <br /> <small> <a href="http://php.net/manual/reference.pcre.pattern.syntax.php" target="_blank"> (<?php echo __('Regular expression', 'formcreator');
/** * Print the reminder form * * @param $ID integer Id of the item to print * @param $options array of possible options: * - target filename : where to go when done. * - from_planning_ajax : set to disable planning form part **/ function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); $rand = mt_rand(); // Show Reminder or blank form $onfocus = ""; if (!$ID > 0) { // Create item : do getempty before check right to set default values $onfocus = "onfocus=\"if (this.value=='" . $this->fields['name'] . "') this.value='';\""; } $canedit = $this->can($ID, UPDATE); $this->showFormHeader($options); echo "<tr class='tab_bg_2'><td>" . __('Title') . "</td>"; echo "<td>"; if (!$ID) { echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n"; } if ($canedit) { Html::autocompletionTextField($this, "name", array('size' => '80', 'entity' => -1, 'user' => $this->fields["users_id"], 'option' => $onfocus)); } else { echo $this->fields['name']; } if (isset($options['from_planning_edit_ajax']) && $options['from_planning_edit_ajax']) { echo Html::hidden('from_planning_edit_ajax'); } echo "</td>"; echo "</tr>"; if (!isset($options['from_planning_ajax'])) { echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Visibility') . "</td>"; echo "<td>"; echo '<table><tr><td>'; echo __('Begin') . '</td><td>'; Html::showDateTimeField("begin_view_date", array('value' => $this->fields["begin_view_date"], 'timestep' => 1, 'maybeempty' => true, 'canedit' => $canedit)); echo '</td><td>' . __('End') . '</td><td>'; Html::showDateTimeField("end_view_date", array('value' => $this->fields["end_view_date"], 'timestep' => 1, 'maybeempty' => true, 'canedit' => $canedit)); echo '</td></tr></table>'; echo "</td>"; echo "</tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Status') . "</td>"; echo "<td>"; if ($canedit) { Planning::dropdownState("state", $this->fields["state"]); } else { echo Planning::getState($this->fields["state"]); } echo "</td>\n"; echo "</tr>\n"; echo "<tr class='tab_bg_2'><td >" . __('Calendar') . "</td>"; echo "<td>"; if (isset($options['from_planning_ajax']) && $options['from_planning_ajax']) { echo Html::hidden('plan[begin]', array('value' => $options['begin'])); echo Html::hidden('plan[end]', array('value' => $options['end'])); printf(__('From %1$s to %2$s'), Html::convDateTime($options["begin"]), Html::convDateTime($options["end"])); echo "</td>"; } else { if ($canedit) { echo "<script type='text/javascript' >\n"; echo "function showPlan{$rand}() {\n"; echo Html::jsHide("plan{$rand}"); $params = array('action' => 'add_event_classic_form', 'form' => 'remind', 'users_id' => $this->fields["users_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); if ($ID && $this->fields["is_planned"]) { $params['begin'] = $this->fields["begin"]; $params['end'] = $this->fields["end"]; } Ajax::updateItemJsCode("viewplan{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; } if (!$ID || !$this->fields["is_planned"]) { if (Session::haveRightsOr("planning", array(Planning::READMY, Planning::READGROUP, Planning::READALL))) { echo "<div id='plan{$rand}' onClick='showPlan{$rand}()'>\n"; echo "<a href='#' class='vsubmit'>" . __('Add to schedule') . "</a>"; } } else { if ($canedit) { echo "<div id='plan{$rand}' onClick='showPlan{$rand}()'>\n"; echo "<span class='showplan'>"; } //TRANS: %1$s is the begin date, %2$s is the end date printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); if ($canedit) { echo "</span>"; } } if ($canedit) { echo "</div>\n"; echo "<div id='viewplan{$rand}'>\n</div>\n"; } echo "</td>"; if ($ID && $this->fields["is_planned"] && PlanningRecall::isAvailable()) { echo "<td>" . _x('Planning', 'Reminder') . "</td>"; echo "<td>"; if ($canedit) { PlanningRecall::dropdown(array('itemtype' => 'Reminder', 'items_id' => $ID)); } else { // No edit right : use specific Planning Recall Form PlanningRecall::specificForm(array('itemtype' => 'Reminder', 'items_id' => $ID)); } echo "</td>"; } else { echo "<td colspan='2'></td>"; } } echo "</tr>\n"; echo "<tr class='tab_bg_2'><td>" . __('Description') . "</td>" . "<td colspan='3'>"; if ($canedit) { $rand = mt_rand(); echo "<textarea rows='15' name='text' id='text{$rand}'>" . $this->fields["text"] . "</textarea>"; Html::initEditorSystem('text' . $rand); } else { echo "<div id='kbanswer'>"; echo Toolbox::unclean_html_cross_side_scripting_deep($this->fields["text"]); echo "</div>"; } echo "</td></tr>\n"; $this->showFormButtons($options); return true; }
/** * Print the reminder form * * @param $ID integer Id of the item to print * @param $options array of possible options: * - target filename : where to go when done. **/ function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); // Show Reminder or blank form $onfocus = ""; if (!$ID > 0) { // Create item : do getempty before check right to set default values $onfocus = "onfocus=\"if (this.value=='" . $this->fields['name'] . "') this.value='';\""; } $canedit = $this->can($ID, 'w'); if ($canedit) { Html::initEditorSystem('text'); } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_2'><td>" . __('Title') . "</td>"; echo "<td>"; if ($canedit) { Html::autocompletionTextField($this, "name", array('size' => 80, 'entity' => -1, 'user' => $this->fields["users_id"], 'option' => $onfocus)); } else { echo $this->fields['name']; } echo "</td>\n"; echo "<td>" . __('By') . "</td>"; echo "<td>"; echo getUserName($this->fields["users_id"]); if (!$ID) { echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n"; } echo "</td></tr>\n"; echo "<tr class='tab_bg_2'>"; echo "<td>" . _x('reminder', 'Visibility') . "</td>"; echo "<td>"; echo '<table><tr><td>'; echo __('Begin') . '</td><td>'; Html::showDateTimeFormItem("begin_view_date", $this->fields["begin_view_date"], 1, true, $canedit); echo '</td><td>' . __('End') . '</td><td>'; Html::showDateTimeFormItem("end_view_date", $this->fields["end_view_date"], 1, true, $canedit); echo '</td></tr></table>'; echo "</td>"; echo "<td>" . __('Status') . "</td>"; echo "<td>"; if ($canedit) { Planning::dropdownState("state", $this->fields["state"]); } else { echo Planning::getState($this->fields["state"]); } echo "</td>\n"; echo "</tr>\n"; echo "<tr class='tab_bg_2'><td >" . __('Calendar') . "</td>"; echo "<td class='center'>"; if ($canedit) { echo "<script type='text/javascript' >\n"; echo "function showPlan() {\n"; echo "Ext.get('plan').setDisplayed('none');"; $params = array('form' => 'remind', 'users_id' => $this->fields["users_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); if ($ID && $this->fields["is_planned"]) { $params['begin'] = $this->fields["begin"]; $params['end'] = $this->fields["end"]; } Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; } if (!$ID || !$this->fields["is_planned"]) { if (Session::haveRight("show_planning", "1") || Session::haveRight("show_group_planning", "1") || Session::haveRight("show_all_planning", "1")) { echo "<div id='plan' onClick='showPlan()'>\n"; echo "<a href='#' class='vsubmit'>" . __('Add to schedule') . "</a>"; } } else { if ($canedit) { echo "<div id='plan' onClick='showPlan()'>\n"; echo "<span class='showplan'>"; } //TRANS: %1$s is the begin date, %2$s is the end date printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); if ($canedit) { echo "</span>"; } } if ($canedit) { echo "</div>\n"; echo "<div id='viewplan'>\n</div>\n"; } echo "</td>"; if ($ID && $this->fields["is_planned"] && PlanningRecall::isAvailable()) { echo "<td>" . _x('Planning', 'Reminder') . "</td>"; echo "<td>"; if ($canedit) { PlanningRecall::dropdown(array('itemtype' => 'Reminder', 'items_id' => $ID)); } else { // No edit right : use specific Planning Recall Form PlanningRecall::specificForm(array('itemtype' => 'Reminder', 'items_id' => $ID)); } echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "</tr>\n"; echo "<tr class='tab_bg_2'><td>" . __('Description') . "</td>" . "<td colspan='3'>"; if ($canedit) { echo "<textarea cols='115' rows='15' name='text'>" . $this->fields["text"] . "</textarea>"; } else { echo "<div id='kbanswer'>"; echo Toolbox::unclean_html_cross_side_scripting_deep($this->fields["text"]); echo "</div>"; } echo "</td></tr>\n"; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ $AJAX_INCLUDE = 1; include '../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); $rand = mt_rand(); Html::initEditorSystem("solution{$rand}"); if (isset($_POST['value']) && $_POST['value'] > 0) { $template = new SolutionTemplate(); if ($template->getFromDB($_POST['value'])) { echo "<textarea id='solution{$rand}' name='solution' rows='12' cols='80'>"; echo $template->getField('content'); echo "</textarea>\n"; echo "<script type='text/javascript'>document.getElementById('" . $_POST["type_id"] . "').\n value = " . $template->getField('solutiontypes_id') . "</script>"; } } else { echo "<textarea id='solution{$rand}' name='solution' rows='12' cols='80'></textarea>"; }
/** * Form to add a solution to an ITIL object * * @since version 0.84 * * @param $entities_id **/ static function showMassiveSolutionForm($entities_id) { global $CFG_GLPI; echo "<table class='tab_cadre_fixe'>"; echo '<tr><th colspan=4>' . __('Solve tickets') . '</th></tr>'; $rand_template = mt_rand(); $rand_text = mt_rand(); $rand_type = mt_rand(); echo "<tr class='tab_bg_2'>"; echo "<td>" . _n('Solution template', 'Solution templates', 1) . "</td><td>"; SolutionTemplate::dropdown(array('value' => 0, 'entity' => $entities_id, 'rand' => $rand_template, 'toupdate' => array('value_fieldname' => 'value', 'to_update' => 'solution' . $rand_text, 'url' => $CFG_GLPI["root_doc"] . "/ajax/solution.php", 'moreparams' => array('type_id' => 'dropdown_solutiontypes_id' . $rand_type)))); echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Solution type') . "</td><td>"; SolutionType::dropdown(array('value' => 0, 'rand' => $rand_type, 'entity' => $entities_id)); echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Description') . "</td><td colspan='3'>"; $rand = mt_rand(); Html::initEditorSystem("solution{$rand}"); echo "<div id='solution{$rand_text}'>"; echo "<textarea id='solution{$rand}' name='solution' rows='12' cols='80' class='form-control'></textarea></div>"; echo "</td></tr>"; echo '</table>'; }
public function showForm($ID, $options = array()) { global $LANG; $this->check($ID, UPDATE); if ($this->getField('message') == 'N/A') { $this->fields['message'] = ""; } Html::initEditorSystem('message'); $this->showFormHeader($options); echo '<tr>'; echo '<td style="width: 150px">' . __('Name') . '</td>'; echo '<td colspan="3"><input name="name" type="text" value="' . $this->getField('name') . '" style="width: 565px" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>' . __('Description') . '</td>'; echo '<td colspan="3">'; echo '<textarea name="message" rows="12" cols="80">' . $this->getField('message') . '</textarea>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td style="width: 150px">' . __("Visibility start date") . '</td>'; echo '<td>'; Html::showDateFormItem('date_start', Html::convDate($this->getField('date_start')), false); echo '</td>'; echo '<td style="width: 150px">' . __("Visibility end date") . '</td>'; echo '<td>'; Html::showDateFormItem('date_end', Html::convDate($this->getField('date_end')), false); echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>' . __("Profile") . '</td>'; echo '<td colspan="3">'; Dropdown::show('Profile', array('name' => 'profiles_id', 'value' => $this->getField('profiles_id') ?: 0)); echo '</td>'; echo '</tr>'; $this->showFormButtons($options); }