Ejemplo n.º 1
0
 /**
  * Include common HTML headers
  *
  * @param $title title used for the page (default '')
  *
  * @return nothing
  **/
 static function includeHeader($title = '')
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // Send UTF8 Headers
     header("Content-Type: text/html; charset=UTF-8");
     // Allow only frame from same server to prevent click-jacking
     header('x-frame-options:SAMEORIGIN');
     // Send extra expires header
     self::header_nocache();
     // Start the page
     echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n             \"http://www.w3.org/TR/html4/loose.dtd\">";
     echo "\n<html><head><title>GLPI - " . $title . "</title>";
     echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";
     // Send extra expires header
     echo "<meta http-equiv='Expires' content='Fri, Jun 12 1981 08:20:00 GMT'>\n";
     echo "<meta http-equiv='Pragma' content='no-cache'>\n";
     echo "<meta http-equiv='Cache-Control' content='no-cache'>\n";
     echo "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n";
     // auto desktop / mobile viewport
     echo "<meta name='viewport' content='width=device-width, initial-scale=1'>";
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jquery/css/smoothness/jquery-ui-1.10.4.custom.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/css/jstree/style.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/rateit/rateit.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/select2/select2.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/qtip2/jquery.qtip.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jcrop/jquery.Jcrop.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/spectrum-colorpicker/spectrum.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-gantt/css/style.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/css/jquery-glpi.css");
     //  CSS link
     echo Html::css($CFG_GLPI["root_doc"] . "/css/styles.css");
     // CSS theme link
     if (isset($_SESSION["glpipalette"])) {
         echo Html::css($CFG_GLPI["root_doc"] . "/css/palettes/" . $_SESSION["glpipalette"] . ".css");
     }
     // surcharge CSS hack for IE
     echo "<!--[if lte IE 6]>";
     echo Html::css($CFG_GLPI["root_doc"] . "/css/styles_ie.css");
     echo "<![endif]-->";
     echo Html::css($CFG_GLPI["root_doc"] . "/css/print.css", array('media' => 'print'));
     echo "<link rel='shortcut icon' type='images/x-icon' href='" . $CFG_GLPI["root_doc"] . "/pics/favicon.ico' >\n";
     // Add specific css for plugins
     if (isset($PLUGIN_HOOKS['add_css']) && count($PLUGIN_HOOKS['add_css'])) {
         foreach ($PLUGIN_HOOKS["add_css"] as $plugin => $files) {
             if (is_array($files)) {
                 foreach ($files as $file) {
                     if (file_exists(GLPI_ROOT . "/plugins/{$plugin}/{$file}")) {
                         echo Html::css($CFG_GLPI["root_doc"] . "/plugins/{$plugin}/{$file}");
                     }
                 }
             } else {
                 if (file_exists(GLPI_ROOT . "/plugins/{$plugin}/{$files}")) {
                     echo Html::css($CFG_GLPI["root_doc"] . "/plugins/{$plugin}/{$files}");
                 }
             }
         }
     }
     // AJAX library
     if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/js/jquery-1.10.2.js");
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/js/jquery-ui-1.10.4.custom.js");
     } else {
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/js/jquery-1.10.2.min.js");
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/js/jquery-ui-1.10.4.custom.min.js");
     }
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/tiny_mce/tiny_mce.js");
     // PLugins jquery
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/backtotop/BackToTop.min.jquery.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/select2/select2.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/qtip2/jquery.qtip.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jstree/jquery.jstree.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/rateit/jquery.rateit.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-file-upload/js/jquery.iframe-transport.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-file-upload/js/jquery.fileupload.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jcrop/jquery.Jcrop.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/imagepaste/jquery.image_paste.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/spectrum-colorpicker/spectrum-min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-gantt/js/jquery.fn.gantt.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/autogrow/jquery.autogrow-textarea.js");
     // layout
     if (CommonGLPI::isLayoutWithMain() && !CommonGLPI::isLayoutExcludedPage()) {
         echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-ui-scrollable-tabs/css/jquery.scrollabletab.css");
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-ui-scrollable-tabs/js/jquery.mousewheel.js");
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-ui-scrollable-tabs/js/jquery.scrollabletab.js");
     }
     if (isset($_SESSION['glpilanguage'])) {
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/i18n/jquery.ui.datepicker-" . $CFG_GLPI["languages"][$_SESSION['glpilanguage']][2] . ".js");
         $filename = "/lib/jqueryplugins/jquery-ui-timepicker-addon/i18n/jquery-ui-timepicker-" . $CFG_GLPI["languages"][$_SESSION['glpilanguage']][2] . ".js";
         if (file_exists(GLPI_ROOT . $filename)) {
             echo Html::script($CFG_GLPI["root_doc"] . $filename);
         }
         $filename = "/lib/jqueryplugins/select2/select2_locale_" . $CFG_GLPI["languages"][$_SESSION['glpilanguage']][2] . ".js";
         if (file_exists(GLPI_ROOT . $filename)) {
             echo Html::script($CFG_GLPI["root_doc"] . $filename);
         }
     }
     // Some Javascript-Functions which we may need later
     echo Html::script($CFG_GLPI["root_doc"] . '/script.js');
     // Add specific javascript for plugins
     if (isset($PLUGIN_HOOKS['add_javascript']) && count($PLUGIN_HOOKS['add_javascript'])) {
         foreach ($PLUGIN_HOOKS["add_javascript"] as $plugin => $files) {
             if (is_array($files)) {
                 foreach ($files as $file) {
                     if (file_exists(GLPI_ROOT . "/plugins/{$plugin}/{$file}")) {
                         echo Html::script($CFG_GLPI["root_doc"] . "/plugins/{$plugin}/{$file}");
                     }
                 }
             } else {
                 if (file_exists(GLPI_ROOT . "/plugins/{$plugin}/{$files}")) {
                     echo Html::script($CFG_GLPI["root_doc"] . "/plugins/{$plugin}/{$files}");
                 }
             }
         }
     }
     // End of Head
     echo "</head>\n";
 }
