예제 #1
0
 /**
  * Print the computer form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_computer`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     ComputerType::dropdown(array('value' => $this->fields["computertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     ComputerModel::dropdown(array('value' => $this->fields["computermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     //TRANS: Number of the alternate username
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'contact_num');
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'contact');
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Network') . "</td>";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     // Display auto inventory informations
     $rowspan = 7;
     $inventory_show = false;
     if (!empty($ID) && Plugin::haveImport() && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 5;
     }
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>";
     echo "<td >";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Operating system') . "</td>";
     echo "<td>";
     OperatingSystem::dropdown(array('value' => $this->fields["operatingsystems_id"]));
     echo "<br /><a href='#' id='toggle_os_information'>" . __("More information") . "</a>";
     echo "</td>";
     if ($inventory_show) {
         echo "<td rowspan='4' colspan='2'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version of the operating system') . "</td>";
     echo "<td >";
     OperatingSystemVersion::dropdown(array('value' => $this->fields["operatingsystemversions_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>";
     echo Html::scriptBlock("\n      \$(document).ready(function(){\n         \$('#os_information').hide();\n\n         \$('#toggle_os_information').on('click',function() {\n            \$('#os_information').dialog({\n               width:'auto',\n               resizable: false,\n               appendTo: '#os_information_parent',\n               position: {\n                  my : 'left top',\n                  at : 'left bottom',\n                  of: \$('#toggle_os_information')\n               }\n            })\n         })\n      });");
     // group os advanced information in a single bloc (who can be toggled)
     echo "<div id='os_information_parent'>";
     echo "<div id='os_information' title=\"" . __('Operating system') . "\">";
     echo "<table>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Service pack') . "</td>";
     echo "<td >";
     OperatingSystemServicePack::dropdown(array('value' => $this->fields["operatingsystemservicepacks_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Operating system architecture') . "</td>";
     echo "<td >";
     OperatingSystemArchitecture::dropdown(array('value' => $this->fields["operatingsystemarchitectures_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Kernel version of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_kernel_version');
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Product ID of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_licenseid');
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Serial of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_license_number');
     echo "</td>";
     echo "</table>";
     echo "</div>";
     echo "</div>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('UUID') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'uuid');
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Update Source') . "</td>";
     echo "<td >";
     AutoUpdateSystem::dropdown(array('value' => $this->fields["autoupdatesystems_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
예제 #2
0
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimeline($rand)
 {
     global $CFG_GLPI, $DB, $autolink_options;
     //get ticket actors
     $ticket_users_keys = $this->getTicketActors();
     $user = new User();
     $group = new Group();
     $followup_obj = new TicketFollowup();
     $pics_url = $CFG_GLPI['root_doc'] . "/pics/timeline";
     $timeline = $this->getTimelineItems();
     $autolink_options['strip_protocols'] = false;
     //display timeline
     echo "<div class='timeline_history'>";
     $tmp = array_values($timeline);
     $first_item = array_shift($tmp);
     // show approbation form on top when ticket is solved
     if ($this->fields["status"] == CommonITILObject::SOLVED) {
         echo "<div class='approbation_form' id='approbation_form{$rand}'>";
         $followup_obj->showApprobationForm($this);
         echo "</div>";
     }
     // show title for timeline
     self::showTimelineHeader();
     $timeline_index = 0;
     foreach ($timeline as $item) {
         $options = array('parent' => $this, 'rand' => $rand);
         if ($obj = getItemForItemtype($item['type'])) {
             $obj->fields = $item['item'];
         } else {
             $obj = $item;
         }
         Plugin::doHook('pre_show_item', array('item' => &$obj, 'options' => &$options));
         if (is_array($obj)) {
             $item_i = $obj['item'];
         } else {
             $item_i = $obj->fields;
         }
         $date = "";
         if (isset($item_i['date'])) {
             $date = $item_i['date'];
         }
         if (isset($item_i['date_mod'])) {
             $date = $item_i['date_mod'];
         }
         // check if curent item user is assignee or requester
         $user_position = 'left';
         if (isset($ticket_users_keys[$item_i['users_id']]) && $ticket_users_keys[$item_i['users_id']] == CommonItilActor::ASSIGN || $item['type'] == 'Assign') {
             $user_position = 'right';
         }
         //display solution in middle
         if ($timeline_index == 0 && $item['type'] == "Solution" && $this->fields["status"] == CommonITILObject::SOLVED) {
             $user_position .= ' middle';
         }
         echo "<div class='h_item {$user_position}'>";
         echo "<div class='h_info'>";
         echo "<div class='h_date'>" . Html::convDateTime($date) . "</div>";
         if ($item_i['users_id'] !== false) {
             echo "<div class='h_user'>";
             if (isset($item_i['users_id']) && $item_i['users_id'] != 0) {
                 $user->getFromDB($item_i['users_id']);
                 echo "<div class='tooltip_picture_border'>";
                 echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>";
                 echo "</div>";
                 echo "<span class='h_user_name'>";
                 $userdata = getUserName($item_i['users_id'], 2);
                 echo $user->getLink() . "&nbsp;";
                 echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link']));
                 echo "</span>";
             } else {
                 _e("Requester");
             }
             echo "</div>";
             // h_user
         }
         echo "</div>";
         //h_date
         echo "<div class='h_content " . $item['type'] . (isset($item_i['status']) ? " " . $item_i['status'] : "") . "'" . "id='viewitem" . $item['type'] . $item_i['id'] . $rand . "'>";
         if (isset($item_i['can_edit']) && $item_i['can_edit']) {
             echo "<div class='edit_item_content'></div>";
             echo "<span class='cancel_edit_item_content'></span>";
         }
         echo "<div class='displayed_content'>";
         if (!in_array($item['type'], array('Document_Item', 'Assign')) && $item_i['can_edit']) {
             echo "<span class='edit_item' ";
             echo "onclick='javascript:viewEditSubitem" . $this->fields['id'] . "{$rand}(event, \"" . $item['type'] . "\", " . $item_i['id'] . ", this, \"viewitem" . $item['type'] . $item_i['id'] . $rand . "\")'";
             echo "></span>";
         }
         if (isset($item_i['requesttypes_id']) && file_exists("{$pics_url}/" . $item_i['requesttypes_id'] . ".png")) {
             echo "<img src='{$pics_url}/" . $item_i['requesttypes_id'] . ".png' title='' class='h_requesttype' />";
         }
         if (isset($item_i['content'])) {
             $content = $item_i['content'];
             $content = autolink($content, 40);
             //$content = nl2br($content);
             $long_text = "";
             if (substr_count($content, "<br") > 30 || strlen($content) > 2000) {
                 $long_text = "long_text";
             }
             echo "<div class='item_content {$long_text}'>";
             echo "<p>";
             if (isset($item_i['state'])) {
                 $onClick = "onclick='change_task_state(" . $item_i['id'] . ", this)'";
                 if (!$item_i['can_edit']) {
                     $onClick = "style='cursor: not-allowed;'";
                 }
                 echo "<span class='state state_" . $item_i['state'] . "'\n                           {$onClick}\n                           title='" . Planning::getState($item_i['state']) . "'>";
                 echo "</span>";
             }
             echo $content;
             echo "</p>";
             if (!empty($long_text)) {
                 echo "<p class='read_more'>";
                 echo "<a class='read_more_button'>.....</a>";
                 echo "</p>";
             }
             echo "</div>";
         }
         echo "<div class='b_right'>";
         if (isset($item_i['solutiontypes_id']) && !empty($item_i['solutiontypes_id'])) {
             echo Dropdown::getDropdownName("glpi_solutiontypes", $item_i['solutiontypes_id']) . "<br>";
         }
         if (isset($item_i['taskcategories_id']) && !empty($item_i['taskcategories_id'])) {
             echo Dropdown::getDropdownName("glpi_taskcategories", $item_i['taskcategories_id']) . "<br>";
         }
         if (isset($item_i['requesttypes_id']) && !empty($item_i['requesttypes_id'])) {
             echo Dropdown::getDropdownName("glpi_requesttypes", $item_i['requesttypes_id']) . "<br>";
         }
         if (isset($item_i['actiontime']) && !empty($item_i['actiontime'])) {
             echo "<span class='actiontime'>";
             echo Html::timestampToString($item_i['actiontime'], false);
             echo "</span>";
         }
         if (isset($item_i['begin'])) {
             echo "<span class='planification'>";
             echo Html::convDateTime($item_i["begin"]);
             echo " &rArr; ";
             echo Html::convDateTime($item_i["end"]);
             echo "</span>";
         }
         if (isset($item_i['users_id_tech']) && $item_i['users_id_tech'] > 0) {
             echo "<div class='users_id_tech' id='users_id_tech_" . $item_i['users_id_tech'] . "'>";
             $user->getFromDB($item_i['users_id_tech']);
             echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . "&nbsp;";
             $userdata = getUserName($item_i['users_id_tech'], 2);
             echo $user->getLink() . "&nbsp;";
             echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link']));
             echo "</div>";
         }
         if (isset($item_i['groups_id_tech']) && $item_i['groups_id_tech'] > 0) {
             echo "<div class='groups_id_tech'>";
             $group->getFromDB($item_i['groups_id_tech']);
             echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . "&nbsp;";
             echo $group->getLink() . "&nbsp;";
             echo Html::showToolTip($group->getComments(), array('link' => $group->getLinkURL()));
             echo "</div>";
         }
         // show "is_private" icon
         if (isset($item_i['is_private']) && $item_i['is_private']) {
             echo "<div class='private'>" . __('Private') . "</div>";
         }
         echo "</div>";
         // b_right
         if ($item['type'] == 'Document_Item') {
             $filename = $item_i['filename'];
             $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
             echo "<img src='";
             if (empty($filename)) {
                 $filename = $item_i['name'];
             }
             if (file_exists(GLPI_ROOT . "/pics/icones/{$ext}-dist.png")) {
                 echo $CFG_GLPI['root_doc'] . "/pics/icones/{$ext}-dist.png";
             } else {
                 echo "{$pics_url}/file.png";
             }
             echo "' title='file' />&nbsp;";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' target='_blank'>{$filename}";
             if (in_array($ext, array('jpg', 'jpeg', 'png', 'bmp'))) {
                 echo "<div class='timeline_img_preview'>";
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "'/>";
                 echo "</div>";
             }
             echo "</a>";
             if (!empty($item_i['mime'])) {
                 echo "&nbsp;(" . $item_i['mime'] . ")";
             }
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.form.php?id=" . $item_i['id'] . "' class='edit_document' title='" . _sx("button", "Update") . "'>";
             echo "<img src='{$pics_url}/edit.png' /></a>";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?delete_document&documents_id=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' class='delete_document' title='" . _sx("button", "Delete permanently") . "'>";
             echo "<img src='{$pics_url}/delete.png' /></a>";
         }
         echo "</div>";
         // displayed_content
         echo "</div>";
         //end h_content
         echo "</div>";
         //end  h_info
         $timeline_index++;
         Plugin::doHook('post_show_item', array('item' => $obj, 'options' => $options));
     }
     // end foreach timeline
     echo "<div class='break'></div>";
     // recall ticket content (not needed in classic and splitted layout)
     if (!CommonGLPI::isLayoutWithMain()) {
         echo "<div class='h_item middle'>";
         echo "<div class='h_info'>";
         echo "<div class='h_date'>" . Html::convDateTime($this->fields['date']) . "</div>";
         echo "<div class='h_user'>";
         $dem = '0';
         foreach ($DB->request("glpi_tickets_users", "`tickets_id` = " . $this->fields['id'] . " AND `type` = 1") as $req) {
             $dem = $req['users_id'];
         }
         if ((!isset($item_i['users_id_recipient']) || $item_i['users_id_recipient'] == 0) && $dem == 0) {
             _e("Requester");
         } else {
             if (isset($item_i['users_id_recipient']) && $item_i['users_id_recipient'] != 0) {
                 $user->getFromDB($this->fields['users_id_recipient']);
             } else {
                 if ($dem > 0) {
                     $requester = new User();
                     if ($requester->getFromDB($dem)) {
                         $user = $requester;
                     }
                 }
             }
             echo "<div class='tooltip_picture_border'>";
             $picture = "";
             if (isset($user->fields['picture'])) {
                 $picture = $user->fields['picture'];
             }
             echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($picture) . "'>";
             echo "</div>";
             echo $user->getLink();
         }
         echo "</div>";
         // h_user
         echo "</div>";
         //h_info
         echo "<div class='h_content TicketContent'>";
         echo "<div class='b_right'>" . __("Ticket recall") . "</div>";
         echo "<div class='ticket_title'>";
         echo html_entity_decode($this->fields['name']);
         echo "</div>";
         echo "<div class='ticket_description'>";
         echo $this->setSimpleTextContent($this->fields['content']);
         echo "</div>";
         echo "</div>";
         // h_content TicketContent
         echo "</div>";
         // h_item middle
         echo "<div class='break'></div>";
     }
     // end timeline
     echo "</div>";
     // h_item $user_position
     echo "<script type='text/javascript'>read_more();</script>";
 }
 /**
  * Print the version form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - computers_id ID of the computer for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("computer", "w")) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, 'r');
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         // Create item
         $this->check(-1, 'w', $options);
         $comp->getFromDB($options['computers_id']);
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if ($this->isNewID($ID)) {
         echo "<input type='hidden' name='computers_id' value='" . $options['computers_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Computer') . "</td>";
     echo "<td>" . $comp->getLink() . "</td>";
     if (Plugin::haveImport()) {
         echo "<td>" . __('Automatic inventory') . "</td>";
         echo "<td>";
         if ($ID && $this->fields['is_dynamic']) {
             Plugin::doHook("autoinventory_information", $this);
         } else {
             _e('No');
         }
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td><td>" . __('Virtualization system') . "</td>";
     echo "<td>";
     VirtualMachineType::dropdown(array('value' => $this->fields['virtualmachinetypes_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Virtualization model') . "</td>";
     echo "<td>";
     VirtualMachineSystem::dropdown(array('value' => $this->fields['virtualmachinesystems_id']));
     echo "</td><td>" . __('State of the virtual machine') . "</td>";
     echo "<td>";
     VirtualMachineState::dropdown(array('value' => $this->fields['virtualmachinestates_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('UUID') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "uuid");
     echo "</td>";
     echo "<td>" . _x('quantity', 'Processors number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "vcpu");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "ram");
     echo "</td>";
     echo "<td>" . __('Machine') . "</td>";
     echo "<td>";
     if ($link_computer = self::findVirtualMachine($this->fields)) {
         $computer = new Computer();
         if ($computer->getFromDB($link_computer)) {
             echo $computer->getLink(array('comments' => true));
         } else {
             echo NOT_AVAILABLE;
         }
     }
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
예제 #4
0
파일: includes.php 프로젝트: gaforeror/glpi
    // PLugin already included
    $PLUGINS_INCLUDED = 1;
    $LOADED_PLUGINS = array();
    $plugin = new Plugin();
    if (!isset($_SESSION["glpi_plugins"])) {
        $plugin->init();
    }
    if (isset($_SESSION["glpi_plugins"]) && is_array($_SESSION["glpi_plugins"])) {
        //Plugin::doHook("config");
        if (count($_SESSION["glpi_plugins"])) {
            foreach ($_SESSION["glpi_plugins"] as $name) {
                Plugin::load($name);
            }
        }
        // For plugins which require action after all plugin init
        Plugin::doHook("post_init");
    }
}
if (!isset($_SESSION["MESSAGE_AFTER_REDIRECT"])) {
    $_SESSION["MESSAGE_AFTER_REDIRECT"] = "";
}
// Manage force tab
if (isset($_REQUEST['forcetab'])) {
    if (preg_match('/([a-zA-Z]+).form.php/', $_SERVER['PHP_SELF'], $matches)) {
        $itemtype = $matches[1];
        Session::setActiveTab($matches[1], $_REQUEST['forcetab']);
    }
}
// Manage tabs
if (isset($_REQUEST['glpi_tab']) && isset($_REQUEST['itemtype'])) {
    Session::setActiveTab($_REQUEST['itemtype'], $_REQUEST['glpi_tab']);
예제 #5
0
 static function uninstall($type, $model_id, $tab_ids, $location)
 {
     global $UNINSTALL_DIRECT_CONNECTIONS_TYPE;
     //Get the model
     $model = new PluginUninstallModel();
     $model->getConfig($model_id);
     //Then destroy all the connexions
     $transfer = new Transfer();
     $transfer->getFromDB($model->fields["transfers_id"]);
     echo "<div class='center'>";
     echo "<table class='tab_cadre_fixe'><tr><th>" . __('Uninstall', 'uninstall') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>";
     $count = 0;
     $tot = count($tab_ids[$type]);
     Html::createProgressBar(__('Please wait, uninstallation is running...', 'uninstall'));
     foreach ($tab_ids[$type] as $id => $value) {
         $count++;
         $item = new $type();
         $item->getFromDB($id);
         //First clean object and change location and status if needed
         $entity = $item->fields["entities_id"];
         $input = array();
         $input["id"] = $id;
         $input["entities_id"] = $entity;
         $fields = array();
         //Hook to perform actions before item is being uninstalled
         $item->fields['_uninstall_event'] = $model->getID();
         $item->fields['_action'] = 'uninstall';
         Plugin::doHook("plugin_uninstall_before", $item);
         //--------------------//
         //Direct connections //
         //------------------//
         if (in_array($type, $UNINSTALL_DIRECT_CONNECTIONS_TYPE)) {
             $conn = new Computer_Item();
             $conn->deleteByCriteria(array('computers_id' => $id), true);
         }
         //--------------------//
         //-- Common fields --//
         //------------------//
         //RAZ contact and contactnumber
         if ($item->isField('contact') && $model->fields["raz_contact"] == 1) {
             $fields["contact"] = '';
             if ($item->isField('contact_num')) {
                 $fields["contact_num"] = '';
             }
         }
         //RAZ user
         if ($model->fields["raz_user"] == 1 && $item->isField('users_id')) {
             $fields["users_id"] = 0;
         }
         //RAZ status
         if ($model->fields["states_id"] > 0 && $item->isField('states_id')) {
             $fields["states_id"] = $model->fields["states_id"];
         }
         //RAZ machine's name
         if ($item->isField('name') && $model->fields["raz_name"] == 1) {
             $fields["name"] = '';
         }
         if ($item->isField('locations_id')) {
             if ($location == '') {
                 $location = 0;
             }
             switch ($location) {
                 case -1:
                     break;
                 default:
                     $fields["locations_id"] = $location;
                     break;
             }
         }
         if ($item->isField('groups_id')) {
             $nbgroup = countElementsInTableForEntity("glpi_groups", $entity, "`id`='" . $item->fields['groups_id'] . "'");
             if ($model->fields["groups_id"] > -1 && $nbgroup == 1) {
                 // If a new group is defined and if the group is accessible in the object's entity
                 $fields["groups_id"] = $model->fields["groups_id"];
             }
         }
         //------------------------------//
         //-- Computer specific fields --//
         //------------------------------//
         if ($type == 'Computer') {
             //RAZ all OS related informations
             if ($model->fields["raz_os"] == 1) {
                 $fields["operatingsystems_id"] = 0;
                 $fields["operatingsystemversions_id"] = 0;
                 $fields["operatingsystemservicepacks_id"] = 0;
                 $fields["os_licenseid"] = '';
                 $fields["os_license_number"] = '';
                 $fields["autoupdatesystems_id"] = 0;
             }
             $plug = new Plugin();
             if ($plug->isActivated('ocsinventoryng')) {
                 if ($item->fields["is_dynamic"] && ($model->fields["remove_from_ocs"] || $model->fields["delete_ocs_link"])) {
                     $input["is_dynamic"] = 0;
                 }
             }
             if ($item->isField('domains_id') && $model->fields["raz_domain"]) {
                 $fields["domains_id"] = 0;
             }
             //RAZ network
             if ($item->isField('networks_id') && $model->fields["raz_network"] == 1) {
                 $fields["networks_id"] = 0;
             }
         }
         //RAZ IPs from all the network cards
         if ($model->fields["raz_ip"] == 1) {
             self::razPortInfos($type, $id);
             // For NetworkEquiment
             if ($item->isField('ip')) {
                 $fields['ip'] = '';
             }
             if ($item->isField('mac')) {
                 $fields['mac'] = '';
             }
         }
         foreach ($fields as $name => $value) {
             if (!($item->getField($name) != NOT_AVAILABLE) || $item->getField($name) != $value) {
                 $input[$name] = $value;
             }
         }
         $item->dohistory = true;
         $item->update($input);
         if ($model->fields["raz_budget"] == 1) {
             $infocom_id = self::getInfocomPresentForDevice($type, $id);
             if ($infocom_id > 0) {
                 $infocom = new InfoCom();
                 $tmp["id"] = $infocom_id;
                 $tmp["budgets_id"] = 0;
                 $infocom->dohistory = false;
                 $infocom->update($tmp);
             }
         }
         //Delete machine from glpi_ocs_link
         if ($type == 'Computer') {
             //Delete computer's volumes
             self::purgeComputerVolumes($id);
             if ($model->fields["raz_history"] == 1) {
                 //Delete history related to software
                 self::deleteHistory($id, false);
             } else {
                 if ($model->fields["raz_soft_history"] == 1) {
                     //Delete history related to software
                     self::deleteHistory($id, true);
                 }
             }
             $plug = new Plugin();
             if ($plug->isActivated('ocsinventoryng')) {
                 //Delete computer from OCS
                 if ($model->fields["remove_from_ocs"] == 1) {
                     self::deleteComputerInOCSByGlpiID($id);
                 }
                 //Delete link in glpi_ocs_link
                 if ($model->fields["delete_ocs_link"] || $model->fields["remove_from_ocs"]) {
                     self::deleteOcsLink($id);
                 }
             }
             //Should never happend that transfer_id = 0, but just in case
             if ($model->fields["transfers_id"] > 0) {
                 $transfer->moveItems(array($type => array($id => $id)), $entity, $transfer->fields);
             }
         }
         if ($model->fields['raz_fusioninventory'] == 1) {
             self::deleteFusionInventoryLink($type, $id);
         }
         //Plugin hook after uninstall
         Plugin::doHook("plugin_uninstall_after", $item);
         Html::changeProgressBarPosition($count, $tot + 1);
     }
     //Add line in machine's history to say that machine was uninstalled
     self::addUninstallLog($type, $id);
     Html::changeProgressBarPosition($count, $tot, __('Uninstallation successful', 'uninstall'));
     echo "</td></tr>";
     echo "</table></div>";
 }
예제 #6
0
 /**
  * @param $type
  * @param $model_id
  * @param $tab_ids
  * @param $location
  **/
 static function replace($type, $model_id, $tab_ids, $location)
 {
     global $DB, $CFG_GLPI, $PLUGIN_HOOKS;
     $model = new PluginUninstallModel();
     $model->getConfig($model_id);
     $overwrite = $model->fields["overwrite"];
     echo "<div class='center'>";
     echo "<table class='tab_cadre_fixe'><tr><th>" . __('Replacement', 'uninstall') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>";
     $count = 0;
     $tot = count($tab_ids);
     Html::createProgressBar(__('Please wait, replacement is running...', 'uninstall'));
     foreach ($tab_ids as $olditem_id => $newitem_id) {
         $count++;
         $olditem = new $type();
         $olditem->getFromDB($olditem_id);
         $newitem = new $type();
         $newitem->getFromDB($newitem_id);
         //Hook to perform actions before item is being replaced
         $olditem->fields['_newid'] = $newitem_id;
         $olditem->fields['_uninstall_event'] = $model_id;
         $olditem->fields['_action'] = 'replace';
         Plugin::doHook("plugin_uninstall_replace_before", $olditem);
         // Retrieve informations
         //States
         if ($model->fields['states_id'] != 0) {
             $olditem->update(array('id' => $olditem_id, 'states_id' => $model->fields['states_id']), false);
         }
         // METHOD REPLACEMENT 1 : Archive
         if ($model->fields['replace_method'] == self::METHOD_PURGE) {
             $name_out = str_shuffle(Toolbox::getRandomString(5) . time());
             $plugin = new Plugin();
             if ($plugin->isActivated('PDF')) {
                 // USE PDF EXPORT
                 $plugin->load('pdf', true);
                 include_once GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php";
                 //Get all item's tabs
                 $tab = array_keys($olditem->defineTabs());
                 //Tell PDF to also export item's main tab, and in first position
                 array_unshift($tab, "_main_");
                 $itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($olditem);
                 $out = $itempdf->generatePDF(array($olditem_id), $tab, 1, false);
                 $name_out .= ".pdf";
             } else {
                 //TODO Which datas ? Add Defaults...
                 $out = __('Replacement', 'uninstall') . "\r\n";
                 $datas = $olditem->fields;
                 unset($datas['comment']);
                 foreach ($datas as $k => $v) {
                     $out .= $k . ";";
                 }
                 $out .= "\r\n";
                 foreach ($datas as $k => $v) {
                     $out .= $v . ";";
                 }
                 // USE CSV EXPORT
                 $name_out .= ".csv";
             }
             // Write document
             $out_file = GLPI_DOC_DIR . "/_uploads/" . $name_out;
             $open_file = fopen($out_file, 'a');
             fwrite($open_file, $out);
             fclose($open_file);
             // Compute comment text
             $comment = __('This document is the archive of this replaced item', 'uninstall') . " " . self::getCommentsForReplacement($olditem, false, false);
             // Create & Attach new document to current item
             $doc = new Document();
             $input = array('name' => addslashes(__('Archive of old material', 'uninstall')), 'upload_file' => $name_out, 'comment' => addslashes($comment), 'add' => __('Add'), 'entities_id' => $newitem->getEntityID(), 'is_recursive' => $newitem->isRecursive(), 'link' => "", 'documentcategories_id' => 0, 'items_id' => $olditem_id, 'itemtype' => $type);
             //Attached the document to the old item, to generate an accurate name
             $document_added = $doc->add($input);
             //Attach the document to the new item, once the document's name is correct
             $docItem = new Document_Item();
             $docItemId = $docItem->add(array('documents_id' => $document_added, 'itemtype' => $type, 'items_id' => (int) $newitem_id));
         }
         // General Informations - NAME
         if ($model->fields["replace_name"]) {
             if ($overwrite || empty($newitem->fields['name'])) {
                 $newitem->update(array('id' => $newitem_id, 'name' => $olditem->getField('name')), false);
             }
         }
         $data['id'] = $newitem->getID();
         // General Informations - SERIAL
         if ($model->fields["replace_serial"]) {
             if ($overwrite || empty($newitem->fields['serial'])) {
                 $newitem->update(array('id' => $newitem_id, 'serial' => $olditem->getField('serial')), false);
             }
         }
         // General Informations - OTHERSERIAL
         if ($model->fields["replace_otherserial"]) {
             if ($overwrite || empty($newitem->fields['otherserial'])) {
                 $newitem->update(array('id' => $newitem_id, 'otherserial' => $olditem->getField('otherserial')), false);
             }
         }
         // Documents
         if ($model->fields["replace_documents"] && in_array($type, $CFG_GLPI["document_types"])) {
             $doc_item = new Document_Item();
             foreach (self::getAssociatedDocuments($olditem) as $document) {
                 $doc_item->update(array('id' => $document['assocID'], 'itemtype' => $type, 'items_id' => $newitem_id), false);
             }
         }
         // Contracts
         if ($model->fields["replace_contracts"] && in_array($type, $CFG_GLPI["contract_types"])) {
             $contract_item = new Contract_Item();
             foreach (self::getAssociatedContracts($olditem) as $contract) {
                 $contract_item->update(array('id' => $contract['id'], 'itemtype' => $type, 'items_id' => $newitem_id), false);
             }
         }
         // Infocoms
         if ($model->fields["replace_infocoms"] && in_array($type, $CFG_GLPI["infocom_types"])) {
             $infocom = new Infocom();
             if ($overwrite) {
                 // Delete current Infocoms of new item
                 if ($infocom->getFromDBforDevice($type, $newitem_id)) {
                     //Do not log infocom deletion in the new item's history
                     $infocom->dohistory = false;
                     $infocom->deleteFromDB(1);
                 }
             }
             // Update current Infocoms of old item
             if ($infocom->getFromDBforDevice($type, $olditem_id)) {
                 $infocom->update(array('id' => $infocom->getID(), 'itemtype' => $type, 'items_id' => $newitem_id), false);
             }
         }
         // Reservations
         if ($model->fields["replace_reservations"] && in_array($type, $CFG_GLPI["reservation_types"])) {
             $resaitem = new ReservationItem();
             if ($overwrite) {
                 // Delete current reservation of new item
                 $resa_new = new Reservation();
                 $resa_new->getFromDB($newitem_id);
                 if ($resa_new->is_reserved()) {
                     $resa_new = new ReservationItem();
                     $resa_new->getFromDBbyItem($type, $newitem_id);
                     if (count($resa_new->fields)) {
                         $resa_new->deleteFromDB(1);
                     }
                 }
             }
             // Update old reservation for attribute to new item
             $resa_old = new Reservation();
             $resa_old->getFromDB($olditem_id);
             if ($resa_old->is_reserved()) {
                 $resa_old = new ReservationItem();
                 $resa_old->getFromDBbyItem($type, $olditem_id);
                 if (count($resa_old->fields)) {
                     $resa_old->update(array('id' => $resa_old->getID(), 'itemtype' => $type, 'items_id' => $newitem_id), false);
                 }
             }
         }
         // User
         if ($model->fields["replace_users"] && in_array($type, $CFG_GLPI["linkuser_types"])) {
             $data = array();
             $data['id'] = $newitem->getID();
             if ($newitem->isField('users_id') && ($overwrite || empty($data['users_id']))) {
                 $data['users_id'] = $olditem->getField('users_id');
             }
             if ($newitem->isField('contact') && ($overwrite || empty($data['contact']))) {
                 $data['contact'] = $olditem->getField('contact');
             }
             if ($newitem->isField('contact_num') && ($overwrite || empty($data['contact_num']))) {
                 $data['contact_num'] = $olditem->getField('contact_num');
             }
             $newitem->update($data, false);
         }
         // Group
         if ($model->fields["replace_groups"] && in_array($type, $CFG_GLPI["linkgroup_types"])) {
             if ($newitem->isField('groups_id') && ($overwrite || empty($data['groups_id']))) {
                 $newitem->update(array('id' => $newitem_id, 'groups_id' => $olditem->getField('groups_id')), false);
             }
         }
         // Tickets
         if ($model->fields["replace_tickets"] && in_array($type, $CFG_GLPI["ticket_types"])) {
             $ticket_item = new Item_Ticket();
             foreach (self::getAssociatedTickets($type, $olditem_id) as $ticket) {
                 $ticket_item->update(array('id' => $ticket['id'], 'items_id' => $newitem_id), false);
             }
         }
         //Array netport_types renamed in networkport_types in GLPI 0.80
         if (isset($CFG_GLPI["netport_types"])) {
             $netport_types = $CFG_GLPI["netport_types"];
         } else {
             $netport_types = $CFG_GLPI["networkport_types"];
         }
         // NetPorts
         if ($model->fields["replace_netports"] && in_array($type, $netport_types)) {
             $netport_item = new NetworkPort();
             foreach (self::getAssociatedNetports($type, $olditem_id) as $netport) {
                 $netport_item->update(array('id' => $netport['id'], 'itemtype' => $type, 'items_id' => $newitem_id), false);
             }
         }
         // Directs connections
         if ($model->fields["replace_direct_connections"] && in_array($type, array('Computer'))) {
             $comp_item = new Computer_Item();
             foreach (self::getAssociatedItems($olditem) as $itemtype => $connections) {
                 foreach ($connections as $connection) {
                     $comp_item->update(array('id' => $connection['id'], 'computers_id' => $newitem_id, 'itemtype' => $itemtype), false);
                 }
             }
         }
         // Location
         if ($location != 0 && $olditem->isField('locations_id')) {
             $olditem->getFromDB($olditem_id);
             switch ($location) {
                 case -1:
                     break;
                 default:
                     $olditem->update(array('id' => $olditem_id, 'locations_id' => $location), false);
                     break;
             }
         }
         $plug = new Plugin();
         if ($plug->isActivated('ocsinventoryng')) {
             //Delete computer from OCS
             if ($model->fields["remove_from_ocs"] == 1) {
                 PluginUninstallUninstall::deleteComputerInOCSByGlpiID($olditem_id);
             }
             //Delete link in glpi_ocs_link
             if ($model->fields["delete_ocs_link"] || $model->fields["remove_from_ocs"]) {
                 PluginUninstallUninstall::deleteOcsLink($olditem_id);
             }
         }
         if ($plug->isActivated('fusioninventory')) {
             if ($model->fields['raz_fusioninventory']) {
                 PluginUninstallUninstall::deleteFusionInventoryLink(get_class($olditem), $olditem_id);
             }
         }
         // METHOD REPLACEMENT 1 : Purge
         if ($model->fields['replace_method'] == self::METHOD_PURGE) {
             // Retrieve, Compute && Update NEW comment field
             $comment = self::getCommentsForReplacement($olditem, true);
             $comment .= "\n- " . __('See attached document', 'uninstall');
             $newitem->update(array('id' => $newitem_id, 'comment' => addslashes($comment)), false);
             // If old item is attached in PDF/CSV
             // Delete AND Purge it in DB
             if ($document_added) {
                 $olditem->delete(array('id' => $olditem_id), true);
             }
         }
         // METHOD REPLACEMENT 2 : Delete AND Comment
         if ($model->fields['replace_method'] == self::METHOD_DELETE_AND_COMMENT) {
             //Add comment on the new item first
             $comment = self::getCommentsForReplacement($olditem, true);
             $newitem->update(array('id' => $newitem_id, 'comment' => Toolbox::addslashes_deep($comment)), false);
             // Retrieve, Compute && Update OLD comment field
             $comment = self::getCommentsForReplacement($newitem, false);
             $olditem->update(array('id' => $olditem_id, 'comment' => Toolbox::addslashes_deep($comment)), false);
             // Delete OLD item from DB (not PURGE)
             PluginUninstallUninstall::addUninstallLog($type, $olditem_id, 'replaced_by');
             $olditem->delete(array('id' => $olditem_id), 0, false);
         }
         //Plugin hook after replacement
         Plugin::doHook("plugin_uninstall_replace_after", $olditem);
         //Add history
         PluginUninstallUninstall::addUninstallLog($type, $newitem_id, 'replace');
         Html::changeProgressBarPosition($count, $tot + 1);
     }
     Html::changeProgressBarPosition($count, $tot, __('Replacement successful', 'uninstall'));
     echo "</td></tr>";
     echo "</table></div>";
 }
        $mailcol = new MailCollector();
        foreach ($mailcollectors as $mc) {
            echo " " . $mc['name'];
            if ($mailcol->getFromDB($mc['id'])) {
                $mailcol->connect();
                if ($mailcol->marubox) {
                    echo "_OK";
                } else {
                    echo "_PROBLEM";
                    $ok = false;
                }
                echo "\n";
                $mailcol->close_mailbox();
            }
        }
    } else {
        echo "No mail collector\n";
    }
    // hook for plugin
    $param = array('ok' => $ok);
    Plugin::doHook("status", $param);
    if (isset($param['ok'])) {
        $ok = $param['ok'];
    }
}
echo "\n";
if ($ok) {
    echo "GLPI_OK\n";
} else {
    echo "GLPI_PROBLEM\n";
}
예제 #8
0
 /**
  * Restore an item put in the dustbin in the database.
  *
  * @param $input     array    the _POST vars returned by the item form when press restore
  * @param $history   boolean  do history log ? (default 1)
  *
  * @return boolean : true on success
  **/
 function restore(array $input, $history = 1)
 {
     if (!$this->getFromDB($input[static::getIndexName()])) {
         return false;
     }
     if (isset($input['restore'])) {
         $input['_restore'] = $input['restore'];
         unset($input['restore']);
     }
     // Store input in the object to be available in all sub-method / hook
     $this->input = $input;
     Plugin::doHook("pre_item_restore", $this);
     if ($this->restoreInDB()) {
         $this->addMessageOnRestoreAction();
         if ($this->dohistory && $history) {
             $changes[0] = 0;
             $changes[1] = $changes[2] = "";
             $logaction = Log::HISTORY_RESTORE_ITEM;
             if ($this->useDeletedToLockIfDynamic() && $this->isDynamic()) {
                 $logaction = Log::HISTORY_UNLOCK_ITEM;
             }
             Log::history($this->input["id"], $this->getType(), $changes, 0, $logaction);
         }
         $this->post_restoreItem();
         Plugin::doHook("item_restore", $this);
         if ($this->mailqueueonaction) {
             QueuedMail::forceSendFor($this->getType(), $this->fields['id']);
         }
         return true;
     }
     return false;
 }
