showCheckbox() static public method

See also: Html::getCheckbox()
static public showCheckbox ( array $options = [] ) : nothing
$options array array
return nothing (display only)
コード例 #1
0
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     $rights = array(array('itemtype' => 'PluginAddressingAddressing', 'label' => __('Generate reports', 'addressing'), 'field' => 'plugin_addressing'));
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     echo "<table class='tab_cadre_fixehov'>";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_addressing_use_ping_in_equipment'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Use ping on equipment form', 'addressing') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_addressing_use_ping_in_equipment[1_0]', 'checked' => $effective_rights['plugin_addressing_use_ping_in_equipment']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
コード例 #2
0
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     if ($profile->getField('interface') == 'central') {
         $rights = $this->getAllRights();
         $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Helpdesk') . "</th></tr>\n";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_racks_open_ticket'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Associable items to a ticket') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_racks_open_ticket', 'checked' => $effective_rights['plugin_racks_open_ticket']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
コード例 #3
0
ファイル: planning.class.php プロジェクト: korial29/glpi
 /**
  * Display a single line of planning filter.
  * See self::showPlanningFilter function
  *
  * @param $filter_key  : identify curent line of filter
  * @param $filter_data : array of filter date, must contains :
  *   * 'show_delete' (boolean): show delete button
  *   * 'filter_color_index' (integer): index of the color to use in self::$palette_bg
  * @param $options
  *
  * @return Nothing (display function)
  */
 static function showSingleLinePlanningFilter($filter_key, $filter_data, $options = array())
 {
     global $CFG_GLPI;
     $params['show_delete'] = true;
     $params['filter_color_index'] = 0;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $actor = explode('_', $filter_key);
     $uID = 0;
     $gID = 0;
     if ($filter_data['type'] == 'user') {
         $uID = $actor[1];
         $user = new User();
         $user->getFromDB($actor[1]);
         $title = $user->getName();
     } else {
         if ($filter_data['type'] == 'group_users') {
             $group = new Group();
             $group->getFromDB($actor[1]);
             $title = $group->getName();
         } else {
             if ($filter_data['type'] == 'group') {
                 $gID = $actor[1];
                 $group = new Group();
                 $group->getFromDB($actor[1]);
                 $title = $group->getName();
             } else {
                 if ($filter_data['type'] == 'event_filter') {
                     $title = $filter_key::getTypeName();
                 }
             }
         }
     }
     echo "<li event_type='" . $filter_data['type'] . "'\n               event_name='{$filter_key}'\n               class='" . $filter_data['type'] . "'>";
     Html::showCheckbox(array('name' => 'filters[]', 'value' => $filter_key, 'title' => $title, 'checked' => $filter_data['display']));
     if ($filter_data['type'] != 'event_filter') {
         $icon_type = explode('_', $filter_data['type']);
         echo "<img class='actor_icon' src='" . $CFG_GLPI['root_doc'] . "/pics/" . $icon_type[0] . ".png'>";
     }
     echo "<label for='{$filter_key}'>{$title}</label>";
     $color = self::$palette_bg[$params['filter_color_index']];
     if (isset($filter_data['color']) && !empty($filter_data['color'])) {
         $color = $filter_data['color'];
     } else {
         $params['filter_color_index']++;
         if (!isset(self::$palette_bg[$params['filter_color_index']])) {
             $params['filter_color_index'] = 0;
             $color = self::$palette_bg[$params['filter_color_index']];
         }
     }
     if ($filter_data['type'] != 'event_filter') {
         echo "<span class='filter_option'>";
         echo "<img class='pointer' src='" . $CFG_GLPI['root_doc'] . "/pics/down.png' />";
         echo "<ul>";
         if ($params['show_delete']) {
             echo "<li class='delete_planning' value='{$filter_key}'>" . __("Delete") . "</li>";
         }
         if ($filter_data['type'] != 'group_users') {
             $url = parse_url($CFG_GLPI["url_base"]);
             $port = 80;
             if (isset($url['port'])) {
                 $port = $url['port'];
             } else {
                 if (isset($url['scheme']) && $url["scheme"] == 'https') {
                     $port = 443;
                 }
             }
             $cal_url = "/front/planning.php?genical=1&uID=" . $uID . "&gID=" . $gID . "&entities_id=" . $_SESSION["glpiactive_entity"] . "&is_recursive=" . $_SESSION["glpiactive_entity_recursive"] . "&token=" . User::getPersonalToken(Session::getLoginUserID(true));
             echo "<li><a target='_blank' href='" . $CFG_GLPI["root_doc"] . "{$cal_url}'>" . _sx("button", "Export") . " - " . __("Ical") . "</a></li>";
             echo "<li><a target='_blank' href='webcal://" . $url['host'] . ":{$port}" . (isset($url['path']) ? $url['path'] : '') . "{$cal_url}'>" . _sx("button", "Export") . " - " . __("Webcal") . "</a></li>";
         }
         echo "</ul>";
         echo "</span>";
     }
     // colors not for groups
     if ($filter_data['type'] != 'group_users') {
         echo "<span class='color_input'>";
         Html::showColorField($filter_key . "_color", array('value' => $color));
         echo "</span>";
     }
     if ($filter_data['type'] == 'group_users') {
         echo "<span class='toggle pointer' />";
     }
     if ($filter_data['type'] == 'group_users') {
         echo "<ul class='group_listofusers filters'>";
         foreach ($filter_data['users'] as $user_key => $userdata) {
             self::showSingleLinePlanningFilter($user_key, $userdata, array('show_delete' => false, 'filter_color_index' => $params['filter_color_index']));
         }
         echo "</ul>";
     }
     echo "</li>";
 }
コード例 #4
0
 static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand)
 {
     global $CFG_GLPI;
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']);
     $checks_types = self::getTypes();
     echo "<table class='tab_cadrehov package_item_list' id='table_check_{$rand}'>";
     $i = 0;
     foreach ($datas['jobs']['checks'] as $check) {
         //specific case for filesystem size
         if (is_numeric($check['value'])) {
             if ($check['type'] == "freespaceGreater") {
                 $check['value'] = $check['value'] * 1024 * 1024;
             }
             $check['value'] = PluginFusioninventoryDeployFile::processFilesize($check['value']);
         }
         echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2);
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='control'>";
             Html::showCheckbox(array('name' => 'check_entries[]'));
             echo "</td>";
         }
         echo "<td>";
         echo "<a class='edit'" . "onclick=\"edit_subtype('check', {$order->fields['id']}, {$rand} ,this)\">" . $checks_types[$check['type']] . "</a><br />";
         echo $check['path'];
         if (!empty($check['value'])) {
             echo "&nbsp;&nbsp;&nbsp;<b>";
             if (strpos($check['type'], "Greater") !== FALSE) {
                 echo "&gt;";
             } else {
                 if (strpos($check['type'], "Lower") !== FALSE) {
                     echo "&lt;";
                 } else {
                     echo "=";
                 }
             }
             echo "</b>&nbsp;&nbsp;&nbsp;";
             echo $check['value'];
         }
         echo "</td>";
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>";
         }
         echo "</tr>";
         $i++;
     }
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "<tr><th>";
         Html::checkAllAsCheckbox("checksList{$rand}", mt_rand());
         echo "</th><th colspan='3' class='mark'></th></tr>";
     }
     echo "</table>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "&nbsp;&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt='' />";
         echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit' />";
     }
 }
