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'>"; initEditorSystem($field['name']); echo "<textarea name='" . $field['name'] . "' rows='3'>" . $this->fields[$field['name']] . "</textarea>"; break; } }
/** * Form to add a solution to a ticket * * @param $knowbase_id_toload integer load a kb article as solution (0 = no load) **/ function showSolutionForm($knowbase_id_toload = 0) { global $LANG, $CFG_GLPI; $this->check($this->getField('id'), 'r'); $canedit = $this->canSolve(); $options = array(); if ($knowbase_id_toload > 0) { $kb = new KnowbaseItem(); if ($kb->getFromDB($knowbase_id_toload)) { $this->fields['solution'] = $kb->getField('answer'); } } $this->showFormHeader($options); $show_template = $canedit; // && $this->getField('ticketsolutiontypes_id') == 0 // && empty($this->fields['solution']); $rand_template = mt_rand(); $rand_text = $rand_type = 0; if ($canedit) { $rand_text = mt_rand(); $rand_type = mt_rand(); } if ($show_template) { echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['jobresolution'][6] . " : </td><td>"; Dropdown::show('TicketSolutionTemplate', array('value' => 0, 'entity' => $this->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_ticketsolutiontypes_id' . $rand_type)))); echo "</td><td colspan='2'>"; echo "<a title\"" . $LANG['job'][23] . "\"\n href='" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.php?tickets_id=" . $this->getField('id') . "'>" . $LANG['job'][23] . "</a>"; echo "</td></tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['job'][48] . " : </td><td>"; $current = $this->fields['status']; // Settings a solution will set status to solved if ($canedit) { Dropdown::show('TicketSolutionType', array('value' => $this->getField('ticketsolutiontypes_id'), 'rand' => $rand_type)); } else { echo Dropdown::getDropdownName('glpi_ticketsolutiontypes', $this->getField('ticketsolutiontypes_id')); } echo "</td><td>" . $LANG['job'][25] . "</td><td>"; Dropdown::showYesNo('_sol_to_kb', false); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['joblist'][6] . " : </td><td colspan='3'>"; if ($canedit) { initEditorSystem("solution"); echo "<div id='solution{$rand_text}'>"; echo "<textarea id='solution' name='solution' rows='12' cols='80'>"; echo $this->getField('solution'); echo "</textarea></div>"; } else { echo unclean_cross_side_scripting_deep($this->getField('solution')); } echo "</td></tr>"; $options['candel'] = false; $options['canedit'] = $canedit; $this->showFormButtons($options); }
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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: Julien Dombre // Purpose of file: // ---------------------------------------------------------------------- $AJAX_INCLUDE = 1; define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); checkLoginUser(); initEditorSystem("solution"); if (isset($_POST['value']) && $_POST['value'] > 0) { $template = new TicketSolutionTemplate(); if ($template->getFromDB($_POST['value'])) { echo "<textarea id='solution' 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('ticketsolutiontypes_id') . "</script>"; } } else { echo "<textarea id='solution' name='solution' rows='12' cols='80'></textarea>"; }
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; }
/** * 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 $LANG; // show kb item form if (!haveRight("knowbase", "w") && !haveRight("faq", "w")) { return false; } if ($ID > 0) { $this->check($ID, 'r'); } else { $this->check(-1, 'w'); } $canedit = $this->can($ID, 'w'); $canrecu = $this->can($ID, 'recursive'); if ($canedit) { // Load ticket solution if (empty($ID) && isset($options['tickets_id']) && $options['tickets_id'] > 0) { $ticket = new Ticket(); if ($ticket->getFromDB($options['tickets_id'])) { $this->fields['question'] = $ticket->getField('name'); $this->fields['answer'] = $ticket->getField('solution'); } } echo "<div id='contenukb'>"; 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>" . $LANG['knowbase'][13] . "</legend>"; echo "<div class='center'>" . $LANG['knowbase'][6]; Dropdown::show('KnowbaseItemCategory', array('value' => $this->fields["knowbaseitemcategories_id"])); echo "</div></fieldset>"; echo "<fieldset>"; echo "<legend>" . $LANG['knowbase'][14] . "</legend>"; echo "<div class='center'>"; echo "<textarea cols='80' rows='2' name='question'>" . $this->fields["question"] . "</textarea>"; echo "</div></fieldset>"; echo "<fieldset>"; echo "<legend>" . $LANG['knowbase'][15] . "</legend>"; echo "<div class='center'>"; echo "<textarea cols='80' rows='30' id='answer' name='answer'>" . $this->fields["answer"]; echo "</textarea></div></fieldset>"; echo "<br>"; if (!empty($ID)) { echo "<fieldset>"; echo "<legend></legend>"; echo "<div class='baskb'>"; if ($this->fields["users_id"]) { echo $LANG['common'][37] . " : " . getUserName($this->fields["users_id"], "1") . " "; } echo "<span class='baskb_right'>"; if ($this->fields["date_mod"]) { echo $LANG['common'][26] . " : " . convDateTime($this->fields["date_mod"]) . " "; } echo "</span><br>"; if ($this->fields["date"]) { echo $LANG['common'][27] . " : " . convDateTime($this->fields["date"]); } echo "<span class='baskb_right'>"; echo $LANG['knowbase'][26] . " : " . $this->fields["view"] . "</span></div>"; echo "</fieldset>"; } echo "<p class='center'>"; if (isMultiEntitiesMode()) { echo $LANG['entity'][0] . " : "; Dropdown::show('Entity', array('value' => $this->fields["entities_id"], 'comments' => 0)); echo " " . $LANG['entity'][9] . " : "; if ($canrecu) { Dropdown::showYesNo("is_recursive", $this->fields["is_recursive"]); } else { echo Dropdown::getYesNo($this->fields["is_recursive"]); } } echo "<br><br>" . $LANG['knowbase'][5] . " : "; if (haveRight("faq", "w") && 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=\"" . $LANG['buttons'][7] . "\">"; } else { echo "<input type='hidden' name='users_id' value=\"" . getLoginUserID() . "\">"; echo "<input type='submit' class='submit' name='add' value=\"" . $LANG['buttons'][8] . "\">"; } echo "<span class='big_space'>"; echo "<input type='reset' class='submit' value=\"" . $LANG['buttons'][16] . "\"></span>"; echo "</p></form></div>"; return true; } // ELSE Cannot edit return false; }