예제 #9
0
 /**
  * Print the peripheral form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $target = $this->getFormURL();
     $withtemplate = $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "");
     echo "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "name", array('value' => $objectName));
     echo "</td>\n";
     echo "<td>" . __('Status') . "</td>\n";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_peripheral`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>\n";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . __('Type') . "</td>\n";
     echo "<td>";
     PeripheralType::dropdown(array('value' => $this->fields["peripheraltypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>\n";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>\n";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>\n";
     echo "<td>";
     PeripheralModel::dropdown(array('value' => $this->fields["peripheralmodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>\n";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>\n";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "otherserial", array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>\n";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>\n";
     echo "<td>" . __('Management type') . "</td>\n";
     echo "<td>";
     Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'management_restrict' => $CFG_GLPI["peripherals_management_restrict"], 'target' => $target));
     echo "</td></tr>\n";
     // Display auto inventory informations
     $rowspan = 2;
     $inventory_show = false;
     if (!empty($ID) && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 1;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>\n";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>\n";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>\n";
     echo "<td rowspan='{$rowspan}'>\n            <textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Brand') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "brand");
     echo "</td></tr>\n";
     if ($inventory_show) {
         echo "<tr class='tab_bg_1'>";
         echo "<td rowspan='1'>" . __('Automatic inventory') . "</td>";
         echo "<td rowspan='1'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
         echo "</tr>\n";
     }
     $this->showFormButtons($options);
     return true;
 }
예제 #10
0
 /**
  * Show the central personal view
  **/
 static function showMyView()
 {
     global $DB, $CFG_GLPI;
     $showticket = Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READALL, Ticket::READASSIGN));
     $showproblem = Session::haveRightsOr('problem', array(Problem::READALL, Problem::READMY));
     echo "<table class='tab_cadre_central'>";
     Plugin::doHook('display_central');
     if (Session::haveRight("config", UPDATE)) {
         $logins = User::checkDefaultPasswords();
         $user = new User();
         if (!empty($logins)) {
             $accouts = array();
             foreach ($logins as $login) {
                 $user->getFromDBbyName($login);
                 $accounts[] = $user->getLink();
             }
             $message = sprintf(__('For security reasons, please change the password for the default users: %s'), implode(" ", $accounts));
             echo "<tr><th colspan='2'>";
             Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", $message, $message);
             echo "</th></tr>";
         }
         if (file_exists(GLPI_ROOT . "/install/install.php")) {
             echo "<tr><th colspan='2'>";
             $message = sprintf(__('For security reasons, please remove file: %s'), "install/install.php");
             Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", $message, $message);
             echo "</th></tr>";
         }
     }
     if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
         if (!DBMysql::isMySQLStrictMode()) {
             echo "<tr><th colspan='2'>";
             $message = __('MySQL strict mode is not enabled');
             Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", $message, $message);
             echo "</th></tr>";
         }
     }
     if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
         $crashedtables = DBMysql::checkForCrashedTables();
         if (!empty($crashedtables)) {
             $tables = array();
             foreach ($crashedtables as $crashedtable) {
                 $tables[] = $crashtable['table'];
             }
             echo "<tr><th colspan='2'>";
             $message = __('The following MySQL tables are marked as crashed:');
             $message .= implode(',', $tables);
             Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", $message, $message);
             echo "</th></tr>";
         }
     }
     if ($DB->isSlave() && !$DB->first_connection) {
         echo "<tr><th colspan='2'>";
         Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", __('MySQL replica: read only'), __('MySQL replica: read only'));
         echo "</th></tr>";
     }
     echo "<tr class='noHover'><td class='top' width='50%'><table class='central'>";
     echo "<tr class='noHover'><td>";
     if (Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights())) {
         Ticket::showCentralList(0, "tovalidate", false);
     }
     if ($showticket) {
         if (Ticket::isAllowedStatus(Ticket::SOLVED, Ticket::CLOSED)) {
             Ticket::showCentralList(0, "toapprove", false);
         }
         Ticket::showCentralList(0, "survey", false);
         Ticket::showCentralList(0, "rejected", false);
         Ticket::showCentralList(0, "requestbyself", false);
         Ticket::showCentralList(0, "observed", false);
         Ticket::showCentralList(0, "process", false);
         Ticket::showCentralList(0, "waiting", false);
     }
     if ($showproblem) {
         Problem::showCentralList(0, "process", false);
     }
     echo "</td></tr>";
     echo "</table></td>";
     echo "<td class='top'  width='50%'><table class='central'>";
     echo "<tr class='noHover'><td>";
     Planning::showCentral(Session::getLoginUserID());
     Reminder::showListForCentral();
     if (Session::haveRight("reminder_public", READ)) {
         Reminder::showListForCentral(false);
     }
     echo "</td></tr>";
     echo "</table></td></tr></table>";
 }
