/**
  * @covers NotificationTargetTicket::getTags
  * @covers NotificationTargetCommonITILObject::getTags
  * @covers NotificationTargetTicket::getDatasForObject
  * @covers NotificationTargetCommonITILObject::getDatasForObject
  */
 public function testgetDatasForObject()
 {
     global $CFG_GLPI;
     $tkt = getItemByTypeName('Ticket', '_ticket01');
     $notiftargetticket = new NotificationTargetTicket(getItemByTypeName('Entity', '_test_root_entity', true), 'new', $tkt);
     $notiftargetticket->getTags();
     // basic test for ##task.categorycomment## tag
     $expected = ['tag' => 'task.categorycomment', 'value' => true, 'label' => 'Category comment', 'events' => 0, 'foreach' => false, 'lang' => true, 'allowed_values' => []];
     $this->assertEquals($expected, $notiftargetticket->tag_descriptions['lang']['##lang.task.categorycomment##']);
     $this->assertEquals($expected, $notiftargetticket->tag_descriptions['tag']['##task.categorycomment##']);
     // basic test for ##task.categorid## tag
     $expected = ['tag' => 'task.categoryid', 'value' => true, 'label' => 'Category id', 'events' => 0, 'foreach' => false, 'lang' => true, 'allowed_values' => []];
     $this->assertEquals($expected, $notiftargetticket->tag_descriptions['lang']['##lang.task.categoryid##']);
     $this->assertEquals($expected, $notiftargetticket->tag_descriptions['tag']['##task.categoryid##']);
     // advanced test for ##task.categorycomment## and ##task.categoryid## tags
     // test of the getDatasForObject for default language en_US
     $taskcat = getItemByTypeName('TaskCategory', '_subcat_1');
     $expected = [['##task.id##' => 1, '##task.isprivate##' => 'No', '##task.author##' => '_test_user', '##task.categoryid##' => $taskcat->getID(), '##task.category##' => '_cat_1 > _subcat_1', '##task.categorycomment##' => 'Comment for sub-category _subcat_1', '##task.date##' => '2016-10-19 11:50', '##task.description##' => 'Task to be done', '##task.time##' => '0 seconds', '##task.status##' => 'To do', '##task.user##' => '_test_user', '##task.group##' => '', '##task.begin##' => '', '##task.end##' => '']];
     $ret = $notiftargetticket->getDatasForObject($tkt, array());
     $this->assertEquals($expected, $ret['tasks']);
     // test of the getDatasForObject for default language fr_FR
     $CFG_GLPI['translate_dropdowns'] = 1;
     $_SESSION["glpilanguage"] = Session::loadLanguage('fr_FR');
     $_SESSION['glpi_dropdowntranslations'] = DropdownTranslation::getAvailableTranslations($_SESSION["glpilanguage"]);
     $ret = $notiftargetticket->getDatasForObject($tkt, array());
     $expected = [['##task.id##' => 1, '##task.isprivate##' => 'Non', '##task.author##' => '_test_user', '##task.categoryid##' => $taskcat->getID(), '##task.category##' => 'FR - _cat_1 > FR - _subcat_1', '##task.categorycomment##' => 'FR - Commentaire pour sous-cat├ęgorie _subcat_1', '##task.date##' => '2016-10-19 11:50', '##task.description##' => 'Task to be done', '##task.time##' => '0 seconde', '##task.status##' => 'A faire', '##task.user##' => '_test_user', '##task.group##' => '', '##task.begin##' => '', '##task.end##' => '']];
     $this->assertEquals($expected, $ret['tasks']);
     // switch back to default language
     $_SESSION["glpilanguage"] = Session::loadLanguage('en_US');
 }
Example #2
0
 public function testInstall($verify = 1)
 {
     global $DB;
     $DB->connect();
     if (file_exists("save.sql") and $verify == '0') {
         $query = "SHOW TABLES";
         $result = $DB->query($query);
         while ($data = $DB->fetch_array($result)) {
             $DB->query("DROP TABLE " . $data[0]);
         }
         $res = $DB->runFile("save.sql");
         $this->assertTrue($res, "Fail: SQL Error during import saved GLPI DB");
         echo "======= Import save.sql file =======\n";
         $TimelineticketInstall = new TimelineticketInstall();
         $TimelineticketInstall->testDB(TRUE);
     } else {
         $query = "SHOW TABLES";
         $result = $DB->query($query);
         while ($data = $DB->fetch_array($result)) {
             if (strstr($data[0], "timelineticket")) {
                 $DB->query("DROP TABLE " . $data[0]);
             }
         }
         passthru("cd ../tools && /usr/local/bin/php -f cli_install.php");
         Session::loadLanguage("en_GB");
         $TimelineticketInstall = new TimelineticketInstall();
         $TimelineticketInstall->testDB(TRUE);
         passthru("mysqldump -h " . $DB->dbhost . " -u " . $DB->dbuser . " -p" . $DB->dbpassword . " " . $DB->dbdefault . " > save.sql");
     }
     $GLPIlog = new GLPIlogs();
     $GLPIlog->testSQLlogs();
     $GLPIlog->testPHPlogs();
 }