コード例 #5
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case "transfert":
             Dropdown::show('Entity');
             echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             return true;
             break;
         case 'target_task':
             echo "<table class='tab_cadre' width='600'>";
             echo "<tr>";
             echo "<td>";
             echo __('Task', 'fusioninventory') . "&nbsp;:";
             echo "</td>";
             echo "<td>";
             $rand = mt_rand();
             Dropdown::show('PluginFusioninventoryTask', array('name' => "tasks_id", 'condition' => "is_active = 0", 'toupdate' => array('value_fieldname' => "id", 'to_update' => "dropdown_packages_id{$rand}", 'url' => $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/dropdown_taskjob.php")));
             echo "</td>";
             echo "</tr>";
             echo "<tr>";
             echo "<td>";
             echo __('Package', 'fusioninventory') . "&nbsp;:";
             echo "</td>";
             echo "<td>";
             Dropdown::show('PluginFusioninventoryDeployPackage', array('name' => "packages_id", 'rand' => $rand));
             echo "</td>";
             echo "</tr>";
             echo "<tr>";
             echo "<td colspan='2'>";
             Html::showCheckbox(array('name' => 'separate_jobs', 'value' => 1));
             echo __('Create a job for each group', 'fusioninventory');
             echo "</td>";
             echo "</tr>";
             echo "<tr>";
             echo "<td colspan='2' align='center'>";
             echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             echo "</td>";
             echo "</tr>";
             echo "</table>";
             return true;
     }
 }
コード例 #6
0
 /** Show LDAP groups to add or synchronise in an entity
  *
  * @param $target    target page for the form
  * @param $start     where to start the list
  * @param $sync      synchronise or add ? (default 0)
  * @param $filter    ldap filter to use (default '')
  * @param $filter2   second ldap filter to use (which case ?) (default '')
  * @param $entity    working entity
  * @param $order     display order (default DESC)
  *
  * @return  nothing
  **/
 static function showLdapGroups($target, $start, $sync = 0, $filter = '', $filter2 = '', $entity, $order = 'DESC')
 {
     echo "<br>";
     $limitexceeded = false;
     $ldap_groups = self::getAllGroups($_SESSION["ldap_server"], $filter, $filter2, $entity, $limitexceeded, $order);
     if (is_array($ldap_groups)) {
         $numrows = count($ldap_groups);
         $rand = mt_rand();
         $colspan = Session::isMultiEntitiesMode() ? 5 : 4;
         if ($numrows > 0) {
             self::displaySizeLimitWarning($limitexceeded);
             $parameters = '';
             Html::printPager($start, $numrows, $target, $parameters);
             // delete end
             array_splice($ldap_groups, $start + $_SESSION['glpilist_limit']);
             // delete begin
             if ($start > 0) {
                 array_splice($ldap_groups, 0, $start);
             }
             echo "<div class='center'>";
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => min($_SESSION['glpilist_limit'], count($ldap_groups)), 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'import_group' => _sx('button', 'Import')), 'extraparams' => array('massive_action_fields' => array('dn', 'ldap_import_type', 'ldap_import_entities', 'ldap_import_recursive')));
             Html::showMassiveActions($massiveactionparams);
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr>";
             echo "<th width='10'>";
             Html::showCheckbox(array('criterion' => array('tag_for_massive' => 'select_item')));
             echo "</th>";
             $header_num = 0;
             echo Search::showHeaderItem(Search::HTML_OUTPUT, __('Group'), $header_num, $target . "?order=" . ($order == "DESC" ? "ASC" : "DESC"), 1, $order);
             echo "<th>" . __('Group DN') . "</th>";
             echo "<th>" . __('Destination entity') . "</th>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<th>" . __('Child entities') . "</th>";
             }
             echo "</tr>";
             $dn_index = 0;
             foreach ($ldap_groups as $groupinfos) {
                 $group = $groupinfos["cn"];
                 $group_dn = $groupinfos["dn"];
                 $search_type = $groupinfos["search_type"];
                 echo "<tr class='tab_bg_2 center'>";
                 echo "<td>";
                 echo Html::hidden("dn[{$dn_index}]", array('value' => $group_dn, 'data-glpicore-ma-tags' => 'common'));
                 echo Html::hidden("ldap_import_type[{$dn_index}]", array('value' => $search_type, 'data-glpicore-ma-tags' => 'common'));
                 Html::showMassiveActionCheckBox(__CLASS__, $dn_index, array('massive_tags' => 'select_item'));
                 echo "</td>";
                 echo "<td>" . $group . "</td>";
                 echo "<td>" . $group_dn . "</td>";
                 echo "<td>";
                 Entity::dropdown(array('value' => $entity, 'name' => "ldap_import_entities[{$dn_index}]", 'specific_tags' => array('data-glpicore-ma-tags' => 'common')));
                 echo "</td>";
                 if (Session::isMultiEntitiesMode()) {
                     echo "<td>";
                     Html::showCheckbox(array('name' => "ldap_import_recursive[{$dn_index}]", 'specific_tags' => array('data-glpicore-ma-tags' => 'common')));
                     echo "</td>";
                 } else {
                     echo Html::hidden("ldap_import_recursive[{$dn_index}]", array('value' => 0, 'data-glpicore-ma-tags' => 'common'));
                 }
                 echo "</tr>\n";
                 $dn_index++;
             }
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
             echo "</div>";
             Html::printPager($start, $numrows, $target, $parameters);
         } else {
             echo "<div class='center b'>" . __('No group to be imported') . "</div>";
         }
     } else {
         echo "<div class='center b'>" . __('No group to be imported') . "</div>";
     }
 }
コード例 #7
0
ファイル: html.class.php プロジェクト: OlivierLM/glpi
 /**
  * Display choice matrix
  *
  * @since version 0.85
  * @param $columns   array   of column field name => column label
  * @param $rows      array    of field name => array(
  *      'label' the label of the row
  *       'columns' an array of specific information regaring current row and given column indexed by column field_name
  *                 * a string if only have to display a string
  *                 * an array('value' => ???, 'readonly' => ???) that is used to Dropdown::showYesNo()
  * @param $options   array   possible:
  *       'title'         of the matrix
  *       'first_cell'    the content of the upper-left cell
  *       'row_check_all' set to true to display a checkbox to check all elements of the row
  *       'col_check_all' set to true to display a checkbox to check all elements of the col
  *       'rand'          random number to use for ids
  *
  * @return random value used to generate the ids
  **/
 static function showCheckboxMatrix(array $columns, array $rows, array $options = array())
 {
     $param['title'] = '';
     $param['first_cell'] = '&nbsp;';
     $param['row_check_all'] = false;
     $param['col_check_all'] = false;
     $param['rotate_column_titles'] = false;
     $param['rand'] = mt_rand();
     $param['table_class'] = 'tab_cadre_fixehov';
     $param['cell_class_method'] = NULL;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $param[$key] = $val;
         }
     }
     $cb_options = array('title' => __s('Check/uncheck all'));
     $number_columns = count($columns) + 1;
     if ($param['row_check_all']) {
         $number_columns += 1;
     }
     $width = round(100 / $number_columns);
     echo "\n<table class='" . $param['table_class'] . "'>\n";
     if (!empty($param['title'])) {
         echo "\t<tr>\n";
         echo "\t\t<th colspan='{$number_columns}'>" . $param['title'] . "</th>\n";
         echo "\t</tr>\n";
     }
     echo "\t<tr class='tab_bg_1'>\n";
     echo "\t\t<td>" . $param['first_cell'] . "</td>\n";
     foreach ($columns as $col_name => $column) {
         $nb_cb_per_col[$col_name] = array('total' => 0, 'checked' => 0);
         $col_id = Html::cleanId('col_label_' . $col_name . '_' . $param['rand']);
         echo "\t\t<td class='center b";
         if ($param['rotate_column_titles']) {
             echo " rotate";
         }
         echo "' id='{$col_id}' width='{$width}%'>";
         if (!is_array($column)) {
             $columns[$col_name] = $column = array('label' => $column);
         }
         if (isset($column['short']) && isset($column['long'])) {
             echo $column['short'];
             self::showToolTip($column['long'], array('applyto' => $col_id));
         } else {
             echo $column['label'];
         }
         echo "</td>\n";
     }
     if ($param['row_check_all']) {
         $col_id = Html::cleanId('col_of_table_' . $param['rand']);
         echo "\t\t<td class='center";
         if ($param['rotate_column_titles']) {
             echo " rotate";
         }
         echo "' id='{$col_id}'>" . __('Select/unselect all') . "</td>\n";
     }
     echo "\t</tr>\n";
     foreach ($rows as $row_name => $row) {
         if (!is_string($row) && !is_array($row)) {
             continue;
         }
         echo "\t<tr class='tab_bg_1'>\n";
         if (is_string($row)) {
             echo "\t\t<th colspan='{$number_columns}'>{$row}</th>\n";
         } else {
             $row_id = Html::cleanId('row_label_' . $row_name . '_' . $param['rand']);
             if (isset($row['class'])) {
                 $class = $row['class'];
             } else {
                 $class = '';
             }
             echo "\t\t<td class='b {$class}' id='{$row_id}'>";
             if (!empty($row['label'])) {
                 echo $row['label'];
             } else {
                 echo "&nbsp;";
             }
             echo "</td>\n";
             $nb_cb_per_row = array('total' => 0, 'checked' => 0);
             foreach ($columns as $col_name => $column) {
                 $class = '';
                 if (!empty($row['class']) && !empty($column['class'])) {
                     if (is_callable($param['cell_class_method'])) {
                         $class = $param['cell_class_method']($row['class'], $column['class']);
                     }
                 } else {
                     if (!empty($row['class'])) {
                         $class = $row['class'];
                     } else {
                         if (!empty($column['class'])) {
                             $class = $column['class'];
                         }
                     }
                 }
                 echo "\t\t<td class='center {$class}'>";
                 // Warning: isset return false if the value is NULL ...
                 if (array_key_exists($col_name, $row['columns'])) {
                     $content = $row['columns'][$col_name];
                     if (is_array($content) && array_key_exists('checked', $content)) {
                         if (!array_key_exists('readonly', $content)) {
                             $content['readonly'] = false;
                         }
                         $content['massive_tags'] = array();
                         if ($param['row_check_all']) {
                             $content['massive_tags'][] = 'row_' . $row_name . '_' . $param['rand'];
                         }
                         if ($param['col_check_all']) {
                             $content['massive_tags'][] = 'col_' . $col_name . '_' . $param['rand'];
                         }
                         if ($param['row_check_all'] && $param['col_check_all']) {
                             $content['massive_tags'][] = 'table_' . $param['rand'];
                         }
                         $content['name'] = $row_name . "[{$col_name}]";
                         $content['id'] = Html::cleanId('cb_' . $row_name . '_' . $col_name . '_' . $param['rand']);
                         Html::showCheckbox($content);
                         $nb_cb_per_col[$col_name]['total']++;
                         $nb_cb_per_row['total']++;
                         if ($content['checked']) {
                             $nb_cb_per_col[$col_name]['checked']++;
                             $nb_cb_per_row['checked']++;
                         }
                     } else {
                         if (is_string($content)) {
                             echo $content;
                         } else {
                             echo "&nbsp;";
                         }
                     }
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>\n";
             }
         }
         if ($param['row_check_all'] && !is_string($row) && $nb_cb_per_row['total'] > 1) {
             $cb_options['criterion'] = array('tag_for_massive' => 'row_' . $row_name . '_' . $param['rand']);
             $cb_options['massive_tags'] = 'table_' . $param['rand'];
             $cb_options['id'] = Html::cleanId('cb_checkall_row_' . $row_name . '_' . $param['rand']);
             $cb_options['checked'] = $nb_cb_per_row['checked'] > $nb_cb_per_row['total'] / 2;
             echo "\t\t<td class='center'>" . Html::getCheckbox($cb_options) . "</td>\n";
         }
         echo "\t</tr>\n";
     }
     if ($param['col_check_all']) {
         echo "\t<tr class='tab_bg_1'>\n";
         echo "\t\t<td>" . __('Select/unselect all') . "</td>\n";
         foreach ($columns as $col_name => $column) {
             echo "\t\t<td class='center'>";
             if ($nb_cb_per_col[$col_name]['total'] > 1) {
                 $cb_options['criterion'] = array('tag_for_massive' => 'col_' . $col_name . '_' . $param['rand']);
                 $cb_options['massive_tags'] = 'table_' . $param['rand'];
                 $cb_options['id'] = Html::cleanId('cb_checkall_col_' . $col_name . '_' . $param['rand']);
                 $cb_options['checked'] = $nb_cb_per_col[$col_name]['checked'] > $nb_cb_per_col[$col_name]['total'] / 2;
                 echo Html::getCheckbox($cb_options);
             } else {
                 echo "&nbsp;";
             }
             echo "</td>\n";
         }
         if ($param['row_check_all']) {
             $cb_options['criterion'] = array('tag_for_massive' => 'table_' . $param['rand']);
             $cb_options['massive_tags'] = '';
             $cb_options['id'] = Html::cleanId('cb_checkall_table_' . $param['rand']);
             echo "\t\t<td class='center'>" . Html::getCheckbox($cb_options) . "</td>\n";
         }
         echo "\t</tr>\n";
     }
     echo "</table>\n";
     return $param['rand'];
 }