예제 #11
0
 /**
  * Print the computer form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_computer`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     ComputerType::dropdown(array('value' => $this->fields["computertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     ComputerModel::dropdown(array('value' => $this->fields["computermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     //TRANS: Number of the alternate username
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'contact_num');
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'contact');
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Network') . "</td>";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     // Display auto inventory informations
     $rowspan = 4;
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>";
     echo "<td >";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('UUID') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'uuid');
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Update Source') . "</td>";
     echo "<td >";
     AutoUpdateSystem::dropdown(array('value' => $this->fields["autoupdatesystems_id"]));
     echo "</td></tr>";
     // Display auto inventory informations
     if (!empty($ID) && Plugin::haveImport() && $this->fields["is_dynamic"]) {
         echo "<tr class='tab_bg_1'><td colspan='4'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
예제 #12
0
 /**
  * Print the networking form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  *@return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "name", array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_networkequipment`"));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     NetworkEquipmentType::dropdown(array('value' => $this->fields["networkequipmenttypes_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     NetworkEquipmentModel::dropdown(array('value' => $this->fields["networkequipmentmodels_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "otherserial", array('value' => $objectName));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Network') . "</td>";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>";
     $rowspan = 5;
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}'>\n            <textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>";
     echo "<td>";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan=2>" . __('The MAC address and the IP of the equipment are included in an aggregated network port') . "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Firmware', 'Firmwares', 1) . "</td>";
     echo "<td>";
     NetworkEquipmentFirmware::dropdown(array('value' => $this->fields["networkequipmentfirmwares_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "ram");
     echo "</td></tr>";
     // Display auto inventory informations
     if (!empty($ID) && $this->fields["is_dynamic"]) {
         echo "<tr class='tab_bg_1'><td colspan='4'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
                _e('Checking write permissions for session files');
                echo "<br>" . GLPI_SESSION_DIR;
                break;
            case 3:
                _e('Invalid use of session ID');
                break;
        }
    }
    echo "</div>";
    // Display FAQ is enable
    if ($CFG_GLPI["use_public_faq"]) {
        echo '<div id="box-faq">' . '<a href="front/helpdesk.faq.php">[ ' . __('Access to the Frequently Asked Questions') . ' ]';
        echo '</a></div>';
    }
    echo "<div id='display-login'>";
    Plugin::doHook('display_login');
    echo "</div>";
    echo "</div>";
    // end contenu login
    if (GLPI_DEMO_MODE) {
        echo "<div class='center'>";
        Event::getCountLogin();
        echo "</div>";
    }
    echo "<div id='footer-login'>";
    echo "<a href='http://glpi-project.org/' title='Powered By Teclib'>";
    echo "GLPI version " . (isset($CFG_GLPI["version"]) ? $CFG_GLPI["version"] : "") . " Copyright (C) " . "2015" . " By Teclib'. <br />" . "Copyright (C) 2003-2015 INDEPNET Development Team";
    echo "</a></div>";
}
// call cron
if (!GLPI_DEMO_MODE) {
예제 #14
0
 /**
  * Show the current ticketfollowup summary
  *
  * @param $ticket Ticket object
  **/
 function showSummary($ticket)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRightsOr(self::$rightname, array(self::SEEPUBLIC, self::SEEPRIVATE, self::ADDMYTICKET))) {
         return false;
     }
     $tID = $ticket->fields['id'];
     // Display existing Followups
     $showprivate = Session::haveRight(self::$rightname, self::SEEPRIVATE);
     $caneditall = Session::haveRight(self::$rightname, self::UPDATEALL);
     $tmp = array('tickets_id' => $tID);
     $canadd = $this->can(-1, CREATE, $tmp);
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $techs = $ticket->getAllUsers(CommonITILActor::ASSIGN);
     $reopen_case = false;
     if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray()) && $ticket->isAllowedStatus($ticket->fields['status'], Ticket::INCOMING)) {
         $reopen_case = true;
     }
     $tech = Session::haveRight(self::$rightname, self::ADDALLTICKET) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']);
     $RESTRICT = "";
     if (!$showprivate) {
         $RESTRICT = " AND (`is_private` = '0'\n                            OR `users_id` ='" . Session::getLoginUserID() . "') ";
     }
     $query = "SELECT `glpi_ticketfollowups`.*, `glpi_users`.`picture`\n                FROM `glpi_ticketfollowups`\n                LEFT JOIN `glpi_users` ON (`glpi_ticketfollowups`.`users_id` = `glpi_users`.`id`)\n                WHERE `tickets_id` = '{$tID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     $rand = mt_rand();
     if ($caneditall || $canadd) {
         echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n";
     }
     if ($canadd) {
         echo "<script type='text/javascript' >\n";
         echo "function viewAddFollowup" . $ticket->fields['id'] . "{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $ticket->fields['id'], 'id' => -1);
         Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo Html::jsHide('addbutton' . $ticket->fields['id'] . "{$rand}");
         echo "};";
         echo "</script>\n";
         // Not closed ticket or closed
         if (!in_array($ticket->fields["status"], array_merge($ticket->getSolvedStatusArray(), $ticket->getClosedStatusArray())) || $reopen_case) {
             if (isset($_GET['_openfollowup']) && $_GET['_openfollowup']) {
                 echo Html::scriptBlock("viewAddFollowup" . $ticket->fields['id'] . "{$rand}()");
             } else {
                 echo "<div id='addbutton" . $ticket->fields['id'] . "{$rand}' class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddFollowup" . $ticket->fields['id'] . "{$rand}();'>";
                 if ($reopen_case) {
                     _e('Reopen the ticket');
                 } else {
                     _e('Add a new followup');
                 }
                 echo "</a></div>\n";
             }
         }
     }
     if ($DB->numrows($result) == 0) {
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
         echo "<th class='b'>" . __('No followup for this ticket.') . "</th></tr></table>";
     } else {
         $today = strtotime('today');
         $lastmonday = strtotime('last monday');
         $lastlastmonday = strtotime('last monday', strtotime('last monday'));
         // Case of monday
         if ($today - $lastmonday == 7 * DAY_TIMESTAMP) {
             $lastlastmonday = $lastmonday;
             $lastmonday = $today;
         }
         $steps = array(0 => array('end' => $today, 'name' => __('Today')), 1 => array('end' => $lastmonday, 'name' => __('This week')), 2 => array('end' => $lastlastmonday, 'name' => __('Last week')), 3 => array('end' => strtotime('midnight first day of'), 'name' => __('This month')), 4 => array('end' => strtotime('midnight first day of last month'), 'name' => __('Last month')), 5 => array('end' => 0, 'name' => __('Before the last month')));
         $currentpos = -1;
         while ($data = $DB->fetch_assoc($result)) {
             $this->getFromDB($data['id']);
             $options = array('parent' => $ticket, 'rand' => $rand);
             Plugin::doHook('pre_show_item', array('item' => $this, 'options' => &$options));
             $data = array_merge($data, $this->fields);
             $candelete = $this->canPurge() && $this->canPurgeItem();
             $canedit = $this->canUpdate() && $this->canUpdateItem();
             $time = strtotime($data['date']);
             if (!isset($steps[$currentpos]) || $steps[$currentpos]['end'] > $time) {
                 $currentpos++;
                 while ($steps[$currentpos]['end'] > $time && isset($steps[$currentpos + 1])) {
                     $currentpos++;
                 }
                 if (isset($steps[$currentpos])) {
                     echo "<h3>" . $steps[$currentpos]['name'] . "</h3>";
                 }
             }
             $id = 'followup' . $data['id'] . $rand;
             $color = 'byuser';
             if (isset($techs[$data['users_id']])) {
                 $color = 'bytech';
             }
             $classtoadd = '';
             if ($canedit) {
                 $classtoadd = " pointer";
             }
             echo "<div class='boxnote {$color}' id='view{$id}'";
             echo ">";
             echo "<div class='boxnoteleft'>";
             echo "<img class='user_picture_verysmall' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($data['picture']) . "'>";
             echo "</div>";
             // boxnoteleft
             echo "<div class='boxnotecontent'";
             echo ">";
             echo "<div class='boxnotefloatright'>";
             $username = NOT_AVAILABLE;
             if ($data['users_id']) {
                 $username = getUserName($data['users_id'], $showuserlink);
             }
             $name = sprintf(__('Create by %1$s on %2$s'), $username, Html::convDateTime($data['date']));
             if ($data['requesttypes_id']) {
                 $name = sprintf(__('%1$s - %2$s'), $name, Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']));
             }
             if ($showprivate && $data["is_private"]) {
                 $name = sprintf(__('%1$s - %2$s'), $name, __('Private'));
             }
             echo $name;
             echo "</div>";
             // floatright
             echo "<div class='boxnotetext {$classtoadd}'";
             if ($canedit) {
                 echo " onClick=\"viewEditFollowup" . $ticket->fields['id'] . $data['id'] . "{$rand}(); " . Html::jsHide("view{$id}") . " " . Html::jsShow("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}") . "\" ";
             }
             echo ">";
             $content = nl2br($data['content']);
             if (empty($content)) {
                 $content = NOT_AVAILABLE;
             }
             echo $content . '</div>';
             // boxnotetext
             echo "</div>";
             // boxnotecontent
             echo "<div class='boxnoteright'>";
             if ($candelete) {
                 Html::showSimpleForm(Toolbox::getItemTypeFormURL('TicketFollowup'), array('purge' => 'purge'), _x('button', 'Delete permanently'), array('id' => $data['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png", '', __('Confirm the final deletion?'));
             }
             echo "</div>";
             // boxnoteright
             echo "</div>";
             // boxnote
             if ($canedit) {
                 echo "<div id='viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}' class='starthidden'></div>\n";
                 echo "\n<script type='text/javascript' >\n";
                 echo "function viewEditFollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}() {\n";
                 $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $data["tickets_id"], 'id' => $data["id"]);
                 Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                 echo "};";
                 echo "</script>\n";
             }
             Plugin::doHook('post_show_item', array('item' => $this, 'options' => $options));
         }
     }
 }
예제 #15
0
 /**
  * transfer an item to another item (may be the same) in the new entity
  *
  * @param $itemtype     item type to transfer
  * @param $ID           ID of the item to transfer
  * @param $newID        new ID of the ite
  *
  * Transfer item to a new Item if $ID==$newID : only update entities_id field :
  *                                $ID!=$new ID -> copy datas (like template system)
  * @return nothing (diplays)
  **/
 function transferItem($itemtype, $ID, $newID)
 {
     global $CFG_GLPI, $DB;
     if (!($item = getItemForItemtype($itemtype))) {
         return;
     }
     // Is already transfer ?
     if (!isset($this->already_transfer[$itemtype][$ID])) {
         // Check computer exists ?
         if ($item->getFromDB($newID)) {
             // Network connection ? keep connected / keep_disconnected / delete
             if (in_array($itemtype, array('Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'))) {
                 $this->transferNetworkLink($itemtype, $ID, $newID);
             }
             // Device : keep / delete : network case : delete if net connection delete in import case
             if (in_array($itemtype, array('Computer'))) {
                 $this->transferDevices($itemtype, $ID);
             }
             // Reservation : keep / delete
             if (in_array($itemtype, $CFG_GLPI["reservation_types"])) {
                 $this->transferReservations($itemtype, $ID, $newID);
             }
             // History : keep / delete
             $this->transferHistory($itemtype, $ID, $newID);
             // Ticket : delete / keep and clean ref / keep and move
             $this->transferTickets($itemtype, $ID, $newID);
             // Infocoms : keep / delete
             if (in_array($itemtype, $CFG_GLPI["infocom_types"])) {
                 $this->transferInfocoms($itemtype, $ID, $newID);
             }
             if ($itemtype == 'Software') {
                 $this->transferSoftwareLicensesAndVersions($ID);
             }
             // Connected item is transfered
             if (in_array($itemtype, $CFG_GLPI["directconnect_types"])) {
                 $this->manageConnectionComputer($itemtype, $ID);
             }
             // Computer Direct Connect : delete link if it is the initial transfer item (no recursion)
             if ($this->inittype == $itemtype && in_array($itemtype, array('Monitor', 'Phone', 'Peripheral', 'Printer'))) {
                 $this->deleteDirectConnection($itemtype, $ID);
             }
             // Contract : keep / delete + clean unused / keep unused
             if (in_array($itemtype, $CFG_GLPI["contract_types"])) {
                 $this->transferContracts($itemtype, $ID, $newID);
             }
             // Contact / Supplier : keep / delete + clean unused / keep unused
             if ($itemtype == 'Supplier') {
                 $this->transferSupplierContacts($ID, $newID);
             }
             // Document : keep / delete + clean unused / keep unused
             if (in_array($itemtype, $CFG_GLPI["document_types"])) {
                 $this->transferDocuments($itemtype, $ID, $newID);
             }
             // Transfer compatible printers
             if ($itemtype == 'CartridgeItem') {
                 $this->transferCompatiblePrinters($ID, $newID);
             }
             // Cartridges  and cartridges items linked to printer
             if ($itemtype == 'Printer') {
                 $this->transferPrinterCartridges($ID, $newID);
             }
             // Transfer Item
             $input = array('id' => $newID, 'entities_id' => $this->to);
             // Manage Location dropdown
             if (isset($item->fields['locations_id'])) {
                 $input['locations_id'] = $this->transferDropdownLocation($item->fields['locations_id']);
             }
             if ($itemtype == 'Ticket') {
                 $input2 = $this->transferTicketAdditionalInformations($item->fields);
                 $input = array_merge($input, $input2);
                 $this->transferTaskCategory($itemtype, $ID, $newID);
                 $this->transferLinkedSuppliers($itemtype, $ID, $newID);
             }
             if ($itemtype == 'Problem') {
                 $input2 = $this->transferTicketAdditionalInformations($item->fields);
                 $input = array_merge($input, $input2);
                 $this->transferTaskCategory($itemtype, $ID, $newID);
                 $this->transferLinkedSuppliers($itemtype, $ID, $newID);
             }
             $item->update($input);
             $this->addToAlreadyTransfer($itemtype, $ID, $newID);
             // Do it after item transfer for entity checks
             if ($itemtype == 'Computer') {
                 // Monitor Direct Connect : keep / delete + clean unused / keep unused
                 $this->transferDirectConnection($itemtype, $ID, 'Monitor');
                 // Peripheral Direct Connect : keep / delete + clean unused / keep unused
                 $this->transferDirectConnection($itemtype, $ID, 'Peripheral');
                 // Phone Direct Connect : keep / delete + clean unused / keep unused
                 $this->transferDirectConnection($itemtype, $ID, 'Phone');
                 // Printer Direct Connect : keep / delete + clean unused / keep unused
                 $this->transferDirectConnection($itemtype, $ID, 'Printer');
                 // License / Software :  keep / delete + clean unused / keep unused
                 $this->transferComputerSoftwares($ID);
                 // Computer Disks :  delete them or not ?
                 $this->transferComputerDisks($ID);
             }
             Plugin::doHook("item_transfer", array('type' => $itemtype, 'id' => $ID, 'newID' => $newID, 'entities_id' => $this->to));
         }
     }
 }
예제 #16
0
 static function cloneItem(array $param)
 {
     // Sanity check
     if (!isset($param['itemtype']) || !isset($param['id']) || !isset($param['name']) || !array_key_exists($param['itemtype'], self::$clone_types) || empty($param['name']) || !($item = getItemForItemtype($param['itemtype']))) {
         return false;
     }
     // Read original and prepare clone
     $item->check($param['id'], 'r');
     $input = ToolBox::addslashes_deep($item->fields);
     $input['name'] = $param['name'];
     $input['_add'] = 1;
     $input['_old_id'] = $input['id'];
     unset($input['id']);
     if ($item->isEntityAssign()) {
         $input['entities_id'] = $_SESSION['glpiactive_entity'];
     }
     // Manage NULL fields in original
     foreach ($input as $k => $v) {
         if (is_null($input[$k])) {
             $input[$k] = "NULL";
         }
     }
     // Specific to itemtype - before clone
     if (method_exists(self::$clone_types[$param['itemtype']], 'preClone')) {
         $input = call_user_func(array(self::$clone_types[$param['itemtype']], 'preClone'), $item, $input);
     }
     // Clone
     $clone = clone $item;
     $clone->check(-1, 'w', $input);
     $new = $clone->add($input);
     // Specific to itemtype - after clone
     if (method_exists(self::$clone_types[$param['itemtype']], 'postClone')) {
         call_user_func(array(self::$clone_types[$param['itemtype']], 'postClone'), $clone, $param['id']);
     }
     Plugin::doHook('item_clone', $clone);
     // History
     if ($clone->dohistory) {
         $changes[0] = '0';
         $changes[1] = '';
         $changes[2] = addslashes(sprintf(__('%1$s %2$s'), __('Clone of', 'behaviors'), $item->getNameID(0, true)));
         Log::history($clone->getID(), $clone->getType(), $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
     }
 }
 function showMethods()
 {
     global $WEBSERVICES_METHOD, $CFG_GLPI;
     echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='4'>" . __('Method list - defined and allowed by this rule', 'webservices') . "</th></tr>";
     echo "<tr><th>" . __('Method name', 'webservices') . "</th>" . "<th>" . __('Provider plugin', 'webservices') . "</th>" . "<th>" . __('Internal function name', 'webservices') . "</th>" . "<th>" . __('Function is available', 'webservices') . "</th></tr>";
     // Allow all plugins to register their methods
     $WEBSERVICES_METHOD = array();
     Plugin::doHook("webservices");
     foreach ($WEBSERVICES_METHOD as $method => $function) {
         // Display if MySQL REGEXP match
         if (countElementsInTable($this->getTable(), "ID='" . $this->fields['id'] . "' AND '" . addslashes($method) . "' REGEXP pattern") > 0) {
             $result = $function;
             if (is_array($function)) {
                 if ($tmp = isPluginItemType($function[0])) {
                     $plugin = $tmp['plugin'];
                 } else {
                     $plugin = "&nbsp;";
                 }
                 $result = implode('::', $function);
             } else {
                 if (preg_match('/^plugin_(.*)_method/', $function, $res)) {
                     $plugin = $res[1];
                 } else {
                     $plugin = "&nbsp;";
                 }
             }
             $call = is_callable($function) ? __('Yes') : __('No');
             $color = is_callable($function) ? "greenbutton" : "redbutton";
             echo "<tr class='tab_bg_1'><td class='b'>{$method}</td><td>{$plugin}</td>" . "<td>{$result}</td><td class='center'>" . "<img src=\"" . $CFG_GLPI['root_doc'] . "/pics/{$color}.png\" alt='ok'>&nbsp;{$call}</td></tr>";
         }
     }
     echo "</table></div>";
 }
예제 #18
0
 /**
  * Change active profile to the $ID one. Update glpiactiveprofile session variable.
  *
  * @param $ID : ID of the new profile
  *
  * @return Nothing
  **/
 static function changeProfile($ID)
 {
     if (isset($_SESSION['glpiprofiles'][$ID]) && count($_SESSION['glpiprofiles'][$ID]['entities'])) {
         $profile = new Profile();
         if ($profile->getFromDB($ID)) {
             $profile->cleanProfile();
             $data = $profile->fields;
             $data['entities'] = $_SESSION['glpiprofiles'][$ID]['entities'];
             $_SESSION['glpiactiveprofile'] = $data;
             $_SESSION['glpiactiveentities'] = array();
             Search::resetSaveSearch();
             $active_entity_done = false;
             // Try to load default entity if it is a root entity
             foreach ($data['entities'] as $key => $val) {
                 if ($val['id'] == $_SESSION["glpidefault_entity"]) {
                     if (self::changeActiveEntities($val['id'], $val['is_recursive'])) {
                         $active_entity_done = true;
                     }
                 }
             }
             if (!$active_entity_done) {
                 // Try to load default entity
                 if (!self::changeActiveEntities($_SESSION["glpidefault_entity"], true)) {
                     // Load all entities
                     self::changeActiveEntities("all");
                 }
             }
             Plugin::doHook("change_profile");
         }
     }
     // Clean specific datas
     if (isset($_SESSION['glpimenu'])) {
         unset($_SESSION['glpimenu']);
     }
     if (isset($_SESSION['glpi_faqcategories'])) {
         unset($_SESSION['glpi_faqcategories']);
     }
 }
예제 #19
0
 /**
  * Show the current task sumnary
  *
  * @param $item   CommonITILObject
  **/
 function showSummary(CommonITILObject $item)
 {
     global $DB, $CFG_GLPI;
     if (!static::canView()) {
         return false;
     }
     $tID = $item->fields['id'];
     // Display existing Followups
     $showprivate = $this->canViewPrivates();
     $caneditall = $this->canEditAll();
     $tmp = array($item->getForeignKeyField() => $tID);
     $canadd = $this->can(-1, CREATE, $tmp);
     $canpurge = $this->canPurgeItem();
     $canview = $this->canViewItem();
     $RESTRICT = "";
     if ($this->maybePrivate() && !$showprivate) {
         $RESTRICT = " AND (`is_private` = '0'\n                            OR `users_id` ='" . Session::getLoginUserID() . "'\n                            OR `users_id_tech` ='" . Session::getLoginUserID() . "'\n                            OR `groups_id_tech` IN ('" . implode("','", $_SESSION["glpigroups"]) . "')) ";
     }
     $query = "SELECT `id`, `date`\n                FROM `" . $this->getTable() . "`\n                WHERE `" . $item->getForeignKeyField() . "` = '{$tID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     $rand = mt_rand();
     if ($caneditall || $canadd || $canpurge) {
         echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n";
     }
     if ($canadd) {
         echo "<script type='text/javascript' >\n";
         echo "function viewAddTask" . $item->fields['id'] . "{$rand}() {\n";
         $params = array('type' => $this->getType(), 'parenttype' => $item->getType(), $item->getForeignKeyField() => $item->fields['id'], 'id' => -1);
         Ajax::updateItemJsCode("viewfollowup" . $item->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo Html::jsHide('addbutton' . $item->fields['id'] . "{$rand}");
         echo "};";
         echo "</script>\n";
         if (!in_array($item->fields["status"], array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray()))) {
             echo "<div id='addbutton" . $item->fields['id'] . "{$rand}' class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddTask" . $item->fields['id'] . "{$rand}();'>";
             echo __('Add a new task') . "</a></div>\n";
         }
     }
     if ($DB->numrows($result) == 0) {
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'><th>" . __('No task found.');
         echo "</th></tr></table>";
     } else {
         echo "<table class='tab_cadre_fixehov'>";
         $header = "<tr><th>&nbsp;</th><th>" . __('Type') . "</th><th>" . __('Date') . "</th>";
         $header .= "<th>" . __('Description') . "</th><th>" . __('Duration') . "</th>";
         $header .= "<th>" . __('Writer') . "</th>";
         if ($this->maybePrivate() && $showprivate) {
             $header .= "<th>" . __('Private') . "</th>";
         }
         $header .= "<th>" . __('Planning') . "</th></tr>\n";
         echo $header;
         while ($data = $DB->fetch_assoc($result)) {
             if ($this->getFromDB($data['id'])) {
                 $options = array('parent' => $item, 'rand' => $rand, 'showprivate' => $showprivate);
                 Plugin::doHook('pre_show_item', array('item' => $this, 'options' => &$options));
                 $this->showInObjectSumnary($item, $rand, $showprivate);
                 Plugin::doHook('post_show_item', array('item' => $this, 'options' => $options));
             }
         }
         echo $header;
         echo "</table>";
     }
 }
예제 #20
0
                                                         $newID = $_POST["id"];
                                                     } else {
                                                         echo "<div align='center'><b><span class='plugin_resources_date_over_color'>" . __('Failed to send the file (probably too large)') . "</span></b></div><br \\>";
                                                     }
                                                 } else {
                                                     echo "<div align='center'><b><span class='plugin_resources_date_over_color'>" . __('Invalid filename') . " : " . $_FILES['picture']['type'] . "</span></b></div><br \\>";
                                                 }
                                             }
                                             $values = array();
                                             $values['target'] = Toolbox::getItemTypeFormURL('PluginResourcesWizard');
                                             $resource->wizardFiveForm($_POST["plugin_resources_resources_id"], $values);
                                         } else {
                                             if (isset($_POST["five_step"])) {
                                                 $resource->fields['plugin_resources_resources_id'] = $_POST['plugin_resources_resources_id'];
                                                 $resource->fields['resources_step'] = 'five_step';
                                                 Plugin::doHook('item_show', $resource);
                                                 $resource->redirectToList();
                                             } else {
                                                 $resource->wizardFirstForm();
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #21
0
@package   Webservices
@author    Nelly Mahu-Lasson
@copyright Copyright (c) 2009-2014 Webservices plugin team
@license   AGPL License 3.0 or (at your option) any later version
           http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link      https://forge.indepnet.net/projects/webservices
@link      http://www.glpi-project.org/
@since     2009
--------------------------------------------------------------------------
*/
if (!extension_loaded("soap")) {
    header("HTTP/1.0 500 Extension soap not loaded");
    die("Extension soap not loaded");
}
ini_set("soap.wsdl_cache_enabled", "0");
define('DO_NOT_CHECK_HTTP_REFERER', 1);
include "../../inc/includes.php";
Plugin::load('webservices', true);
Plugin::doHook("webservices");
plugin_webservices_registerMethods();
error_reporting(E_ALL);
try {
    $server = new SoapServer(null, array('uri' => ''));
    $server->setclass('PluginWebservicesSoap');
} catch (Exception $e) {
    echo $e;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $server->handle();
}
예제 #22
0
 /**
  * @param $event
  * @param $options
  **/
 function &getForTemplate($event, $options)
 {
     global $CFG_GLPI;
     $this->datas = array();
     $this->addTagToList(array('tag' => 'glpi.url', 'value' => $CFG_GLPI['root_doc'], 'label' => __('URL of the application')));
     $this->getDatasForTemplate($event, $options);
     Plugin::doHook('item_get_datas', $this);
     return $this->datas;
 }
예제 #23
0
 /**
  * Print the printer form
  *
  * @param $ID        integer ID of the item
  * @param $options   array of possible options:
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  *@return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $target = $this->getFormURL();
     $withtemplate = $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>\n";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>\n";
     echo "<td>" . __('Status') . "</td>\n";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_printer`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>\n";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . __('Type') . "</td>\n";
     echo "<td>";
     PrinterType::dropdown(array('value' => $this->fields["printertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>\n";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . __('Manufacturer') . "</td>\n";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>\n";
     echo "<td>";
     PrinterModel::dropdown(array('value' => $this->fields["printermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>\n";
     echo "<td>" . __('Serial number') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>\n";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>\n";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>\n";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>\n";
     echo "<td>" . __('Management type') . "</td>";
     echo "<td>";
     $globalitem = array();
     $globalitem['withtemplate'] = $withtemplate;
     $globalitem['value'] = $this->fields["is_global"];
     $globalitem['target'] = $target;
     if ($this->can($ID, UPDATE)) {
         $globalitem['management_restrict'] = $CFG_GLPI["printers_management_restrict"];
     }
     Dropdown::showGlobalSwitch($this->fields["id"], $globalitem);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>\n";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>\n";
     echo "<td>" . __('Network') . "</td>\n";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     // Display auto inventory informations
     $rowspan = 6;
     $inventory_show = false;
     if (!empty($ID) && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 2;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>\n";
     echo "<td>";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>\n";
     echo "<td rowspan='{$rowspan}'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Memory') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "memory_size");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Initial page counter') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "init_pages_counter", array('size' => 10));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Current counter of pages') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "last_pages_counter", array('size' => 10));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Port', 'Ports', Session::getPluralNumber()) . "</td>";
     echo "<td>\n<table>";
     // serial interface
     echo "<tr><td>" . __('Serial') . "</td><td width='80'>";
     Dropdown::showYesNo("have_serial", $this->fields["have_serial"]);
     echo "</td>";
     // parallel interface?
     echo "<td>" . __('Parallel') . "</td><td width='80'>";
     Dropdown::showYesNo("have_parallel", $this->fields["have_parallel"]);
     echo "</td></tr>";
     // USB interface?
     echo "<tr><td>" . __('USB') . "</td><td>";
     Dropdown::showYesNo("have_usb", $this->fields["have_usb"]);
     echo "</td>";
     // ethernet interface?
     echo "<td>" . __('Ethernet') . "</td><td>";
     Dropdown::showYesNo("have_ethernet", $this->fields["have_ethernet"]);
     echo "</td></tr>";
     // wifi ?
     echo "<tr><td>" . __('Wifi') . "</td><td colspan='3'>";
     Dropdown::showYesNo("have_wifi", $this->fields["have_wifi"]);
     echo "</td></tr></table>\n";
     echo "</td>";
     if ($inventory_show) {
         echo "<td rowspan='2'>" . __('Automatic inventory') . "</td>";
         echo "<td rowspan='2'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of insertion
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
예제 #24
0
 /**
  * Display form for antivirus
  *
  * @param $ID                id of the antivirus
  * @param $options array
  *
  * @return bool TRUE if form is ok
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("computer", UPDATE)) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, READ);
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $this->check(-1, CREATE, $options);
         $comp->getFromDB($options['computers_id']);
     }
     $this->showFormHeader($options);
     if ($this->isNewID($ID)) {
         echo "<input type='hidden' name='computers_id' value='" . $options['computers_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Computer') . "</td>";
     echo "<td>" . $comp->getLink() . "</td>";
     if (Plugin::haveImport()) {
         echo "<td>" . __('Automatic inventory') . "</td>";
         echo "<td>";
         if ($ID && $this->fields['is_dynamic']) {
             Plugin::doHook("autoinventory_information", $this);
         } else {
             _e('No');
         }
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Active') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td>";
     echo "<td>" . __('Up to date') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_uptodate', $this->fields['is_uptodate']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Antivirus version') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "antivirus_version");
     echo "</td>";
     echo "<td>" . __('Signature database version') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "signature_version");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration date') . "</td>";
     echo "<td>";
     Html::showDateField("date_expiration", array('value' => $this->fields['date_expiration']));
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Print the version form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - computers_id ID of the computer for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("computer", UPDATE)) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, READ);
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $this->check(-1, CREATE, $options);
         $comp->getFromDB($options['computers_id']);
     }
     $this->showFormHeader($options);
     if ($this->isNewID($ID)) {
         echo "<input type='hidden' name='computers_id' value='" . $options['computers_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Computer') . "</td>";
     echo "<td>" . $comp->getLink() . "</td>";
     if (Plugin::haveImport()) {
         echo "<td>" . __('Automatic inventory') . "</td>";
         echo "<td>";
         if ($ID && $this->fields['is_dynamic']) {
             Plugin::doHook("autoinventory_information", $this);
         } else {
             _e('No');
         }
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td><td>" . __('Partition') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "device");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Mount point') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "mountpoint");
     echo "</td><td>" . __('File system') . "</td>";
     echo "<td>";
     FileSystem::dropdown(array('value' => $this->fields["filesystems_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Global size') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "totalsize");
     echo "&nbsp;" . __('Mio') . "</td>";
     echo "<td>" . __('Free size') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "freesize");
     echo "&nbsp;" . __('Mio') . "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
예제 #26
0
 /**
  * @since version 0.90
  *
  * @param $options   array
  *
  * @return boolean
  **/
 function showPrimaryForm($options = array())
 {
     if (!method_exists($this, "showForm")) {
         return false;
     }
     $ong = $this->defineAllTabs();
     $class = "main_form";
     if (count($ong) == 0) {
         $class .= " no_tab";
     }
     if (!isset($_GET['id']) || $_GET['id'] <= 0 && !$this instanceof Entity) {
         $class .= " create_form";
     } else {
         $class .= " modify_form";
     }
     echo "<div class='form_content'>";
     echo "<div class='{$class}'>";
     Plugin::doHook('pre_show_item', array('item' => $this, 'options' => &$options));
     $this->showForm($options['id'], $options);
     Plugin::doHook('post_show_item', array('item' => $this, 'options' => $options));
     echo "</div>";
     echo "</div>";
 }
예제 #27
0
 /**
  * Print the computer form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_computer`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     ComputerType::dropdown(array('value' => $this->fields["computertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     ComputerModel::dropdown(array('value' => $this->fields["computermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     //TRANS: Number of the alternate username
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'contact_num');
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'contact');
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Network') . "</td>";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     // Display auto inventory informations
     $rowspan = 10;
     $inventory_show = false;
     if (!empty($ID) && Plugin::haveImport() && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 4;
     }
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>";
     echo "<td >";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Operating system') . "</td>";
     echo "<td>";
     OperatingSystem::dropdown(array('value' => $this->fields["operatingsystems_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Service pack') . "</td>";
     echo "<td >";
     OperatingSystemServicePack::dropdown(array('value' => $this->fields["operatingsystemservicepacks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version of the operating system') . "</td>";
     echo "<td >";
     OperatingSystemVersion::dropdown(array('value' => $this->fields["operatingsystemversions_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Product ID of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_licenseid');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Serial of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_license_number');
     echo "</td>";
     if ($inventory_show) {
         echo "<td rowspan='4' colspan='2'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('UUID') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'uuid');
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of update
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Update Source') . "</td>";
     echo "<td >";
     AutoUpdateSystem::dropdown(array('value' => $this->fields["autoupdatesystems_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
예제 #28
0
 /**
  * Process the rule
  *
  * @param &$input          the input data used to check criterias
  * @param &$output         the initial ouput array used to be manipulate by actions
  * @param &$params         parameters for all internal functions
  * @param &options   array options:
  *                     - only_criteria : only react on specific criteria
  *
  * @return the output array updated by actions.
  *         If rule matched add field _rule_process to return value
  **/
 function process(&$input, &$output, &$params, &$options = array())
 {
     if ($this->validateCriterias($options)) {
         $this->regex_results = array();
         $this->criterias_results = array();
         $input = $this->prepareInputDataForProcess($input, $params);
         if ($this->checkCriterias($input)) {
             unset($output["_no_rule_matches"]);
             $refoutput = $output;
             $output = $this->executeActions($output, $params);
             $this->updateOnlyCriteria($options, $refoutput, $output);
             //Hook
             $hook_params["sub_type"] = $this->getType();
             $hook_params["ruleid"] = $this->fields["id"];
             $hook_params["input"] = $input;
             $hook_params["output"] = $output;
             Plugin::doHook("rule_matched", $hook_params);
             $output["_rule_process"] = true;
         }
     }
 }
 /**
  * Print the phone form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $target = $this->getFormURL();
     $withtemplate = $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_phone`='1'"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     PhoneType::dropdown(array('value' => $this->fields["phonetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     PhoneModel::dropdown(array('value' => $this->fields["phonemodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td><td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Management type') . "</td>";
     echo "<td>";
     Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'management_restrict' => $CFG_GLPI["phones_management_restrict"], 'target' => $target));
     echo "</td></tr>\n";
     // Display auto inventory informations
     $rowspan = 7;
     $inventory_show = false;
     if (!empty($ID) && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 2;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}'>\n            <textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' class='form-control' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Brand') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "brand");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Power supply') . "</td>";
     echo "<td>";
     PhonePowerSupply::dropdown(array('value' => $this->fields["phonepowersupplies_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Firmware', 'Firmwares', 1) . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "firmware");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('quantity', 'Number of lines') . "</td><td>";
     Html::autocompletionTextField($this, "number_line");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Flags') . "</td>";
     echo "<td>";
     // micro?
     echo "\n<table><tr><td>" . __('Headset') . "</td>";
     echo "<td>&nbsp;";
     Dropdown::showYesNo("have_headset", $this->fields["have_headset"]);
     echo "</td></tr>";
     // hp?
     echo "<tr><td>" . __('Speaker') . "</td>";
     echo "<td>&nbsp;";
     Dropdown::showYesNo("have_hp", $this->fields["have_hp"]);
     echo "</td></tr></table>\n";
     echo "</td>";
     if ($inventory_show) {
         echo "<td rowspan='2'>" . __('Automatic inventory') . "</td>";
         echo "<td rowspan='2'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of insertion
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
예제 #30
0
/**
 * Return all types that can be injected using datainjection
 *
 * @return an array of injection class => plugin
 */
function getTypesToInject()
{
    global $INJECTABLE_TYPES, $PLUGIN_HOOKS;
    if (count($INJECTABLE_TYPES)) {
        // already populated
        return;
    }
    $INJECTABLE_TYPES = array('PluginDatainjectionCartridgeItemInjection' => 'datainjection', 'PluginDatainjectionBudgetInjection' => 'datainjection', 'PluginDatainjectionComputerInjection' => 'datainjection', 'PluginDatainjectionComputer_ItemInjection' => 'datainjection', 'PluginDatainjectionConsumableItemInjection' => 'datainjection', 'PluginDatainjectionContactInjection' => 'datainjection', 'PluginDatainjectionContact_SupplierInjection' => 'datainjection', 'PluginDatainjectionContractInjection' => 'datainjection', 'PluginDatainjectionContract_ItemInjection' => 'datainjection', 'PluginDatainjectionContract_SupplierInjection' => 'datainjection', 'PluginDatainjectionEntityInjection' => 'datainjection', 'PluginDatainjectionGroupInjection' => 'datainjection', 'PluginDatainjectionGroup_UserInjection' => 'datainjection', 'PluginDatainjectionInfocomInjection' => 'datainjection', 'PluginDatainjectionLocationInjection' => 'datainjection', 'PluginDatainjectionStateInjection' => 'datainjection', 'PluginDatainjectionManufacturerInjection' => 'datainjection', 'PluginDatainjectionMonitorInjection' => 'datainjection', 'PluginDatainjectionNetworkequipmentInjection' => 'datainjection', 'PluginDatainjectionPeripheralInjection' => 'datainjection', 'PluginDatainjectionPhoneInjection' => 'datainjection', 'PluginDatainjectionPrinterInjection' => 'datainjection', 'PluginDatainjectionProfileInjection' => 'datainjection', 'PluginDatainjectionProfile_UserInjection' => 'datainjection', 'PluginDatainjectionSoftwareInjection' => 'datainjection', 'PluginDatainjectionComputer_SoftwareVersionInjection' => 'datainjection', 'PluginDatainjectionComputer_SoftwareLicenseInjection' => 'datainjection', 'PluginDatainjectionSoftwareLicenseInjection' => 'datainjection', 'PluginDatainjectionSoftwareVersionInjection' => 'datainjection', 'PluginDatainjectionSupplierInjection' => 'datainjection', 'PluginDatainjectionUserInjection' => 'datainjection', 'PluginDatainjectionNetworkportInjection' => 'datainjection', 'PluginDatainjectionVlanInjection' => 'datainjection', 'PluginDatainjectionNetworkport_VlanInjection' => 'datainjection', 'PluginDatainjectionNetworkNameInjection' => 'datainjection', 'PluginDatainjectionNetpointInjection' => 'datainjection', 'PluginDatainjectionKnowbaseItemCategoryInjection' => 'datainjection', 'PluginDatainjectionKnowbaseItemInjection' => 'datainjection', 'PluginDatainjectionITILCategoryInjection' => 'datainjection', 'PluginDatainjectionTaskCategoryInjection' => 'datainjection', 'PluginDatainjectionSolutionTypeInjection' => 'datainjection', 'PluginDatainjectionRequestTypeInjection' => 'datainjection', 'PluginDatainjectionSolutionTemplateInjection' => 'datainjection', 'PluginDatainjectionComputerTypeInjection' => 'datainjection', 'PluginDatainjectionMonitorTypeInjection' => 'datainjection', 'PluginDatainjectionNetworkEquipmentTypeInjection' => 'datainjection', 'PluginDatainjectionPeripheralTypeInjection' => 'datainjection', 'PluginDatainjectionPrinterTypeInjection' => 'datainjection', 'PluginDatainjectionPhoneTypeInjection' => 'datainjection', 'PluginDatainjectionSoftwareLicenseTypeInjection' => 'datainjection', 'PluginDatainjectionContractTypeInjection' => 'datainjection', 'PluginDatainjectionContactTypeInjection' => 'datainjection', 'PluginDatainjectionSupplierTypeInjection' => 'datainjection', 'PluginDatainjectionDeviceMemoryTypeInjection' => 'datainjection', 'PluginDatainjectionInterfaceTypeInjection' => 'datainjection', 'PluginDatainjectionPhonePowerSupplyTypeInjection' => 'datainjection', 'PluginDatainjectionFilesystemTypeInjection' => 'datainjection', 'PluginDatainjectionComputerModelInjection' => 'datainjection', 'PluginDatainjectionMonitorModelInjection' => 'datainjection', 'PluginDatainjectionPhoneModelInjection' => 'datainjection', 'PluginDatainjectionPrinterModelInjection' => 'datainjection', 'PluginDatainjectionPeripheralModelInjection' => 'datainjection', 'PluginDatainjectionNetworkEquipmentModelInjection' => 'datainjection', 'PluginDatainjectionNetworkEquipmentFirmwareInjection' => 'datainjection', 'PluginDatainjectionVirtualMachineTypeInjection' => 'datainjection', 'PluginDatainjectionVirtualMachineSystemInjection' => 'datainjection', 'PluginDatainjectionVirtualMachineStateInjection' => 'datainjection', 'PluginDatainjectionDocumentTypeInjection' => 'datainjection', 'PluginDatainjectionAutoUpdateSystemInjection' => 'datainjection', 'PluginDatainjectionOperatingSystemInjection' => 'datainjection', 'PluginDatainjectionOperatingSystemVersionInjection' => 'datainjection', 'PluginDatainjectionOperatingSystemServicePackInjection' => 'datainjection', 'PluginDatainjectionNetworkInterfaceInjection' => 'datainjection', 'PluginDatainjectionDomainInjection' => 'datainjection', 'PluginDatainjectionNetworkInjection' => 'datainjection', 'PluginDatainjectionDeviceCaseInjection' => 'datainjection', 'PluginDatainjectionDeviceCaseTypeInjection' => 'datainjection', 'PluginDatainjectionDeviceControlInjection' => 'datainjection', 'PluginDatainjectionDeviceProcessorInjection' => 'datainjection', 'PluginDatainjectionDeviceMemoryInjection' => 'datainjection', 'PluginDatainjectionDeviceHardDriveInjection' => 'datainjection', 'PluginDatainjectionDeviceMotherboardInjection' => 'datainjection', 'PluginDatainjectionDeviceDriveInjection' => 'datainjection', 'PluginDatainjectionDeviceNetworkCardInjection' => 'datainjection');
    //Add plugins
    Plugin::doHook('plugin_datainjection_populate');
}