Example #3
0
 /**
  * Load minimal session for user
  *
  * @param $entities_id : entity to use
  * @param $is_recursive : load recursive entity
  *
  * @since version 0.83.7
  **/
 function loadMinimalSession($entities_id, $is_recursive)
 {
     global $CFG_GLPI;
     if (isset($this->fields['id']) && !isset($_SESSION["glpiID"])) {
         Session::destroy();
         Session::start();
         $_SESSION["glpiID"] = $this->fields['id'];
         $_SESSION["glpi_use_mode"] = Session::NORMAL_MODE;
         $_SESSION["glpiactive_entity"] = $entities_id;
         $_SESSION["glpiactive_entity_recursive"] = $is_recursive;
         if ($is_recursive) {
             $entities = getSonsOf("glpi_entities", $entities_id);
         } else {
             $entities = array($entities_id);
         }
         $_SESSION['glpiactiveentities'] = $entities;
         $_SESSION['glpiactiveentities_string'] = "'" . implode("', '", $entities) . "'";
         $this->computePreferences();
         foreach ($CFG_GLPI['user_pref_field'] as $field) {
             if (isset($this->fields[$field])) {
                 $_SESSION["glpi{$field}"] = $this->fields[$field];
             }
         }
         Session::loadGroups();
         Session::loadLanguage();
     }
 }
        echo "</p>";
        Html::closeForm();
    }
}
//------------Start of install script---------------------------
// Use default session dir if not writable
if (is_writable(GLPI_SESSION_DIR)) {
    Session::setPath();
}
Session::start();
error_reporting(0);
// we want to check system before affraid the user.
if (isset($_POST["language"])) {
    $_SESSION["glpilanguage"] = $_POST["language"];
}
Session::loadLanguage();
/**
 * @since version 0.84.2
**/
function checkConfigFile()
{
    if (file_exists(GLPI_CONFIG_DIR . "/config_db.php")) {
        Html::redirect($CFG_GLPI['root_doc'] . "/index.php");
        die;
    }
}
if (!isset($_POST["install"])) {
    $_SESSION = array();
    checkConfigFile();
    header_html("Select your language");
    choose_language();
 /**
  * Display a HTML report about systeme information / configuration
  **/
 function showSystemInformations()
 {
     global $DB, $CFG_GLPI;
     if (!Config::canUpdate()) {
         return false;
     }
     echo "<div class='center' id='tabsbody'>";
     echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('General setup') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Log Level') . "</td><td>";
     $values[1] = __('1- Critical (login error only)');
     $values[2] = __('2- Severe (not used)');
     $values[3] = __('3- Important (successful logins)');
     $values[4] = __('4- Notices (add, delete, tracking)');
     $values[5] = __('5- Complete (all)');
     Dropdown::showFromArray('event_loglevel', $values, array('value' => $CFG_GLPI["event_loglevel"]));
     echo "</td><td>" . __('Maximal number of automatic actions (run by CLI)') . "</td><td>";
     Dropdown::showNumber('cron_limit', array('value' => $CFG_GLPI["cron_limit"], 'min' => 1, 'max' => 30));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('Logs in files (SQL, email, automatic action...)') . "</td><td>";
     Dropdown::showYesNo("use_log_in_files", $CFG_GLPI["use_log_in_files"]);
     echo "</td><td> " . _n('Mysql replica', 'Mysql replicas', 1) . "</td><td>";
     $active = DBConnection::isDBSlaveActive();
     Dropdown::showYesNo("_dbslave_status", $active);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='4' class='center b'>" . __('Password security policy');
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Password security policy validation') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("use_password_security", $CFG_GLPI["use_password_security"]);
     echo "</td>";
     echo "<td>" . __('Password minimum length') . "</td>";
     echo "<td>";
     Dropdown::showNumber('password_min_length', array('value' => $CFG_GLPI["password_min_length"], 'min' => 4, 'max' => 30));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Password need digit') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("password_need_number", $CFG_GLPI["password_need_number"]);
     echo "</td>";
     echo "<td>" . __('Password need lowercase character') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("password_need_letter", $CFG_GLPI["password_need_letter"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Password need uppercase character') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("password_need_caps", $CFG_GLPI["password_need_caps"]);
     echo "</td>";
     echo "<td>" . __('Password need symbol') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("password_need_symbol", $CFG_GLPI["password_need_symbol"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='4' class='center b'>" . __('Maintenance mode');
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Maintenance mode') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("maintenance_mode", $CFG_GLPI["maintenance_mode"]);
     echo "</td>";
     //TRANS: Proxy port
     echo "<td>" . __('Maintenance text') . "</td>";
     echo "<td>";
     echo "<textarea cols='70' rows='4' name='maintenance_text'>" . $CFG_GLPI["maintenance_text"];
     echo "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='4' class='center b'>" . __('Proxy configuration for upgrade check');
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Server') . "</td>";
     echo "<td><input type='text' name='proxy_name' value='" . $CFG_GLPI["proxy_name"] . "'></td>";
     //TRANS: Proxy port
     echo "<td>" . __('Port') . "</td>";
     echo "<td><input type='text' name='proxy_port' value='" . $CFG_GLPI["proxy_port"] . "'></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Login') . "</td>";
     echo "<td><input type='text' name='proxy_user' value='" . $CFG_GLPI["proxy_user"] . "'></td>";
     echo "<td>" . __('Password') . "</td>";
     echo "<td><input type='password' name='proxy_passwd' value='' autocomplete='off'>";
     echo "<br><input type='checkbox' name='_blank_proxy_passwd'>" . __('Clear');
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     $width = 128;
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th>" . __('Information about system installation and configuration') . "</th></tr>";
     $oldlang = $_SESSION['glpilanguage'];
     // Keep this, for some function call which still use translation (ex showAllReplicateDelay)
     Session::loadLanguage('en_GB');
     // No need to translate, this part always display in english (for copy/paste to forum)
     // Try to compute a better version for .git
     if (is_dir(GLPI_ROOT . "/.git")) {
         $dir = getcwd();
         chdir(GLPI_ROOT);
         $returnCode = 1;
         $result = @exec('git describe --tags 2>&1', $output, $returnCode);
         chdir($dir);
         $ver = $returnCode ? $CFG_GLPI['version'] . '-git' : $result;
     } else {
         $ver = $CFG_GLPI['version'];
     }
     echo "<tr class='tab_bg_1'><td><pre>[code]\n&nbsp;\n";
     echo "GLPI {$ver} (" . $CFG_GLPI['root_doc'] . " => " . GLPI_ROOT . ")\n";
     echo "\n</pre></td></tr>";
     echo "<tr><th>Server</th></tr>\n";
     echo "<tr class='tab_bg_1'><td><pre>\n&nbsp;\n";
     echo wordwrap("Operating system: " . php_uname() . "\n", $width, "\n\t");
     $exts = get_loaded_extensions();
     sort($exts);
     echo wordwrap("PHP " . phpversion() . ' ' . php_sapi_name() . " (" . implode(', ', $exts) . ")\n", $width, "\n\t");
     $msg = "Setup: ";
     foreach (array('max_execution_time', 'memory_limit', 'post_max_size', 'safe_mode', 'session.save_handler', 'upload_max_filesize') as $key) {
         $msg .= $key . '="' . ini_get($key) . '" ';
     }
     echo wordwrap($msg . "\n", $width, "\n\t");
     $msg = 'Software: ';
     if (isset($_SERVER["SERVER_SOFTWARE"])) {
         $msg .= $_SERVER["SERVER_SOFTWARE"];
     }
     if (isset($_SERVER["SERVER_SIGNATURE"])) {
         $msg .= ' (' . Html::clean($_SERVER["SERVER_SIGNATURE"]) . ')';
     }
     echo wordwrap($msg . "\n", $width, "\n\t");
     if (isset($_SERVER["HTTP_USER_AGENT"])) {
         echo "\t" . $_SERVER["HTTP_USER_AGENT"] . "\n";
     }
     foreach ($DB->getInfo() as $key => $val) {
         echo "{$key}: {$val}\n\t";
     }
     echo "\n";
     self::checkWriteAccessToDirs(true);
     toolbox::checkSELinux(true);
     echo "\n</pre></td></tr>";
     self::showLibrariesInformation();
     foreach ($CFG_GLPI["systeminformations_types"] as $type) {
         $tmp = new $type();
         $tmp->showSystemInformations($width);
     }
     Session::loadLanguage($oldlang);
     echo "<tr class='tab_bg_1'><td>[/code]\n</td></tr>";
     echo "<tr class='tab_bg_2'><th>" . __('To copy/paste in your support request') . "</th></tr>\n";
     echo "</table></div>\n";
 }
Example #6
0
 /**
  * @param $target             NotificationTarget object
  * @param $user_infos   array
  * @param $event
  * @param $options      array
  *
  * @return id of the template in templates_by_languages / false if computation failed
  **/
 function getTemplateByLanguage(NotificationTarget $target, $user_infos = array(), $event, $options = array())
 {
     $lang = array();
     $language = $user_infos['language'];
     if (isset($user_infos['additionnaloption'])) {
         $additionnaloption = $user_infos['additionnaloption'];
     } else {
         $additionnaloption = array();
     }
     $tid = $language;
     $tid .= serialize($additionnaloption);
     $tid = sha1($tid);
     if (!isset($this->templates_by_languages[$tid])) {
         //Switch to the desired language
         $bak_dropdowntranslations = $_SESSION['glpi_dropdowntranslations'];
         $_SESSION['glpi_dropdowntranslations'] = DropdownTranslation::getAvailableTranslations($language);
         Session::loadLanguage($language);
         $bak_language = $_SESSION["glpilanguage"];
         $_SESSION["glpilanguage"] = $language;
         //If event is raised by a plugin, load it in order to get the language file available
         if ($plug = isPluginItemType(get_class($target->obj))) {
             Plugin::loadLang(strtolower($plug['plugin']), $language);
         }
         //Get template's language data for in this language
         $options['additionnaloption'] = $additionnaloption;
         $data =& $target->getForTemplate($event, $options);
         $footer_string = Html::entity_decode_deep(sprintf(__('Automatically generated by GLPI %s'), GLPI_VERSION));
         $add_header = Html::entity_decode_deep($target->getContentHeader());
         $add_footer = Html::entity_decode_deep($target->getContentFooter());
         //Restore default language
         $_SESSION["glpilanguage"] = $bak_language;
         Session::loadLanguage();
         $_SESSION['glpi_dropdowntranslations'] = $bak_dropdowntranslations;
         if ($plug = isPluginItemType(get_class($target->obj))) {
             Plugin::loadLang(strtolower($plug['plugin']));
         }
         if ($template_datas = $this->getByLanguage($language)) {
             //Template processing
             // Decode html chars to have clean text
             $template_datas['content_text'] = Html::entity_decode_deep($template_datas['content_text']);
             $save_data = $data;
             $data = Html::entity_decode_deep($data);
             $template_datas['subject'] = Html::entity_decode_deep($template_datas['subject']);
             $this->signature = Html::entity_decode_deep($this->signature);
             $lang['subject'] = $target->getSubjectPrefix($event) . self::process($template_datas['subject'], $data);
             $lang['content_html'] = '';
             //If no html content, then send only in text
             if (!empty($template_datas['content_html'])) {
                 // Encode in HTML all chars
                 $data_html = Html::entities_deep($data);
                 $data_html = Html::nl2br_deep($data_html);
                 // Restore HTML tags
                 if (count($target->html_tags)) {
                     foreach ($target->html_tags as $tag) {
                         if (isset($save_data[$tag])) {
                             $data_html[$tag] = $save_data[$tag];
                         }
                     }
                 }
                 $signature_html = Html::entities_deep($this->signature);
                 $signature_html = Html::nl2br_deep($signature_html);
                 $template_datas['content_html'] = self::process($template_datas['content_html'], $data_html);
                 $lang['content_html'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n                        'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" . "<html>\n                        <head>\n                         <META http-equiv='Content-Type' content='text/html; charset=utf-8'>\n                         <title>" . Html::entities_deep($lang['subject']) . "</title>\n                         <style type='text/css'>\n                           " . $this->fields['css'] . "\n                         </style>\n                        </head>\n                        <body>\n" . (!empty($add_header) ? $add_header . "\n<br><br>" : '') . $template_datas['content_html'] . "<br><br>-- \n<br>" . $signature_html . "<br>{$footer_string}" . "<br><br>\n" . (!empty($add_footer) ? $add_footer . "\n<br><br>" : '') . "\n</body></html>";
             }
             $lang['content_text'] = (!empty($add_header) ? $add_header . "\n\n" : '') . Html::clean(self::process($template_datas['content_text'], $data) . "\n\n-- \n" . $this->signature . "\n" . Html::entity_decode_deep(sprintf(__('Automatically generated by GLPI %s'), GLPI_VERSION))) . "\n\n" . $add_footer;
             $this->templates_by_languages[$tid] = $lang;
         }
     }
     if (isset($this->templates_by_languages[$tid])) {
         return $tid;
     }
     return false;
 }
Example #7
0
if (isset($_GET['help'])) {
   echo "\nUsage : php getsearchoptions.php --type=<itemtype> [ --lang=<locale> ]\n\n";
   exit (0);
}

include ('../inc/includes.php');

if (!isset($_GET['type'])) {
   die("** mandatory option 'type' is missing\n");
}
if (!class_exists($_GET['type'])) {
   die("** unknown type\n");
}
if (isset($_GET['lang'])) {
   Session::loadLanguage($_GET['lang']);
}

$opts = &Search::getOptions($_GET['type']);
$sort = array();
$group = 'N/A';

foreach ($opts as $ref => $opt) {
   if (is_array($opt)) {
      $sort[$ref] = $group . " / " . $opt['name'];
   } else {
      $group = $opt;
   }
}
ksort($sort);
if (!isCommandLine()) {
 function reconstructTimeline()
 {
     global $DB;
     $ticket = new Ticket();
     $query = "TRUNCATE `" . $this->getTable() . "`";
     $DB->query($query);
     $status_translation = array();
     // Get the new 0.84 interger status
     $status_translation[Ticket::INCOMING] = Ticket::INCOMING;
     $status_translation[Ticket::ASSIGNED] = Ticket::ASSIGNED;
     $status_translation[Ticket::PLANNED] = Ticket::PLANNED;
     $status_translation[Ticket::WAITING] = Ticket::WAITING;
     $status_translation[Ticket::SOLVED] = Ticket::SOLVED;
     $status_translation[Ticket::CLOSED] = Ticket::CLOSED;
     // Unset plugin session to avoid loadLanguage on plugin
     $save_plugin_session = $_SESSION['glpi_plugins'];
     unset($_SESSION['glpi_plugins']);
     // Get all existing languages status
     foreach (glob(GLPI_ROOT . '/locales/*.po') as $file) {
         $locale = basename($file, '.po');
         Session::loadLanguage($locale);
         $status_translation[_x('ticket', 'New')] = Ticket::INCOMING;
         $status_translation[__('Processing (assigned)')] = Ticket::ASSIGNED;
         $status_translation[__('Processing (planned)')] = Ticket::PLANNED;
         $status_translation[__('Pending')] = Ticket::WAITING;
         $status_translation[__('Solved')] = Ticket::SOLVED;
         $status_translation[__('Closed')] = Ticket::CLOSED;
     }
     $_SESSION['glpi_plugins'] = $save_plugin_session;
     $query = "SELECT * FROM `glpi_tickets`\n         ORDER BY `date`";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $ticket->getFromDB($data['id']);
         $this->createFollowup($ticket, $data['date'], '', Ticket::INCOMING);
         $queryl = "SELECT * FROM `glpi_logs`\n            WHERE `itemtype`='Ticket'\n               AND `items_id`='" . $data['id'] . "'\n               AND `id_search_option`='12'\n         ORDER BY `id`";
         $resultl = $DB->query($queryl);
         $first = 0;
         while ($datal = $DB->fetch_array($resultl)) {
             if ($first == 0) {
                 if ($datal['old_value'] != Ticket::INCOMING || $datal['old_value'] != 'new' || $datal['old_value'] != _x('ticket', 'New')) {
                     $this->createFollowup($ticket, $data['date'], Ticket::INCOMING, $status_translation[$datal['old_value']]);
                 }
             }
             $this->createFollowup($ticket, $datal['date_mod'], $status_translation[$datal['old_value']], $status_translation[$datal['new_value']]);
             $first++;
         }
     }
 }
Example #9
0
 /**
  * @covers Dropdown::getDropdownName
  * @covers ::getTreeValueCompleteName
  */
 public function testGetDropdownName()
 {
     global $CFG_GLPI;
     $cat = getItemByTypeName('TaskCategory', '_cat_1');
     $subCat = getItemByTypeName('TaskCategory', '_subcat_1');
     // basic test returns string only
     $expected = $cat->fields['name'] . " > " . $subCat->fields['name'];
     $ret = Dropdown::getDropdownName('glpi_taskcategories', $subCat->getID());
     $this->assertEquals($expected, $ret);
     // test of return with comments
     $expected = array('name' => $cat->fields['name'] . " > " . $subCat->fields['name'], 'comment' => "<span class='b'>Complete name</span>: " . $cat->fields['name'] . " > " . $subCat->fields['name'] . "<br><span class='b'>&nbsp;Comments&nbsp;</span>" . $subCat->fields['comment']);
     $ret = Dropdown::getDropdownName('glpi_taskcategories', $subCat->getID(), true);
     $this->assertEquals($expected, $ret);
     // test of return without $tooltip
     $expected = array('name' => $cat->fields['name'] . " > " . $subCat->fields['name'], 'comment' => $subCat->fields['comment']);
     $ret = Dropdown::getDropdownName('glpi_taskcategories', $subCat->getID(), true, true, false);
     $this->assertEquals($expected, $ret);
     // test of return with translations
     $CFG_GLPI['translate_dropdowns'] = 1;
     $_SESSION["glpilanguage"] = Session::loadLanguage('fr_FR');
     $_SESSION['glpi_dropdowntranslations'] = DropdownTranslation::getAvailableTranslations($_SESSION["glpilanguage"]);
     $expected = array('name' => 'FR - _cat_1 > FR - _subcat_1', 'comment' => 'FR - Commentaire pour sous-cat├ęgorie _subcat_1');
     $ret = Dropdown::getDropdownName('glpi_taskcategories', $subCat->getID(), true, true, false);
     $this->assertEquals($expected, $ret);
     // switch back to default language
     $_SESSION["glpilanguage"] = Session::loadLanguage('en_US');
     ////////////////////////////////
     // test for other dropdown types
     ////////////////////////////////
     ///////////
     // Computer
     $computer = getItemByTypeName('Computer', '_test_pc01');
     $ret = Dropdown::getDropdownName('glpi_computers', $computer->getID());
     $this->assertEquals($computer->getName(), $ret);
     $expected = array('name' => $computer->getName(), 'comment' => $computer->fields['comment']);
     $ret = Dropdown::getDropdownName('glpi_computers', $computer->getID(), true);
     $this->assertEquals($expected, $ret);
     //////////
     // Contact
     $contact = getItemByTypeName('Contact', '_contact01_name');
     $expected = $contact->getName();
     $ret = Dropdown::getDropdownName('glpi_contacts', $contact->getID());
     $this->assertEquals($expected, $ret);
     // test of return with comments
     $expected = array('name' => $contact->getName(), 'comment' => "Comment for contact _contact01_name<br><span class='b'>" . "Phone: </span>0123456789<br><span class='b'>Phone 2: </span>0123456788<br><span class='b'>" . "Mobile phone: </span>0623456789<br><span class='b'>Fax: </span>0123456787<br>" . "<span class='b'>Email: </span>_contact01_firstname._contact01_name@glpi.com");
     $ret = Dropdown::getDropdownName('glpi_contacts', $contact->getID(), true);
     $this->assertEquals($expected, $ret);
     // test of return without $tooltip
     $expected = array('name' => $contact->getName(), 'comment' => $contact->fields['comment']);
     $ret = Dropdown::getDropdownName('glpi_contacts', $contact->getID(), true, true, false);
     $this->assertEquals($expected, $ret);
     ///////////
     // Supplier
     $supplier = getItemByTypeName('Supplier', '_suplier01_name');
     $expected = $supplier->getName();
     $ret = Dropdown::getDropdownName('glpi_suppliers', $supplier->getID());
     $this->assertEquals($expected, $ret);
     // test of return with comments
     $expected = array('name' => $supplier->getName(), 'comment' => "Comment for supplier _suplier01_name<br><span class='b'>Phone: </span>0123456789<br>" . "<span class='b'>Fax: </span>0123456787<br><span class='b'>Email: </span>info@_supplier01_name.com");
     $ret = Dropdown::getDropdownName('glpi_suppliers', $supplier->getID(), true);
     $this->assertEquals($expected, $ret);
     // test of return without $tooltip
     $expected = array('name' => $supplier->getName(), 'comment' => $supplier->fields['comment']);
     $ret = Dropdown::getDropdownName('glpi_suppliers', $supplier->getID(), true, true, false);
     $this->assertEquals($expected, $ret);
     ///////////
     // Netpoint
     $netpoint = getItemByTypeName('Netpoint', '_netpoint01');
     $location = getItemByTypeName('Location', '_location01');
     $expected = $netpoint->getName() . " (" . $location->getName() . ")";
     $ret = Dropdown::getDropdownName('glpi_netpoints', $netpoint->getID());
     $this->assertEquals($expected, $ret);
     // test of return with comments
     $expected = array('name' => $expected, 'comment' => "Comment for netpoint _netpoint01");
     $ret = Dropdown::getDropdownName('glpi_netpoints', $netpoint->getID(), true);
     $this->assertEquals($expected, $ret);
     // test of return without $tooltip
     $ret = Dropdown::getDropdownName('glpi_netpoints', $netpoint->getID(), true, true, false);
     $this->assertEquals($expected, $ret);
     ///////////
     // Budget
     $budget = getItemByTypeName('Budget', '_budget01');
     $expected = $budget->getName();
     $ret = Dropdown::getDropdownName('glpi_budgets', $budget->getID());
     $this->assertEquals($expected, $ret);
     // test of return with comments
     $expected = array('name' => $budget->getName(), 'comment' => "Comment for budget _budget01<br><span class='b'>Location</span>: " . "_location01<br><span class='b'>Type</span>: _budgettype01<br><span class='b'>" . "Start date</span>: 2016-10-18 <br><span class='b'>End date</span>: 2016-12-31 ");
     $ret = Dropdown::getDropdownName('glpi_budgets', $budget->getID(), true);
     $this->assertEquals($expected, $ret);
     // test of return without $tooltip
     $expected = array('name' => $budget->getName(), 'comment' => $budget->fields['comment']);
     $ret = Dropdown::getDropdownName('glpi_budgets', $budget->getID(), true, true, false);
     $this->assertEquals($expected, $ret);
 }
Example #10
0
based on GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2014 by the INDEPNET Development Team.

-------------------------------------------------------------------------

LICENSE

This file is part of GLPI.

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

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Toolbox::setDebugMode(Session::DEBUG_MODE, 0, 0, 1);
foreach ($CFG_GLPI['languages'] as $key => $lang) {
    Session::loadLanguage($key);
}
 private function displayGroups($closed = true)
 {
     global $DB, $CFG_GLPI;
     $DB->connect();
     $CFG_GLPI['root_doc'] = "http://127.0.0.1/fusion0.83/";
     Session::loadLanguage("en_GB");
     $ticket = new Ticket();
     $ptAssignGroup = new PluginTimelineticketAssignGroup();
     $a_storedate_temp = self::$storedate;
     $ticket->getFromDB(1);
     //      $a_data = PluginTimelineticketDisplay::getTotaltimeEnddate($ticket);
     //      ob_start();
     //      $a_data = $ptAssignGroup->showTimeline($ticket, $a_data);
     //      ob_end_clean();
     $a_data = PluginTimelineticketToolbox::getDetails($ticket, 'group', 0);
     foreach ($a_data as $num => $data) {
         foreach ($data as $num2 => $data2) {
             unset($data2['Caption']);
             unset($data2['R']);
             unset($data2['G']);
             unset($data2['B']);
             $a_data[$num][$num2] = $data2;
         }
     }
     $ticket_date = $ticket->fields['date'];
     $a_ref = array();
     $a_ref[1] = array(array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[3]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[5]), 'Status' => Ticket::ASSIGNED), array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[5]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[7]), 'Status' => Ticket::WAITING), array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[13]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[16]), 'Status' => Ticket::WAITING), array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[16]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[18]), 'Status' => Ticket::ASSIGNED));
     if ($closed) {
         $a_ref[1][] = array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[18]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[20]), 'Status' => Ticket::SOLVED);
     }
     $a_ref[2] = array(array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[9]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[11]), 'Status' => Ticket::ASSIGNED), array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[11]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[13]), 'Status' => Ticket::WAITING));
     $this->assertEquals($a_ref, $a_data, 'Data used to display groups in graph');
 }