cleanInputText() static public method

Clean string for input text field
static public cleanInputText ( $string ) : clean
$string string: input text
return clean string
示例#1
0
 static function selectGroupOnAdd($item)
 {
     global $CFG_GLPI, $DB;
     if (isset($item->input['_auto_import']) || isset($item->input['bypassgrouponadd'])) {
         return;
     }
     $peGroup_group = new self();
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         $peConfig = new PluginEscalationConfig();
         if ($peConfig->getValue('workflow', $item->fields['entities_id']) == '1') {
             if (isset($_POST['_groups_id_assign']) && $_POST['_groups_id_assign'] > 0) {
                 if (isset($_SESSION['plugin_escalation_files'])) {
                     $_FILES = $_SESSION['plugin_escalation_files'];
                 }
                 return;
             } else {
                 $group = new Group();
                 Html::header(__('Administration'), '', "maintain", "ticket");
                 if (isset($_POST['dropdown__groups_id_requester']) && $_POST['dropdown__groups_id_requester'] > 0) {
                     $_SESSION['plugin_escalation_groups_id_requester'] = $_POST['dropdown__groups_id_requester'];
                 }
                 if (isset($_FILES)) {
                     foreach ($_FILES['filename']['tmp_name'] as $numfile => $datafile) {
                         if ($datafile != '') {
                             $split = explode("/", $datafile);
                             Document::renameForce($datafile, GLPI_DOC_DIR . "/_tmp/" . end($split));
                             $_FILES['filename']['tmp_name'][$numfile] = GLPI_DOC_DIR . "/_tmp/" . end($split);
                         }
                     }
                     $_SESSION['plugin_escalation_files'] = $_FILES;
                 }
                 echo '<form action="' . $CFG_GLPI['root_doc'] . '/front/ticket.form.php"
               enctype="multipart/form-data" name="form_ticket" method="post">';
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<th colspan='2'>Sélection du groupe de techniciens</th>";
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td>";
                 echo __('Group in charge of the ticket') . "&nbsp;:";
                 echo "</td>";
                 echo "<td>";
                 $a_groups = array();
                 foreach ($_SESSION['glpigroups'] as $groups_id) {
                     $group->getFromDB($groups_id);
                     $a_groups[$groups_id] = $group->getName();
                     $queryg = "SELECT * FROM `" . $peGroup_group->getTable() . "`\n                     WHERE `groups_id_source` = '" . $groups_id . "' ";
                     $resultg = $DB->query($queryg);
                     while ($datag = $DB->fetch_array($resultg)) {
                         $group->getFromDB($datag['groups_id_destination']);
                         $a_groups[$groups_id . "_" . $datag['groups_id_destination']] = "&nbsp;&nbsp;&nbsp;> " . $group->getName();
                     }
                 }
                 $rand = Dropdown::showFromArray("_groups_id_assign_escalation", $a_groups);
                 $params = array('groups_id' => '__VALUE__', 'entity' => $_POST['entities_id'], 'rand' => $rand);
                 Ajax::updateItemOnSelectEvent("dropdown__groups_id_assign" . $rand, "show_assignuser{$rand}", $CFG_GLPI["root_doc"] . "/plugins/escalation/ajax/dropdownUserassign.php", $params);
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td colspan='2'>";
                 foreach ($_POST as $key => $value) {
                     if (is_array($value)) {
                         foreach ($value as $keyy => $valuee) {
                             echo '<input type="hidden" name="' . $key . '[' . $keyy . ']" value="' . $valuee . '" />';
                         }
                     } else {
                         if ($key == 'content') {
                             $value = Html::cleanPostForTextArea(Toolbox::clean_cross_side_scripting_deep($value));
                             echo '<textarea name="' . $key . '" style="display:none;">' . $value . '</textarea>';
                         } else {
                             if ($key == 'dropdown__groups_id_requester') {
                                 echo '<input type="hidden" name="_groups_id_requester" value="' . $value . '" />';
                             } else {
                                 $value = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(stripslashes($value)));
                                 echo '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
                             }
                         }
                     }
                 }
                 if (!isset($_POST['_users_id_assign']) or $_POST['_users_id_assign'] == '0') {
                     echo "<span id='show_assignuser{$rand}'></span>";
                 }
                 echo "</td>";
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td colspan='2' align='center'>";
                 echo "<input type='submit' name='add' value=\"" . __('Add') . "\" class='submit'>";
                 echo "</td>";
                 echo "</tr>";
                 echo "</table>";
                 Html::closeForm();
                 Html::footer();
                 exit;
             }
         }
     }
 }
