public function showForm($datas) { if (!isset($datas['id']) || !$this->getFromDB($datas['id'])) { Html::displayNotFoundError(); } $form = new PluginFormcreatorForm(); $form->getFromDB($this->fields['plugin_formcreator_forms_id']); echo '<form name="formcreator_form' . $form->getID() . '" method="post" role="form" enctype="multipart/form-data" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/formanswer.form.php" class="formcreator_form form_horizontal">'; echo '<h1 class="form-title">' . $form->fields['name'] . '</h1>'; // Form Header if (!empty($form->fields['content'])) { echo '<div class="form_header">'; echo html_entity_decode($form->fields['content']); echo '</div>'; } if ($this->fields['status'] == 'refused') { echo '<div class="refused_header">'; echo '<div>' . nl2br($this->fields['comment']) . '</div>'; echo '</div>'; } elseif ($this->fields['status'] == 'accepted') { echo '<div class="accepted_header">'; echo '<div>'; if (!empty($this->fields['comment'])) { echo nl2br($this->fields['comment']); } elseif ($form->fields['validation_required']) { echo __('Form accepted by validator.', 'formcreator'); } else { echo __('Form successfully saved.', 'formcreator'); } echo '</div>'; echo '</div>'; } // Get and display sections of the form $question = new PluginFormcreatorQuestion(); $questions = array(); $section_class = new PluginFormcreatorSection(); $find_sections = $section_class->find('plugin_formcreator_forms_id = ' . $form->getID(), '`order` ASC'); echo '<div class="form_section">'; foreach ($find_sections as $section_line) { echo '<h2>' . $section_line['name'] . '</h2>'; // Display all fields of the section $questions = $question->find('plugin_formcreator_sections_id = ' . $section_line['id'], '`order` ASC'); foreach ($questions as $question_line) { $answer = new PluginFormcreatorAnswer(); $found = $answer->find('plugin_formcreator_formanwers_id = "' . $this->getID() . '" AND plugin_formcreator_question_id = "' . $question_line['id'] . '"'); $found = array_shift($found); // if (in_array($question_line['fieldtype'], array('checkboxes', 'multiselect'))) { // $found['answer'] = json_decode($found['answer']); // } $canEdit = $this->fields['status'] == 'refused' && $_SESSION['glpiID'] == $this->fields['requester_id']; if ($canEdit || $question_line['fieldtype'] != "description" && $question_line['fieldtype'] != "hidden") { PluginFormcreatorFields::showField($question_line, $found['answer'], $canEdit); } } } echo '<script type="text/javascript">formcreatorShowFields();</script>'; // Display submit button if ($this->fields['status'] == 'refused' && $_SESSION['glpiID'] == $this->fields['requester_id']) { echo '<div class="form-group line' . (count($questions) + 1) % 2 . '">'; echo '<div class="center">'; echo '<input type="submit" name="save_formanswer" class="submit_button" value="' . __('Save') . '" />'; echo '</div>'; echo '</div>'; // Display validation form } elseif ($this->fields['status'] == 'waiting' && $_SESSION['glpiID'] == $this->fields['validator_id']) { if (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST)) { echo '<div class="form-group required line' . (count($questions) + 1) % 2 . '">'; echo '<label for="comment">' . __('Comment', 'formcreator') . ' <span class="red">*</span></label>'; echo '<textarea class="form-control" rows="5" name="comment" id="comment">' . $this->fields['comment'] . '</textarea>'; echo '<div class="help-block">' . __('Required if refused', 'formcreator') . '</div>'; echo '</div>'; echo '<div class="form-group line' . count($questions) % 2 . '">'; echo '<div class="center" style="float: left; width: 50%;">'; echo '<input type="submit" name="refuse_formanswer" class="submit_button" value="' . __('Refuse', 'formcreator') . '" onclick="return checkComment(this);" />'; echo '</div>'; echo '<div class="center">'; echo '<input type="submit" name="accept_formanswer" class="submit_button" value="' . __('Accept', 'formcreator') . '" />'; echo '</div>'; echo '</div>'; } } echo '<input type="hidden" name="formcreator_form" value="' . $form->getID() . '">'; echo '<input type="hidden" name="id" value="' . $this->getID() . '">'; echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">'; echo '</div>'; echo '</form>'; echo '<script type="text/javascript"> function checkComment(field) { if (document.getElementById("comment").value == "") { alert("' . __('Refused comment is required!', 'formcreator') . '"); return false; } } </script>'; }
/** * @param $input array of input: should be $_POST **/ static function updateAll($input) { if (!isset($input['itemtype']) || !isset($input['items_id'])) { Html::displayNotFoundError(); } $itemtype = $input['itemtype']; $items_id = $input['items_id']; if (!($item = getItemForItemtype($itemtype))) { Html::displayNotFoundError(); } $item->check($input['items_id'], UPDATE, $_POST); $is_device = $item instanceof CommonDevice; if ($is_device) { $link_type = $itemtype::getItem_DeviceType(); } $links = array(); // Update quantity or values $device_type = ''; foreach ($input as $key => $val) { $data = explode("_", $key); if (!empty($data[0])) { $command = $data[0]; } else { continue; } if ($command != 'quantity' && $command != 'value') { // items_id, itemtype, devicetype ... continue; } if (!$is_device) { if (empty($data[1])) { continue; } $device_type = $data[1]; if (in_array($device_type::getItem_DeviceType(), self::getItemAffinities($itemtype))) { $link_type = $device_type::getItem_DeviceType(); } } if (!empty($data[2])) { $links_id = $data[2]; } else { continue; } if (!isset($links[$link_type])) { $links[$link_type] = array('add' => array(), 'update' => array()); } switch ($command) { case 'quantity': $links[$link_type]['add'][$links_id] = $val; break; case 'value': if (!isset($links[$link_type]['update'][$links_id])) { $links[$link_type]['update'][$links_id] = array(); } if (isset($data[3])) { $links[$link_type]['update'][$links_id][$data[3]] = $val; } break; } } foreach ($links as $type => $commands) { if ($link = getItemForItemtype($type)) { foreach ($commands['add'] as $link_to_add => $number) { $link->addDevices($number, $itemtype, $items_id, $link_to_add); } foreach ($commands['update'] as $link_to_update => $input) { $input['id'] = $link_to_update; $link->update($input); } unset($link); } } }
<?php include '../../../inc/includes.php'; Session::checkRight("config", "w"); // Check if plugin is activated... $plugin = new Plugin(); if ($plugin->isActivated("formcreator")) { if (isset($_POST["profiles_id"]) && isset($_POST["form_id"])) { if (isset($_POST['access_rights'])) { $form = new PluginFormcreatorForm(); $form->update(array('id' => $_POST['form_id'], 'access_rights' => $_POST['access_rights'])); } $table = getTableForItemType('PluginFormcreatorFormprofiles'); $DB->query("DELETE FROM {$table} WHERE plugin_formcreator_forms_id = " . (int) $_POST["form_id"]); foreach ($_POST["profiles_id"] as $profile_id) { if ($profile_id != 0) { $query = "INSERT IGNORE INTO {$table} SET\n `plugin_formcreator_forms_id` = " . (int) $_POST["form_id"] . ",\n `plugin_formcreator_profiles_id` = " . (int) $profile_id; $DB->query($query); } } Html::back(); } else { Html::back(); } // Or display a "Not found" error } else { Html::displayNotFoundError(); }
/** Display item with tabs * * @since version 0.85 * * @param $options array **/ function display($options = array()) { global $CFG_GLPI; if (isset($options['id']) && !$this->isNewID($options['id'])) { if (!$this->getFromDB($options['id'])) { Html::displayNotFoundError(); } } $this->showNavigationHeader($options); if (!self::isLayoutExcludedPage() && self::isLayoutWithMain()) { if (!isset($_REQUEST['id'])) { $_REQUEST['id'] = 0; } $this->showPrimaryForm($options); } // in case of lefttab layout, we couldn't see "right error" message if ($this->get_item_to_display_tab) { if (isset($_GET["id"]) && $_GET["id"] && !$this->can($_GET["id"], READ)) { html::displayRightError(); } } $this->showTabsContent($options); }
/** Display item with tabs * * @since version 0.85 * * @param $options array **/ function display($options = array()) { global $CFG_GLPI; if (isset($options['id']) && !$this->isNewID($options['id'])) { if (!$this->getFromDB($options['id'])) { Html::displayNotFoundError(); } } // in case of lefttab layout, we couldn't see "right error" message if ($this->get_item_to_display_tab) { if (isset($_GET["id"]) && $_GET["id"] && !$this->can($_GET["id"], READ)) { // This triggers from a profile switch. // If we don't have right, redirect instead to central page if (isset($_SESSION['_redirected_from_profile_selector']) && $_SESSION['_redirected_from_profile_selector']) { unset($_SESSION['_redirected_from_profile_selector']); Html::redirect($CFG_GLPI['root_doc'] . "/front/central.php"); } html::displayRightError(); } } // try to lock object // $options must contains the id of the object, and if locked by manageObjectLock will contains 'locked' => 1 ObjectLock::manageObjectLock(get_class($this), $options); $this->showNavigationHeader($options); if (!self::isLayoutExcludedPage() && self::isLayoutWithMain()) { if (!isset($options['id'])) { $options['id'] = 0; } $this->showPrimaryForm($options); } $this->showTabsContent($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($options = array()) { if (!$this->getFromDB($options['id'])) { Html::displayNotFoundError(); } $obj = new PluginFormcreatorTarget(); $founded = $obj->find('itemtype = "' . __CLASS__ . '" AND items_id = ' . $this->getID()); $target = array_shift($founded); echo '<form name="form_target" method="post" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/targetticket.form.php">'; echo '<table class="tab_cadre_fixe">'; echo '<tr><th colspan="5">' . __('Edit a destination', 'formcreator') . '</th></tr>'; echo '<tr class="line1">'; echo '<td width="20%"><strong>' . __('Name') . ' <span style="color:red;">*</span></strong></td>'; echo '<td width="70%" colspan="4"><input type="text" name="name" style="width:650px;" value="' . $target['name'] . '"></textarea</td>'; echo '</tr>'; echo '<tr><td colspan="5"> </td></tr>'; echo '<tr><th colspan="5">' . _n('Target ticket', 'Target tickets', 1, 'formcreator') . '</th></tr>'; echo '<tr class="line1">'; echo '<td width="20%"><strong>' . __('Ticket title', 'formcreator') . ' <span style="color:red;">*</span></strong></td>'; echo '<td width="70%" colspan="4"><input type="text" name="title" style="width:650px;" value="' . $this->fields['name'] . '"></textarea</td>'; echo '</tr>'; echo '<tr class="line0">'; echo '<td width="20%"><strong>' . __('Description') . ' <span style="color:red;">*</span></strong></td>'; echo '<td width="70%" colspan="4"><textarea name="comment" style="width:646px;" rows="15">' . $this->fields['comment'] . '</textarea></td>'; echo '</tr>'; echo '<tr class="line1">'; echo '<td width="20%">' . _n('Ticket template', 'Ticket templates', 1) . '</td>'; echo '<td width="70%" colspan="4">'; Dropdown::show('TicketTemplate', array('name' => 'tickettemplates_id', 'value' => $this->fields['tickettemplates_id'])); echo '</td>'; echo '</tr>'; echo '<tr><td colspan="5"> </td></tr>'; 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%">' . __('Answer', '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 '<tr class="line' . ++$i % 2 . '"><td colspan="5"> </td></tr>'; echo '<tr class="line' . ++$i % 2 . '">'; 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(); }
/** Display item with tabs * * @since version 0.85 * * @param $options array **/ function display($options = array()) { global $CFG_GLPI; if (isset($options['id']) && !$this->isNewID($options['id'])) { if (!$this->getFromDB($options['id'])) { Html::displayNotFoundError(); } } $this->showNavigationHeader($options); if (!in_array(basename($_SERVER['SCRIPT_NAME']), $CFG_GLPI['layout_excluded_pages']) && in_array($_SESSION['glpilayout'], array('classic', 'vsplit'))) { if (!isset($_REQUEST['id'])) { $_REQUEST['id'] = ""; } $this->showPrimaryForm($options); } $this->showTabsContent($options); }
/** * @param $input * @param $delete **/ static function updateAll($input, $delete) { if (!isset($input['itemtype']) || !isset($input['items_id'])) { Html::displayNotFoundError(); } $itemtype = $input['itemtype']; $items_id = $input['items_id']; if (!($item = getItemForItemtype($itemtype))) { Html::displayNotFoundError(); } $item->check($input['items_id'], 'w', $_POST); $links = array(); // Update quantity $device_type = ''; foreach ($input as $key => $val) { $data = explode("_", $key); if (!empty($data[0])) { $command = $data[0]; } else { continue; } if (!empty($data[1]) && in_array('Item_' . $data[1], self::getDeviceTypes())) { $link_type = 'Item_' . $data[1]; } else { continue; } if (!empty($data[2])) { $links_id = $data[2]; } else { continue; } if (!isset($links[$link_type])) { $links[$link_type] = array('add' => array(), 'update' => array(), 'remove' => array()); } switch ($command) { case 'quantity': $links[$link_type]['add'][$links_id] = $val; break; case 'value': if (!isset($links[$link_type]['update'][$links_id])) { $links[$link_type]['update'][$links_id] = array(); } if (isset($data[3])) { $links[$link_type]['update'][$links_id][$data[3]] = $val; } break; case 'remove': if ($val == 1) { $links[$link_type]['remove'][] = $links_id; } break; } } foreach ($links as $type => $commands) { if ($link = getItemForItemtype($type)) { if ($delete) { foreach ($commands['remove'] as $link_to_remove) { $link->delete(array('id' => $link_to_remove)); } } else { foreach ($commands['add'] as $link_to_add => $number) { $link->addDevices($number, $itemtype, $items_id, $link_to_add); } foreach ($commands['update'] as $link_to_update => $input) { $input['id'] = $link_to_update; $link->update($input); } } unset($link); } } }
/** Display item with tabs * * @since version 0.85 * * @param $options array **/ function display($options = array()) { global $CFG_GLPI; if (isset($options['id']) && !$this->isNewID($options['id'])) { if (!$this->getFromDB($options['id'])) { Html::displayNotFoundError(); } } // in case of lefttab layout, we couldn't see "right error" message if ($this->get_item_to_display_tab) { if (isset($_GET["id"]) && $_GET["id"] && !$this->can($_GET["id"], READ)) { html::displayRightError(); } } // try to lock object // $options must contains the id of the object, and if locked by manageObjectLock will contains 'locked' => 1 ObjectLock::manageObjectLock(get_class($this), $options); $this->showNavigationHeader($options); if (!self::isLayoutExcludedPage() && self::isLayoutWithMain()) { if (!isset($options['id'])) { $options['id'] = 0; } $this->showPrimaryForm($options); } $this->showTabsContent($options); }
/** * Check right on an item with block * * @param $ID ID of the item (-1 if new item) * @param $right Right to check : r / w / recursive * @param &$input array of input data (used for adding item) (default NULL) * * @return nothing **/ function check($ID, $right, array &$input = NULL) { global $CFG_GLPI; // Check item exists if (!$this->isNewID($ID) && !$this->getFromDB($ID)) { // Gestion timeout session Session::redirectIfNotLoggedIn(); Html::displayNotFoundError(); } else { if (!$this->can($ID, $right, $input)) { // Gestion timeout session Session::redirectIfNotLoggedIn(); Html::displayRightError(); } } }
/** Display item with tabs * * @since version 0.85 * * @param $options array **/ function display($options = array()) { if (isset($options['id']) && !$this->isNewID($options['id'])) { if (!$this->getFromDB($options['id'])) { Html::displayNotFoundError(); } } $this->showNavigationHeader($options); $this->showTabsContent($options); }
function ajaxLoadItem($options) { /* * The following has been borrowed from Html::display() and CommonGLPI::showTabsContent(). * * TODO: maybe this can be shared through CommonView. -- Kevin Roy <*****@*****.**> */ if (isset($options['id']) and !$this->isNewID($options['id'])) { if (!$this->getFromDB($options['id'])) { Html::displayNotFoundError(); } } // for objects not in table like central $ID = 0; if (isset($this->fields['id'])) { $ID = $this->fields['id']; } else { if (isset($options['id'])) { $option_id = $options['id']; //Check for correct type of ID received from outside. if (is_string($option_id) and ctype_digit($options_id)) { $ID = (int) $options['id']; } else { if (is_int($option_id)) { $ID = $option_id; } else { trigger_error("Using default ID({$ID}) " . "since we can't determine correctly the type of ID ('{$option_id}')"); } } } } return $ID; }
public function showForm($ID, $options = array()) { if (!isset($ID) || !$this->getFromDB($ID)) { Html::displayNotFoundError(); } $options = array('canedit' => false); $this->initForm($ID, $options); $this->showFormHeader($options); $form = new PluginFormcreatorForm(); $form->getFromDB($this->fields['plugin_formcreator_forms_id']); $canEdit = $this->fields['status'] == 'refused' && $_SESSION['glpiID'] == $this->fields['requester_id']; if ($form->fields['validation_required'] == 1 && $_SESSION['glpiID'] == $this->fields['validator_id']) { $canValidate = true; } elseif ($form->fields['validation_required'] == 2) { // Get validator users from group $query = "SELECT u.`id`\n FROM `glpi_users` u\n INNER JOIN `glpi_groups_users` gu ON gu.`users_id` = u.`id`\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 gu.`groups_id` = " . $this->fields['validator_id'] . "\n AND u.`id` = " . (int) $_SESSION['glpiID']; $result = $GLOBALS['DB']->query($query); if ($GLOBALS['DB']->numrows($result) == 1) { $canValidate = true; } else { $canValidate = false; } } else { $canValidate = false; } echo '<tr><td colspan="4" class="formcreator_form form_horizontal">'; // Form Header if (!empty($form->fields['content'])) { echo '<div class="form_header">'; echo html_entity_decode($form->fields['content']); echo '</div>'; } if ($this->fields['status'] == 'refused') { echo '<div class="refused_header">'; echo '<div>' . nl2br($this->fields['comment']) . '</div>'; echo '</div>'; } elseif ($this->fields['status'] == 'accepted') { echo '<div class="accepted_header">'; echo '<div>'; if (!empty($this->fields['comment'])) { echo nl2br($this->fields['comment']); } elseif ($form->fields['validation_required']) { echo __('Form accepted by validator.', 'formcreator'); } else { echo __('Form successfully saved.', 'formcreator'); } echo '</div>'; echo '</div>'; } // Get and display sections of the form $question = new PluginFormcreatorQuestion(); $questions = array(); $section_class = new PluginFormcreatorSection(); $find_sections = $section_class->find('plugin_formcreator_forms_id = ' . (int) $form->getID(), '`order` ASC'); echo '<div class="form_section">'; foreach ($find_sections as $section_line) { echo '<h2>' . $section_line['name'] . '</h2>'; // Display all fields of the section $questions = $question->find('plugin_formcreator_sections_id = ' . (int) $section_line['id'], '`order` ASC'); foreach ($questions as $question_line) { $answer = new PluginFormcreatorAnswer(); $found = $answer->find("plugin_formcreator_formanwers_id = " . (int) $this->getID() . "\n AND plugin_formcreator_question_id = " . (int) $question_line['id']); $found = array_shift($found); // if (in_array($question_line['fieldtype'], array('checkboxes', 'multiselect'))) { // $found['answer'] = json_decode($found['answer']); // } if ($canEdit || $question_line['fieldtype'] != "description" && $question_line['fieldtype'] != "hidden") { PluginFormcreatorFields::showField($question_line, $found['answer'], $canEdit); } } } echo '<script type="text/javascript">formcreatorShowFields();</script>'; // Display submit button if ($this->fields['status'] == 'refused' && $_SESSION['glpiID'] == $this->fields['requester_id']) { echo '<div class="form-group line' . (count($questions) + 1) % 2 . '">'; echo '<div class="center">'; echo '<input type="submit" name="save_formanswer" class="submit_button" value="' . __('Save') . '" />'; echo '</div>'; echo '</div>'; // Display validation form } elseif ($this->fields['status'] == 'waiting' && $canValidate) { if (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST)) { echo '<div class="form-group required line' . (count($questions) + 1) % 2 . '">'; echo '<label for="comment">' . __('Comment', 'formcreator') . ' <span class="red">*</span></label>'; echo '<textarea class="form-control" rows="5" name="comment" id="comment">' . $this->fields['comment'] . '</textarea>'; echo '<div class="help-block">' . __('Required if refused', 'formcreator') . '</div>'; echo '</div>'; echo '<div class="form-group line' . count($questions) % 2 . '">'; echo '<div class="center" style="float: left; width: 50%;">'; echo '<input type="submit" name="refuse_formanswer" class="submit_button" value="' . __('Refuse', 'formcreator') . '" onclick="return checkComment(this);" />'; echo '</div>'; echo '<div class="center">'; echo '<input type="submit" name="accept_formanswer" class="submit_button" value="' . __('Accept', 'formcreator') . '" />'; echo '</div>'; echo '</div>'; } } echo '<input type="hidden" name="formcreator_form" value="' . $form->getID() . '">'; echo '<input type="hidden" name="id" value="' . $this->getID() . '">'; echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">'; echo '</div>'; // echo '</form>'; echo '<script type="text/javascript"> function checkComment(field) { if (document.getElementById("comment").value == "") { alert("' . __('Refused comment is required!', 'formcreator') . '"); return false; } } </script>'; echo '</td></tr>'; $this->showFormButtons($options); return true; }
/** * Check right on an item with block * * @param $ID ID of the item (-1 if new item) * @param $right Right to check : r / w / recursive * @param &$input array of input data (used for adding item) (default NULL) * * @return nothing **/ function check($ID, $right, array &$input = NULL) { global $CFG_GLPI; // Check item exists if (!$this->isNewID($ID) && !$this->getFromDB($ID)) { // Gestion timeout session if (!Session::getLoginUserID()) { Html::redirect($CFG_GLPI["root_doc"] . "/index.php"); exit; } Html::displayNotFoundError(); } else { if (!$this->can($ID, $right, $input)) { // Gestion timeout session if (!Session::getLoginUserID()) { Html::redirect($CFG_GLPI["root_doc"] . "/index.php"); exit; } Html::displayRightError(); } } }