Exemple #1
0
 /**
  * @see CommonGLPI::getTabNameForItem()
  **/
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         $nb = 0;
         switch ($item->getType()) {
             case 'Entity':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     $types = array();
                     $collection = new RuleRightCollection();
                     if ($collection->canList()) {
                         $types[] = 'RuleRight';
                     }
                     $collection = new RuleImportEntityCollection();
                     if ($collection->canList()) {
                         $types[] = 'RuleImportEntity';
                     }
                     $collection = new RuleMailCollectorCollection();
                     if ($collection->canList()) {
                         $types[] = 'RuleMailCollector';
                     }
                     if (count($types)) {
                         $nb = countElementsInTable(array('glpi_rules', 'glpi_ruleactions'), "`glpi_ruleactions`.`rules_id` = `glpi_rules`.`id`\n                                                  AND `glpi_rules`.`sub_type`\n                                                         IN ('" . implode("','", $types) . "')\n                                                  AND `glpi_ruleactions`.`field` = 'entities_id'\n                                                  AND `glpi_ruleactions`.`value`\n                                                            = '" . $item->getID() . "'");
                     }
                 }
                 return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $nb);
             case 'SLA':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     $nb = countElementsInTable('glpi_ruleactions', "`field` = 'slas_id'\n                                                AND `value` = '" . $item->getID() . "'");
                 }
                 return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $nb);
             default:
                 if ($item instanceof Rule) {
                     $ong = array();
                     $nbcriteria = 0;
                     $nbaction = 0;
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         $nbcriteria = countElementsInTable(getTableForItemType($item->getRuleCriteriaClass()), "`" . $item->getRuleIdField() . "` = '" . $item->getID() . "'");
                         $nbaction = countElementsInTable(getTableForItemType($item->getRuleActionClass()), "`" . $item->getRuleIdField() . "` = '" . $item->getID() . "'");
                     }
                     $ong[1] = self::createTabEntry(RuleCriteria::getTypeName(Session::getPluralNumber()), $nbcriteria);
                     $ong[2] = self::createTabEntry(RuleAction::getTypeName(Session::getPluralNumber()), $nbaction);
                     return $ong;
                 }
         }
     }
     return '';
 }