示例#2
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     if (!static::canView()) {
         return false;
     }
     // In percent
     $colsize1 = '13';
     $colsize2 = '37';
     $default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1);
     // Set default options
     if (!$ID) {
         $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_suppliers_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0);
         foreach ($values as $key => $val) {
             if (!isset($options[$key])) {
                 $options[$key] = $val;
             }
         }
         if (isset($options['tickets_id'])) {
             $ticket = new Ticket();
             if ($ticket->getFromDB($options['tickets_id'])) {
                 $options['content'] = $ticket->getField('content');
                 $options['name'] = $ticket->getField('name');
                 $options['impact'] = $ticket->getField('impact');
                 $options['urgency'] = $ticket->getField('urgency');
                 $options['priority'] = $ticket->getField('priority');
                 $options['itilcategories_id'] = $ticket->getField('itilcategories_id');
                 $options['due_date'] = $ticket->getField('due_date');
             }
         }
         if (isset($options['problems_id'])) {
             $problem = new Problem();
             if ($problem->getFromDB($options['problems_id'])) {
                 $options['content'] = $problem->getField('content');
                 $options['name'] = $problem->getField('name');
                 $options['impact'] = $problem->getField('impact');
                 $options['urgency'] = $problem->getField('urgency');
                 $options['priority'] = $problem->getField('priority');
                 $options['itilcategories_id'] = $problem->getField('itilcategories_id');
                 $options['due_date'] = $problem->getField('due_date');
             }
         }
     }
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE, $options);
     }
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>";
     echo "<td class='left' width='{$colsize2}%'>";
     if (isset($options['tickets_id'])) {
         echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
     }
     if (isset($options['problems_id'])) {
         echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>";
     }
     $date = $this->fields["date"];
     if (!$ID) {
         $date = date("Y-m-d H:i:s");
     }
     Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
     echo "</td>";
     echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>";
     echo "<td width='{$colsize2}%' class='left'>";
     if ($this->fields["due_date"] == 'NULL') {
         $this->fields["due_date"] = '';
     }
     Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1));
     echo "</td></tr>";
     if ($ID) {
         echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>";
         User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         echo "</td>";
         echo "<th>" . __('Last update') . "</th>";
         echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
         if ($this->fields['users_id_lastupdater'] > 0) {
             printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
         }
         echo "</td></tr>";
     }
     if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
         echo "<tr class='tab_bg_1'>";
         echo "<th>" . __('Date of solving') . "</th>";
         echo "<td>";
         Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false));
         echo "</td>";
         if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
             echo "<th>" . __('Closing date') . "</th>";
             echo "<td>";
             Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
     }
     echo "</table>";
     echo "<table class='tab_cadre_fixe' id='mainformtable2'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . __('Status') . "</th>";
     echo "<td width='{$colsize2}%'>";
     self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed'));
     ChangeValidation::alertValidation($this, 'status');
     echo "</td>";
     echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>";
     echo "<td width='{$colsize2}%'>";
     // Only change during creation OR when allowed to change priority OR when user is the creator
     $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Category') . "</th>";
     echo "<td >";
     $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_change`='1'");
     ITILCategory::dropdown($opt);
     echo "</td>";
     echo "<th>" . __('Impact') . "</th>";
     echo "<td>";
     $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Total duration') . "</th>";
     echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>";
     echo "<th class='left'>" . __('Priority') . "</th>";
     echo "<td>";
     $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true));
     $idajax = 'change_priority_' . mt_rand();
     echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => 'dropdown_priority' . $idpriority);
     Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     $this->showActorsPartForm($ID, $options);
     echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . __('Title') . "</th>";
     echo "<td colspan='3'>";
     echo "<input type='text' size='90' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Description') . "</th>";
     echo "<td colspan='3'>";
     $rand = mt_rand();
     echo "<textarea id='content{$rand}' name='content' cols='90' rows='6'>" . Html::clean(Html::entity_decode_deep($this->fields["content"])) . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $options['colspan'] = 3;
     $this->showFormButtons($options);
     return true;
 }
 function showGenericSearch($itemtype, $params)
 {
     global $CFG_GLPI;
     // Default values of parameters
     $p = array();
     $p['link'] = array();
     //
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '';
     $p['is_deleted'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $options = Search::getCleanedOptions($itemtype);
     //      $target  = Toolbox::getItemTypeSearchURL($itemtype);
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     $linked = Search::getMetaItemtypeAvailable($itemtype);
     if (!isset($_GET['id']) || strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) {
         $item->getEmpty();
     } else {
         $item->getFromDB($_GET['id']);
     }
     if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) {
         echo "<form name='searchform{$itemtype}' method='get' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayview_rule.form.php\">";
     } else {
         echo "<form name='searchform{$itemtype}' method='get' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/componentscatalog_rule.form.php\">";
     }
     $item->showFormHeader();
     //      echo "<form name='searchform$itemtype' method='get' action=\"".
     //              $CFG_GLPI['root_doc']."/plugins/monitoring/front/componentscatalog_rule.form.php\">";
     //      echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo __('Name') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='text' name='name' value='" . $_GET['name'] . "'/>";
     echo "</td>";
     echo "<td>";
     echo __('Status') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo $_GET['itemtype'];
     echo "</td>";
     echo "</tr>";
     if (isset($_GET['itemtype'])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         echo "<table>";
         // Display normal search parameters
         for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
             echo "<tr><td class='left' width='50%'>";
             // First line display add / delete images for normal and meta search items
             if ($i == 0) {
                 echo "<input type='hidden' disabled id='add_search_count' name='add_search_count'\n                   value='1'>";
                 echo "<a href='#' onClick = \"document.getElementById('add_search_count').disabled=false;\n                   document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/plus.png\" alt='+' title=\"" . __s('Add a search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 if ($_SESSION["glpisearchcount"][$itemtype] > 1) {
                     echo "<input type='hidden' disabled id='delete_search_count'\n                      name='delete_search_count' value='1'>";
                     echo "<a href='#' onClick = \"document.getElementById('delete_search_count').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/moins.png\" alt='-' title=\"" . __s('Delete a search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 }
                 if (is_array($linked) && count($linked) > 0) {
                     echo "<input type='hidden' disabled id='add_search_count2' name='add_search_count2'\n                      value='1'>";
                     echo "<a href='#' onClick=\"document.getElementById('add_search_count2').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_plus.png\" alt='+' title=\"" . __s('Add a global search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                     if ($_SESSION["glpisearchcount2"][$itemtype] > 0) {
                         echo "<input type='hidden' disabled id='delete_search_count2'\n                         name='delete_search_count2' value='1'>";
                         echo "<a href='#' onClick=\"document.getElementById('delete_search_count2').disabled=false;\n                         document.forms['searchform{$itemtype}'].submit();\">";
                         echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title=\"" . __s('Delete a global search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                     }
                 }
                 //            $itemtable = getTableForItemType($itemtype);
                 //            if ($item && $item->maybeDeleted()) {
                 //               echo "<input type='hidden' id='is_deleted' name='is_deleted' value='".
                 //                      $p['is_deleted']."'>";
                 //               echo "<a href='#' onClick = \"toogle('is_deleted','','','');
                 //                      document.forms['searchform$itemtype'].submit();\">
                 //                      <img src=\"".$CFG_GLPI["root_doc"]."/pics/showdeleted".
                 //                       (!$p['is_deleted']?'_no':'').".png\" name='img_deleted'  alt=\"".
                 //                       (!$p['is_deleted']?$LANG['common'][3]:$LANG['common'][81])."\" title=\"".
                 //                       (!$p['is_deleted']?$LANG['common'][3]:$LANG['common'][81])."\" ></a>";
                 //               // Dropdown::showYesNo("is_deleted",$p['is_deleted']);
                 //               echo '&nbsp;&nbsp;';
                 //            }
             }
             // Display link item
             if ($i > 0) {
                 echo "<select name='link[{$i}]'>";
                 echo "<option value = 'AND' ";
                 if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND") {
                     echo "selected";
                 }
                 echo ">AND</option>\n";
                 echo "<option value='OR' ";
                 if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR") {
                     echo "selected";
                 }
                 echo ">OR</option>\n";
                 echo "<option value='AND NOT' ";
                 if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND NOT") {
                     echo "selected";
                 }
                 echo ">AND NOT</option>\n";
                 echo "<option value='OR NOT' ";
                 if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR NOT") {
                     echo "selected";
                 }
                 echo ">OR NOT</option>";
                 echo "</select>&nbsp;";
             }
             // display select box to define search item
             echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>";
             echo "<option value='view' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
                 echo "selected";
             }
             echo ">" . __('Items seen') . "</option>\n";
             reset($options);
             $first_group = true;
             $selected = 'view';
             $str_limit = 28;
             $nb_in_group = 0;
             $group = '';
             foreach ($options as $key => $val) {
                 // print groups
                 if (!is_array($val)) {
                     if (!$first_group) {
                         $group .= "</optgroup>\n";
                     } else {
                         $first_group = false;
                     }
                     if ($nb_in_group) {
                         echo $group;
                     }
                     $group = '';
                     $nb_in_group = 0;
                     $group .= "<optgroup label=\"" . Toolbox::substr($val, 0, $str_limit) . "\">";
                 } else {
                     if (!isset($val['nosearch']) || $val['nosearch'] == false) {
                         $nb_in_group++;
                         $group .= "<option title=\"" . Html::cleanInputText($val["name"]) . "\" value='{$key}'";
                         if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) {
                             $group .= "selected";
                             $selected = $key;
                         }
                         $group .= ">" . Toolbox::substr($val["name"], 0, $str_limit) . "</option>\n";
                     }
                 }
             }
             if (!$first_group) {
                 $group .= "</optgroup>\n";
             }
             if ($nb_in_group) {
                 echo $group;
             }
             echo "<option value='all' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
                 echo "selected";
             }
             echo ">" . __('All') . "</option>";
             echo "</select>\n";
             echo "</td><td class='left'>";
             echo "<div id='SearchSpan{$itemtype}{$i}'>\n";
             $_POST['itemtype'] = $itemtype;
             $_POST['num'] = $i;
             $_POST['field'] = $selected;
             $_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : "";
             $_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : "";
             include GLPI_ROOT . "/ajax/searchoption.php";
             echo "</div>\n";
             $params = array('field' => '__VALUE__', 'itemtype' => $itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]);
             Ajax::updateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params, false);
             echo "</td></tr>\n";
         }
         $metanames = array();
         if (is_array($linked) && count($linked) > 0) {
             for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
                 echo "<tr><td class='left' colspan='2'>";
                 $rand = mt_rand();
                 echo "<table width='100%'><tr class='left'><td width='35%'>";
                 // Display link item (not for the first item)
                 echo "<select name='link2[{$i}]'>";
                 echo "<option value='AND' ";
                 if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") {
                     echo "selected";
                 }
                 echo ">AND</option>\n";
                 echo "<option value='OR' ";
                 if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") {
                     echo "selected";
                 }
                 echo ">OR</option>\n";
                 echo "<option value='AND NOT' ";
                 if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") {
                     echo "selected";
                 }
                 echo ">AND NOT</option>\n";
                 echo "<option value='OR NOT' ";
                 if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") {
                     echo "selected";
                 }
                 echo ">OR NOT</option>\n";
                 echo "</select>&nbsp;";
                 // Display select of the linked item type available
                 echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
                 echo "<option value=''>" . Dropdown::EMPTY_VALUE . "</option>";
                 foreach ($linked as $key) {
                     if (!isset($metanames[$key])) {
                         $linkitem = new $key();
                         $metanames[$key] = $linkitem->getTypeName();
                     }
                     echo "<option value='{$key}'>" . Toolbox::substr($metanames[$key], 0, 20) . "</option>\n";
                 }
                 echo "</select>&nbsp;";
                 echo "</td><td>";
                 // Ajax script for display search met& item
                 echo "<span id='show_" . $itemtype . "_" . $i . "_{$rand}'>&nbsp;</span>\n";
                 $params = array('itemtype' => '__VALUE__', 'num' => $i, 'field' => is_array($p['field2']) && isset($p['field2'][$i]) ? $p['field2'][$i] : "", 'value' => is_array($p['contains2']) && isset($p['contains2'][$i]) ? $p['contains2'][$i] : "", 'searchtype2' => is_array($p['searchtype2']) && isset($p['searchtype2'][$i]) ? $p['searchtype2'][$i] : "");
                 Ajax::updateItemOnSelectEvent("itemtype2_" . $itemtype . "_" . $i . "_{$rand}", "show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
                 if (is_array($p['itemtype2']) && isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i])) {
                     $params['itemtype'] = $p['itemtype2'][$i];
                     Ajax::updateItem("show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
                     echo "<script type='text/javascript' >";
                     echo "window.document.getElementById('itemtype2_" . $itemtype . "_" . $i . "_{$rand}').value='" . $p['itemtype2'][$i] . "';";
                     echo "</script>\n";
                 }
                 echo "</td></tr></table>";
                 echo "</td></tr>\n";
             }
         }
         echo "</table>\n";
         echo "</td>\n";
         echo "<td width='150px'>";
         echo "<table width='100%'>";
         // Display sort selection
         /*      echo "<tr><td colspan='2'>".$LANG['search'][4];
               echo "&nbsp;<select name='sort' size='1'>";
               reset($options);
               $first_group=true;
               foreach ($options as $key => $val) {
                  if (!is_array($val)) {
                     if (!$first_group) {
                        echo "</optgroup>\n";
                     } else {
                        $first_group=false;
                     }
                     echo "<optgroup label=\"$val\">";
                  } else {
                     echo "<option value='$key'";
                     if ($key == $p['sort']) {
                        echo " selected";
                     }
                     echo ">".Toolbox::substr($val["name"],0,20)."</option>\n";
                  }
               }
               if (!$first_group) {
                  echo "</optgroup>\n";
               }
               echo "</select> ";
               echo "</td></tr>\n";
         */
         // Display deleted selection
         echo "<tr>";
         // Display submit button
         echo "<td width='80' class='center'>";
         echo "<input type='submit' value=\"" . _sx('button', 'Search') . "\" class='submit' >";
         echo "</td><td>";
         //      Bookmark::showSaveButton(Bookmark::SEARCH,$itemtype);
         if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) {
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayview_rule.form.php?" . "reset=reset" . "&name=" . $_GET['name'] . "&plugin_monitoring_displayviews_id=" . $_GET['plugin_monitoring_displayviews_id'] . "&itemtype=" . $_GET['itemtype'] . "' >";
         } else {
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/componentscatalog_rule.form.php?" . "reset=reset" . "&name=" . $_GET['name'] . "&plugin_monitoring_componentscalalog_id=" . $_GET['plugin_monitoring_componentscalalog_id'] . "&itemtype=" . $_GET['itemtype'] . "' >";
         }
         echo "&nbsp;&nbsp;<img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
         echo "</td></tr>";
         echo "</table>\n";
         echo "</td></tr>";
         echo "<tr>";
     }
     if (isset($_GET['id'])) {
         echo "<td colspan='2' class='center'>";
         if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) {
             echo "<input type='hidden' name='plugin_monitoring_displayviews_id' value='" . $_GET['plugin_monitoring_displayviews_id'] . "' >";
         } else {
             echo "<input type='hidden' name='plugin_monitoring_componentscalalog_id' value='" . $_GET['plugin_monitoring_componentscalalog_id'] . "' >";
         }
         echo "<input type='hidden' name='id' value='" . $_GET['id'] . "' >";
         echo "<input type='submit' name='updaterule' value=\"Update this rule\" class='submit' >";
         echo "</td>";
         echo "<td colspan='2' class='center'>";
         echo "<input type='submit' name='deleterule' value=\"Delete this rule\" class='submit' >";
     } else {
         echo "<td colspan='4' class='center'>";
         echo "<input type='hidden' name='plugin_monitoring_componentscalalog_id' value='" . $_GET['plugin_monitoring_componentscalalog_id'] . "' >";
         echo "<input type='submit' name='addrule' value=\"Add this rule\" class='submit' >";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>\n";
     // For dropdown
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
     // Reset to start when submit new search
     echo "<input type='hidden' name='start' value='0'>";
     Html::closeForm();
 }
示例#4
0
 public function dropdownContacts($suppliers_id, $value = 0, $entity_restrict = '')
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $entities = getEntitiesRestrictRequest("AND", "glpi_contacts", '', $entity_restrict, true);
     $query = "SELECT `glpi_contacts`.*\n                FROM `glpi_contacts`,`glpi_contacts_suppliers`\n                WHERE `glpi_contacts_suppliers`.`contacts_id` = `glpi_contacts`.`id`\n                AND `glpi_contacts_suppliers`.`suppliers_id` = '{$suppliers_id}'\n                AND `glpi_contacts`.`is_deleted` = '0'\n                {$entities}\n                ORDER BY `entities_id`, `name`";
     $result = $DB->query($query);
     echo "<select name=\"contacts_id\">";
     echo "<option value=\"0\">" . Dropdown::EMPTY_VALUE . "</option>";
     if ($DB->numrows($result)) {
         $prev = -1;
         while ($data = $DB->fetch_array($result)) {
             if ($data["entities_id"] != $prev) {
                 if ($prev >= 0) {
                     echo "</optgroup>";
                 }
                 $prev = $data["entities_id"];
                 echo "<optgroup label=\"" . Dropdown::getDropdownName("glpi_entities", $prev) . "\">";
             }
             $output = formatUserName($data["id"], "", $data["name"], $data["firstname"]);
             if ($_SESSION["glpiis_ids_visible"] || empty($output)) {
                 $output .= " (" . $data["id"] . ")";
             }
             echo "<option value='" . $data["id"] . "' " . ($value == $data["id"] ? " selected " : "") . " title=\"" . Html::cleanInputText($output) . "\">" . substr($output, 0, $CFG_GLPI["dropdown_chars_limit"]) . "</option>";
         }
         if ($prev >= 0) {
             echo "</optgroup>";
         }
     }
     echo "</select>";
 }
示例#5
0
 /**
  * Construit le code HTML pour un champ de saisie texte libre
  *
  * @param integer/string $id
  *           id de la règle dont fait partie le champ (integer ou tag de nouvel id)
  * @param string $param
  *           nom du paramètre à afficher (champ name du select)
  * @param array $desc
  *           description du paramètre à afficher
  * @param string $values
  *           valeur à utiliser pour préremplir le champ (doit être html-échappée)
  * @param boolean $can_write
  *           vrai ssi on doit afficher un menu sélectionnable, sinon on affiche juste le texte.
  * @return string code html à afficher
  */
 private static final function makeTextInput($id, $param, $desc, $value, $can_write)
 {
     $result = '';
     $size = isset($desc['size']) ? $desc['size'] : 50;
     $maxlength = $desc['maxlength'];
     if ($can_write) {
         $result .= '<input type="text" name="rules[' . $id . '][' . $param . ']" value="' . Html::cleanInputText($value) . '" size="' . $size . '" maxlength="' . $maxlength . '">';
     } else {
         $result .= $value;
     }
     return $result;
 }
示例#6
0
 /**
  * Print generic search form
  *
  *@param $itemtype type to display the form
  *@param $params parameters array may include field, contains, sort, is_deleted, link, link2, contains2, field2, type2
  *
  *@return nothing (displays)
  *
  **/
 function showGenericSearch($params)
 {
     global $CFG_GLPI;
     $itemtype = "PluginResourcesDirectory";
     $itemtable = $this->table;
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '';
     $p['is_deleted'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $options = Search::getCleanedOptions("PluginResourcesDirectory");
     $target = $CFG_GLPI["root_doc"] . "/plugins/resources/front/directory.php";
     // Instanciate an object to access method
     $item = NULL;
     if (class_exists($itemtype)) {
         $item = new $itemtype();
     }
     $linked = Search::getMetaItemtypeAvailable($itemtype);
     echo "<form name='searchform{$itemtype}' method='get' action=\"{$target}\">";
     echo "<table class='tab_cadre_fixe' >";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo "<table>";
     // Display normal search parameters
     for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
         echo "<tr><td class='left' width='50%'>";
         // First line display add / delete images for normal and meta search items
         if ($i == 0) {
             echo "<input type='hidden' disabled  id='add_search_count' name='add_search_count' value='1'>";
             echo "<a href='#' onClick = \"document.getElementById('add_search_count').disabled=false;document.forms['searchform{$itemtype}'].submit();\">";
             echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/plus.png\" alt='+' title='" . __s('Add a search criterion') . "'></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             if ($_SESSION["glpisearchcount"][$itemtype] > 1) {
                 echo "<input type='hidden' disabled  id='delete_search_count' name='delete_search_count' value='1'>";
                 echo "<a href='#' onClick = \"document.getElementById('delete_search_count').disabled=false;document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/moins.png\" alt='-' title='" . __s('Delete a search criterion') . "'></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             }
             if (is_array($linked) && count($linked) > 0) {
                 echo "<input type='hidden' disabled id='add_search_count2' name='add_search_count2' value='1'>";
                 echo "<a href='#' onClick = \"document.getElementById('add_search_count2').disabled=false;document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_plus.png\" alt='+' title='" . __s('Add a global search criterion') . "'></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 if ($_SESSION["glpisearchcount2"][$itemtype] > 0) {
                     echo "<input type='hidden' disabled  id='delete_search_count2' name='delete_search_count2' value='1'>";
                     echo "<a href='#' onClick = \"document.getElementById('delete_search_count2').disabled=false;document.forms['searchform{$itemtype}'].submit();\">";
                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title='" . __s('Delete a global search criterion') . "'></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 }
             }
             $itemtable = getTableForItemType($itemtype);
         }
         // Display link item
         if ($i > 0) {
             echo "<select name='link[{$i}]'>";
             echo "<option value='AND' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>";
             echo "</select>&nbsp;";
         }
         // display select box to define serach item
         echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>";
         echo "<option value='view' ";
         if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
             echo "selected";
         }
         echo ">" . __('Items seen') . "</option>\n";
         reset($options);
         $first_group = true;
         $selected = 'view';
         foreach ($options as $key => $val) {
             // print groups
             if (!is_array($val)) {
                 if (!$first_group) {
                     echo "</optgroup>\n";
                 } else {
                     $first_group = false;
                 }
                 echo "<optgroup label='{$val}'>";
             } else {
                 if (!isset($val['nosearch']) || $val['nosearch'] == false) {
                     echo "<option title=\"" . Html::cleanInputText($val["name"]) . "\" value='{$key}'";
                     if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) {
                         echo "selected";
                         $selected = $key;
                     }
                     echo ">" . Toolbox::substr($val["name"], 0, 28) . "</option>\n";
                 }
             }
         }
         if (!$first_group) {
             echo "</optgroup>\n";
         }
         echo "<option value='all' ";
         if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
             echo "selected";
         }
         echo ">" . __('All') . "</option>";
         echo "</select>&nbsp;\n";
         echo "</td><td class='left'>";
         echo "<div id='SearchSpan{$itemtype}{$i}'>\n";
         $_POST['itemtype'] = $itemtype;
         $_POST['num'] = $i;
         $_POST['field'] = $selected;
         $_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : "";
         $_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : "";
         include GLPI_ROOT . "/ajax/searchoption.php";
         echo "</div>\n";
         $params = array('field' => '__VALUE__', 'itemtype' => $itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]);
         Ajax::updateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params, false);
         echo "</td></tr>\n";
     }
     $metanames = array();
     if (is_array($linked) && count($linked) > 0) {
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             echo "<tr><td class='left'>";
             $rand = mt_rand();
             // Display link item (not for the first item)
             echo "<select name='link2[{$i}]'>";
             echo "<option value='AND' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>\n";
             echo "</select>&nbsp;";
             // Display select of the linked item type available
             echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
             echo "<option value=''>" . Dropdown::EMPTY_VALUE . "</option>";
             foreach ($linked as $key) {
                 if (!isset($metanames[$key])) {
                     $linkitem = new $key();
                     $metanames[$key] = $linkitem->getTypeName();
                 }
                 echo "<option value='{$key}'>" . Toolbox::substr($metanames[$key], 0, 20) . "</option>\n";
             }
             echo "</select>&nbsp;";
             echo "</td><td>";
             // Ajax script for display search met& item
             echo "<span id='show_" . $itemtype . "_" . $i . "_{$rand}'>&nbsp;</span>\n";
             $params = array('itemtype' => '__VALUE__', 'num' => $i, 'field' => is_array($p['field2']) && isset($p['field2'][$i]) ? $p['field2'][$i] : "", 'value' => is_array($p['contains2']) && isset($p['contains2'][$i]) ? $p['contains2'][$i] : "", 'searchtype2' => is_array($p['searchtype2']) && isset($p['searchtype2'][$i]) ? $p['searchtype2'][$i] : "");
             Ajax::updateItemOnSelectEvent("itemtype2_" . $itemtype . "_" . $i . "_{$rand}", "show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
             if (is_array($p['itemtype2']) && isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i])) {
                 $params['itemtype'] = $p['itemtype2'][$i];
                 Ajax::updateItem("show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
                 echo "<script type='text/javascript' >";
                 echo "window.document.getElementById('itemtype2_" . $itemtype . "_" . $i . "_{$rand}').value='" . $p['itemtype2'][$i] . "';";
                 echo "</script>\n";
             }
             echo "</td></tr></table>";
             echo "</td></tr>\n";
         }
     }
     echo "</table>\n";
     echo "</td>\n";
     echo "<td width='150px'>";
     echo "<table width='100%'>";
     // Display deleted selection
     echo "<tr>";
     // Display submit button
     echo "<td width='80' class='center'>";
     echo "<input type='submit' value=\"" . _sx('button', 'Search') . "\" class='submit' >";
     echo "</td><td>";
     Bookmark::showSaveButton(Bookmark::SEARCH, $itemtype);
     echo "<a href='{$target}?reset=reset' >";
     echo "&nbsp;&nbsp;<img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/templates/infotel/pics/reset.png' class='calendrier'></a>";
     echo "</td></tr></table>\n";
     echo "</td></tr>";
     echo "</table>\n";
     // For dropdown
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
     // Reset to start when submit new search
     echo "<input type='hidden' name='start' value='0'>";
     Html::closeForm();
 }
* @brief
*/
if (strpos($_SERVER['PHP_SELF'], "dropdownSelectSoftware.php")) {
    $AJAX_INCLUDE = 1;
    include '../inc/includes.php';
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
Session::checkRight("software", "w");
// Make a select box
$rand = mt_rand();
$where = "";
if (strlen($_POST['searchText']) > 0 && $_POST['searchText'] != $CFG_GLPI["ajax_wildcard"]) {
    $where .= " AND `name` " . Search::makeTextSearch($_POST['searchText']) . " ";
}
$where .= getEntitiesRestrictRequest(' AND', 'glpi_softwares', 'entities_id', $_POST["entity_restrict"], true);
$query = "SELECT DISTINCT `glpi_softwares`.`id`,\n                          `glpi_softwares`.`name`\n          FROM `glpi_softwares`\n          WHERE `glpi_softwares`.`is_deleted` = '0'\n                AND `glpi_softwares`.`is_template` = '0'\n                {$where}\n          ORDER BY `glpi_softwares`.`name`";
$result = $DB->query($query);
echo "<select name='softwares_id' id='item_type{$rand}'>\n";
echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n";
if ($DB->numrows($result)) {
    while ($data = $DB->fetch_assoc($result)) {
        $softwares_id = $data["id"];
        $output = $data["name"];
        echo "<option value='{$softwares_id}' title=\"" . Html::cleanInputText($output) . "\">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
    }
}
echo "</select>\n";
$paramsselsoft = array('softwares_id' => '__VALUE__', 'myname' => $_POST["myname"]);
Ajax::updateItemOnSelectEvent("item_type{$rand}", "show_" . $_POST["myname"] . $rand, $CFG_GLPI["root_doc"] . "/ajax/dropdownInstallVersion.php", $paramsselsoft);
echo "<span id='show_" . $_POST["myname"] . "{$rand}'>&nbsp;</span>\n";
 static function showGenericSearch($itemtype, array $params)
 {
     global $LANG, $CFG_GLPI;
     // Default values of parameters
     $p['link'] = array();
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '';
     $p['is_deleted'] = 0;
     $p['link2'] = '';
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $options = Search::getCleanedOptions($itemtype);
     //$target = Toolbox::getItemTypeSearchURL($itemtype);
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     // Meta search names
     $metaactivated = array('Computer' => $LANG['Menu'][0], 'Printer' => $LANG['Menu'][2], 'Monitor' => $LANG['Menu'][3], 'Peripheral' => $LANG['Menu'][16], 'Software' => $LANG['Menu'][4], 'Phone' => $LANG['Menu'][34], 'Ticket' => $LANG['Menu'][5]);
     //$target = substr_replace($target, '/central.php#', strrpos($target, '/'), 1);
     //echo $target;
     //echo "<form name='searchform$itemtype' method='get' action='$target'>";
     echo "<form name='searchform{$itemtype}' method='get' action='" . $CFG_GLPI["root_doc"] . "/plugins/mobile/front/search.php'>";
     echo "<input type='hidden' name='menu' value='" . $_GET['menu'] . "' />";
     echo "<input type='hidden' name='ssmenu' value='" . $_GET['ssmenu'] . "' />";
     // Display normal search parameters
     for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
         // Display link item
         if ($i > 0) {
             echo "<select name='link[{$i}]'>";
             echo "<option value='AND' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>";
             echo "<option value='OR' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>";
             echo "<option value='AND NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>";
             echo "<option value='OR NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>";
             echo "</select>";
         }
         // display select box to define search item
         echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>";
         echo "<option value='view' ";
         if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
             echo "selected";
         }
         echo ">" . $LANG['search'][11] . "</option>";
         reset($options);
         $first_group = true;
         $selected = 'view';
         foreach ($options as $key => $val) {
             // print groups
             if (!is_array($val)) {
                 if (!$first_group) {
                     echo "</optgroup>";
                 } else {
                     $first_group = false;
                 }
                 echo "<optgroup label='{$val}'>";
             } else {
                 if (!isset($val['nosearch']) || $val['nosearch'] == false) {
                     echo "<option title=\"" . Html::cleanInputText($val["name"]) . "\" value='{$key}'";
                     if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) {
                         echo "selected";
                         $selected = $key;
                     }
                     echo ">" . Toolbox::substr($val["name"], 0, 28) . "</option>";
                 }
             }
         }
         if (!$first_group) {
             echo "</optgroup>";
         }
         echo "<option value='all' ";
         if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
             echo "selected";
         }
         echo ">" . $LANG['common'][66] . "</option>";
         echo "</select>";
         echo "<span id='SearchSpan{$itemtype}{$i}'>\n";
         $_POST['itemtype'] = $itemtype;
         $_POST['num'] = $i;
         $_POST['field'] = $selected;
         //$_POST['meta']="type='search'";
         $_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : "";
         $_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : "";
         include GLPI_ROOT . "/plugins/mobile/inc/ajax.function.php";
         include GLPI_ROOT . "/plugins/mobile/ajax/searchoption.php";
         echo "</span>\n";
         $params = array('field' => '__VALUE__', 'itemtype' => $itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]);
         mobileAjaxUpdateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/plugins/mobile/ajax/searchoption.php", $params, false);
     }
     // Display meta search items
     $linked = array();
     if ($_SESSION["glpisearchcount2"][$itemtype] > 0) {
         // Define meta search items to linked
         switch ($itemtype) {
             case 'Computer':
                 $linked = array('Printer', 'Monitor', 'Peripheral', 'Software', 'Phone');
                 break;
             case 'Ticket':
                 if (Session::haveRight("ticket", CREATE)) {
                     $linked = array_keys(Ticket::getAllTypesForHelpdesk());
                 }
                 break;
             case 'Printer':
             case 'Monitor':
             case 'Peripheral':
             case 'Software':
             case 'Phone':
                 $linked = array('Computer');
                 break;
         }
     }
     $metanames = array();
     if (is_array($linked) && count($linked) > 0) {
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             $rand = mt_rand();
             // Display link item (not for the first item)
             echo "<select name='link2[{$i}]'>";
             echo "<option value='AND' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>";
             echo "<option value='OR' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>";
             echo "<option value='AND NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>";
             echo "<option value='OR NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>";
             echo "</select>";
             // Display select of the linked item type available
             echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
             echo "<option value=''>" . DROPDOWN_EMPTY_VALUE . "</option>";
             foreach ($linked as $key) {
                 if (!isset($metanames[$key])) {
                     $linkitem = new $key();
                     $metanames[$key] = $linkitem->getTypeName();
                 }
                 echo "<option value='{$key}'>" . Toolbox::substr($metanames[$key], 0, 20) . "</option>\n";
             }
             echo "</select>";
         }
     }
     // Display submit button
     echo "<br /><input type='submit' value=\"" . $LANG['buttons'][0] . "\" class='submit' data-theme='a' data-inline='true'>";
     // For dropdown
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
     // Reset to start when submit new search
     echo "<input type='hidden' name='start' value='0'>";
     //echo "</form>";
     Html::closeForm();
 }
                            // No access not displayed because empty not take into account for search
                            Profile::dropdownNoneReadWrite($inputname, $_REQUEST['value'], 1, 1, 1);
                            $display = true;
                            break;
                        case "itemtypename":
                            Dropdown::dropdownUsedItemTypes($inputname, getItemTypeForTable($searchopt['table']), array('value' => $_REQUEST['value'], 'comments' => 0));
                            $display = true;
                            break;
                    }
                }
                // Standard field usage
                if (!$display) {
                    switch ($searchopt['field']) {
                        case "name":
                        case "completename":
                            Dropdown::show(getItemTypeForTable($searchopt['table']), array('value' => $_REQUEST['value'], 'name' => $inputname, 'comments' => 0));
                            $display = true;
                            break;
                    }
                }
            }
            break;
    }
    //    static function dropdownValue($table,$myname,$value='',$display_comment=1,$entity_restrict=-1,
    //                           $update_item="",$used=array(),$auto_submit=0) {
    // Default case : text field
    if (!$display) {
        echo "<input type='search' size='13' name=\"{$inputname}\" value=\"" . Html::cleanInputText($_REQUEST['value']) . "\" >";
    }
}
//ajaxFooter();
                // Standard datatype usage
                if (!$display && isset($searchopt['datatype'])) {
                    switch ($searchopt['datatype']) {
                        case "date":
                        case "date_delay":
                        case "datetime":
                            $options2['relative_dates'] = true;
                            break;
                    }
                }
                $out = $item->getValueToSelect($searchopt, $inputname, $_POST['value'], $options2);
                if (strlen($out)) {
                    echo $out;
                    $display = true;
                }
                //Could display be handled by a plugin ?
                if (!$display && ($plug = isPluginItemType(getItemTypeForTable($searchopt['table'])))) {
                    $function = 'plugin_' . $plug['plugin'] . '_searchOptionsValues';
                    if (function_exists($function)) {
                        $params = array('name' => $inputname, 'searchtype' => $_POST['searchtype'], 'searchoption' => $searchopt, 'value' => $_POST['value']);
                        $display = $function($params);
                    }
                }
            }
            break;
    }
    // Default case : text field
    if (!$display) {
        echo "<input type='text' size='13' style='width:180px; height:30px;' class='form-control' name='{$inputname}' value=\"" . Html::cleanInputText($_POST['value']) . "\">";
    }
}
    echo "<br>";
    echo "<select name='" . $_POST['myname'] . "' size='1'>";
    echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>";
    if ($DB->numrows($result)) {
        while ($data = $DB->fetch_assoc($result)) {
            // Device name + port name
            $output = $output_long = $data['cname'];
            if (!empty($data['nname'])) {
                $output = sprintf(__('%1$s - %2$s'), $output, $data['nname']);
                //TRANS: %1$s is device name, %2$s is port name
                $output_long = sprintf(__('%1$s - The port %2$s'), $output_long, $data['nname']);
            }
            // display netpoint (which will be copied)
            if (!empty($data['npname'])) {
                $output = sprintf(__('%1$s - %2$s'), $output, $data['npname']);
                //TRANS: %1$s is a string (device name - port name...), %2$s is network outlet name
                $output_long = sprintf(__('%1$s - Network outlet %2$s'), $output_long, $data['npname']);
            }
            $ID = $data['did'];
            if ($_SESSION["glpiis_ids_visible"] || empty($output) || empty($output_long)) {
                $output = sprintf(__('%1$s (%2$s)'), $output, $ID);
                $output_long = sprintf(__('%1$s (%2$s)'), $output_long, $ID);
            }
            $output = Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]);
            echo "<option value='{$ID}' title=\"" . Html::cleanInputText($output_long) . "\">" . $output;
            echo "</option>";
        }
    }
    echo "</select>";
    //    echo "<input type='submit' name='connect' value=\"".__s('Connect')."\" class='submit'>";
}
示例#12
0
 /**
  * Show list of activated reports
  *
  * @param array $opt : short_classname,f_name,gtype,rand
  */
 static function title($opt)
 {
     global $LANG;
     $self = new self();
     $params['classname'] = 'PluginMreporting' . $opt['short_classname'];
     $reports = $self->getAllReports(true, $params);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __("Select statistics to be displayed") . "&nbsp;:</th></tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     echo "<select name='graphmenu' onchange='window.location.href=this.options\n    [this.selectedIndex].value'>";
     echo "<option value='-1' selected>" . Dropdown::EMPTY_VALUE . "</option>";
     $i = 0;
     foreach ($reports as $classname => $report) {
         foreach ($report['functions'] as $function) {
             if ($function['is_active']) {
                 $graphs[$function['category_func']][] = $function;
             }
         }
         echo "<optgroup label=\"" . $report['title'] . "\">";
         foreach ($graphs as $cat => $graph) {
             echo "<optgroup label=\"" . $cat . "\">";
             foreach ($graph as $k => $v) {
                 if ($v['is_active']) {
                     $comment = "";
                     if (isset($v["desc"])) {
                         $comment = $v["desc"];
                         $desc = " (" . $comment . ")";
                     }
                     echo "<option value='" . $v["url_graph"] . "' title=\"" . Html::cleanInputText($comment) . "\">" . $v["title"] . $desc . "</option>";
                     $i++;
                 }
             }
             echo "</optgroup>";
         }
         echo "</optgroup>";
     }
     echo "</select>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
 }
示例#13
0
 function displayField($name, $fieldname, $valuedisplay, $value = '', $checked = '')
 {
     if ($value == '') {
         $value = $valuedisplay;
     }
     $type = 'checkbox';
     $inputname = 'checked[]';
     if (strstr($fieldname, 'requester') || strstr($fieldname, 'assign')) {
         $type = 'radio';
         $inputname = $fieldname;
         $fieldname = $value;
     }
     echo "<tr class='tab_bg_3'>";
     echo "<td>";
     echo "<input type='" . $type . "' name='" . $inputname . "' value='" . $fieldname . "' " . $checked . " />";
     echo "</td>";
     echo "<td>";
     echo $name;
     echo "</td>";
     echo "<td>";
     echo $valuedisplay;
     if ($type == 'checkbox') {
         $value = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(stripslashes($value)));
         echo '<input type="hidden" name="' . $fieldname . '" value="' . $value . '" />';
     }
     echo "</td>";
     echo "</tr>";
 }
示例#14
0
        if (!empty($newgroup) && $items_in_group > 0) {
            echo $newgroup;
            $first_group = false;
        }
        $items_in_group = 0;
        $newgroup = "";
        if (!$first_group) {
            $newgroup .= "</optgroup>";
        }
        $val = Toolbox::substr($val, 0, $str_limit);
        $newgroup .= "<optgroup label=\"{$val}\">";
    } else {
        // No search on plugins
        echo $key . "--";
        if (!isPluginItemType($key) && !isset($val["nometa"])) {
            $newgroup .= "<option value='{$key}' title=\"" . Html::cleanInputText($val["name"]) . "\"";
            if ($key == $_POST["field"]) {
                $newgroup .= "selected";
            }
            $newgroup .= ">" . Toolbox::substr($val["name"], 0, $str_limit) . "</option>\n";
            $items_in_group++;
        }
    }
}
if (!empty($newgroup) && $items_in_group > 0) {
    echo $newgroup;
}
if (!$first_group) {
    echo "</optgroup>";
}
echo "</select>";
if (strlen($_POST['searchText']) > 0 && $_POST['searchText'] != $CFG_GLPI["ajax_wildcard"]) {
    $search = Search::makeTextSearch($_POST['searchText']);
    $where .= " AND (`name` " . $search . "\n                    OR `id` = '" . $_POST['searchText'] . "'";
    $where .= ")";
}
$NBMAX = $CFG_GLPI["dropdown_max"];
$LIMIT = "LIMIT 0, {$NBMAX}";
if ($_POST['searchText'] == $CFG_GLPI["ajax_wildcard"]) {
    $LIMIT = "";
}
$query = "SELECT *\n          FROM `" . $_POST['table'] . "`\n          {$where}\n          ORDER BY `name`\n          {$LIMIT}";
$result = $DB->query($query);
echo "<select name='" . $_POST['myname'] . "' id='" . $_POST['myname'] . "' size='1'>";
if ($_POST['searchText'] != $CFG_GLPI["ajax_wildcard"] && $DB->numrows($result) == $NBMAX) {
    echo "<option value='0'>--" . __('Limited view') . "--</option>";
}
echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>";
if ($DB->numrows($result)) {
    while ($data = $DB->fetch_array($result)) {
        $output = $data['name'];
        if (empty($output) || $_SESSION['glpiis_ids_visible']) {
            $output .= " (" . $data['id'] . ")";
        }
        $selected = "";
        if ($data['id'] == $_POST['value']) {
            $selected = "selected='selected'";
        }
        echo "<option value='" . $data['id'] . "' {$selected} title=\"" . Html::cleanInputText($output) . "\">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
    }
}
echo "</select>";
示例#16
0
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

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
*/
include '../../../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST['name'])) {
    $step = 1;
    if (!isset($_REQUEST['force_integer'])) {
        $step = PLUGIN_ORDER_NUMBER_STEP;
    }
    $class = "";
    if (isset($_REQUEST['class'])) {
        $class = "class='" . $_REQUEST['class'] . "'";
    }
    $data = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(rawurldecode(stripslashes($_POST["data"]))));
    echo "<input type='number' step='{$step}' name='" . $_POST['name'] . "' value='{$data}' {$class}>";
}
示例#17
0
 /**
  * Print out an HTML form for Search knowbase item
  *
  * @param $options   $_GET
  *
  * @return nothing (display the form)
  **/
 function searchForm($options)
 {
     global $CFG_GLPI;
     if (!$CFG_GLPI["use_public_faq"] && !Session::haveRightsOr(self::$rightname, array(READ, self::READFAQ))) {
         return false;
     }
     // Default values of parameters
     $params["contains"] = "";
     $params["target"] = $_SERVER['PHP_SELF'];
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     echo "<div>";
     echo "<form method='get' action='" . $this->getSearchURL() . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_2'><td class='right' width='50%'>";
     echo "<input type='text' size='50' name='contains' value=\"" . Html::cleanInputText(stripslashes($params["contains"])) . "\"></td>";
     echo "<td class='left'>";
     echo "<input type='submit' value=\"" . _sx('button', 'Search') . "\" class='submit'></td></tr>";
     echo "</table>";
     if (isset($options['item_itemtype']) && isset($options['item_items_id'])) {
         echo "<input type='hidden' name='item_itemtype' value='" . $options['item_itemtype'] . "'>";
         echo "<input type='hidden' name='item_items_id' value='" . $options['item_items_id'] . "'>";
     }
     Html::closeForm();
     echo "</div>";
 }
示例#18
0
 /**
  * Print generic search form
  *
  * @param $itemtype        type to display the form
  * @param $params    array of parameters may include field, contains, sort, is_deleted, link,
  *                         link2, contains2, field2, type2
  *
  * @return nothing (displays)
  **/
 static function showGenericSearch($itemtype, array $params)
 {
     global $CFG_GLPI;
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '';
     $p['is_deleted'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $options = self::getCleanedOptions($itemtype);
     $target = Toolbox::getItemTypeSearchURL($itemtype);
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'AllAssets') {
         $item = getItemForItemtype($itemtype);
     }
     $linked = self::getMetaItemtypeAvailable($itemtype);
     echo "<form name='searchform{$itemtype}' method='get' action=\"{$target}\">";
     echo "<div id='searchcriterias'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     if ($_SESSION["glpisearchcount"][$itemtype] + $_SESSION["glpisearchcount2"][$itemtype] > 1) {
         echo "<td width='10' class='center'>";
         echo "<a href=\"javascript:toggleTableDisplay('searchcriteriastable','searchcriteriasimg',\n                                                       '" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png',\n                                                       '" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png')\">";
         echo "<img alt='' name='searchcriteriasimg' src=\"" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png\">";
         echo "</td>";
     }
     echo "<td>";
     echo "<table id='searchcriteriastable'>";
     // Display normal search parameters
     for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
         echo "<tr " . ($i == 0 ? "class='headerRow'" : '') . "><td class='left' width='50%'>";
         // First line display add / delete images for normal and meta search items
         if ($i == 0) {
             echo "<input type='hidden' disabled id='add_search_count' name='add_search_count'\n                   value='1'>";
             echo "<a href='#' onClick = \"document.getElementById('add_search_count').disabled=false;\n                   document.forms['searchform{$itemtype}'].submit();\">";
             echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/plus.png\" alt='+' title=\"" . __s('Add a search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             if ($_SESSION["glpisearchcount"][$itemtype] > 1) {
                 echo "<input type='hidden' disabled id='delete_search_count'\n                      name='delete_search_count' value='1'>";
                 echo "<a href='#' onClick = \"document.getElementById('delete_search_count').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/moins.png\" alt='-' title=\"" . __s('Delete a search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             }
             if (is_array($linked) && count($linked) > 0) {
                 echo "<input type='hidden' disabled id='add_search_count2' name='add_search_count2'\n                      value='1'>";
                 echo "<a href='#' onClick=\"document.getElementById('add_search_count2').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_plus.png\" alt='+' title=\"" . __s('Add a global search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 if ($_SESSION["glpisearchcount2"][$itemtype] > 0) {
                     echo "<input type='hidden' disabled id='delete_search_count2'\n                         name='delete_search_count2' value='1'>";
                     echo "<a href='#' onClick=\"document.getElementById('delete_search_count2').disabled=false;\n                         document.forms['searchform{$itemtype}'].submit();\">";
                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title=\"" . __s('Delete a global search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 }
             }
             $itemtable = getTableForItemType($itemtype);
             if ($item && $item->maybeDeleted()) {
                 echo "<input type='hidden' id='is_deleted' name='is_deleted' value='" . $p['is_deleted'] . "'>";
                 echo "<a href='#' onClick = \"toogle('is_deleted','','','');\n                      document.forms['searchform{$itemtype}'].submit();\">\n                      <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/showdeleted" . (!$p['is_deleted'] ? '_no' : '') . ".png\" name='img_deleted' alt=\"" . (!$p['is_deleted'] ? __s('Show the dustbin') : __s("Don't show deleted items")) . "\" title=\"" . (!$p['is_deleted'] ? __s('Show the dustbin') : __s("Don't show deleted items")) . "\"></a>";
                 echo '&nbsp;&nbsp;';
             }
         }
         // Display link item
         if ($i > 0) {
             echo "<select name='link[{$i}]'>";
             echo "<option value = 'AND' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>";
             echo "</select>&nbsp;";
         }
         $selected = $first = '';
         // display select box to define search item
         echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>";
         if ($CFG_GLPI['allow_search_view'] == 2) {
             echo "<option value='view' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
                 echo "selected";
                 $selected = 'view';
             }
             echo ">" . __('Items seen') . "</option>\n";
         }
         reset($options);
         $first_group = true;
         $str_limit = 28;
         // Not $_SESSION['glpidropdown_chars_limit'] because must be really to short (5 or 10) and search engine will be unusable
         $nb_in_group = 0;
         $group = '';
         foreach ($options as $key => $val) {
             // print groups
             if (!is_array($val)) {
                 if (!$first_group) {
                     $group .= "</optgroup>\n";
                 } else {
                     $first_group = false;
                 }
                 if ($nb_in_group) {
                     echo $group;
                 }
                 $group = '';
                 $nb_in_group = 0;
                 $group .= "<optgroup label=\"" . Toolbox::substr($val, 0, $str_limit) . "\">";
             } else {
                 if (!isset($val['nosearch']) || $val['nosearch'] == false) {
                     $nb_in_group++;
                     $group .= "<option title=\"" . Html::cleanInputText($val["name"]) . "\" value='{$key}'";
                     if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) {
                         $group .= "selected";
                         $selected = $key;
                     } else {
                         if (empty($first)) {
                             $first = $key;
                         }
                     }
                     $group .= ">" . Toolbox::substr($val["name"], 0, $str_limit) . "</option>\n";
                 }
             }
         }
         if (!$first_group) {
             $group .= "</optgroup>\n";
         }
         if ($nb_in_group) {
             echo $group;
         }
         if ($CFG_GLPI['allow_search_view'] == 1) {
             echo "<option value='view' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
                 echo "selected";
                 $selected = 'view';
             }
             echo ">" . __('Items seen') . "</option>\n";
         }
         if ($CFG_GLPI['allow_search_all']) {
             echo "<option value='all' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
                 echo "selected";
                 $selected = 'all';
             }
             echo ">" . __('All') . "</option>";
         }
         if (empty($selected)) {
             $selected = $first;
         }
         echo "</select>\n";
         echo "</td><td class='left'>";
         echo "<div id='SearchSpan{$itemtype}{$i}'>\n";
         $used_itemtype = $itemtype;
         // Force Computer itemtype for AllAssets to permit to show specific items
         if ($itemtype == 'AllAssets') {
             $used_itemtype = 'Computer';
         }
         $_POST['itemtype'] = $used_itemtype;
         $_POST['num'] = $i;
         $_POST['field'] = $selected;
         $_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : "";
         $_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : "";
         include GLPI_ROOT . "/ajax/searchoption.php";
         echo "</div>\n";
         $params = array('field' => '__VALUE__', 'itemtype' => $used_itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]);
         Ajax::updateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params);
         echo "</td></tr>\n";
     }
     $metanames = array();
     if (is_array($linked) && count($linked) > 0) {
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             echo "<tr><td class='left' colspan='2'>";
             $rand = mt_rand();
             echo "<table width='100%'><tr class='left'><td width='35%'>";
             // Display link item (not for the first item)
             echo "<select name='link2[{$i}]'>";
             echo "<option value='AND' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>\n";
             echo "</select>&nbsp;";
             // Display select of the linked item type available
             echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
             echo "<option value=''>" . Dropdown::EMPTY_VALUE . "</option>";
             foreach ($linked as $key) {
                 if (!isset($metanames[$key])) {
                     if ($linkitem = getItemForItemtype($key)) {
                         $metanames[$key] = $linkitem->getTypeName();
                     }
                 }
                 echo "<option value='{$key}'>" . Toolbox::substr($metanames[$key], 0, 20) . "</option>\n";
             }
             echo "</select>&nbsp;";
             echo "</td><td>";
             // Ajax script for display search met& item
             echo "<span id='show_" . $itemtype . "_" . $i . "_{$rand}'>&nbsp;</span>\n";
             $params = array('itemtype' => '__VALUE__', 'num' => $i, 'field' => is_array($p['field2']) && isset($p['field2'][$i]) ? $p['field2'][$i] : "", 'value' => is_array($p['contains2']) && isset($p['contains2'][$i]) ? $p['contains2'][$i] : "", 'searchtype2' => is_array($p['searchtype2']) && isset($p['searchtype2'][$i]) ? $p['searchtype2'][$i] : "");
             Ajax::updateItemOnSelectEvent("itemtype2_" . $itemtype . "_" . $i . "_{$rand}", "show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params);
             if (is_array($p['itemtype2']) && isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i])) {
                 $params['itemtype'] = $p['itemtype2'][$i];
                 Ajax::updateItem("show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params);
                 echo "<script type='text/javascript' >";
                 echo "window.document.getElementById('itemtype2_" . $itemtype . "_" . $i . "_{$rand}').value='" . $p['itemtype2'][$i] . "';";
                 echo "</script>\n";
             }
             echo "</td></tr></table>";
             echo "</td></tr>\n";
         }
     }
     echo "</table>\n";
     echo "</td>\n";
     echo "<td width='150px'>";
     echo "<table width='100%'>";
     // Display sort selection
     /*      echo "<tr><td colspan='2'>".__('sorted by');
           echo "&nbsp;<select name='sort' size='1'>";
           reset($options);
           $first_group=true;
           foreach ($options as $key => $val) {
              if (!is_array($val)) {
                 if (!$first_group) {
                    echo "</optgroup>\n";
                 } else {
                    $first_group=false;
                 }
                 echo "<optgroup label=\"$val\">";
              } else {
                 echo "<option value='$key'";
                 if ($key == $p['sort']) {
                    echo " selected";
                 }
                 echo ">".Toolbox::substr($val["name"],0,20)."</option>\n";
              }
           }
           if (!$first_group) {
              echo "</optgroup>\n";
           }
           echo "</select> ";
           echo "</td></tr>\n";
     */
     // Display deleted selection
     echo "<tr>";
     // Display submit button
     echo "<td width='80' class='center'>";
     echo "<input type='submit' value=\"" . _sx('button', 'Search') . "\" class='submit' >";
     echo "</td><td>";
     Bookmark::showSaveButton(Bookmark::SEARCH, $itemtype);
     echo "<a href='{$target}?reset=reset' >";
     echo "&nbsp;&nbsp;<img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
     echo "</td></tr></table>\n";
     echo "</td></tr>";
     echo "</table>\n";
     // For dropdown
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
     // Reset to start when submit new search
     echo "<input type='hidden' name='start' value='0'>";
     echo "</div>";
     Html::closeForm();
 }
示例#19
0
        if (is_array($_POST['used'])) {
            $used = $_POST['used'];
        } else {
            $used = Toolbox::decodeArrayFromInput($_POST['used']);
        }
        if (count($used)) {
            $where = " AND `glpi_softwareversions`.`id` NOT IN ('" . implode("','", $used) . "')";
        }
    }
    // Make a select box
    $query = "SELECT DISTINCT `glpi_softwareversions`.*,\n                             `glpi_states`.`name` AS sname\n             FROM `glpi_softwareversions`\n             LEFT JOIN `glpi_states` ON (`glpi_softwareversions`.`states_id` = `glpi_states`.`id`)\n             WHERE `glpi_softwareversions`.`softwares_id` = '" . $_POST['softwares_id'] . "'\n                   {$where}\n             ORDER BY `name`";
    $result = $DB->query($query);
    $number = $DB->numrows($result);
    echo "<select name='" . $_POST['myname'] . "' size='1'>";
    echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>";
    $today = date("Y-m-d");
    if ($number) {
        while ($data = $DB->fetch_assoc($result)) {
            $ID = $data['id'];
            $output = $data['name'];
            if (empty($output) || $_SESSION['glpiis_ids_visible']) {
                $output = sprintf(__('%1$s (%2$s)'), $output, $ID);
            }
            if (!empty($data['sname'])) {
                $output = sprintf(__('%1$s - %2$s'), $output, $data['sname']);
            }
            echo "<option " . ($ID == $_POST['value'] ? "selected" : "") . " value='{$ID}' title=\"" . Html::cleanInputText($output) . "\">" . $output . "</option>";
        }
    }
    echo "</select>&nbsp;";
}
示例#20
0
 static function prepareHtmlFields($fields, $items_id, $canedit = true, $show_table = true, $massiveaction = false)
 {
     if (empty($fields)) {
         return false;
     }
     //get object associated with this fields
     $tmp = $fields;
     $first_field = array_shift($tmp);
     $container_obj = new PluginFieldsContainer();
     $container_obj->getFromDB($first_field['plugin_fields_containers_id']);
     $items_itemtype = ucfirst($container_obj->fields['itemtype']);
     $classname = "PluginFields" . $items_itemtype . preg_replace('/s$/', '', $container_obj->fields['name']);
     $obj = new $classname();
     //find row for this object with the items_id
     $found_values = $obj->find("plugin_fields_containers_id = " . $first_field['plugin_fields_containers_id'] . " AND items_id = " . $items_id);
     $found_v = array_shift($found_values);
     // find profiles (to check if current profile can edit fields)
     $fprofile = new PluginFieldsProfile();
     $found_p = $fprofile->find("`profiles_id` = '" . $_SESSION['glpiactiveprofile']['id'] . "'\n                                  AND `plugin_fields_containers_id` = '" . $first_field['plugin_fields_containers_id'] . "'");
     $first_found_p = array_shift($found_p);
     // test status for "CommonITILObject" objects
     if (is_subclass_of($items_itemtype, "CommonITILObject")) {
         $items_obj = new $items_itemtype();
         $items_obj->getFromDB($items_id);
         if (in_array($items_obj->fields['status'], $items_obj->getClosedStatusArray()) || in_array($items_obj->fields['status'], $items_obj->getSolvedStatusArray()) || $first_found_p['right'] != CREATE) {
             $canedit = false;
         }
     }
     //show all fields
     $html = "";
     $odd = 0;
     foreach ($fields as $field) {
         if ($field['type'] === 'header') {
             $html .= "<tr class='tab_bg_2'>";
             $html .= "<th colspan='4'>" . $field['label'] . "</td>";
             $html .= "</tr>";
             $odd = 0;
         } else {
             //get value
             $value = "";
             if (is_array($found_v)) {
                 if ($field['type'] == "dropdown") {
                     $value = $found_v["plugin_fields_" . $field['name'] . "dropdowns_id"];
                 } else {
                     $value = $found_v[$field['name']];
                 }
             }
             if (isset($_SESSION['plugin']['fields']['values_sent'])) {
                 if ($field['type'] == "dropdown") {
                     $value = $_SESSION['plugin']['fields']['values_sent']["plugin_fields_" . $field['name'] . "dropdowns_id"];
                 } else {
                     $value = $_SESSION['plugin']['fields']['values_sent'][$field['name']];
                 }
             }
             //get default value
             if (empty($value) && !empty($field['default_value'])) {
                 $value = $field['default_value'];
             }
             //show field
             if ($show_table) {
                 if ($odd % 2 == 0) {
                     $html .= "<tr class='tab_bg_2'>";
                 }
                 $required = $field['mandatory'] == 1 ? "<span class='red'>*</span>" : '';
                 if ($container_obj->fields['itemtype'] == 'Ticket' && $container_obj->fields['type'] == 'dom' && strpos($_SERVER['HTTP_REFERER'], ".injector.php") === false && strpos($_SERVER['HTTP_REFERER'], ".public.php") === false) {
                     $html .= "<th width='13%'>" . $field['label'] . " : {$required}</th>";
                 } else {
                     $html .= "<td>" . $field['label'] . " : {$required}</td>";
                 }
                 $html .= "<td>";
             }
             $readonly = $field['is_readonly'];
             switch ($field['type']) {
                 case 'number':
                 case 'text':
                     $value = Html::cleanInputText($value);
                     if ($canedit && !$readonly) {
                         $html .= "<input type='text' name='" . $field['name'] . "' value=\"{$value}\" />";
                     } else {
                         $html .= $value;
                     }
                     break;
                 case 'textarea':
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         $html .= "<textarea cols='45' rows='4' name='" . $field['name'] . "'>" . "{$value}</textarea>";
                     } else {
                         $html .= nl2br($value);
                     }
                     break;
                 case 'dropdown':
                     if ($canedit && !$readonly) {
                         //find entity on current object
                         $obj = new $container_obj->fields['itemtype']();
                         $obj->getFromDB($items_id);
                         ob_start();
                         if (strpos($field['name'], "dropdowns_id") !== false) {
                             $dropdown_itemtype = getItemTypeForTable(getTableNameForForeignKeyField($field['name']));
                         } else {
                             $dropdown_itemtype = PluginFieldsDropdown::getClassname($field['name']);
                         }
                         Dropdown::show($dropdown_itemtype, array('value' => $value, 'entity' => $obj->getEntityID()));
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $dropdown_table = "glpi_plugin_fields_" . $field['name'] . "dropdowns";
                         $html .= Dropdown::getDropdownName($dropdown_table, $value);
                     }
                     break;
                 case 'yesno':
                     //in massive action, we must skip display for yesno (possible bug in framework)
                     //otherwise double display of field
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         ob_start();
                         Dropdown::showYesNo($field['name'], $value);
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $html .= Dropdown::getYesNo($value);
                     }
                     break;
                 case 'date':
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         ob_start();
                         Html::showDateFormItem($field['name'], $value);
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $html .= Html::convDate($value);
                     }
                     break;
                 case 'datetime':
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         ob_start();
                         Html::showDateTimeFormItem($field['name'], $value);
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $html .= Html::convDateTime($value);
                     }
                 case 'dropdownuser':
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         ob_start();
                         User::dropdown(array('name' => $field['name'], 'value' => $value, 'entity' => -1, 'right' => 'all', 'condition' => 'is_active=1 && is_deleted=0'));
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $showuserlink = 0;
                         if (Session::haveRight('user', 'r')) {
                             $showuserlink = 1;
                         }
                         $html .= getUserName($value, $showuserlink);
                     }
             }
             if ($show_table) {
                 $html .= "</td>";
                 if ($odd % 2 == 1) {
                     $html .= "</tr>";
                 }
                 $odd++;
             }
         }
     }
     if ($show_table && $odd % 2 == 1) {
         $html .= "</tr>";
     }
     unset($_SESSION['plugin']['fields']['values_sent']);
     return $html;
 }
示例#21
0
文件: HtmlTest.php 项目: btry/glpi
 /**
  * @covers Html::cleanInputText
  */
 public function testCleanInputText()
 {
     $origin = 'This is a \'string\' with some "replacements" needed, but not « others »!';
     $expected = 'This is a &apos;string&apos; with some &quot;replacements&quot; needed, but not « others »!';
     $this->assertEquals($expected, Html::cleanInputText($origin));
 }
示例#22
0
-------------------------------------------------------------------------

LICENSE

This file is part of GLPI.

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

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();
if (isset($_POST['name'])) {
    echo "<input type='text' " . (isset($_POST["size"]) ? " size='" . $_POST["size"] . "' " : "") . " " . (isset($_POST["maxlength"]) ? "maxlength='" . $_POST["maxlength"] . "' " : "") . " name='" . $_POST['name'] . "' value=\"" . Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(rawurldecode(stripslashes($_POST["data"])))) . "\">";
}
示例#23
0
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     $default_values = self::getDefaultValues();
     // Get default values from posted values on reload form
     // On get because of tabs
     // we use REQUEST because method differ with layout (lefttab : GET, vsplit: POST)
     if (!isset($options['template_preview'])) {
         if (isset($_REQUEST)) {
             $values = Html::cleanPostForTextArea($_REQUEST);
         }
     }
     // Restore saved value or override with page parameter
     $saved = $this->restoreInput();
     foreach ($default_values as $name => $value) {
         if (!isset($values[$name])) {
             if (isset($saved[$name])) {
                 $values[$name] = $saved[$name];
             } else {
                 $values[$name] = $value;
             }
         }
     }
     if (isset($values['content'])) {
         // Clean new lines to be fix encoding
         $order = array('\\r', '\\n', "\\");
         $replace = array("", "", "");
         $values['content'] = str_replace($order, $replace, $values['content']);
     }
     if (isset($values['name'])) {
         $values['name'] = str_replace("\\", "", $values['name']);
     }
     if (!$ID) {
         // Override defaut values from projecttask if needed
         if (isset($options['_projecttasks_id'])) {
             $pt = new ProjectTask();
             if ($pt->getFromDB($options['_projecttasks_id'])) {
                 $values['name'] = $pt->getField('name');
                 $values['content'] = $pt->getField('name');
             }
         }
     }
     // Check category / type validity
     if ($values['itilcategories_id']) {
         $cat = new ITILCategory();
         if ($cat->getFromDB($values['itilcategories_id'])) {
             switch ($values['type']) {
                 case self::INCIDENT_TYPE:
                     if (!$cat->getField('is_incident')) {
                         $values['itilcategories_id'] = 0;
                     }
                     break;
                 case self::DEMAND_TYPE:
                     if (!$cat->getField('is_request')) {
                         $values['itilcategories_id'] = 0;
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     // Default check
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE, $values);
     }
     if (!$ID) {
         $this->userentities = array();
         if ($values["_users_id_requester"]) {
             //Get all the user's entities
             $all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true);
             //For each user's entity, check if the technician which creates the ticket have access to it
             foreach ($all_entities as $tmp => $ID_entity) {
                 if (Session::haveAccessToEntity($ID_entity)) {
                     $this->userentities[] = $ID_entity;
                 }
             }
         }
         $this->countentitiesforuser = count($this->userentities);
         if ($this->countentitiesforuser > 0 && !in_array($this->fields["entities_id"], $this->userentities)) {
             // If entity is not in the list of user's entities,
             // then use as default value the first value of the user's entites list
             $this->fields["entities_id"] = $this->userentities[0];
             // Pass to values
             $values['entities_id'] = $this->userentities[0];
         }
     }
     if ($values['type'] <= 0) {
         $values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE);
     }
     if (!isset($options['template_preview'])) {
         $options['template_preview'] = 0;
     }
     // Load ticket template if available :
     if ($ID) {
         $tt = $this->getTicketTemplateToUse($options['template_preview'], $this->fields['type'], $this->fields['itilcategories_id'], $this->fields['entities_id']);
     } else {
         $tt = $this->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']);
     }
     // Predefined fields from template : reset them
     if (isset($values['_predefined_fields'])) {
         $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
     } else {
         $values['_predefined_fields'] = array();
     }
     // Store predefined fields to be able not to take into account on change template
     // Only manage predefined values on ticket creation
     $predefined_fields = array();
     if (!$ID) {
         if (isset($tt->predefined) && count($tt->predefined)) {
             foreach ($tt->predefined as $predeffield => $predefvalue) {
                 if (isset($default_values[$predeffield])) {
                     // Is always default value : not set
                     // Set if already predefined field
                     // Set if ticket template change
                     if (count($values['_predefined_fields']) == 0 && $values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID() || $predeffield == 'requesttypes_id' && empty($saved)) {
                         // Load template data
                         $values[$predeffield] = $predefvalue;
                         $this->fields[$predeffield] = $predefvalue;
                         $predefined_fields[$predeffield] = $predefvalue;
                     }
                 }
             }
             // All predefined override : add option to say predifined exists
             if (count($predefined_fields) == 0) {
                 $predefined_fields['_all_predefined_override'] = 1;
             }
         } else {
             // No template load : reset predefined values
             if (count($values['_predefined_fields'])) {
                 foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
                     if ($values[$predeffield] == $predefvalue) {
                         $values[$predeffield] = $default_values[$predeffield];
                     }
                 }
             }
         }
     }
     // Put ticket template on $values for actors
     $values['_tickettemplate'] = $tt;
     $canupdate = Session::haveRight(self::$rightname, UPDATE);
     $canpriority = Session::haveRight(self::$rightname, self::CHANGEPRIORITY);
     $canstatus = $canupdate;
     if ($ID && in_array($this->fields['status'], $this->getClosedStatusArray())) {
         $canupdate = false;
         // No update for actors
         $values['_noupdate'] = true;
     }
     $showuserlink = 0;
     if (Session::haveRight('user', READ)) {
         $showuserlink = 1;
     }
     if ($options['template_preview']) {
         // Add all values to fields of tickets for template preview
         foreach ($values as $key => $val) {
             if (!isset($this->fields[$key])) {
                 $this->fields[$key] = $val;
             }
         }
     }
     // In percent
     $colsize1 = '13';
     $colsize2 = '29';
     $colsize3 = '13';
     $colsize4 = '45';
     $canupdate_descr = $canupdate || $this->fields['status'] == self::INCOMING && $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0;
     if (!$options['template_preview']) {
         echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>";
         if (isset($options['_projecttasks_id'])) {
             echo "<input type='hidden' name='_projecttasks_id' value='" . $options['_projecttasks_id'] . "'>";
         }
     }
     echo "<div class='spaced' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe' id='mainformtable'>";
     // Optional line
     $ismultientities = Session::isMultiEntitiesMode();
     echo "<tr class='headerRow responsive_hidden'>";
     echo "<th colspan='4'>";
     if ($ID) {
         $text = sprintf(__('%1$s - %2$s'), $this->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID));
         if ($ismultientities) {
             $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']));
         }
         echo $text;
     } else {
         if ($ismultientities) {
             printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $this->fields['entities_id']));
         } else {
             _e('New ticket');
         }
     }
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>";
     echo $tt->getBeginHiddenFieldText('date');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date'));
     } else {
         _e('Opening date');
     }
     echo $tt->getEndHiddenFieldText('date');
     echo "</th>";
     echo "<td width='{$colsize2}%'>";
     echo $tt->getBeginHiddenFieldValue('date');
     $date = $this->fields["date"];
     if ($canupdate) {
         Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
     } else {
         echo Html::convDateTime($date);
     }
     echo $tt->getEndHiddenFieldValue('date', $this);
     echo "</td><td colspan='2'></td></tr>";
     // SLTs
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('time_to_own');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Time to own'), $tt->getMandatoryMark('time_to_own'));
     } else {
         _e('Time to own');
     }
     echo $tt->getEndHiddenFieldText('time_to_own');
     echo "</th>";
     echo "<td width='{$colsize2}%' class='nopadding'>";
     $slt = new SLT();
     $slt->showSltForTicket($this, SLT::TTO, $tt, $canupdate);
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('due_date');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Time to resolve'), $tt->getMandatoryMark('due_date'));
     } else {
         _e('Time to resolve');
     }
     echo $tt->getEndHiddenFieldText('due_date');
     echo "</th>";
     echo "<td width='{$colsize4}%' class='nopadding'>";
     $slt->showSltForTicket($this, SLT::TTR, $tt, $canupdate);
     echo "</td>";
     echo "</tr>";
     if ($ID) {
         echo "<tr class='tab_bg_1'>";
         echo "<th width='{$colsize1}%'>" . __('By') . "</th>";
         echo "<td width='{$colsize2}%'>";
         if ($canupdate) {
             User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         } else {
             echo getUserName($this->fields["users_id_recipient"], $showuserlink);
         }
         echo "</td>";
         echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>";
         echo "<td width='{$colsize4}%'>";
         if ($this->fields['users_id_lastupdater'] > 0) {
             //TRANS: %1$s is the update date, %2$s is the last updater name
             printf(__('%1$s by %2$s'), Html::convDateTime($this->fields["date_mod"]), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
         }
         echo "</td>";
         echo "</tr>";
     }
     if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
         echo "<tr class='tab_bg_1'>";
         echo "<th width='{$colsize1}%'>" . __('Resolution date') . "</th>";
         echo "<td width='{$colsize2}%'>";
         Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate));
         echo "</td>";
         if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
             echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>";
             echo "<td width='{$colsize4}%'>";
             Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
     }
     if ($ID) {
         echo "</table>";
         echo "<table  class='tab_cadre_fixe' id='mainformtable2'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>";
     echo "<td width='{$colsize2}%'>";
     // Permit to set type when creating ticket without update right
     if ($canupdate || !$ID) {
         $opt = array('value' => $this->fields["type"]);
         /// Auto submit to load template
         if (!$ID) {
             $opt['on_change'] = 'this.form.submit()';
         }
         $rand = self::dropdownType('type', $opt);
         if ($ID) {
             $params = array('type' => '__VALUE__', 'entity_restrict' => $this->fields['entities_id'], 'value' => $this->fields['itilcategories_id'], 'currenttype' => $this->fields['type']);
             Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params);
         }
     } else {
         echo self::getTicketTypeName($this->fields["type"]);
     }
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</th>";
     echo "<td width='{$colsize4}%'>";
     // Permit to set category when creating ticket without update right
     if ($canupdate || !$ID || $canupdate_descr) {
         $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"]);
         if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
             $opt['condition'] = "`is_helpdeskvisible`='1' AND ";
         } else {
             $opt['condition'] = '';
         }
         /// Auto submit to load template
         if (!$ID) {
             $opt['on_change'] = 'this.form.submit()';
         }
         /// if category mandatory, no empty choice
         /// no empty choice is default value set on ticket creation, else yes
         if (($ID || $values['itilcategories_id']) && $tt->isMandatoryField("itilcategories_id") && $this->fields["itilcategories_id"] > 0) {
             $opt['display_emptychoice'] = false;
         }
         switch ($this->fields["type"]) {
             case self::INCIDENT_TYPE:
                 $opt['condition'] .= "`is_incident`='1'";
                 break;
             case self::DEMAND_TYPE:
                 $opt['condition'] .= "`is_request`='1'";
                 break;
             default:
                 break;
         }
         echo "<span id='show_category_by_type'>";
         ITILCategory::dropdown($opt);
         echo "</span>";
     } else {
         echo Dropdown::getDropdownName("glpi_itilcategories", $this->fields["itilcategories_id"]);
     }
     echo "</td>";
     echo "</tr>";
     if (!$ID) {
         echo "</table>";
         $this->showActorsPartForm($ID, $values);
         echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('status');
     printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status'));
     echo $tt->getEndHiddenFieldText('status') . "</th>";
     echo "<td width='{$colsize2}%'>";
     echo $tt->getBeginHiddenFieldValue('status');
     if ($canstatus) {
         self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed'));
         TicketValidation::alertValidation($this, 'status');
     } else {
         echo self::getStatus($this->fields["status"]);
         if (in_array($this->fields["status"], $this->getClosedStatusArray()) && $this->isAllowedStatus($this->fields['status'], Ticket::INCOMING)) {
             echo "&nbsp;<a class='vsubmit' href='" . $this->getLinkURL() . "&amp;forcetab=TicketFollowup\$1&amp;_openfollowup=1'>" . __('Reopen') . "</a>";
         }
     }
     echo $tt->getEndHiddenFieldValue('status', $this);
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('requesttypes_id');
     printf(__('%1$s%2$s'), __('Request source'), $tt->getMandatoryMark('requesttypes_id'));
     echo $tt->getEndHiddenFieldText('requesttypes_id') . "</th>";
     echo "<td width='{$colsize4}%'>";
     echo $tt->getBeginHiddenFieldValue('requesttypes_id');
     if ($canupdate) {
         RequestType::dropdown(array('value' => $this->fields["requesttypes_id"], 'condition' => 'is_active = 1 AND is_ticketheader = 1'));
     } else {
         echo Dropdown::getDropdownName('glpi_requesttypes', $this->fields["requesttypes_id"]);
         echo Html::hidden('requesttypes_id', array('value' => $this->fields["requesttypes_id"]));
     }
     echo $tt->getEndHiddenFieldValue('requesttypes_id', $this);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('urgency');
     printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency'));
     echo $tt->getEndHiddenFieldText('urgency') . "</th>";
     echo "<td>";
     if ($canupdate && $canpriority || !$ID || $canupdate_descr) {
         // Only change during creation OR when allowed to change priority OR when user is the creator
         echo $tt->getBeginHiddenFieldValue('urgency');
         $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"]));
         echo $tt->getEndHiddenFieldValue('urgency', $this);
     } else {
         $idurgency = "value_urgency" . mt_rand();
         echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $this->fields["urgency"] . "'>";
         echo $tt->getBeginHiddenFieldValue('urgency');
         echo parent::getUrgencyName($this->fields["urgency"]);
         echo $tt->getEndHiddenFieldValue('urgency', $this);
     }
     echo "</td>";
     // Display validation state
     echo "<th>";
     if (!$ID) {
         echo $tt->getBeginHiddenFieldText('_add_validation');
         printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation'));
         echo $tt->getEndHiddenFieldText('_add_validation');
     } else {
         echo $tt->getBeginHiddenFieldText('global_validation');
         _e('Approval');
         echo $tt->getEndHiddenFieldText('global_validation');
     }
     echo "</th>";
     echo "<td>";
     if (!$ID) {
         echo $tt->getBeginHiddenFieldValue('_add_validation');
         $validation_right = '';
         if ($values['type'] == self::INCIDENT_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT)) {
             $validation_right = 'validate_incident';
         }
         if ($values['type'] == self::DEMAND_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) {
             $validation_right = 'validate_request';
         }
         if (!empty($validation_right)) {
             echo "<input type='hidden' name='_add_validation' value='" . $values['_add_validation'] . "'>";
             $params = array('name' => "users_id_validate", 'entity' => $this->fields['entities_id'], 'right' => $validation_right, 'users_id_validate' => $values['users_id_validate']);
             TicketValidation::dropdownValidator($params);
         }
         echo $tt->getEndHiddenFieldValue('_add_validation', $this);
         if ($tt->isPredefinedField('global_validation')) {
             echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>";
         }
     } else {
         echo $tt->getBeginHiddenFieldValue('global_validation');
         if (Session::haveRightsOr('ticketvalidation', TicketValidation::getCreateRights()) && $canupdate) {
             TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $this->fields['global_validation']));
         } else {
             echo TicketValidation::getStatus($this->fields['global_validation']);
         }
         echo $tt->getEndHiddenFieldValue('global_validation', $this);
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('impact');
     printf(__('%1$s%2$s'), __('Impact'), $tt->getMandatoryMark('impact'));
     echo $tt->getEndHiddenFieldText('impact') . "</th>";
     echo "<td>";
     echo $tt->getBeginHiddenFieldValue('impact');
     if ($canupdate) {
         $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"]));
     } else {
         $idimpact = "value_impact" . mt_rand();
         echo "<input id='{$idimpact}' type='hidden' name='impact' value='" . $this->fields["impact"] . "'>";
         echo parent::getImpactName($this->fields["impact"]);
     }
     echo $tt->getEndHiddenFieldValue('impact', $this);
     echo "</td>";
     echo "<th>" . $tt->getBeginHiddenFieldText('locations_id');
     printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
     echo $tt->getEndHiddenFieldText('locations_id') . "</th>";
     echo "<td>";
     echo $tt->getBeginHiddenFieldValue('locations_id');
     if ($canupdate || !$ID) {
         Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $this->fields['entities_id']));
     } else {
         echo Dropdown::getDropdownName('glpi_locations', $this->fields["locations_id"]);
     }
     echo $tt->getEndHiddenFieldValue('locations_id', $this);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('priority');
     printf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority'));
     echo $tt->getEndHiddenFieldText('priority') . "</th>";
     echo "<td>";
     $idajax = 'change_priority_' . mt_rand();
     if ($canpriority && !$tt->isHiddenField('priority')) {
         $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true));
         $idpriority = 'dropdown_priority' . $idpriority;
         echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     } else {
         $idpriority = 0;
         echo $tt->getBeginHiddenFieldValue('priority');
         echo "<span id='{$idajax}'>" . parent::getPriorityName($this->fields["priority"]) . "</span>";
         echo $tt->getEndHiddenFieldValue('priority', $this);
     }
     if ($canupdate || $canupdate_descr) {
         $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority);
         Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     }
     echo "</td>";
     echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('items_id');
     printf(__('%1$s%2$s'), _n('Associated element', 'Associated elements', Session::getPluralNumber()), $tt->getMandatoryMark('items_id'));
     if ($ID && $canupdate) {
         echo "&nbsp;<a  href='" . $this->getFormURL() . "?id=" . $ID . "&amp;forcetab=Item_Ticket\$1'><img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n                      class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'></a>";
     }
     echo $tt->getEndHiddenFieldText('items_id');
     echo "</th>";
     if (!$ID) {
         echo "<td rowspan='2'>";
         echo $tt->getBeginHiddenFieldValue('items_id');
         $values['_canupdate'] = Session::haveRight('ticket', CREATE);
         if ($values['_canupdate']) {
             Item_Ticket::itemAddForm($this, $values);
         }
         echo $tt->getEndHiddenFieldValue('items_id', $this);
         echo "</td>";
     } else {
         echo "<td>";
         echo $tt->getBeginHiddenFieldValue('items_id');
         $values['_canupdate'] = $canupdate || $canupdate_descr;
         Item_Ticket::itemAddForm($this, $values);
         echo $tt->getEndHiddenFieldValue('items_id', $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     // Need comment right to add a followup with the actiontime
     if (!$ID && Session::haveRight('followup', TicketFollowup::ADDALLTICKET)) {
         echo "<th>" . $tt->getBeginHiddenFieldText('actiontime');
         printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime'));
         echo $tt->getEndHiddenFieldText('actiontime') . "</th>";
         echo "<td>";
         echo $tt->getBeginHiddenFieldValue('actiontime');
         Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true));
         echo $tt->getEndHiddenFieldValue('actiontime', $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "</table>";
     if ($ID) {
         $this->showActorsPartForm($ID, $values);
     }
     $view_linked_tickets = $ID || $canupdate;
     echo "<table class='tab_cadre_fixe' id='mainformtable4'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('name');
     printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name'));
     echo $tt->getEndHiddenFieldText('name') . "</th>";
     echo "<td colspan='3'>";
     if (!$ID || $canupdate_descr) {
         echo $tt->getBeginHiddenFieldValue('name');
         echo "<input type='text' style='width:98%' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">";
         echo $tt->getEndHiddenFieldValue('name', $this);
     } else {
         if (empty($this->fields["name"])) {
             _e('Without title');
         } else {
             echo $this->fields["name"];
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('content');
     printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content'));
     if (!$ID || $canupdate_descr) {
         $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
         Html::showTooltip(nl2br(Html::Clean($content)));
     }
     echo $tt->getEndHiddenFieldText('content') . "</th>";
     echo "<td colspan='3'>";
     if (!$ID || $canupdate_descr) {
         // Admin =oui on autorise la modification de la description
         echo $tt->getBeginHiddenFieldValue('content');
         $rand = mt_rand();
         $rand_text = mt_rand();
         $rows = 6;
         $content_id = "content{$rand}";
         if ($CFG_GLPI["use_rich_text"]) {
             $this->fields["content"] = $this->setRichTextContent($content_id, $this->fields["content"], $rand);
             $rows = 10;
         } else {
             $this->fields["content"] = $this->setSimpleTextContent($this->fields["content"]);
         }
         echo "<div id='content{$rand_text}'>";
         echo "<textarea id='{$content_id}' name='content' style='width:100%' rows='{$rows}'>" . $this->fields["content"] . "</textarea></div>";
         echo Html::scriptBlock("\$(document).ready(function() { \$('#{$content_id}').autogrow(); });");
         echo $tt->getEndHiddenFieldValue('content', $this);
     } else {
         $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
         echo nl2br(Html::Clean($content));
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     if ($view_linked_tickets) {
         echo "<th style='width:{$colsize1}%'>" . _n('Linked ticket', 'Linked tickets', Session::getPluralNumber());
         $rand_linked_ticket = mt_rand();
         if ($canupdate) {
             echo "&nbsp;";
             echo "<img onClick=\"" . Html::jsShow("linkedticket{$rand_linked_ticket}") . "\"\n                   title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                   class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         }
         echo '</th>';
         echo "<td colspan='3'>";
         if ($canupdate) {
             echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>";
             echo "<table class='tab_format' width='100%'><tr><td width='30%'>";
             Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : '');
             echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n";
             echo "</td><td width='70%'>";
             $linkparam = array('name' => '_link[tickets_id_2]', 'displaywith' => array('id'));
             if (isset($values["_link"])) {
                 $linkparam['value'] = $values["_link"]['tickets_id_2'];
             }
             Ticket::dropdown($linkparam);
             echo "</td></tr></table>";
             echo "</div>";
             if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) {
                 echo "<script language='javascript'>";
                 echo Html::jsShow("linkedticket{$rand_linked_ticket}");
                 echo "</script>";
             }
         }
         Ticket_Ticket::displayLinkedTicketsTo($ID);
         echo "</td>";
     }
     echo "</tr>";
     // View files added
     echo "<tr class='tab_bg_1'>";
     // Permit to add doc when creating a ticket
     echo "<th style='width:{$colsize1}%'>";
     echo $tt->getBeginHiddenFieldText('_documents_id');
     $doctitle = sprintf(__('File (%s)'), Document::getMaxUploadSize());
     printf(__('%1$s%2$s'), $doctitle, $tt->getMandatoryMark('_documents_id'));
     // Do not show if hidden.
     if (!$tt->isHiddenField('_documents_id')) {
         DocumentType::showAvailableTypesLink();
     }
     echo $tt->getEndHiddenFieldText('_documents_id');
     echo "</th>";
     echo "<td colspan='3'>";
     // Do not set values
     echo $tt->getEndHiddenFieldValue('_documents_id');
     if ($tt->isPredefinedField('_documents_id')) {
         if (isset($values['_documents_id']) && is_array($values['_documents_id']) && count($values['_documents_id'])) {
             echo "<span class='b'>" . __('Default documents:') . '</span>';
             echo "<br>";
             $doc = new Document();
             foreach ($values['_documents_id'] as $key => $val) {
                 if ($doc->getFromDB($val)) {
                     echo "<input type='hidden' name='_documents_id[{$key}]' value='{$val}'>";
                     echo "- " . $doc->getNameID() . "<br>";
                 }
             }
         }
     }
     echo "<div id='fileupload_info'></div>";
     echo "</td>";
     echo "</tr>";
     if ((!$ID || $canupdate || $canupdate_descr || Session::haveRightsOr(self::$rightname, array(self::ASSIGN, self::STEAL, DELETE, PURGE))) && !$options['template_preview']) {
         echo "<tr class='tab_bg_1'>";
         if ($ID) {
             if (Session::haveRightsOr(self::$rightname, array(UPDATE, DELETE, PURGE)) || $this->canDeleteItem() || $this->canUpdateItem()) {
                 echo "<td class='tab_bg_2 center' colspan='4'>";
                 if ($this->fields["is_deleted"] == 1) {
                     if (self::canPurge()) {
                         echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                     }
                 } else {
                     if (self::canUpdate()) {
                         echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                     }
                 }
                 if ($this->fields["is_deleted"] == 1) {
                     if (self::canPurge()) {
                         echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">";
                     }
                 } else {
                     if ($this->canDeleteItem()) {
                         echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'>";
                     }
                 }
                 echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>";
                 echo "</td>";
             }
         } else {
             echo "<td class='tab_bg_2 center' colspan='4'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             if ($tt->isField('id') && $tt->fields['id'] > 0) {
                 echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
                 echo "<input type='hidden' name='_predefined_fields'\n                      value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
             }
         }
     }
     // File upload system
     $colspan = 3;
     if (!$CFG_GLPI['use_rich_text']) {
         $colspan = 4;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='{$colspan}'>";
     echo $tt->getBeginHiddenFieldValue('_documents_id');
     echo Html::file(array('multiple' => true, 'showfilecontainer' => 'fileupload_info', 'values' => array('filename' => $values['_filename'], 'tag' => $values['_tag_filename'])));
     echo "</td>";
     if ($CFG_GLPI['use_rich_text']) {
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='{$colspan}'>";
         if (!isset($rand)) {
             $rand = mt_rand();
         }
         if ($canupdate_descr) {
             echo Html::initImagePasteSystem($content_id, $rand);
         }
         echo "</td>";
     }
     echo "</tr>";
     echo "</table>";
     echo "<input type='hidden' name='id' value='{$ID}'>";
     echo "</div>";
     if (!$options['template_preview']) {
         Html::closeForm();
     }
     return true;
 }
示例#24
0
                $ID = $data['id'];
                $addcomment = "";
                $title = $outputval;
                if (isset($data["comment"])) {
                    $title = sprintf(__('%1$s - %2$s'), $title, $data["comment"]);
                }
                if ($_SESSION["glpiis_ids_visible"] || strlen($outputval) == 0) {
                    //TRANS: %1$s is the name, %2$s the ID
                    $outputval = sprintf(__('%1$s (%2$s)'), $outputval, $ID);
                }
                if ($multi && $data["entities_id"] != $prev) {
                    if ($prev >= 0) {
                        echo "</optgroup>";
                    }
                    $prev = $data["entities_id"];
                    echo "<optgroup label=\"" . Dropdown::getDropdownName("glpi_entities", $prev) . "\">";
                }
                echo "<option value='{$ID}' title=\"" . Html::cleanInputText($title) . "\">" . Toolbox::substr($outputval, 0, $_POST["limit"]) . "</option>";
            }
            if ($multi) {
                echo "</optgroup>";
            }
        }
        echo "</select>";
    }
}
if (isset($_POST["comment"]) && $_POST["comment"]) {
    $paramscomment = array('value' => '__VALUE__', 'table' => $table);
    Ajax::updateItemOnSelectEvent("dropdown_" . $_POST["myname"] . $_POST["rand"], "comment_" . $_POST["myname"] . $_POST["rand"], $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment);
}
Ajax::commonDropdownUpdateItem($_POST);
示例#25
0
 /**
  * Formats an individual attribute, and returns the string value of the composed attribute.
  *
  * @since version 0.85
  *
  * @param $key       The name of the attribute to create
  * @param $value     The value of the attribute to create.
  *
  * @return string The composed attribute.
  **/
 static function formatAttribute($key, $value)
 {
     if (is_array($value)) {
         $value = implode(' ', $value);
     }
     return sprintf('%1$s="%2$s"', $key, Html::cleanInputText($value));
 }
示例#26
0
 /**
  * @since version 0.84
  **/
 static function title()
 {
     global $PLUGIN_HOOKS, $CFG_GLPI;
     $show_problem = Session::haveRight("edit_all_problem", "1") || Session::haveRight("show_all_problem", "1");
     $opt_list["Ticket"] = __('Tickets');
     $stat_list["Ticket"]["Ticket_Global"]["name"] = __('Global');
     $stat_list["Ticket"]["Ticket_Global"]["file"] = "stat.global.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Ticket"]["name"] = __('By ticket');
     $stat_list["Ticket"]["Ticket_Ticket"]["file"] = "stat.tracking.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Location"]["name"] = __('By hardware characteristics');
     $stat_list["Ticket"]["Ticket_Location"]["file"] = "stat.location.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Item"]["name"] = __('By hardware');
     $stat_list["Ticket"]["Ticket_Item"]["file"] = "stat.item.php";
     if ($show_problem) {
         $opt_list["Problem"] = _n('Problem', 'Problems', 2);
         $stat_list["Problem"]["Problem_Global"]["name"] = __('Global');
         $stat_list["Problem"]["Problem_Global"]["file"] = "stat.global.php?itemtype=Problem";
         $stat_list["Problem"]["Problem_Problem"]["name"] = __('By problem');
         $stat_list["Problem"]["Problem_Problem"]["file"] = "stat.tracking.php?itemtype=Problem";
     }
     //Affichage du tableau de presentation des stats
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __('Select statistics to be displayed') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     echo "<select name='statmenu' onchange='window.location.href=this.options\n               [this.selectedIndex].value'>";
     echo "<option value='-1' selected>" . Dropdown::EMPTY_VALUE . "</option>";
     $i = 0;
     $count = count($stat_list);
     foreach ($opt_list as $opt => $group) {
         echo "<optgroup label=\"" . $group . "\">";
         while ($data = each($stat_list[$opt])) {
             $name = $data[1]["name"];
             $file = $data[1]["file"];
             $comment = "";
             if (isset($data[1]["comment"])) {
                 $comment = $data[1]["comment"];
             }
             echo "<option value='" . $CFG_GLPI["root_doc"] . "/front/" . $file . "'\n                   title=\"" . Html::cleanInputText($comment) . "\">" . $name . "</option>";
             $i++;
         }
         echo "</optgroup>";
     }
     $names = array();
     $optgroup = array();
     if (isset($PLUGIN_HOOKS["stats"]) && is_array($PLUGIN_HOOKS["stats"])) {
         foreach ($PLUGIN_HOOKS["stats"] as $plug => $pages) {
             if (is_array($pages) && count($pages)) {
                 foreach ($pages as $page => $name) {
                     $names[$plug . '/' . $page] = array("name" => $name, "plug" => $plug);
                     $optgroup[$plug] = Plugin::getInfo($plug, 'name');
                 }
             }
         }
         asort($names);
     }
     foreach ($optgroup as $opt => $title) {
         echo "<optgroup label=\"" . $title . "\">";
         foreach ($names as $key => $val) {
             if ($opt == $val["plug"]) {
                 echo "<option value='" . $CFG_GLPI["root_doc"] . "/plugins/" . $key . "'>" . $val["name"] . "</option>";
             }
         }
         echo "</optgroup>";
     }
     echo "</select>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
 }
示例#27
0
Copyright (C) 2006-2012 by the Resources Development Team.

https://forge.indepnet.net/projects/resources
-------------------------------------------------------------------------

LICENSE

This file is part of Resources.

Resources is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Resources 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 Resources. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST['name'])) {
    echo "<textarea cols='30' rows='3' name='" . $_POST['name'] . "'>" . Html::cleanInputText(rawurldecode(stripslashes($_POST["data"])));
    echo "</textarea>";
}
示例#28
0
if (isset($_POST['searchText']) && $_POST['searchText'] != $CFG_GLPI["ajax_wildcard"] && $DB->numrows($result) == $NBMAX) {
    echo "<option value='0'>--" . __('Limited view') . "--</option>";
} else {
    echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>";
}
$output = Dropdown::getDropdownName('glpi_netpoints', $_POST['value']);
if (!empty($output) && $output != "&nbsp;") {
    echo "<option selected value='" . $_POST['value'] . "'>" . $output . "</option>";
}
if ($DB->numrows($result)) {
    while ($data = $DB->fetch_assoc($result)) {
        $output = $data['netpname'];
        $loc = $data['loc'];
        $ID = $data['id'];
        $title = $output;
        if (isset($data["comment"])) {
            //TRANS: %1$s is the location, %2$s is the comment
            $title = sprintf(__('%1$s - %2$s'), $title, $loc);
            $title = sprintf(__('%1$s - %2$s'), $title, $data["comment"]);
        }
        if (!$location_restrict) {
            $output = sprintf(__('%1$s (%2$s)'), $output, $loc);
        }
        echo "<option value='{$ID}' title=\"" . Html::cleanInputText($title) . "\">" . $output . "</option>";
    }
}
echo "</select>\n";
if (isset($_POST["comment"]) && $_POST["comment"]) {
    $paramscomment = array('value' => '__VALUE__', 'table' => "glpi_netpoints");
    Ajax::updateItemOnSelectEvent("dropdown_" . $_POST["myname"] . $_POST["rand"], "comment_" . $_POST["myname"] . $_POST["rand"], $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment);
}
示例#29
0
                // Standard datatype usage
                if (!$display && isset($searchopt['datatype'])) {
                    switch ($searchopt['datatype']) {
                        case "date":
                        case "date_delay":
                        case "datetime":
                            $options2['relative_dates'] = true;
                            break;
                    }
                }
                $out = $item->getValueToSelect($searchopt, $inputname, $_POST['value'], $options2);
                if (strlen($out)) {
                    echo $out;
                    $display = true;
                }
                //Could display be handled by a plugin ?
                if (!$display && ($plug = isPluginItemType(getItemTypeForTable($searchopt['table'])))) {
                    $function = 'plugin_' . $plug['plugin'] . '_searchOptionsValues';
                    if (function_exists($function)) {
                        $params = array('name' => $inputname, 'searchtype' => $_POST['searchtype'], 'searchoption' => $searchopt, 'value' => $_POST['value']);
                        $display = $function($params);
                    }
                }
            }
            break;
    }
    // Default case : text field
    if (!$display) {
        echo "<input type='text' size='13' name='{$inputname}' value=\"" . Html::cleanInputText($_POST['value']) . "\">";
    }
}
示例#30
0
 /**
  * Fonction d'affichage d'un champs de saisie texte libre
  *
  * @param string $param
  *           nom du paramètre à afficher
  * @param array $desc
  *           description de la configuration de ce paramètre
  * @param string $inheritText
  *           texte à afficher pour le choix 'hériter', ou '' si l'héritage est impossible pour cette option
  * @param boolean $can_write
  *           vrai ssi on doit afficher un input éditable, sinon on affiche juste le texte.
  */
 private static final function showTextInput($param, $desc, $value, $can_write, $inheritText)
 {
     $size = isset($desc['size']) ? $desc['size'] : 50;
     $maxlength = $desc['maxlength'];
     $doesinherit = $value === self::INHERIT_VALUE;
     if ($can_write) {
         if ($inheritText !== '') {
             // L'héritage est géré en mettant 2 champs, un caché, l'autre affiché, et en désactivant celui qui n'est pas pertinent.
             // Un checkbox permet de choisir entre les deux
             $chkid = 'configmanager_checkbox_inherit_' . $param;
             $txtid = 'configmanager_text_inherit_' . $param;
             echo $inheritText . ' <input type="checkbox" id="' . $chkid . '" ' . ($doesinherit ? 'checked' : '') . '><br>';
             echo '<input type="hidden" id="' . $txtid . '_inherit" value="' . self::INHERIT_VALUE . '" name="' . $param . '" ' . (!$doesinherit ? 'disabled' : '') . '>';
             echo '<input type="text" id="' . $txtid . '_value" value="' . ($doesinherit ? '' : Html::cleanInputText($value)) . '" name="' . $param . '" size="' . $size . '" maxlength="' . $maxlength . '" ' . ($doesinherit ? 'disabled style="display: none;"' : '') . '>';
             // Ajout du script permettant de basculer l'activation des champs de saisie
             self::showCheckboxJs($chkid, $txtid);
         } else {
             echo '<input type="text" name="' . $param . '" value="' . Html::cleanInputText($value) . '" size="' . $size . '" maxlength="' . $maxlength . '">';
         }
     } else {
         if ($doesinherit) {
             echo $inheritText;
         } else {
             echo $value;
         }
     }
 }