コード例 #8
0
 function showForm($id, $options = array())
 {
     if (!Session::haveRight('plugin_fusioninventory_printer', READ)) {
         return FALSE;
     }
     // display stats
     $stats = $this->stats($id);
     if ($stats) {
         $this->showTabs($options);
         $this->showFormHeader($options);
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Total printed pages', 'fusioninventory') . " : </td>";
         echo "<td>" . $stats["num_pages"] . "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Pages / day', 'fusioninventory') . " : </td>";
         echo "<td>" . $stats["pages_per_day"] . "</td></tr>";
         echo "</table></div>";
     }
     // preparing to display history
     if (!isset($_GET['start'])) {
         $_GET['start'] = 0;
     }
     $numrows = $this->countAllEntries($id);
     $parameters = "id=" . $_GET["id"] . "&onglet=" . $_SESSION["glpi_onglet"];
     echo "<br>";
     Html::printPager($_GET['start'], $numrows, $_SERVER['PHP_SELF'], $parameters);
     $limit = $numrows;
     if ($_SESSION["glpilist_limit"] < $numrows) {
         $limit = $_SESSION["glpilist_limit"];
     }
     // Get history
     $data = $this->getEntries($id, $_GET['start'], $limit);
     if (!$data) {
         return FALSE;
     }
     echo "<div align='center'><form method='post' name='printer_history_form'\n                 id='printer_history_form'  action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\">";
     echo "<table class='tab_cadre' cellpadding='5'><tr><th colspan='3'>";
     echo __('History meter printer', 'fusioninventory') . " :</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th></th>";
     echo "<th>" . __('Date') . " :</th>";
     echo "<th>" . __('Meter', 'fusioninventory') . " :</th></tr>";
     for ($i = 0; $i < $limit; $i++) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>";
         Html::showCheckbox(array('name' => "checked_{$i}", 'value' => 1));
         echo "</td>";
         echo "<td align='center'>" . $data["{$i}"]['date'] . "</td>";
         echo "<td align='center'>" . $data["{$i}"]['pages'] . "</td>";
         echo "</td></tr>";
         echo "<input type='hidden' name='ID_{$i}' value='" . $data["{$i}"]['id'] . "'>";
     }
     if (!Session::haveRight('plugin_fusioninventory_printer', UPDATE)) {
         return FALSE;
     }
     echo "<input type='hidden' name='limit' value='" . $limit . "'>";
     echo "<tr class='tab_bg_1'><td colspan='3'>";
     echo "<div align='center'><a onclick= \"if (markAllRows('printer_history_form'))\n                 return FALSE;\"\n                 href='" . $_SERVER['PHP_SELF'] . "?select=all'>" . __('Check All', 'fusioninventory') . "</a>";
     echo " - <a onclick= \"if ( unMarkAllRows('printer_history_form') ) return FALSE;\"\n                  href='" . $_SERVER['PHP_SELF'] . "?select=none'>" . __('Uncheck All', 'fusioninventory') . "</a> ";
     echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit' ></div></td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
コード例 #9
0
 public function showCheckboxField($title, $varname, $options = array())
 {
     echo "<label>" . $title . "&nbsp;:" . "</label>";
     $options['name'] = $varname;
     $options['checked'] = $this->fields[$varname];
     $options['zero_on_empty'] = true;
     echo "<div class='input_wrap'>";
     Html::showCheckbox($options);
     echo "</div>";
 }
コード例 #10
0
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $options = array())
 {
     echo "<div class='firstbloc'>";
     $profile = new Profile();
     if ($profiles_id > 0) {
         $profile->check($profiles_id, READ);
     } else {
         // Create item
         $profile->check(-1, CREATE);
     }
     $profile->showFormHeader($options);
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('default_class' => 'tab_bg_2', 'title' => __('General')));
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Advanced', 'consumables') . "</th></tr>\n";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_consumables_user', 'plugin_consumables_group', 'plugin_consumables_validation', 'plugin_consumables_request'));
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Consumable validation', 'consumables') . "</td>";
     echo "<td>";
     Html::showCheckbox(array('name' => '_plugin_consumables_validation[1_0]', 'checked' => $effective_rights['plugin_consumables_validation']));
     echo "<td>" . __('Make a consumable request', 'consumables') . "</td>";
     echo "<td>";
     Html::showCheckbox(array('name' => '_plugin_consumables_request[1_0]', 'checked' => $effective_rights['plugin_consumables_request']));
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Make a consumable request for all users', 'consumables') . "</td>";
     echo "<td>";
     Html::showCheckbox(array('name' => '_plugin_consumables_user[1_0]', 'checked' => $effective_rights['plugin_consumables_user']));
     echo "</td>";
     echo "<td>" . __('Make a consumable request for my groups', 'consumables') . "</td>";
     echo "<td>";
     Html::showCheckbox(array('name' => '_plugin_consumables_group[1_0]', 'checked' => $effective_rights['plugin_consumables_group']));
     echo "</td>";
     echo "</tr>\n";
     $profile->showFormButtons($options);
     echo "</div>";
 }
コード例 #11
0
 static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand)
 {
     global $CFG_GLPI;
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']);
     echo "<table class='tab_cadrehov package_item_list' id='table_action_{$rand}'>";
     $i = 0;
     foreach ($datas['jobs']['actions'] as $action) {
         echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2);
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='control'>";
             Html::showCheckbox(array('name' => 'action_entries[]'));
             echo "</td>";
         }
         $keys = array_keys($action);
         $action_type = array_shift($keys);
         echo "<td>";
         echo "<a class='edit' " . "onclick=\"edit_subtype('action', {$order->fields['id']}, {$rand}, this)\">";
         echo PluginFusioninventoryDeployAction::getType($action_type);
         echo "</a><br />";
         foreach ($action[$action_type] as $key => $value) {
             if (is_array($value)) {
                 if ($key === "list") {
                     foreach ($value as $list) {
                         echo $list;
                         echo " ";
                     }
                 }
             } else {
                 echo "<b>";
                 if ($key == 'exec') {
                     echo __('Command to execute', 'fusioninventory');
                 } else {
                     echo $key;
                 }
                 echo "</b>";
                 if ($key === "exec") {
                     echo "<pre style='border-left:solid lightgrey 3px;margin-left: 5px;" . "padding-left:2px'>{$value}</pre>";
                 } else {
                     echo " {$value} ";
                 }
             }
         }
         if (isset($action[$action_type]['retChecks'])) {
             echo "<br><b>" . __("return codes saved for this command", 'fusioninventory') . "</b> : <ul class='retChecks'>";
             foreach ($action[$action_type]['retChecks'] as $retCheck) {
                 echo "<li>";
                 $retchecks_entries = self::retchecks_entries();
                 echo $retchecks_entries[$retCheck['type']] . " " . array_shift($retCheck['values']);
                 echo "</li>";
             }
             echo "</ul>";
         }
         echo "</td>";
         echo "</td>";
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>";
         }
         echo "</tr>";
         $i++;
     }
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "<tr><th>";
         Html::checkAllAsCheckbox("actionsList{$rand}", mt_rand());
         echo "</th><th colspan='3' class='mark'></th></tr>";
     }
     echo "</table>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "&nbsp;&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>";
         echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>";
     }
 }
