getTypeName() static public method

static public getTypeName ( $nb )
示例#1
0
 /**
  * @param $itemtype
  * @param $base                  HTMLTableBase object
  * @param $super                 HTMLTableSuperHeader object (default NULL)
  * @param $father                HTMLTableHeader object (default NULL)
  * @param $options      array
  **/
 static function getHTMLTableHeader($itemtype, HTMLTableBase $base, HTMLTableSuperHeader $super = NULL, HTMLTableHeader $father = NULL, array $options = array())
 {
     $column_name = __CLASS__;
     $content = self::getTypeName();
     if ($itemtype == 'IPNetwork') {
         $base->addHeader('Item', _n('Item', 'Items', 1), $super, $father);
         $base->addHeader('NetworkPort', NetworkPort::getTypeName(0), $super, $father);
         $base->addHeader('NetworkName', NetworkName::getTypeName(1), $super, $father);
         $base->addHeader('Entity', Entity::getTypeName(1), $super, $father);
     } else {
         if (isset($options['dont_display'][$column_name])) {
             return;
         }
         if (isset($options['column_links'][$column_name])) {
             $content = "<a href='" . $options['column_links'][$column_name] . "'>{$content}</a>";
         }
         $father = $base->addHeader($column_name, $content, $super, $father);
         if (isset($options['display_isDynamic']) && $options['display_isDynamic']) {
             $father = $base->addHeader($column_name . '_dynamic', __('Automatic inventory'), $super, $father);
         }
         IPNetwork::getHTMLTableHeader(__CLASS__, $base, $super, $father, $options);
     }
 }