Ejemplo n.º 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>";
 }
Ejemplo n.º 3
0
 /**
  *  Create Ajax Tabs apply to 'tabspanel' div. Content is displayed in 'tabcontent'
  *
  * @param $tabdiv_id                ID of the div containing the tabs (default 'tabspanel')
  * @param $tabdivcontent_id         ID of the div containing the content loaded by tabs
  *                                  (default 'tabcontent')
  * @param $tabs               array of tabs to create :
  *                                  tabs is array('key' => array('title'=> 'x',
  *                                                                url    => 'url_toload',
  *                                                                params => 'url_params')...
  * @param $type                     itemtype for active tab
  * @param $ID                       ID of element for active tab (default 0)
  * @param $orientation              orientation of tabs (default vertical may also be horizontal)
  *
  * @return nothing
  **/
 static function createTabs($tabdiv_id = 'tabspanel', $tabdivcontent_id = 'tabcontent', $tabs = array(), $type, $ID = 0, $orientation = 'vertical')
 {
     global $CFG_GLPI;
     /// TODO need to clean params !!
     $active_tabs = Session::getActiveTab($type);
     $rand = mt_rand();
     if (count($tabs) > 0) {
         echo "<div id='tabs{$rand}' class='center {$orientation}'>";
         if (CommonGLPI::isLayoutWithMain() && !CommonGLPI::isLayoutExcludedPage()) {
             $orientation = 'horizontal';
         }
         echo "<ul>";
         $current = 0;
         $selected_tab = 0;
         foreach ($tabs as $key => $val) {
             if ($key == $active_tabs) {
                 $selected_tab = $current;
             }
             echo "<li><a title=\"" . str_replace(array("<sup class='tab_nb'>", '</sup>'), '', $val['title']) . "\" ";
             echo " href='" . $val['url'] . (isset($val['params']) ? '?' . $val['params'] : '') . "'>";
             // extract sup information
             // $title = '';
             // $limit = 16;
             // No title strip for horizontal menu
             $title = $val['title'];
             echo $title . "</a></li>";
             $current++;
         }
         echo "</ul>";
         echo "</div>";
         echo "<div id='loadingtabs{$rand}' class='invisible'>" . "<div class='loadingindicator'>" . __s('Loading...') . "</div></div>";
         $js = "\n         forceReload{$rand} = false;\n         \$('#tabs{$rand}').tabs({\n            active: {$selected_tab},\n            // Loading indicator\n            beforeLoad: function (event, ui) {\n               if (\$(ui.panel).html()\n                   && !forceReload{$rand}) {\n                  event.preventDefault();\n               } else {\n                  ui.panel.html(\$('#loadingtabs{$rand}').html());\n                  forceReload{$rand} = false;\n                }\n            },\n            ajaxOptions: {type: 'POST'},\n            activate : function( event, ui ) {\n               // Get future value\n               var newIndex = ui.newTab.parent().children().index(ui.newTab);\n               \$.get('" . $CFG_GLPI['root_doc'] . "/ajax/updatecurrenttab.php',\n                  { itemtype: '{$type}', id: '{$ID}', tab: newIndex });\n            }\n         });";
         if ($orientation == 'vertical') {
             $js .= "\$('#tabs{$rand}').tabs().addClass( 'ui-tabs-vertical ui-helper-clearfix' );";
         }
         if (CommonGLPI::isLayoutWithMain() && !CommonGLPI::isLayoutExcludedPage()) {
             $js .= "\$('#tabs{$rand}').scrollabletabs();";
         } else {
             $js .= "\$('#tabs{$rand}').removeClass( 'ui-corner-top' ).addClass( 'ui-corner-left' );";
         }
         $js .= "// force reload\n            function reloadTab(add) {\n               forceReload{$rand} = true;\n               var current_index = \$('#tabs{$rand}').tabs('option','active');\n               // Save tab\n               currenthref = \$('#tabs{$rand} ul>li a').eq(current_index).attr('href');\n               \$('#tabs{$rand} ul>li a').eq(current_index).attr('href',currenthref+'&'+add);\n               \$('#tabs{$rand}').tabs( 'load' , current_index);\n               // Restore tab\n               \$('#tabs{$rand} ul>li a').eq(current_index).attr('href',currenthref);\n            };";
         echo Html::scriptBlock($js);
     }
 }