コード例 #12
0
 public function _showActors()
 {
     global $CFG_GLPI;
     //$ok = $this->getFromDB($id);
     $id = $this->fields['id'];
     $name = $this->fields['name'];
     echo "<table class='tab_cadre'>";
     $nb = 0;
     if ($ok) {
         $a_typenames = importArrayFromDB($this->fields[$name]);
         foreach ($a_typenames as $key => $a_typename) {
             foreach ($a_typename as $itemtype => $items_id) {
                 $display = '';
                 if ($itemtype == "PluginFusioninventoryAgent" and $items_id == "") {
                     $display = __('Auto managenement dynamic of agents', 'fusioninventory');
                 } else {
                     if ($itemtype == "PluginFusioninventoryAgent" and $items_id == ".2") {
                         $display = __('Auto managenement dynamic of agents (same subnet)', 'fusioninventory');
                     } else {
                         $class = new $itemtype();
                         $class->getFromDB($items_id);
                         $display = $class->getLink(1);
                     }
                 }
                 echo "<tr>";
                 echo "<td style='padding: 1px 2px;'>";
                 Html::showCheckbox(array('name' => $name . "item", 'value' => $key));
                 echo "</td>";
                 echo "<td style='padding: 1px 2px;'>";
                 echo $display;
                 echo "</td>";
                 echo "</tr>";
                 $nb++;
             }
         }
     }
     echo "</table>";
     if ($nb > 0) {
         echo "<center><input type='button' id='delete" . $name . $id . "' name='delete" . $name . $id . "' " . "value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'></center>";
         $params = array($name . 'item' => '__CHECKBOX__', 'type' => $name, 'taskjobs_id' => $id);
         $toobserve = "delete" . $name . $id;
         $toupdate = "Deleteitem";
         $url = $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/taskjobdeletetype.php";
         $parameters = $params;
         $events = array("click");
         $minsize = -1;
         $forceloadfor = array(__('Delete', 'fusioninventory'));
         echo "<script type='text/javascript'>";
         echo implode("\n", array("  function checkboxvalues(item) {", "     var inputs = document.getElementsByName(item);", "     var namelist = '';", "     for(var i = 0; i < inputs.length; i++){", "        if(inputs[i].checked) {", "           namelist += inputs[i].value + '-';", "        }", "     }", "     return namelist;", "  }"));
         $zones = array($toobserve);
         if (is_array($toobserve)) {
             $zones = $toobserve;
         }
         foreach ($zones as $zone) {
             foreach ($events as $event) {
                 echo "\n                  Ext.get('{$zone}').on(\n                   '{$event}',\n                   function() {";
                 $condition = '';
                 if ($minsize >= 0) {
                     $condition = " Ext.get('{$zone}').getValue().length >= {$minsize} ";
                 }
                 if (count($forceloadfor)) {
                     foreach ($forceloadfor as $value) {
                         if (!empty($condition)) {
                             $condition .= " || ";
                         }
                         $condition .= "Ext.get('{$zone}').getValue() == '{$value}'";
                     }
                 }
                 if (!empty($condition)) {
                     echo "if ({$condition}) {";
                 }
                 //self::updateItemJsCode($toupdate, $url, $parameters, $toobserve);
                 // Get it from a Ext.Element object
                 $out = "Ext.get('{$toupdate}').load({\n                         url: '{$url}',\n                         scripts: true";
                 if (count($parameters)) {
                     $out .= ",\n                            params:'";
                     $first = TRUE;
                     foreach ($parameters as $key => $val) {
                         if ($first) {
                             $first = FALSE;
                         } else {
                             $out .= "&";
                         }
                         $out .= $key . "=";
                         if ($val === "__CHECKBOX__") {
                             $out .= "'+checkboxvalues('" . $key . "')+'";
                         } else {
                             if (preg_match("/'/", $val)) {
                                 $out .= rawurlencode($val);
                             } else {
                                 $out .= $val;
                             }
                         }
                     }
                     echo $out . "'\n";
                 }
                 echo "});";
                 if (!empty($condition)) {
                     echo "}";
                 }
                 echo "});\n";
             }
         }
         echo "</script>";
         echo "<span id='Deleteitem'>&nbsp;</span>";
     }
 }
コード例 #13
0
 /**
  * Display form to add exception of modules activation for each agent
  *
  * @param interger $items_id ID of the agent
  *
  * @return bool TRUE if form is ok
  *
  **/
 function showFormAgentException($items_id)
 {
     global $CFG_GLPI;
     $pfAgent = new PluginFusioninventoryAgent();
     $pfAgent->getFromDB($items_id);
     $canedit = $pfAgent->can($items_id, UPDATE);
     echo "<br/>";
     if ($canedit) {
         echo "<form name='form_ic' method='post' action='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/agentmodule.form.php'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th>" . __('Module', 'fusioninventory') . "</th>";
     echo "<th>Activation</th>";
     echo "<th>" . __('Module', 'fusioninventory') . "</th>";
     echo "<th>Activation</th>";
     echo "</tr>";
     $a_modules = $this->find();
     $i = 0;
     $a_methods = PluginFusioninventoryStaticmisc::getmethods();
     foreach ($a_modules as $data) {
         if ($i == 0) {
             echo "<tr class='tab_bg_1'>";
         }
         $modulename = $data["modulename"];
         foreach ($a_methods as $datamod) {
             if (strtolower($data["modulename"]) == strtolower($datamod['method']) || isset($datamod['task']) && strtolower($data["modulename"]) == strtolower($datamod['task'])) {
                 if (isset($datamod['name'])) {
                     $modulename = $datamod['name'];
                 }
                 break;
             }
         }
         // Hack for snmpquery
         if ($data["modulename"] == 'SNMPQUERY') {
             $modulename = __('Network inventory (SNMP)', 'fusioninventory');
         }
         // Hack for deploy
         if ($data["modulename"] == 'DEPLOY') {
             $modulename = __('Package deployment', 'fusioninventory');
         }
         echo "<td width='50%'>" . $modulename . " :</td>";
         echo "<td align='center'>";
         $checked = $data['is_active'];
         $a_agentList = importArrayFromDB($data['exceptions']);
         if (in_array($items_id, $a_agentList)) {
             if ($checked == 1) {
                 $checked = 0;
             } else {
                 $checked = 1;
             }
         }
         $check = "";
         Html::showCheckbox(array('name' => "activation-" . $data["modulename"], 'value' => '1', 'checked' => $checked));
         echo "</td>";
         if ($i == 1) {
             echo "</tr>";
             $i = -1;
         }
         $i++;
     }
     if ($i == 1) {
         echo "<td></td>";
         echo "<td></td>";
         echo "</tr>";
     }
     if ($canedit) {
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='4'>";
         echo Html::hidden('id', array('value' => $items_id));
         echo "<input type='submit' name='updateexceptions' " . "value=\"" . __('Update') . "\" class='submit'>";
         echo "</td>";
         echo "</tr>";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
 }
コード例 #14
0
 function displayList($tasks_id)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     echo "<script type=\"text/javascript\">\nfunction edit_subtype(id,el) {\n\n   //remove all border to previous selected item (remove classes)\n//   Ext.select('#table_taskjob_'+ _rand +' tr').removeClass('selected');\n\n\n   var row = null;\n   if (el) {\n      // get parent row of the selected element\n      row = jQuery(el).parents('tr:first')\n   }\n\n   if (row) {\n      //add border to selected index (add class)\n      row.addClass('selected');\n//      params['index'] = row.index();\n      // change mode to edit\n//      params['mode'] = 'edit';\n      arg = 'taskjobs_id=' + id;\n   } else {\n      arg = 'tasks_id=' + id;\n   }\n\n   //scroll to edit form\n//   document.getElementById('th_title_taskjob_' + _rand).scrollIntoView();\n\n   //show and load form\n//   \$('taskjobs_block' + _rand).setDisplayed('block');\n   \$('#taskjobs_block').load('../ajax/taskjob_form.php?' + arg);\n}\n\n/*\n * Create a new subtype element.\n * This method just override *edit_subtype* with a null element.\n */\nfunction new_subtype(id) {\n   edit_subtype(id, null);\n}\n</script>";
     echo "<table class='tab_cadre_fixe' id='package_order_" . $tasks_id . "'>";
     echo "<tr>";
     echo "<th id='th_title_taskjob_{$rand}'>";
     //echo "<img src='".$CFG_GLPI["root_doc"]."/plugins/fusioninventory/pics/$subtype.png' />";
     echo "&nbsp;" . $this->getTypeName();
     echo "&nbsp;";
     echo "<img id='plus_taskjobs_block{$rand}'";
     echo " onclick=\"new_subtype({$tasks_id})\" ";
     echo " title='" . __('Add') . "' alt='" . __('Add') . "' ";
     echo " class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' /> ";
     echo "</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<td style='vertical-align:top'>";
     /**
      * Display subtype form
      **/
     echo "<form name='additiontaskjob' method='post' " . " action='taskjob.form.php'>";
     echo "<input type='hidden' name='orders_id' value='{$tasks_id}' />";
     echo "<input type='hidden' name='itemtype' value='PluginFusioninventoryDeploy" . ucfirst('taskjob') . "' />";
     echo "<div id='taskjobs_block'></div>";
     Html::closeForm();
     $a_taskjobs = getAllDatasFromTable($this->getTable(), "`plugin_fusioninventory_tasks_id`='" . $tasks_id . "'", FALSE, '`ranking`');
     echo "<div id='drag_taskjob_taskjobs'>";
     echo "<table class='tab_cadrehov package_item_list' id='table_taskjob_{$rand}' style='width: 950px'>";
     $i = 0;
     foreach ($a_taskjobs as $data) {
         echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2);
         echo "<td class='control'>";
         Html::showCheckbox(array('name' => 'taskjob_entries[]', 'value' => $i));
         echo "</td>";
         echo "<td>";
         echo "<a class='edit' " . "onclick=\"edit_subtype({$data['id']}, this)\">";
         echo $data['name'];
         echo "</a><br />";
         echo "<b>";
         echo __('Definition', 'fusioninventory');
         echo "</b>";
         echo "<ul class='retChecks'>";
         $a_definitions = importArrayFromDB($data['definition']);
         foreach ($a_definitions as $a_definition) {
             foreach ($a_definition as $itemtype => $items_id) {
                 echo "<li>";
                 $item = new $itemtype();
                 $item->getFromDB($items_id);
                 echo $item->getTypeName() . " > ";
                 echo $item->getLink();
                 echo "</li>";
             }
         }
         echo "</ul>";
         echo "<b>";
         echo __('Action', 'fusioninventory');
         echo "</b>";
         echo "<ul class='retChecks'>";
         $a_actions = importArrayFromDB($data['action']);
         foreach ($a_actions as $a_action) {
             foreach ($a_action as $itemtype => $items_id) {
                 echo "<li>";
                 $item = new $itemtype();
                 $item->getFromDB($items_id);
                 echo $item->getTypeName() . " > ";
                 echo $item->getLink();
                 echo "</li>";
             }
         }
         echo "</ul>";
         echo "</td>";
         echo "</td>";
         echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>";
         echo "</tr>";
         $i++;
     }
     echo "<tr><th>";
     Html::checkAllAsCheckbox("taskjobsList{$rand}", mt_rand());
     echo "</th><th colspan='3' class='mark'></th></tr>";
     echo "</table>";
     echo "</div>";
     echo "&nbsp;&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>";
     echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>";
     /**
      * Initialize drag and drop on subtype lists
      **/
     echo "<script type=\"text/javascript\">\n      redipsInit('taskjob', 'taskjob', {$tasks_id});\n</script>";
     echo "</table>";
 }