示例#2
0
 /**
  * Show users of an entity
  *
  * @param $entity Entity object
  **/
 static function showForEntity(Entity $entity)
 {
     global $DB;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, READ)) {
         return false;
     }
     $canedit = $entity->canEdit($ID);
     $canshowuser = User::canView();
     $nb_per_line = 3;
     $rand = mt_rand();
     if ($canedit) {
         $headerspan = $nb_per_line * 2;
     } else {
         $headerspan = $nb_per_line;
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Add an authorization to a user') . "</tr>";
         echo "<tr class='tab_bg_1'><td class='tab_bg_2 center'>" . __('User') . "&nbsp;";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         User::dropdown(array('right' => 'all'));
         echo "</td><td class='tab_bg_2 center'>" . self::getTypeName(1) . "</td><td>";
         Profile::dropdownUnder(array('value' => Profile::getDefault()));
         echo "</td><td class='tab_bg_2 center'>" . __('Recursive') . "</td><td>";
         Dropdown::showYesNo("is_recursive", 0);
         echo "</td><td class='tab_bg_2 center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     $query = "SELECT DISTINCT `glpi_profiles`.`id`, `glpi_profiles`.`name`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_profiles`\n                     ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                     AND `glpi_users`.`is_deleted` = '0'";
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<thead><tr>";
     echo "<th class='noHover' colspan='{$headerspan}'>";
     printf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive'));
     echo "</th></tr></thead>";
     if ($nb) {
         Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Entity::getTypeName(1), $entity->getName()));
         while ($data = $DB->fetch_assoc($result)) {
             echo "<tbody><tr class='noHover'>";
             $reduce_header = 0;
             if ($canedit && $nb) {
                 echo "<th width='10'>";
                 echo Html::checkAllAsCheckbox("profile" . $data['id'] . "_{$rand}");
                 echo "</th>";
                 $reduce_header++;
             }
             echo "<th colspan='" . ($headerspan - $reduce_header) . "'>";
             printf(__('%1$s: %2$s'), __('Profile'), $data["name"]);
             echo "</th></tr></tbody>";
             echo "<tbody id='profile" . $data['id'] . "_{$rand}'>";
             $query = "SELECT `glpi_users`.*,\n                             `glpi_profiles_users`.`id` AS linkID,\n                             `glpi_profiles_users`.`is_recursive`,\n                             `glpi_profiles_users`.`is_dynamic`\n                      FROM `glpi_profiles_users`\n                      LEFT JOIN `glpi_users`\n                           ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                      WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                            AND `glpi_users`.`is_deleted` = '0'\n                            AND `glpi_profiles_users`.`profiles_id` = '" . $data['id'] . "'\n                      ORDER BY `glpi_profiles_users`.`profiles_id`,\n                               `glpi_users`.`name`,\n                               `glpi_users`.`realname`,\n                               `glpi_users`.`firstname`";
             $result2 = $DB->query($query);
             if ($DB->numrows($result2) > 0) {
                 $i = 0;
                 while ($data2 = $DB->fetch_assoc($result2)) {
                     Session::addToNavigateListItems('User', $data2["id"]);
                     if ($i % $nb_per_line == 0) {
                         if ($i != 0) {
                             echo "</tr>";
                         }
                         echo "<tr class='tab_bg_1'>";
                     }
                     if ($canedit) {
                         echo "<td width='10'>";
                         Html::showMassiveActionCheckBox(__CLASS__, $data2["linkID"]);
                         echo "</td>";
                     }
                     $username = formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"], $canshowuser);
                     if ($data2["is_dynamic"] || $data2["is_recursive"]) {
                         $username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>(");
                         if ($data2["is_dynamic"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, __('D'));
                         }
                         if ($data2["is_dynamic"] && $data2["is_recursive"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, ", ");
                         }
                         if ($data2["is_recursive"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, __('R'));
                         }
                         $username = sprintf(__('%1$s%2$s'), $username, ")</span>");
                     }
                     echo "<td>" . $username . "</td>";
                     $i++;
                 }
                 while ($i % $nb_per_line != 0) {
                     echo "<td>&nbsp;</td>";
                     if ($canedit) {
                         echo "<td>&nbsp;</td>";
                     }
                     $i++;
                 }
                 echo "</tr>";
                 echo "</tbody>";
             } else {
                 echo "<tr colspan='{$headerspan}'>" . __('Item not found') . "</tr>";
             }
         }
     }
     echo "</table>";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
示例#3
0
 /**
  * Display notification registered for a group
  *
  * @since version 0.83
  *
  * @param $group Group object
  *
  * @return nothing
  **/
 static function showForGroup(Group $group)
 {
     global $DB;
     if (!Notification::canView()) {
         return false;
     }
     $sql = "SELECT `glpi_notifications`.`id`\n              FROM `glpi_notificationtargets`\n              INNER JOIN `glpi_notifications`\n                    ON (`glpi_notifications`.`id` = `glpi_notificationtargets`.`notifications_id`)\n              WHERE `items_id` = '" . $group->getID() . "'\n                    AND (`type` = '" . Notification::SUPERVISOR_GROUP_TYPE . "'\n                         OR `type` = '" . Notification::GROUP_TYPE . "') " . getEntitiesRestrictRequest('AND', 'glpi_notifications', '', '', true);
     $req = $DB->request($sql);
     echo "<table class='tab_cadre_fixe'>";
     if ($req->numrows()) {
         echo "<tr><th>" . __('Name') . "</th>";
         echo "<th>" . Entity::getTypeName(1) . "</th>";
         echo "<th>" . __('Active') . "</th>";
         echo "<th>" . __('Type') . "</th>";
         echo "<th>" . __('Notification method') . "</th>";
         echo "<th>" . NotificationEvent::getTypeName(1) . "</th>";
         echo "<th>" . NotificationTemplate::getTypeName(1) . "</th></tr>";
         $notif = new Notification();
         Session::initNavigateListItems('Notification', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName()));
         foreach ($req as $data) {
             Session::addToNavigateListItems('Notification', $data['id']);
             if ($notif->getFromDB($data['id'])) {
                 echo "<tr class='tab_bg_2'><td>" . $notif->getLink();
                 echo "</td><td>" . Dropdown::getDropdownName('glpi_entities', $notif->getEntityID());
                 echo "</td><td>" . Dropdown::getYesNo($notif->getField('is_active')) . "</td><td>";
                 $itemtype = $notif->getField('itemtype');
                 if ($tmp = getItemForItemtype($itemtype)) {
                     echo $tmp->getTypeName(1);
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td><td>" . Notification::getMode($notif->getField('mode'));
                 echo "</td><td>" . NotificationEvent::getEventName($itemtype, $notif->getField('event'));
                 echo "</td>" . "<td>" . Dropdown::getDropdownName('glpi_notificationtemplates', $notif->getField('notificationtemplates_id'));
                 echo "</td></tr>";
             }
         }
     } else {
         echo "<tr class='tab_bg_2'><td class='b center'>" . __('No item found') . "</td></tr>";
     }
     echo "</table>";
 }