Ejemplo n.º 4
0
 /**
  * Include common HTML headers
  *
  * @param $title title used for the page (default '')
  *
  * @return nothing
  **/
 static function includeHeader($title = '')
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // complete title with id if exist
     if (isset($_GET['id']) && $_GET['id']) {
         $title = sprintf(__('%1$s - %2$s'), $title, $_GET['id']);
     }
     // Send UTF8 Headers
     header("Content-Type: text/html; charset=UTF-8");
     // Allow only frame from same server to prevent click-jacking
     header('x-frame-options:SAMEORIGIN');
     // Send extra expires header
     self::header_nocache();
     // Start the page
     echo "<!DOCTYPE html>\n";
     echo "<html lang=\"{$CFG_GLPI["languages"][$_SESSION['glpilanguage']][3]}\">";
     echo "<head><title>GLPI - " . $title . "</title>";
     echo "<meta charset=\"utf-8\">";
     //prevent IE to turn into compatible mode...
     echo "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n";
     // auto desktop / mobile viewport
     echo "<meta name='viewport' content='width=device-width, initial-scale=1'>";
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jquery/css/smoothness/jquery-ui-1.10.4.custom.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/css/jstree/style.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/rateit/rateit.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/select2/select2.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/qtip2/jquery.qtip.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jcrop/jquery.Jcrop.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/spectrum-colorpicker/spectrum.min.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-gantt/css/style.css");
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/fullcalendar/fullcalendar.min.css", array('media' => ''));
     echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/fullcalendar/fullcalendar.print.min.css", array('media' => 'print'));
     echo Html::css($CFG_GLPI["root_doc"] . "/css/jquery-glpi.css");
     if (CommonGLPI::isLayoutWithMain() && !CommonGLPI::isLayoutExcludedPage()) {
         echo Html::css($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-ui-scrollable-tabs/css/jquery.scrollabletab.min.css");
     }
     //  CSS link
     echo Html::css($CFG_GLPI["root_doc"] . "/css/styles.css");
     // High constrast CSS link
     if (isset($_SESSION['glpihighcontrast_css']) && $_SESSION['glpihighcontrast_css']) {
         echo Html::css($CFG_GLPI["root_doc"] . "/css/highcontrast.css");
     }
     // CSS theme link
     if (isset($_SESSION["glpipalette"])) {
         echo Html::css($CFG_GLPI["root_doc"] . "/css/palettes/" . $_SESSION["glpipalette"] . ".css");
     }
     // surcharge CSS hack for IE
     echo "<!--[if lte IE 6]>";
     echo Html::css($CFG_GLPI["root_doc"] . "/css/styles_ie.css");
     echo "<![endif]-->";
     echo Html::css($CFG_GLPI["root_doc"] . "/css/print.css", array('media' => 'print'));
     echo "<link rel='shortcut icon' type='images/x-icon' href='" . $CFG_GLPI["root_doc"] . "/pics/favicon.ico' >\n";
     // Add specific css for plugins
     if (isset($PLUGIN_HOOKS['add_css']) && count($PLUGIN_HOOKS['add_css'])) {
         foreach ($PLUGIN_HOOKS["add_css"] as $plugin => $files) {
             if (is_array($files)) {
                 foreach ($files as $file) {
                     if (file_exists(GLPI_ROOT . "/plugins/{$plugin}/{$file}")) {
                         echo Html::css($CFG_GLPI["root_doc"] . "/plugins/{$plugin}/{$file}");
                     }
                 }
             } else {
                 if (file_exists(GLPI_ROOT . "/plugins/{$plugin}/{$files}")) {
                     echo Html::css($CFG_GLPI["root_doc"] . "/plugins/{$plugin}/{$files}");
                 }
             }
         }
     }
     // AJAX library
     if (isset($_SESSION['glpi_use_mode']) && $_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/js/jquery-1.10.2.js");
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/js/jquery-ui-1.10.4.custom.js");
     } else {
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/js/jquery-1.10.2.min.js");
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/js/jquery-ui-1.10.4.custom.min.js");
     }
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/tiny_mce/tinymce.min.js");
     // PLugins jquery
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/backtotop/BackToTop.min.jquery.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/select2/select2.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/qtip2/jquery.qtip.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jstree/jquery.jstree.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/rateit/jquery.rateit.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-file-upload/js/jquery.iframe-transport.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-file-upload/js/jquery.fileupload.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jcrop/jquery.Jcrop.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/imagepaste/jquery.image_paste.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/spectrum-colorpicker/spectrum-min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-gantt/js/jquery.fn.gantt.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/autogrow/jquery.autogrow-textarea.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/fullcalendar/lib/moment.min.js");
     echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/fullcalendar/fullcalendar.min.js");
     // layout
     if (CommonGLPI::isLayoutWithMain() && !CommonGLPI::isLayoutExcludedPage()) {
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-ui-scrollable-tabs/js/jquery.mousewheel.min.js");
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jqueryplugins/jquery-ui-scrollable-tabs/js/jquery.scrollabletab.min.js");
     }
     //locales for js library
     if (isset($_SESSION['glpilanguage'])) {
         // jquery ui
         echo Html::script($CFG_GLPI["root_doc"] . "/lib/jquery/i18n/jquery.ui.datepicker-" . $CFG_GLPI["languages"][$_SESSION['glpilanguage']][2] . ".js");
         $filename = "/lib/jqueryplugins/jquery-ui-timepicker-addon/i18n/jquery-ui-timepicker-" . $CFG_GLPI["languages"][$_SESSION['glpilanguage']][2] . ".js";
         if (file_exists(GLPI_ROOT . $filename)) {
             echo Html::script($CFG_GLPI["root_doc"] . $filename);
         }
         // select2
         $filename = "/lib/jqueryplugins/select2/select2_locale_" . $CFG_GLPI["languages"][$_SESSION['glpilanguage']][2] . ".js";
         if (file_exists(GLPI_ROOT . $filename)) {
             echo Html::script($CFG_GLPI["root_doc"] . $filename);
         }
         //fullcalendar
         $filename = "/lib/jqueryplugins/fullcalendar/locale/" . strtolower($CFG_GLPI["languages"][$_SESSION['glpilanguage']][2]) . ".js";
         if (file_exists(GLPI_ROOT . $filename)) {
             echo Html::script($CFG_GLPI["root_doc"] . $filename);
         }
     }
     // Some Javascript-Functions which we may need later
     echo Html::script($CFG_GLPI["root_doc"] . '/script.js');
     self::redefineAlert();
     self::redefineConfirm();
     // add Ajax display message after redirect
     Html::displayAjaxMessageAfterRedirect();
     // Add specific javascript for plugins
     if (isset($PLUGIN_HOOKS['add_javascript']) && count($PLUGIN_HOOKS['add_javascript'])) {
         foreach ($PLUGIN_HOOKS["add_javascript"] as $plugin => $files) {
             if (is_array($files)) {
                 foreach ($files as $file) {
                     if (file_exists(GLPI_ROOT . "/plugins/{$plugin}/{$file}")) {
                         echo Html::script($CFG_GLPI["root_doc"] . "/plugins/{$plugin}/{$file}");
                     }
                 }
             } else {
                 if (file_exists(GLPI_ROOT . "/plugins/{$plugin}/{$files}")) {
                     echo Html::script($CFG_GLPI["root_doc"] . "/plugins/{$plugin}/{$files}");
                 }
             }
         }
     }
     // End of Head
     echo "</head>\n";
 }