コード例 #15
0
ファイル: profile_user.class.php プロジェクト: Ixertec/glpi
 /**
  * @since version 0.85
  *
  * @see CommonDBRelation::showRelationMassiveActionsSubForm()
  **/
 static function showRelationMassiveActionsSubForm(MassiveAction $ma, $peer_number)
 {
     if ($ma->getAction() == 'add' && $peer_number == 2) {
         echo "<br><br>" . sprintf(__('%1$s: %2$s'), _n('Entity', 'Entities', 1), '');
         Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities']));
         echo "<br><br>" . sprintf(__('%1$s: %2$s'), __('Recursive'), '');
         Html::showCheckbox(array('name' => 'is_recursive'));
     }
 }
コード例 #16
0
 function showFormItemtype($p_itemtype)
 {
     $can = 0;
     $typeright = strtolower($p_itemtype);
     if ($typeright == "networkequipment") {
         $typeright = "networking";
     }
     if (Session::haveRight($typeright, UPDATE)) {
         $can = 1;
     }
     $tableName = getTableForItemType($p_itemtype);
     echo "<div width='50%'>";
     $locked = PluginFusioninventoryLock::getLockFields($tableName, 0);
     if (!count($locked)) {
         $locked = array();
     }
     $colspan = '2';
     $item = new $p_itemtype();
     $item->getEmpty();
     echo "<form method='post' action='" . PluginFusioninventoryLock::getFormURL() . "'>";
     echo "<input type='hidden' name='id' value='0'>";
     echo "<input type='hidden' name='type' value='{$p_itemtype}'>";
     echo "<table class='tab_cadre'>";
     echo "<tr>";
     echo "<th colspan='2'>" . $item->getTypeName(1) . "</th>";
     echo "</tr>";
     echo "<tr><th>&nbsp;" . __('Fields') . "&nbsp;</th>";
     echo "<th>&nbsp;" . _n('Lock', 'Locks', 2, 'fusioninventory') . "&nbsp;</th>";
     echo "</tr>";
     $checked = false;
     $a_exclude = $this->excludeFields();
     $serialized = $this->getSerialized_InventoryArray($p_itemtype, 0);
     $options = search::getOptions($p_itemtype);
     foreach ($item->fields as $key => $val) {
         $name = "";
         $key_source = $key;
         if (!in_array($key, $a_exclude)) {
             if (in_array($key, $locked)) {
                 $checked = true;
             } else {
                 $checked = false;
             }
             // Get name of field
             $num = Search::getOptionNumber($p_itemtype, $key);
             if (isset($options[$num]['name'])) {
                 $name = $options[$num]['name'];
             } else {
                 //Get name by search in linkfields
                 foreach ($options as $opt) {
                     if (isset($opt['linkfield']) && $opt['linkfield'] == $key) {
                         $name = $opt['name'];
                         break;
                     }
                 }
             }
             $css_glpi_value = '';
             // Get value of field
             $val = $this->getValueForKey($val, $key);
             echo "<tr class='tab_bg_1'>";
             $table = getTableNameForForeignKeyField($key);
             if ($name == "" && $table != "") {
                 $linkItemtype = getItemTypeForTable($table);
                 $class = new $linkItemtype();
                 $name = $class->getTypeName();
             }
             echo "<td>" . $name . "</td>";
             echo "<td align='center'>";
             Html::showCheckbox(array('name' => "lockfield_fusioninventory[{$key_source}]", 'checked' => $checked));
             echo "</td>";
             echo "</tr>";
         }
     }
     if ($can == '1') {
         echo "<tr class='tab_bg_2'>";
         echo "<td align='center' colspan='" . ($colspan + 1) . "'>";
         echo "<input class='submit' type='submit' name='unlock_field_fusioninventory'\n                         value='" . __('Update') . "'>";
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
コード例 #17
0
ファイル: user.class.php プロジェクト: pvasener/glpi
 /**
  * Print the user preference form
  *
  * @param $target          form target
  * @param $ID     integer  Id of the user
  *
  * @return boolean : user found
  **/
 function showMyForm($target, $ID)
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // Affiche un formulaire User
     if ($ID != Session::getLoginUserID() && !$this->currentUserHaveMoreRightThan($ID)) {
         return false;
     }
     if ($this->getFromDB($ID)) {
         $rand = mt_rand();
         $authtype = $this->getAuthMethodsByID();
         $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
         // No autocopletion :
         $save_autocompletion = $CFG_GLPI["use_ajax_autocompletion"];
         $CFG_GLPI["use_ajax_autocompletion"] = false;
         echo "<div class='center'>";
         echo "<form method='post' name='user_manager' enctype='multipart/form-data' action='" . $target . "' autocomplete='off'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>" . sprintf(__('%1$s: %2$s'), __('Login'), $this->fields["name"]);
         echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>";
         echo "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>";
         if ($extauth && isset($authtype['realname_field']) && !empty($authtype['realname_field'])) {
             echo $this->fields["realname"];
         } else {
             Html::autocompletionTextField($this, "realname");
         }
         echo "</td>";
         if (!empty($this->fields["name"])) {
             echo "<td rowspan='3'>" . __('Picture') . "</td>";
             echo "<td rowspan='3'>";
             echo "<div class='user_picture_border_small' id='picture{$rand}'>";
             echo "<img class='user_picture_small' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($this->fields['picture']) . "'>";
             echo "</div>";
             $full_picture = "<div class='user_picture_border'>";
             $full_picture .= "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getURLForPicture($this->fields['picture']) . "'>";
             $full_picture .= "</div>";
             Html::showTooltip($full_picture, array('applyto' => "picture{$rand}"));
             echo "<input type='file' name='picture' accept='image/*'>";
             echo "&nbsp;";
             Html::showCheckbox(array('name' => '_blank_picture', 'title' => __('Clear')));
             echo "&nbsp;" . __('Clear');
             echo "</td>";
             echo "</tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
         if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) {
             echo $this->fields["firstname"];
         } else {
             Html::autocompletionTextField($this, "firstname");
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         if (!GLPI_DEMO_MODE) {
             echo "<td>" . __('Language') . "</td><td>";
             // Use session variable because field in table may be null if same of the global config
             Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"]));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
         //do some rights verification
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Password') . "</td>";
             echo "<td><input id='password' type='password' name='password' value='' size='30' autocomplete='off' onkeyup=\"return passwordCheck();\">";
             echo "</td>";
             echo "<td rowspan='2'>" . __('Password security policy') . "</td>";
             echo "<td rowspan='2'>";
             Config::displayPasswordSecurityChecks();
             echo "</td>";
             echo "</tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Password confirmation') . "</td>";
             echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>";
             echo "</td></tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . __('Phone') . "</td><td>";
         if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) {
             echo $this->fields["phone"];
         } else {
             Html::autocompletionTextField($this, "phone");
         }
         echo "</td>";
         echo "<td class='top'>" . _n('Email', 'Emails', Session::getPluralNumber());
         UserEmail::showAddEmailButton($this);
         echo "</td><td>";
         UserEmail::showForUser($this);
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Mobile phone') . "&nbsp;</td><td>";
         if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) {
             echo $this->fields["mobile"];
         } else {
             Html::autocompletionTextField($this, "mobile");
         }
         echo "</td>";
         if (count($_SESSION['glpiprofiles']) > 1) {
             echo "<td>" . __('Default profile') . "</td><td>";
             $options = Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"], 'display_emptychoice' => true));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Phone 2') . "</td><td>";
         if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) {
             echo $this->fields["phone2"];
         } else {
             Html::autocompletionTextField($this, "phone2");
         }
         echo "</td>";
         $entities = Profile_User::getUserEntities($this->fields['id'], 1);
         if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) {
             echo "<td>" . __('Default entity') . "</td><td>";
             Entity::dropdown(array('value' => $this->fields['entities_id'], 'entity' => $entities));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Administrative number') . "</td><td>";
         if ($extauth && isset($authtype['registration_number_field']) && !empty($authtype['registration_number_field'])) {
             echo $this->fields["registration_number"];
         } else {
             Html::autocompletionTextField($this, "registration_number");
         }
         echo "</td><td colspan='2'></td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>";
         $entities = Profile_User::getUserEntities($ID, true);
         Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $entities));
         if (Config::canUpdate()) {
             echo "<td>" . __('Use GLPI in mode') . "</td><td>";
             $modes[Session::NORMAL_MODE] = __('Normal');
             //$modes[Session::TRANSLATION_MODE] = __('Translation');
             $modes[Session::DEBUG_MODE] = __('Debug');
             Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr><td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         $CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion;
         return true;
     }
     return false;
 }