Ejemplo n.º 5
0
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimeline($rand)
 {
     global $CFG_GLPI, $DB;
     //get ticket actors
     $ticket_users_keys = $this->getTicketActors();
     $user = new User();
     $followup_obj = new TicketFollowup();
     $pics_url = $CFG_GLPI['root_doc'] . "/pics/timeline";
     $timeline = $this->getTimelineItems();
     //include lib for parsing url
     require GLPI_ROOT . "/lib/urllinker/urllinker.php";
     //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) {
         $item_i = $item['item'];
         // don't display empty followup (ex : solution approbation)
         if ($item['type'] == 'TicketFollowup' && empty($item_i['content'])) {
             continue;
         }
         $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 $user->getLink();
             } 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'] : "") . "'";
         if (!in_array($item['type'], array('Document_Item', 'Assign')) && $item_i['can_edit']) {
             echo " ondblclick='javascript:viewEditSubitem" . $this->fields['id'] . "{$rand}(event, \"" . $item['type'] . "\", " . $item_i['id'] . ", this)'";
         }
         echo ">";
         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 = linkUrlsInTrustedHtml($content);
             //$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>{$content}</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['actiontime']) && !empty($item_i['actiontime'])) {
             echo "<span class='actiontime'>";
             echo Html::timestampToString($item_i['actiontime'], false);
             echo "</span>";
         }
         if (isset($item_i['state'])) {
             echo "<span class='state state_" . $item_i['state'] . "'>";
             echo Planning::getState($item_i['state']);
             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'])) {
             echo "<div class='users_id_tech'>";
             $user->getFromDB($item_i['users_id_tech']);
             echo "<div class='tooltip_picture_border'>";
             echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>";
             echo "</div>";
             echo $user->getLink();
             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>";
         //end h_content
         echo "</div>";
         //end  h_info
         $timeline_index++;
     }
     // 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'>";
         if (isset($item_i['users_id_recipient']) && $item_i['users_id_recipient'] != 0) {
             $user->getFromDB($this->fields['users_id_recipient']);
             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();
         } else {
             _e("Requester");
         }
         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 Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($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>";
 }