コード例 #18
0
ファイル: dropdown.class.php プロジェクト: glpi-project/glpi
 /**
  * Make a select box for a boolean choice (Yes/No) or display a checkbox. Add a
  * 'use_checkbox' = true to the $params array to display a checkbox instead a select box
  *
  * @param $name               select name
  * @param $value              preselected value. (default 0)
  * @param $restrict_to        allows to display only yes or no in the dropdown (default -1)
  * @param $params       Array of optional options (passed to showFromArray)
  *
  * @return rand value
  **/
 static function showYesNo($name, $value = 0, $restrict_to = -1, $params = array())
 {
     if (!array_key_exists('use_checkbox', $params)) {
         // TODO: switch to true when Html::showCheckbox() is validated
         $params['use_checkbox'] = false;
     }
     if ($params['use_checkbox']) {
         if (!empty($params['rand'])) {
             $rand = $params['rand'];
         } else {
             $rand = mt_rand();
         }
         $options = array('name' => $name, 'id' => Html::cleanId("dropdown_" . $name . $rand));
         switch ($restrict_to) {
             case 0:
                 $options['checked'] = false;
                 $options['readonly'] = true;
                 break;
             case 1:
                 $options['checked'] = true;
                 $options['readonly'] = true;
                 break;
             default:
                 $options['checked'] = $value ? 1 : 0;
                 $options['readonly'] = false;
                 break;
         }
         Html::showCheckbox($options);
         return $rand;
     }
     if ($restrict_to != 0) {
         $options[0] = __('No');
     }
     if ($restrict_to != 1) {
         $options[1] = __('Yes');
     }
     $params['value'] = $value;
     $params['width'] = "65px";
     return self::showFromArray($name, $options, $params);
 }
コード例 #19
0
 static function displayAjaxValues($config, $request_data, $rand, $mode)
 {
     global $CFG_GLPI;
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployOrder = new PluginFusioninventoryDeployOrder();
     if (isset($request_data['orders_id'])) {
         $pfDeployOrder->getFromDB($request_data['orders_id']);
         $pfDeployPackage->getFromDB($pfDeployOrder->fields['plugin_fusioninventory_deploypackages_id']);
     } else {
         $pfDeployPackage->getEmpty();
     }
     $p2p = 0;
     $p2p_retention_duration = 0;
     $uncompress = 0;
     if ($mode === 'create') {
         $source = $request_data['value'];
         /**
          * No need to continue if there is no selected source
          */
         if ($source === '0') {
             return;
         }
     } else {
         $p2p = $config['data']['p2p'];
         $p2p_retention_duration = $config['data']['p2p-retention-duration'];
         $uncompress = $config['data']['uncompress'];
     }
     echo "<table class='package_item'>";
     /*
      * Display file upload input only in 'create' mode
      */
     echo "<tr>";
     echo "<th>" . __("File", 'fusioninventory') . "</th>";
     echo "<td>";
     if ($mode === 'create') {
         switch ($source) {
             case "Computer":
                 echo "<input type='file' name='file' value='" . __("filename", 'fusioninventory') . "' />";
                 echo "<i>" . self::getMaxUploadSize() . "</i>";
                 break;
             case "Server":
                 echo "<input type='text' name='filename' id='server_filename{$rand}'" . " style='width:120px;float:left' />";
                 echo "<input type='button' class='submit' value='" . __("Choose", 'fusioninventory') . "' onclick='fileModal{$rand}.dialog(\"open\");' />";
                 Ajax::createModalWindow("fileModal{$rand}", $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/ajax/deployfilemodal.php", array('title' => __('Select the file on server', 'fusioninventory'), 'extraparams' => array('rand' => $rand)));
                 break;
         }
     } else {
         /*
          * Display only name in 'edit' mode
          */
         echo $config['data']['name'];
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<th>" . __("Uncompress", 'fusioninventory') . "<img style='float:right' " . "src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory//pics/uncompress.png' /></th>";
     echo "<td>";
     Html::showCheckbox(array('name' => 'uncompress', 'checked' => $uncompress));
     echo "</td>";
     echo "</tr><tr>";
     echo "<th>" . __("P2P", 'fusioninventory') . "<img style='float:right' src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory//pics/p2p.png' /></th>";
     echo "<td>";
     Html::showCheckbox(array('name' => 'p2p', 'checked' => $p2p));
     echo "</td>";
     echo "</tr><tr>";
     echo "<th>" . __("retention days", 'fusioninventory') . "</th>";
     echo "<td>";
     /*
      * TODO: use task periodicity input to propose days, months and years
      */
     Dropdown::showNumber('p2p-retention-duration', array('value' => $p2p_retention_duration, 'min' => 0, 'max' => 400));
     echo "</td>";
     echo "</tr><tr>";
     echo "<td>";
     echo "</td><td>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         if ($mode === 'edit') {
             echo "<input type='submit' name='save_item' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add_item' value=\"" . _sx('button', 'Add') . "\" class='submit' >";
         }
     }
     echo "</td>";
     echo "</tr></table>";
 }
コード例 #20
0
ファイル: type.class.php プロジェクト: btry/genericobject
 function showBehaviorForm($ID, $options = array())
 {
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check($ID, CREATE);
         $use_cache = false;
         $this->getEmpty();
     }
     $this->fields['id'] = $ID;
     $right_name = PluginGenericobjectProfile::getProfileNameForItemtype(__CLASS__);
     $canedit = Session::haveRight($right_name, UPDATE);
     self::includeLocales($this->fields["name"]);
     self::includeConstants($this->fields["name"]);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Internal identifier", "genericobject") . "</td>";
     echo "<td>";
     if (!$ID) {
         Html::autocompletionTextField($this, 'name', array('value' => $this->fields["name"]));
     } else {
         echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         echo $this->fields["name"];
     }
     echo "</td>";
     echo "<td></td>";
     echo "<td></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Label") . "</td>";
     echo "<td>";
     if ($ID) {
         $itemtype = $this->fields["itemtype"];
         echo $itemtype::getTypeName();
     }
     echo "</td>";
     echo "<td rowspan='3' class='middle right'>" . __("Comments") . "&nbsp;: </td>";
     echo "<td class='center middle' rowspan='3'><textarea cols='45' rows='4'\n             name='comment' >" . $this->fields["comment"] . "</textarea></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Active") . "</td>";
     echo "<td>";
     if (!$ID) {
         echo __("No");
     } else {
         Dropdown::showYesNo("is_active", $this->fields["is_active"]);
     }
     echo "</td></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Family of type of objects", 'genericobject') . "</td>";
     echo "<td>";
     PluginGenericobjectTypeFamily::dropdown(array('value' => $this->fields["plugin_genericobject_typefamilies_id"]));
     echo "</td></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     if (!$this->isNewID($ID)) {
         $canedit = $this->can($ID, CREATE);
         echo "<tr class='tab_bg_1'><th colspan='4'>";
         echo __("Behaviour", "genericobject");
         echo "</th></tr>";
         $use = array("use_recursivity" => __("Child entities"), "use_tickets" => __("Assistance"), "use_deleted" => __("Item in the dustbin"), "use_notepad" => _n('Note', 'Notes', 2), "use_history" => __("Historical"), "use_template" => __("Templates"), "use_infocoms" => __("Financial and administratives information"), "use_contracts" => _n("Contract", "Contracts", 2), "use_documents" => _n("Document", "Documents", 2), "use_loans" => _n("Reservation", "Reservations", 2), "use_global_search" => __("Global search"), "use_projects" => _n("Project", "Projects", 2), "use_network_ports" => __("Network connections", "genericobject"));
         $plugins = array("use_plugin_datainjection" => __("injection file plugin", "genericobject"), "use_plugin_geninventorynumber" => __("geninventorynumber plugin", "genericobject"), "use_plugin_order" => __("order plugin", "genericobject"), "use_plugin_uninstall" => __("item's uninstallation plugin", "genericobject"), "use_plugin_simcard" => __("simcard plugin", "genericobject"));
         $plugin = new Plugin();
         $odd = 0;
         foreach ($use as $right => $label) {
             if (!$odd) {
                 echo "<tr class='tab_bg_2'>";
             }
             echo "<td>" . _sx('button', 'Use') . " " . $label . "</td>";
             echo "<td>";
             switch ($right) {
                 case 'use_deleted':
                     Html::showCheckbox(array('name' => $right, 'checked' => $this->canBeDeleted()));
                     break;
                 case 'use_recursivity':
                     Html::showCheckbox(array('name' => $right, 'value' => $this->canBeRecursive(), 'checked' => $this->canBeRecursive()));
                     break;
                 case 'use_notes':
                     Html::showCheckbox(array('name' => $right, 'checked' => $this->canUseNotepad()));
                     break;
                 case 'use_template':
                     Html::showCheckbox(array('name' => $right, 'checked' => $this->canUseTemplate()));
                     break;
                 default:
                     Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     break;
             }
             echo "</td>";
             if ($odd == 1) {
                 $odd = 0;
                 echo "</tr>";
             } else {
                 $odd++;
             }
         }
         if ($odd != 0) {
             echo "<td></td></tr>";
         }
         echo "<tr class='tab_bg_1'><th colspan='4'>";
         echo _n("Plugin", "Plugins", 2);
         echo "</th></tr>";
         $odd = 0;
         foreach ($plugins as $right => $label) {
             if (!$odd) {
                 echo "<tr class='tab_bg_2'>";
             }
             echo "<td>" . _sx('button', 'Use') . " " . $label . "</td>";
             echo "<td>";
             switch ($right) {
                 case 'use_plugin_datainjection':
                     if ($plugin->isActivated('datainjection')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_datainjection' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_pdf':
                     if ($plugin->isActivated('pdf')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_pdf' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_order':
                     if ($plugin->isActivated('order')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_order' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_uninstall':
                     if ($plugin->isActivated('uninstall')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_uninstall' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_simcard':
                     if ($plugin->isActivated('simcard')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_simcard' value='0'>\n";
                     }
                     break;
                 case 'use_plugin_geninventorynumber':
                     if ($plugin->isActivated('geninventorynumber')) {
                         Html::showCheckbox(array('name' => $right, 'checked' => $this->fields[$right]));
                     } else {
                         echo Dropdown::EMPTY_VALUE;
                         echo "<input type='hidden' name='use_plugin_geninventorynumber' value='0'>\n";
                     }
                     break;
             }
             echo "</td>";
             if ($odd == 1) {
                 $odd = 0;
                 echo "</tr>";
             } else {
                 $odd++;
             }
         }
         if ($odd != 0) {
             echo "<td></td></tr>";
         }
     }
     $this->showFormButtons($options);
 }
コード例 #21
0
ファイル: profile.class.php プロジェクト: glpi-project/glpi
 /**
  * Print the Tracking right form for the current profile
  *
  * @param $openform     boolean  open the form (true by default)
  * @param $closeform    boolean  close the form (true by default)
  **/
 function showFormTracking($openform = true, $closeform = true)
 {
     global $CFG_GLPI;
     if (!self::canView()) {
         return false;
     }
     echo "<div class='spaced'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         echo "<form method='post' action='" . $this->getFormURL() . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     // Assistance / Tracking-helpdesk
     echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Assistance') . "</th></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . _n('Ticket', 'Tickets', Session::getPluralNumber()) . ': ' . __('Default ticket template') . "</td><td  width='30%'>";
     // Only root entity ones and recursive
     $options = array('value' => $this->fields["tickettemplates_id"], 'entity' => 0);
     if (Session::isMultiEntitiesMode()) {
         $options['condition'] = '`is_recursive`';
     }
     // Only add profile if on root entity
     if (!isset($_SESSION['glpiactiveentities'][0])) {
         $options['addicon'] = false;
     }
     TicketTemplate::dropdown($options);
     echo "</td></tr>\n";
     echo "</table>";
     $matrix_options = array('canedit' => $canedit, 'default_class' => 'tab_bg_2');
     $rights = array(array('itemtype' => 'Ticket', 'label' => _n('Ticket', 'Tickets', Session::getPluralNumber()), 'field' => 'ticket'), array('itemtype' => 'TicketCost', 'label' => _n('Ticket cost', 'Ticket costs', Session::getPluralNumber()), 'field' => 'ticketcost'), array('itemtype' => 'TicketRecurrent', 'label' => __('Recurrent tickets'), 'field' => 'ticketrecurrent'), array('itemtype' => 'TicketTemplate', 'label' => _n('Ticket template', 'Ticket templates', Session::getPluralNumber()), 'field' => 'tickettemplate'));
     $matrix_options['title'] = _n('Ticket', 'Tickets', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     $rights = array(array('itemtype' => 'TicketFollowup', 'label' => _n('Followup', 'Followups', Session::getPluralNumber()), 'field' => 'followup'), array('itemtype' => 'TicketTask', 'label' => _n('Task', 'Tasks', Session::getPluralNumber()), 'field' => 'task'));
     $matrix_options['title'] = _n('Followup', 'Followups', Session::getPluralNumber()) . " / " . _n('Task', 'Tasks', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     $rights = array(array('itemtype' => 'TicketValidation', 'label' => _n('Validation', 'Validations', Session::getPluralNumber()), 'field' => 'ticketvalidation'));
     $matrix_options['title'] = _n('Validation', 'Validations', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_5'><th colspan='2'>" . __('Association') . "</th>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See hardware of my groups') . "</td><td>";
     Html::showCheckbox(array('name' => '_show_group_hardware', 'checked' => $this->fields['show_group_hardware']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Link with items for the creation of tickets') . "</td>";
     echo "\n<td>";
     self::getLinearRightChoice(self::getHelpdeskHardwareTypes(true), array('field' => 'helpdesk_hardware', 'value' => $this->fields['helpdesk_hardware']));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Associable items to a ticket') . "</td>";
     echo "<td><input type='hidden' name='_helpdesk_item_types' value='1'>";
     self::dropdownHelpdeskItemtypes(array('values' => $this->fields["helpdesk_item_type"]));
     // Linear_HIT
     // self::getLinearRightChoice(self::getHelpdeskItemtypes(),
     //                               array('field'         => 'helpdesk_item_type',
     //                                     'value'         => $this->fields['helpdesk_item_type'],
     //                                     'check_all'     => true,
     //                                     'zero_on_empty' => false,
     //                                     'max_per_line'  => 4,
     //                                     'check_method'  =>
     //                                     function ($element, $field) {
     //                                        return in_array($element,$field);
     //                                     }));
     echo "</td>";
     echo "</tr>\n";
     echo "</table>";
     $rights = array(array('itemtype' => 'Stat', 'label' => __('Statistics'), 'field' => 'statistic'), array('itemtype' => 'Planning', 'label' => __('Planning'), 'field' => 'planning'));
     $matrix_options['title'] = __('Visibility');
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     $rights = array(array('itemtype' => 'Problem', 'label' => _n('Problem', 'Problems', Session::getPluralNumber()), 'field' => 'problem'));
     $matrix_options['title'] = _n('Problem', 'Problems', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     $rights = array(array('itemtype' => 'Change', 'label' => _n('Change', 'Changes', Session::getPluralNumber()), 'field' => 'change'), array('itemtype' => 'ChangeValidation', 'label' => _n('Validation', 'Validations', Session::getPluralNumber()), 'field' => 'changevalidation'));
     $matrix_options['title'] = _n('Change', 'Changes', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo "<input type='hidden' name='id' value='" . $this->fields['id'] . "'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
コード例 #22
0
 /**
  * Display detail networkport based on glpi core networkport and fusioninventory
  * networkport
  *
  * @param array $data with id ant fusionid
  * @param boolean $monitoring true if monitoring installed && actived
  * @param boolean $aggrega true if this port is aggregate port
  *
  * @return nothing
  */
 function showNetworkPortDetail($data, $monitoring, $aggrega = 0)
 {
     global $CFG_GLPI, $DB;
     $nw = new NetworkPort_NetworkPort();
     $networkName = new NetworkName();
     $networkPort = new NetworkPort();
     $pfNetworkPort = new PluginFusioninventoryNetworkPort();
     $iPAddress = new IPAddress();
     $networkPort->getFromDB($data['id']);
     $pfNetworkPort->getFromDB($data['fusionid']);
     $background_img = "";
     if ($pfNetworkPort->fields["trunk"] == "1" && (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1)) {
         $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/port_trunk.png\"); '";
     } else {
         if (PluginFusioninventoryNetworkPort::isPortHasMultipleMac($data['id']) && (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1)) {
             $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/multiple_mac_addresses.png\"); '";
         } else {
             if (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1) {
                 $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/connected_trunk.png\"); '";
             }
         }
     }
     echo "<tr class='tab_bg_1 center' height='40'" . $background_img . ">";
     if ($aggrega) {
         echo "<td style='background-color: #f2f2f2;'></td><td>";
     }
     if (!$aggrega) {
         if ($networkPort->fields['instantiation_type'] == 'NetworkPortAggregate') {
             echo "<td>";
         } else {
             echo "<td colspan='2'>";
         }
     }
     echo "<a href='networkport.form.php?id=" . $networkPort->fields["id"] . "'>" . $networkPort->fields["name"] . "</a>";
     Html::showToolTip($pfNetworkPort->fields['ifdescr']);
     if (!$aggrega) {
         if ($networkPort->fields['instantiation_type'] == 'NetworkPortAggregate') {
             echo "<td><i><font style='color: grey'>" . __('Aggregation port') . "</font></i></td>";
         }
     }
     if ($monitoring == '1') {
         echo "<td>";
         $state = PluginMonitoringNetworkport::isMonitoredNetworkport($data['id']);
         if (Session::haveRight("plugin_monitoring_componentscatalog", UPDATE)) {
             Html::showCheckbox(array('name' => 'networkports_id[]', 'value' => $data['id'], 'checked' => $state));
         } else {
             if (Session::haveRight("plugin_monitoring_componentscatalog", READ)) {
                 echo Dropdown::getYesNo($state);
             }
         }
         echo "</td>";
     }
     $a_pref = DisplayPreference::getForTypeUser('PluginFusioninventoryNetworkport', Session::getLoginUserID());
     foreach ($a_pref as $data_array) {
         switch ($data_array) {
             case 3:
                 echo "<td>" . $pfNetworkPort->fields["ifmtu"] . "</td>";
                 break;
             case 5:
                 echo "<td>" . $this->byteSize($pfNetworkPort->fields["ifspeed"], 1000) . "bps</td>";
                 break;
             case 6:
                 echo "<td>";
                 if (strstr($pfNetworkPort->fields["ifstatus"], "up") || strstr($pfNetworkPort->fields["ifinternalstatus"], "1")) {
                     echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/greenbutton.png'/>";
                 } else {
                     if (strstr($pfNetworkPort->fields["ifstatus"], "down") || strstr($pfNetworkPort->fields["ifinternalstatus"], "2")) {
                         echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'/>";
                     } else {
                         if (strstr($pfNetworkPort->fields["ifstatus"], "testing") || strstr($pfNetworkPort->fields["ifinternalstatus"], "3")) {
                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                         }
                     }
                 }
                 echo "</td>";
                 break;
             case 7:
                 echo "<td>" . $pfNetworkPort->fields["iflastchange"] . "</td>";
                 break;
             case 8:
                 echo "<td>";
                 if ($pfNetworkPort->fields["ifinoctets"] == "0") {
                     echo "-";
                 } else {
                     echo $this->byteSize($pfNetworkPort->fields["ifinoctets"], 1000) . "o";
                 }
                 echo " / ";
                 if ($pfNetworkPort->fields["ifinoctets"] == "0") {
                     echo "-";
                 } else {
                     echo $this->byteSize($pfNetworkPort->fields["ifoutoctets"], 1000) . "o";
                 }
                 echo "</td>";
                 break;
             case 9:
                 $color = '';
                 if ($pfNetworkPort->fields["ifinerrors"] != "0" || $pfNetworkPort->fields["ifouterrors"] != "0") {
                     $color = "background='#cf9b9b' class='tab_bg_1_2'";
                 }
                 if ($pfNetworkPort->fields["ifinerrors"] == "0") {
                     echo "<td " . $color . ">-";
                 } else {
                     echo "<td " . $color . ">";
                     echo $pfNetworkPort->fields["ifinerrors"];
                 }
                 echo " / ";
                 if ($pfNetworkPort->fields["ifouterrors"] == "0") {
                     echo "-";
                 } else {
                     echo $pfNetworkPort->fields["ifouterrors"];
                 }
                 echo "</td>";
                 break;
             case 10:
                 if ($pfNetworkPort->fields["portduplex"] == 2) {
                     echo "<td background='#cf9b9b' class='tab_bg_1_2'>";
                     echo __('Half', 'fusioninventory');
                     echo '</td>';
                 } else {
                     if ($pfNetworkPort->fields["portduplex"] == 3) {
                         echo '<td>';
                         echo __('Full', 'fusioninventory');
                         echo '</td>';
                     } else {
                         echo "<td></td>";
                     }
                 }
                 break;
             case 11:
                 // ** internal mac
                 echo "<td>" . $networkPort->fields["mac"] . "</td>";
                 break;
             case 13:
                 // ** Mac address and link to device which are connected to this port
                 $opposite_port = $nw->getOppositeContact($data["id"]);
                 if ($opposite_port != "" && $opposite_port != 0) {
                     $networkPortOpposite = new NetworkPort();
                     if ($networkPortOpposite->getFromDB($opposite_port)) {
                         $data_device = $networkPortOpposite->fields;
                         $item = new $data_device["itemtype"]();
                         $item->getFromDB($data_device["items_id"]);
                         $link1 = $item->getLink(1);
                         $link = str_replace($item->getName(0), $data_device["mac"], $item->getLink());
                         // * GetIP
                         $a_networknames = current($networkName->find("`itemtype`='NetworkPort'\n                                          AND `items_id`='" . $item->getID() . "'", "", 1));
                         $a_ipaddresses = current($iPAddress->find("`itemtype`='NetworkName'\n                                          AND `items_id`='" . $a_networknames['id'] . "'", "", 1));
                         $link2 = str_replace($item->getName(0), $a_ipaddresses['name'], $item->getLink());
                         if ($data_device["itemtype"] == 'PluginFusioninventoryUnmanaged') {
                             $icon = $this->getItemtypeIcon($item->fields["item_type"]);
                             if ($item->getField("accepted") == "1") {
                                 echo "<td style='background:#bfec75'\n                                     class='tab_bg_1_2'>" . $icon . $link1;
                             } else {
                                 echo "<td background='#cf9b9b'\n                                     class='tab_bg_1_2'>" . $icon . $link1;
                             }
                             if (!empty($link)) {
                                 echo "<br/>" . $link;
                             }
                             if (!empty($link2)) {
                                 echo "<br/>" . $link2;
                             }
                             if ($item->getField("hub") == "1") {
                                 $this->displayHubConnections($data_device["items_id"], $background_img);
                             }
                             echo "</td>";
                         } else {
                             $icon = $this->getItemtypeIcon($data_device["itemtype"]);
                             echo "<td>" . $icon . $link1;
                             if (!empty($link)) {
                                 echo "<br/>" . $link;
                             }
                             if (!empty($link2)) {
                                 echo "<br/>" . $link2;
                             }
                             if ($data_device["itemtype"] == 'Phone') {
                                 $query_devicephone = "SELECT *\n                                   FROM `glpi_networkports`\n                                   WHERE `itemtype`='Phone'\n                                       AND `items_id`='" . $data_device["items_id"] . "'\n                                       AND `id`!='" . $data_device["id"] . "'\n                                   LIMIT 1";
                                 $result_devicephone = $DB->query($query_devicephone);
                                 if ($DB->numrows($result_devicephone) > 0) {
                                     $data_devicephone = $DB->fetch_assoc($result_devicephone);
                                     $computer_ports_id = $nw->getOppositeContact($data_devicephone["id"]);
                                     if ($computer_ports_id) {
                                         $networkport = new NetworkPort();
                                         $networkport->getFromDB($computer_ports_id);
                                         if ($networkport->fields['itemtype'] == 'Computer') {
                                             echo "<hr/>";
                                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/computer_icon.png' " . "style='float:left'/> ";
                                             $computer = new Computer();
                                             $computer->getFromDB($networkport->fields["items_id"]);
                                             $link1 = $computer->getLink(1);
                                             $link = str_replace($computer->getName(0), $networkport->fields["mac"], $computer->getLink());
                                             $link2 = str_replace($computer->getName(0), $networkport->fields["ip"], $computer->getLink());
                                             echo $icon . $link1;
                                             if (!empty($link)) {
                                                 echo "<br/>" . $link;
                                             }
                                             if (!empty($link2)) {
                                                 echo "<br/>" . $link2;
                                             }
                                         }
                                     }
                                 }
                             }
                             echo "</td>";
                         }
                     } else {
                         echo "<td></td>";
                     }
                 } else {
                     echo "<td></td>";
                 }
                 break;
             case 14:
                 // ** Connection status
                 echo "<td>";
                 if (strstr($pfNetworkPort->fields["ifstatus"], "up") || strstr($pfNetworkPort->fields["ifstatus"], "1")) {
                     echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/wired_on.png'/>";
                 } else {
                     if (strstr($pfNetworkPort->fields["ifstatus"], "down") || strstr($pfNetworkPort->fields["ifstatus"], "2")) {
                         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/wired_off.png'/>";
                     } else {
                         if (strstr($pfNetworkPort->fields["ifstatus"], "testing") || strstr($pfNetworkPort->fields["ifstatus"], "3")) {
                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                         } else {
                             if (strstr($pfNetworkPort->fields["ifstatus"], "dormant") || strstr($pfNetworkPort->fields["ifstatus"], "5")) {
                                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/orangebutton.png'/>";
                             }
                         }
                     }
                 }
                 echo "</td>";
                 break;
             case 12:
                 echo "<td>";
                 $canedit = Session::haveRight('networking', UPDATE);
                 $used = array();
                 $query_vlan = "SELECT * FROM glpi_networkports_vlans\n                              WHERE networkports_id='" . $data["id"] . "'";
                 $result_vlan = $DB->query($query_vlan);
                 if ($DB->numrows($result_vlan) > 0) {
                     echo "<table cellpadding='0' cellspacing='0'>";
                     while ($line = $DB->fetch_array($result_vlan)) {
                         $used[] = $line["vlans_id"];
                         $vlan = new Vlan();
                         $vlan->getFromDB($line["vlans_id"]);
                         if ($line['tagged'] == '1') {
                             $state = 'T';
                         } else {
                             $state = 'U';
                         }
                         echo "<tr><td>" . $vlan->fields['name'] . " [" . $vlan->fields['tag'] . "] " . $state;
                         echo "</td><td>";
                         if ($canedit) {
                             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?unassign_vlan=unassigned&amp;id=" . $line["id"] . "'>";
                             echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/delete.png\" alt='" . __('Delete', 'fusioninventory') . "' title='" . __('Delete', 'fusioninventory') . "'></a>";
                         } else {
                             echo "&nbsp;";
                         }
                         echo "</td>";
                         echo "</tr>";
                     }
                     echo "</table>";
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
                 break;
             case 15:
                 echo "<td align='center'>";
                 if ($pfNetworkPort->fields['ifstatus'] == 1) {
                     echo __('Connected');
                 } else {
                     if ($pfNetworkPort->fields['lastup'] == "0000-00-00 00:00:00") {
                         echo '-';
                     } else {
                         $time = strtotime(date('Y-m-d H:i:s')) - strtotime($pfNetworkPort->fields['lastup']);
                         echo Html::timestampToString($time, FALSE);
                     }
                 }
                 echo "</td>";
                 break;
             case 16:
                 echo "<td>" . $pfNetworkPort->fields["ifalias"] . "</td>";
                 break;
         }
     }
     echo "</tr>";
 }