當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Group::getFromDB方法代碼示例

本文整理匯總了PHP中Group::getFromDB方法的典型用法代碼示例。如果您正苦於以下問題:PHP Group::getFromDB方法的具體用法?PHP Group::getFromDB怎麽用?PHP Group::getFromDB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Group的用法示例。


在下文中一共展示了Group::getFromDB方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getHistory

 static function getHistory($tickets_id, $full_history = false)
 {
     global $CFG_GLPI;
     $filter_groups_id = array();
     if ($_SESSION['plugins']['escalade']['config']['use_filter_assign_group']) {
         $groups_groups = new PluginEscaladeGroup_Group();
         $filter_groups_id = $groups_groups->getGroups($tickets_id);
         $use_filter_assign_group = true;
     } else {
         $use_filter_assign_group = false;
     }
     $plugin_dir = $full_history ? ".." : "../plugins/escalade";
     //get all line for this ticket
     $group = new Group();
     $history = new self();
     $found = $history->find("tickets_id = {$tickets_id}", "date_mod DESC");
     $nb_histories = count($found);
     //remove first line (current assign)
     $first_group = array_shift($found);
     if ($full_history) {
         //show 1st group
         echo "<div class='escalade_active'>";
         echo "&nbsp;<img src='" . $CFG_GLPI['root_doc'] . "/pics/group.png' />&nbsp;";
         if ($group->getFromDB($first_group['groups_id'])) {
             echo $group->getLink(true);
         }
         echo "</div>";
     }
     echo "<div class='escalade'>";
     //parse all lines
     $i = 0;
     foreach ($found as $key => $hline) {
         echo "<div class='escalade_history'>";
         if (!$use_filter_assign_group || isset($filter_groups_id[$hline['groups_id']])) {
             //up link and image
             echo "<a href='{$plugin_dir}/front/climb_group.php?tickets_id=" . $tickets_id . "&groups_id=" . $hline['groups_id'];
             if ($full_history) {
                 echo "&full_history=true";
             }
             echo "' title='" . __("Reassign the ticket to group", "escalade") . "' class='up_a'></a>";
         } else {
             echo "&nbsp;&nbsp;&nbsp;";
         }
         //group link
         echo "&nbsp;<img src='" . $CFG_GLPI['root_doc'] . "/pics/group.png' />&nbsp;";
         if ($group->getFromDB($hline['groups_id'])) {
             echo self::showGroupLink($group, $full_history);
         }
         echo "</div>";
         $i++;
         if ($i == self::HISTORY_LIMIT && !$full_history) {
             break;
         }
     }
     //In case there are more than 10 group changes, a popup can display historical
     if ($nb_histories - 1 > self::HISTORY_LIMIT && !$full_history) {
         echo "<a href='#' onclick='var w=window.open(\"" . $plugin_dir . "/front/popup_histories.php?tickets_id=" . $tickets_id . "\" ,\"\", \"height=500, width=250, top=100, left=100, scrollbars=yes\" ); " . "w.focus();' title='" . __("View full history", "escalade") . "'>...</a>";
     }
     echo "</div>";
 }
開發者ID:korial29,項目名稱:escalade,代碼行數:60,代碼來源:history.class.php

示例2: plugin_init_escalation

function plugin_init_escalation()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['change_profile']['escalation'] = array('PluginEscalationProfile', 'changeprofile');
    $PLUGIN_HOOKS['csrf_compliant']['escalation'] = true;
    // After escalation, if user can't see the ticket (dan't see all ticket right), it redirect to ticket list
    if (isset($_SERVER['HTTP_REFERER']) and strstr($_SERVER['HTTP_REFERER'], "escalation/front/group_group.form.php")) {
        if (isset($_GET['id'])) {
            $ticket = new Ticket();
            $ticket->getFromDB($_GET['id']);
            if (!$ticket->canViewItem()) {
                // Can't see ticket, go in ticket list
                $ticket->redirectToList();
            }
        }
    }
    if (isset($_SESSION["glpiID"])) {
        $plugin = new Plugin();
        if ($plugin->isActivated('escalation')) {
            Plugin::registerClass('PluginEscalationProfile', array('addtabon' => array('Profile')));
            Plugin::registerClass('PluginEscalationTicketCopy', array('addtabon' => array('Ticket')));
            Plugin::registerClass('PluginEscalationConfig', array('addtabon' => array('Entity')));
            Plugin::registerClass('PluginEscalationGroup_Group', array('addtabon' => array('Ticket', 'Group')));
            $PLUGIN_HOOKS['menu_entry']['escalation'] = false;
            PluginEscalationGroup_Group::convertNewTicket();
            // limit group
            $peConfig = new PluginEscalationConfig();
            if ($peConfig->getValue('limitgroup', $_SESSION['glpidefault_entity']) == '1') {
                if (strpos($_SERVER['PHP_SELF'], "ticket.form.php") && !isset($_GET['id'])) {
                    $group = new Group();
                    $a_groups = array();
                    $a_groups[0] = Dropdown::EMPTY_VALUE;
                    foreach ($_SESSION['glpigroups'] as $groups_id) {
                        $group->getFromDB($groups_id);
                        $a_groups[$groups_id] = $group->getName();
                    }
                    $_SESSION['plugin_escalation_requestergroups'] = $a_groups;
                    register_shutdown_function('plugin_escalation_on_exit');
                    ob_start();
                }
            }
            // end limit group
        }
        $PLUGIN_HOOKS['pre_item_add']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'selectGroupOnAdd'));
        $PLUGIN_HOOKS['item_add']['escalation'] = array('Ticket' => array('PluginEscalationTicketCopy', 'finishAdd'));
        //         $PLUGIN_HOOKS['pre_item_update']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'notMultiple'));
    }
}
開發者ID:geldarr,項目名稱:hack-space,代碼行數:48,代碼來源:setup.php

示例3: pdfForGroup

 static function pdfForGroup(PluginPdfSimplePDF $pdf, Group $group, $tree)
 {
     global $DB, $CFG_GLPI;
     $used = array();
     $ids = array();
     // Retrieve member list
     $entityrestrict = Group_User::getDataForGroup($group, $used, $ids, '', $tree);
     $title = "<b>" . sprintf(__('%1$s (%2$s)'), _n('User', 'Users', 2) . "</b>", __('D=Dynamic'));
     $number = count($used);
     if ($number > $_SESSION['glpilist_limit']) {
         $title = sprintf(__('%1$s (%2$s)'), $title, $_SESSION['glpilist_limit'] . "/" . $number);
     } else {
         $title = sprintf(__('%1$s (%2$s)'), $title, $number);
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle($title);
     if ($number) {
         $user = new User();
         $group = new Group();
         if ($tree) {
             $pdf->setColumnsSize(35, 45, 10, 10);
             $pdf->displayTitle(User::getTypeName(1), Group::getTypeName(1), __('Manager'), __('Delegatee'));
         } else {
             $pdf->setColumnsSize(60, 20, 20);
             $pdf->displayTitle(User::getTypeName(1), __('Manager'), __('Delegatee'));
         }
         for ($i = 0; $i < $number && $i < $_SESSION['glpilist_limit']; $i++) {
             $data = $used[$i];
             $name = Html::clean(getUserName($data["id"]));
             if ($data["is_dynamic"]) {
                 $name = sprintf(__('%1$s (%2$s)'), $name, '<b>' . __('D') . '</b>');
             }
             if ($tree) {
                 $group->getFromDB($data["groups_id"]);
                 $pdf->displayLine($name, $group->getName(), Dropdown::getYesNo($data['is_manager']), Dropdown::getYesNo($data['is_userdelegate']));
             } else {
                 $pdf->displayLine($name, Dropdown::getYesNo($data['is_manager']), Dropdown::getYesNo($data['is_userdelegate']));
             }
         }
     } else {
         $pdf->setColumnsAlign('center');
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:45,代碼來源:group_user.class.php

示例4: showContacts

 function showContacts($itemtype, $items_id)
 {
     global $DB, $LANG, $CFG_GLPI;
     $this->addContact($itemtype, $items_id);
     $group = new Group();
     $user = new User();
     $rand = mt_rand();
     echo "<form method='post' name='contact_item_form{$rand}' id='contact_item_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/contact_item.form.php\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th>";
     echo $LANG['plugin_monitoring']['contact'][20];
     echo "</th>";
     echo "</tr>";
     echo "</table>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th width='10'>&nbsp;</th>";
     echo "<th>" . $LANG['common'][35] . " - " . $LANG['common'][16] . "</th>";
     echo "<th colspan='3'></th>";
     echo "</tr>";
     $used = array();
     // Display groups first
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `items_id`='" . $items_id . "'\n            AND `itemtype`='" . $itemtype . "'\n            AND `groups_id` > 0";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $group->getFromDB($data['groups_id']);
         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $group->getLink(1);
         echo "</td>";
         echo "<td colspan='3'>";
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr>";
     echo "<th width='10'>&nbsp;</th>";
     echo "<th>" . $LANG['common'][34] . " - " . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['setup'][14] . "</th>";
     echo "<th>" . $LANG['help'][35] . "</th>";
     echo "</tr>";
     $entity = new Entity();
     $used = array();
     // Display Users
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `items_id`='" . $items_id . "'\n            AND `itemtype`='" . $itemtype . "'\n            AND `users_id` > 0";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $user->getFromDB($data['users_id']);
         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $user->getLink(1);
         echo "</td>";
         $entity->getFromDB($data['entities_id']);
         echo "<td class='center'>";
         echo $entity->getName() . " <strong>(R)</strong>";
         echo "</td>";
         echo "<td class='center'>";
         echo $user->fields['email'];
         echo "</td>";
         echo "<td class='center'>";
         echo $user->fields['phone'];
         echo "</td>";
         echo "</tr>";
     }
     openArrowMassive("contact_item_form{$rand}", true);
     closeArrowMassive('deleteitem', $LANG['buttons'][6]);
     echo "</table>";
 }
開發者ID:RubichonL,項目名稱:glpi_monitoring,代碼行數:75,代碼來源:contact_item.class.php

示例5: generateServicesCfg

 function generateServicesCfg($file = 0, $tag = '')
 {
     global $DB;
     $pMonitoringCommand = new PluginMonitoringCommand();
     $pmEventhandler = new PluginMonitoringEventhandler();
     $pMonitoringCheck = new PluginMonitoringCheck();
     $pmComponent = new PluginMonitoringComponent();
     $pmEntity = new PluginMonitoringEntity();
     $pmContact_Item = new PluginMonitoringContact_Item();
     $pmService = new PluginMonitoringService();
     $pmComponentscatalog = new PluginMonitoringComponentscatalog();
     $calendar = new Calendar();
     $user = new User();
     $pmLog = new PluginMonitoringLog();
     $profile_User = new Profile_User();
     if (isset($_SERVER['HTTP_USER_AGENT']) and strstr($_SERVER['HTTP_USER_AGENT'], 'xmlrpclib.py')) {
         if (!isset($_SESSION['glpi_currenttime'])) {
             $_SESSION['glpi_currenttime'] = date("Y-m-d H:i:s");
         }
         $input = array();
         $input['user_name'] = "Shinken";
         $input['action'] = "restart";
         $input['date_mod'] = date("Y-m-d H:i:s");
         $pmLog->add($input);
     }
     $hostnamebp = '';
     $a_services = array();
     $i = 0;
     // * Prepare contacts
     $a_contacts_entities = array();
     $a_list_contact = $pmContact_Item->find("`itemtype`='PluginMonitoringComponentscatalog'\n         AND `users_id`>0");
     foreach ($a_list_contact as $data) {
         $contactentities = getSonsOf('glpi_entities', $data['entities_id']);
         if (isset($a_contacts_entities[$data['items_id']][$data['users_id']])) {
             $contactentities = array_merge($contactentities, $a_contacts_entities[$data['items_id']][$data['users_id']]);
         }
         $a_contacts_entities[$data['items_id']][$data['users_id']] = $contactentities;
     }
     // Groups
     $group = new Group();
     $a_list_contact = $pmContact_Item->find("`itemtype`='PluginMonitoringComponentscatalog'\n         AND `groups_id`>0");
     foreach ($a_list_contact as $data) {
         $group->getFromDB($data['groups_id']);
         if ($group->fields['is_recursive'] == 1) {
             $contactentities = getSonsOf('glpi_entities', $group->fields['entities_id']);
         } else {
             $contactentities = array($group->fields['entities_id'] => $group->fields['entities_id']);
         }
         $queryg = "SELECT * FROM `glpi_groups_users`\n            WHERE `groups_id`='" . $data['groups_id'] . "'";
         $resultg = $DB->query($queryg);
         while ($datag = $DB->fetch_array($resultg)) {
             if (isset($a_contacts_entities[$data['items_id']][$datag['users_id']])) {
                 $contactentities = array_merge($contactentities, $a_contacts_entities[$data['items_id']][$datag['users_id']]);
             }
             $a_contacts_entities[$data['items_id']][$datag['users_id']] = $contactentities;
         }
     }
     $a_entities_allowed = $pmEntity->getEntitiesByTag($tag);
     $query = "SELECT * FROM `glpi_plugin_monitoring_services`";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $notadd = 0;
         $notadddescription = '';
         $a_component = current($pmComponent->find("`id`='" . $data['plugin_monitoring_components_id'] . "'", "", 1));
         $a_hostname = array();
         $queryh = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts` \n            WHERE `id` = '" . $data['plugin_monitoring_componentscatalogs_hosts_id'] . "'\n            LIMIT 1";
         $resulth = $DB->query($queryh);
         $hostname = '';
         $plugin_monitoring_componentscatalogs_id = 0;
         while ($datah = $DB->fetch_array($resulth)) {
             $itemtype = $datah['itemtype'];
             $item = new $itemtype();
             if ($item->getFromDB($datah['items_id'])) {
                 if (isset($a_entities_allowed['-1']) or isset($a_entities_allowed[$item->fields['entities_id']])) {
                     $a_hostname[] = $itemtype . "-" . $datah['items_id'] . "-" . preg_replace("/[^A-Za-z0-9]/", "", $item->fields['name']);
                     $hostname = $item->fields['name'];
                     $plugin_monitoring_componentscatalogs_id = $datah['plugin_monitoring_componentscalalog_id'];
                 }
             }
         }
         if (count($a_hostname) > 0) {
             if (isset($_SESSION['plugin_monitoring']['servicetemplates'][$a_component['id']])) {
                 $a_services[$i]['use'] = $_SESSION['plugin_monitoring']['servicetemplates'][$a_component['id']];
             }
             $a_services[$i]['host_name'] = implode(",", array_unique($a_hostname));
             $hostnamebp = $a_services[$i]['host_name'];
             // For business rules
             $a_services[$i]['service_description'] = preg_replace("/[^A-Za-z0-9]/", "", $a_component['name']) . "-" . $data['id'];
             $pMonitoringCommand->getFromDB($a_component['plugin_monitoring_commands_id']);
             // Manage arguments
             $array = array();
             preg_match_all("/\\\$(ARG\\d+)\\\$/", $pMonitoringCommand->fields['command_line'], $array);
             sort($array[0]);
             $a_arguments = importArrayFromDB($a_component['arguments']);
             $a_argumentscustom = importArrayFromDB($data['arguments']);
             foreach ($a_argumentscustom as $key => $value) {
                 $a_arguments[$key] = $value;
             }
             $args = '';
             foreach ($array[0] as $arg) {
//.........這裏部分代碼省略.........
開發者ID:geldarr,項目名稱:hack-space,代碼行數:101,代碼來源:shinken.class.php

示例6: showGroupsAssociated

 /**
  * show groups asociated
  *
  * @param $type      integer : user type
  * @param $canedit   boolean : can edit ?
  * @param $options   array    options for default values ($options of showForm)
  *
  * @return nothing display
  **/
 function showGroupsAssociated($type, $canedit, array $options = array())
 {
     global $CFG_GLPI;
     $groupicon = self::getActorIcon('group', $type);
     $group = new Group();
     $linkclass = new $this->grouplinkclass();
     $itemtype = $this->getType();
     $typename = self::getActorFieldNameType($type);
     $candelete = true;
     $mandatory = '';
     // For ticket templates : mandatories
     if ($itemtype == 'Ticket' && isset($options['_tickettemplate'])) {
         $mandatory = $options['_tickettemplate']->getMandatoryMark("_groups_id_" . $typename);
         if ($options['_tickettemplate']->isMandatoryField("_groups_id_" . $typename) && isset($this->groups[$type]) && count($this->groups[$type]) == 1) {
             $candelete = false;
         }
     }
     if (isset($this->groups[$type]) && count($this->groups[$type])) {
         foreach ($this->groups[$type] as $d) {
             $k = $d['groups_id'];
             echo "{$mandatory}{$groupicon}&nbsp;";
             if ($group->getFromDB($k)) {
                 echo $group->getLink(array('comments' => true));
             }
             if ($canedit && $candelete) {
                 echo "&nbsp;";
                 Html::showSimpleForm($linkclass->getFormURL(), 'delete', _x('button', 'Delete permanently'), array('id' => $d['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png");
             }
             echo '<br>';
         }
     }
 }
開發者ID:paisdelconocimiento,項目名稱:glpi-smartcities,代碼行數:41,代碼來源:commonitilobject.class.php

示例7: showItems

 /**
  * Show items for the group
  *
  * @param $tech   boolean  false search groups_id, true, search groups_id_tech
  **/
 function showItems($tech)
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $ID = $this->fields['id'];
     if ($tech) {
         $types = $CFG_GLPI['linkgroup_tech_types'];
         $field = 'groups_id_tech';
         $title = __('Managed items');
     } else {
         $types = $CFG_GLPI['linkgroup_types'];
         $field = 'groups_id';
         $title = __('Used items');
     }
     $tree = Session::getSavedOption(__CLASS__, 'tree', 0);
     $user = Session::getSavedOption(__CLASS__, 'user', 0);
     $type = Session::getSavedOption(__CLASS__, 'onlytype', '');
     if (!in_array($type, $types)) {
         $type = '';
     }
     echo "<div class='spaced'>";
     // Mini Search engine
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><th colspan='3'>{$title}</tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     echo __('Type') . "&nbsp;";
     Dropdown::showItemType($types, array('value' => $type, 'name' => 'onlytype', 'plural' => true, 'on_change' => 'reloadTab("start=0&onlytype="+this.value)', 'checkright' => true));
     if ($this->haveChildren()) {
         echo "</td><td class='center'>" . __('Child groups') . "&nbsp;";
         Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
     } else {
         $tree = 0;
     }
     if ($this->getField('is_usergroup')) {
         echo "</td><td class='center'>" . User::getTypeName(Session::getPluralNumber()) . "&nbsp;";
         Dropdown::showYesNo('user', $user, -1, array('on_change' => 'reloadTab("start=0&user="+this.value)'));
     } else {
         $user = 0;
     }
     echo "</td></tr></table>";
     $datas = array();
     if ($type) {
         $types = array($type);
     }
     $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
     $nb = $this->getDataItems($types, $field, $tree, $user, $start, $datas);
     $nbcan = 0;
     if ($nb) {
         Html::printAjaxPager('', $start, $nb);
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         echo Html::hidden('field', array('value' => $field, 'data-glpicore-ma-tags' => 'common'));
         $massiveactionparams = array('num_displayed' => $nb, 'check_itemtype' => 'Group', 'check_items_id' => $ID, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('is_tech' => $tech, 'massive_action_fields' => array('field')), 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'changegroup' => __('Move')));
         Html::showMassiveActions($massiveactionparams);
         echo "<table class='tab_cadre_fixehov'>";
         $header_begin = "<tr><th width='10'>";
         $header_top = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_end = '</th>';
         $header_end .= "<th>" . __('Type') . "</th><th>" . __('Name') . "</th><th>" . __('Entity') . "</th>";
         if ($tree || $user) {
             $header_end .= "<th>" . sprintf(__('%1$s / %2$s'), self::getTypeName(1), User::getTypeName(1)) . "</th>";
         }
         $header_end .= "</tr>";
         echo $header_begin . $header_top . $header_end;
         $tuser = new User();
         $group = new Group();
         foreach ($datas as $data) {
             if (!($item = getItemForItemtype($data['itemtype']))) {
                 continue;
             }
             echo "<tr class='tab_bg_1'><td>";
             if ($item->canEdit($data['items_id'])) {
                 Html::showMassiveActionCheckBox($data['itemtype'], $data['items_id']);
             }
             echo "</td><td>" . $item->getTypeName(1);
             echo "</td><td>" . $item->getLink(array('comments' => true));
             echo "</td><td>" . Dropdown::getDropdownName("glpi_entities", $item->getEntityID());
             if ($tree || $user) {
                 echo "</td><td>";
                 if ($grp = $item->getField($field)) {
                     if ($group->getFromDB($grp)) {
                         echo $group->getLink(array('comments' => true));
                     }
                 } else {
                     if ($usr = $item->getField(str_replace('groups', 'users', $field))) {
                         if ($tuser->getFromDB($usr)) {
                             echo $tuser->getLink(array('comments' => true));
                         }
                     }
                 }
             }
             echo "</td></tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
//.........這裏部分代碼省略.........
開發者ID:korial29,項目名稱:glpi,代碼行數:101,代碼來源:group.class.php

示例8: getGroups

 function getGroups($ticket_id, $removeAlreadyAssigned = true)
 {
     $groups = $user_groups = $ticket_groups = array();
     // get groups for user connected
     $tmp_user_groups = Group_User::getUserGroups($_SESSION['glpiID']);
     foreach ($tmp_user_groups as $current_group) {
         $user_groups[$current_group['id']] = $current_group['id'];
         $groups[$current_group['id']] = $current_group['id'];
     }
     // get groups already assigned in the ticket
     if ($ticket_id > 0) {
         $ticket = new Ticket();
         $ticket->getFromDB($ticket_id);
         foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $current_group) {
             $ticket_groups[$current_group['groups_id']] = $current_group['groups_id'];
         }
     }
     // To do an escalation, the user must be in a group currently assigned to the ticket
     // or no group is assigned to the ticket
     // TODO : matching with "view all tickets (yes/no) option in profile user"
     if (!empty($ticket_groups) && count(array_intersect($ticket_groups, $user_groups)) == 0) {
         return array();
     }
     //get all group which we can climb
     if (count($groups) > 0) {
         $group_group = $this->find("groups_id_source IN (" . implode(", ", $groups) . ")");
         foreach ($group_group as $current_group) {
             $groups[$current_group['groups_id_destination']] = $current_group['groups_id_destination'];
         }
     }
     //remove already assigned groups
     if (!empty($ticket_groups) && $removeAlreadyAssigned) {
         $groups = array_diff_assoc($groups, $ticket_groups);
     }
     //add name to returned groups and remove non assignable groups
     $group_obj = new Group();
     foreach ($groups as $groups_id => &$groupname) {
         $group_obj->getFromDB($groups_id);
         //check if we can assign this group
         if ($group_obj->fields['is_assign'] == 0) {
             unset($groups[$groups_id]);
             continue;
         }
         //add name
         $groupname = $group_obj->fields['name'];
     }
     //sort by group name (and keep associative index)
     asort($groups);
     return $groups;
 }
開發者ID:korial29,項目名稱:escalade,代碼行數:50,代碼來源:group_group.class.php

示例9: pdfItems

 static function pdfItems(PluginPdfSimplePDF $pdf, Group $group, $tech, $tree, $user)
 {
     global $CFG_GLPI;
     if ($tech) {
         $types = $CFG_GLPI['linkgroup_tech_types'];
         $field = 'groups_id_tech';
         $title = __('Managed items');
     } else {
         $types = $CFG_GLPI['linkgroup_types'];
         $field = 'groups_id';
         $title = __('Used items');
     }
     $datas = array();
     $max = $group->getDataItems($types, $field, $tree, $user, 0, $datas);
     $nb = count($datas);
     if ($nb < $max) {
         $title = sprintf(__('%1$s (%2$s)'), $title, $nb / $max);
     } else {
         $title = sprintf(__('%1$s (%2$s)'), $title, $nb);
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle($title);
     if ($nb) {
         if ($tree || $user) {
             $pdf->setColumnsSize(16, 20, 34, 30);
             $pdf->displayTitle(__('Type'), __('Name'), __('Entity'), Group::getTypeName(1) . " / " . User::getTypeName(1));
         } else {
             $pdf->setColumnsSize(20, 25, 55);
             $pdf->displayTitle(__('Type'), __('Name'), __('Entity'));
         }
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $tmpgrp = new Group();
     $tmpusr = new User();
     foreach ($datas as $data) {
         if (!($item = getItemForItemtype($data['itemtype']))) {
             continue;
         }
         $item->getFromDB($data['items_id']);
         $col4 = '';
         if ($tree || $user) {
             if ($grp = $item->getField($field)) {
                 if ($tmpgrp->getFromDB($grp)) {
                     $col4 = $tmpgrp->getNameID();
                 }
             } else {
                 if ($usr = $item->getField(str_replace('groups', 'users', $field))) {
                     $col4 = Html::clean(getUserName($usr));
                 }
             }
         }
         $pdf->displayLine($item->getTypeName(1), $item->getName(), Html::clean(Dropdown::getDropdownName("glpi_entities", $item->getEntityID())), $col4);
     }
     $pdf->displaySpace();
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:56,代碼來源:group.class.php

示例10: showContacts

   function showContacts($itemtype, $items_id) {
      global $DB,$CFG_GLPI;

      $this->addContact($itemtype, $items_id);

      $group = new Group();
      $user  = new User();

      $rand = mt_rand();

      echo "<form method='post' name='contact_item_form$rand' id='contact_item_form$rand' action=\"".
                $CFG_GLPI["root_doc"]."/plugins/monitoring/front/contact_item.form.php\">";

      echo "<table class='tab_cadre_fixe'>";

      echo "<tr>";
      echo "<th>";
      echo __('Contacts', 'monitoring');
      echo "</th>";
      echo "</tr>";

      echo "</table>";

      echo "<table class='tab_cadre_fixe'>";

      echo "<tr>";
      echo "<th width='10'>&nbsp;</th>";
      echo "<th>".__('Group')." - ".__('Name')."</th>";
      echo "<th colspan='3'></th>";
      echo "</tr>";

      $used = array();
      // Display groups first
      $query = "SELECT * FROM `".$this->getTable()."`
         WHERE `items_id`='".$items_id."'
            AND `itemtype`='".$itemtype."'
            AND `groups_id` > 0";
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $group->getFromDB($data['groups_id']);

         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[".$data["id"]."]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $group->getLink(1);
         echo "</td>";
         echo "<td colspan='3'>";

         echo "</td>";

         echo "</tr>";
      }

      echo "<tr>";
      echo "<th width='10'>&nbsp;</th>";
      echo "<th>".__('User')." - ".__('Name')."</th>";
      echo "<th>".__('Entity')."</th>";
      echo "<th>".__('Email address')."</th>";
      echo "<th>".__('Phone')."</th>";
      echo "</tr>";

      $entity = new Entity();
      $used = array();
      // Display Users
      $query = "SELECT * FROM `".$this->getTable()."`
         WHERE `items_id`='".$items_id."'
            AND `itemtype`='".$itemtype."'
            AND `users_id` > 0";
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $user->getFromDB($data['users_id']);

         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[".$data["id"]."]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $user->getLink(1);
         echo "</td>";
         $entity->getFromDB($data['entities_id']);
         echo "<td class='center'>";
         echo $entity->getName()." <strong>(R)</strong>";
         echo "</td>";
         echo "<td class='center'>";
         $a_emails = UserEmail::getAllForUser($data['users_id']);
         $first = 0;
         foreach ($a_emails as $email) {
            if ($first == 0) {
               echo $email;
            }
            $first++;
         }
         echo "</td>";
         echo "<td class='center'>";
         echo $user->fields['phone'];
         echo "</td>";

         echo "</tr>";
//.........這裏部分代碼省略.........
開發者ID:euqip,項目名稱:glpi-smartcities,代碼行數:101,代碼來源:contact_item.class.php

示例11: plugin_timelineticket_giveItem

function plugin_timelineticket_giveItem($type, $ID, $data, $num)
{
    global $CFG_GLPI, $DB;
    $searchopt =& Search::getOptions($type);
    $table = $searchopt[$ID]["table"];
    $field = $searchopt[$ID]["field"];
    switch ($table . '.' . $field) {
        case "glpi_plugin_timelineticket_grouplevels.groups":
            if (empty($data["ITEM_{$num}"])) {
                $out = __('None');
            } else {
                $out = "";
                $groups = json_decode($data["ITEM_{$num}"], true);
                if (!empty($groups)) {
                    foreach ($groups as $key => $val) {
                        $out .= Dropdown::getDropdownName("glpi_groups", $val) . "<br>";
                    }
                }
            }
            return $out;
            break;
        case "glpi_plugin_timelineticket_assigngroups.groups_id":
            $ptAssignGroup = new PluginTimelineticketAssignGroup();
            $group = new Group();
            $ticket = new Ticket();
            $out = "";
            $a_out = array();
            $a_groupname = array();
            if (!isset($data["ITEM_{$num}"]) or !strstr($data["ITEM_{$num}"], '$$')) {
                return "";
            }
            $splitg = explode("\$\$\$\$", $data["ITEM_{$num}"]);
            foreach ($splitg as $datag) {
                $split = explode("\$\$", $datag);
                $group->getFromDB($split[0]);
                $ptAssignGroup->getFromDB($split[1]);
                $time = $ptAssignGroup->fields['delay'];
                if ($ptAssignGroup->fields['delay'] === NULL) {
                    $ticket->getFromDB($data["ITEM_0"]);
                    $calendar = new Calendar();
                    $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
                    $datedebut = $ptAssignGroup->fields['date'];
                    $enddate = $_SESSION["glpi_currenttime"];
                    if ($ticket->fields['status'] == Ticket::CLOSED) {
                        $enddate = $ticket->fields['closedate'];
                    }
                    if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
                        $time = $calendar->getActiveTimeBetween($datedebut, $enddate);
                    } else {
                        // cas 24/24 - 7/7
                        $time = strtotime($enddate) - strtotime($datedebut);
                    }
                } else {
                    if ($ptAssignGroup->fields['delay'] == 0) {
                        $time = 0;
                    }
                }
                $a_groupname[$group->fields['id']] = $group->getLink();
                if (isset($a_out[$group->fields['id']])) {
                    $a_out[$group->fields['id']] += $time;
                } else {
                    $a_out[$group->fields['id']] = $time;
                }
            }
            $a_out_comp = array();
            foreach ($a_out as $groups_id => $time) {
                $a_out_comp[] = $a_groupname[$groups_id] . " : " . Html::timestampToString($time, TRUE, FALSE);
            }
            $out = implode("<hr/>", $a_out_comp);
            return $out;
            break;
    }
    return "";
}
開發者ID:pluginsGLPI,項目名稱:timelineticket,代碼行數:74,代碼來源:hook.php

示例12: addHistoryOnAddGroup

 /**
  *  remove old groups to a ticket when a new group assigned
  *  called by "pre_item_add" hook on Group_Ticket object
  * @param CommonDBTM $item the ticket object
  */
 static function addHistoryOnAddGroup(CommonDBTM $item)
 {
     global $DB;
     if ($_SESSION['plugins']['escalade']['config']['remove_group'] == false) {
         return true;
     }
     //if group sent is not an assign group, return
     if ($item->input['type'] != CommonITILActor::ASSIGN) {
         return;
     }
     $tickets_id = $item->input['tickets_id'];
     $groups_id = $item->input['groups_id'];
     //if group already assigned, return
     $group_ticket = new Group_Ticket();
     $condition = "tickets_id = {$tickets_id} AND groups_id = {$groups_id} AND type = 2";
     if ($group_ticket->find($condition)) {
         unset($_SESSION['plugin_escalade']['keep_users']);
         return;
     }
     $item->fields['status'] = CommonITILObject::ASSIGNED;
     //add line in history table
     $history = new PluginEscaladeHistory();
     $history->add(array('tickets_id' => $tickets_id, 'groups_id' => $groups_id));
     //remove old user(s) (pass if user added by new ticket form)
     $backtrace = debug_backtrace();
     $first_trace = array_pop($backtrace);
     if (strpos($first_trace['file'], 'ticket.form.php') === false || $first_trace['function'] != "add" || !$first_trace['object'] instanceof Ticket) {
         self::removeAssignUsers($tickets_id);
     }
     //add a task to inform the escalation (pass if solution)
     if (isset($_SESSION['plugin_escalade']['solution'])) {
         unset($_SESSION['plugin_escalade']['solution']);
         return $item;
     }
     if ($_SESSION['plugins']['escalade']['config']['task_history']) {
         $group = new Group();
         $group->getFromDB($groups_id);
         $task = new TicketTask();
         $task->add(array('tickets_id' => $tickets_id, 'is_private' => true, 'state' => 0, 'content' => __("escalated to the group", "escalade") . " " . $group->getName()));
     }
     //check if event is not triggered by behaviors plugin
     //to prevent user remove when "add technician group" option is active
     if (strpos($first_trace['file'], 'ticket.form.php') !== false && $first_trace['function'] == "add" && $first_trace['object'] instanceof Ticket) {
         return;
     }
     if ($_SESSION['plugins']['escalade']['config']['ticket_last_status'] != -1) {
         $ticket = new Ticket();
         $ticket->update(array('id' => $tickets_id, 'status' => $_SESSION['plugins']['escalade']['config']['ticket_last_status']));
     }
     return $item;
 }
開發者ID:korial29,項目名稱:escalade,代碼行數:56,代碼來源:ticket.class.php

示例13: showGrupos

 static function showGrupos(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $objeto = $item->getType();
     $appli = new $objeto();
     $ID = $item->fields['id'];
     $appli->getFromDB($item->fields['id']);
     //$canedit = $appli->can($appli->fields['id'],'w');
     $canedit = $appli->canCreate();
     //$canedit = Session::haveRight('update_ticket', 1);
     $rand = mt_rand();
     $groups = self::getFormGroups($ID);
     $used = array();
     if (!empty($groups)) {
         foreach ($groups as $data) {
             $used[$data["id"]] = $data["id"];
         }
     }
     echo "<div class='center'>";
     echo "<form name='form_grupo' id='form_grupo' method='post' action='../front/formgroup.form.php'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<th colspan=2>" . __('Grupos', 'Grupos') . "</th>";
     echo "<tr>";
     echo "<th>" . __('Grupo', 'Grupo') . "&nbsp;:" . "</th>";
     echo "<td>";
     if ($canedit) {
         Group::dropdown(array('name' => 'groups_id', 'entity' => $_SESSION['glpiactive_entity'], 'condition' => '`is_assign`'));
     }
     echo "</td>";
     //-----------------------------
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' align = 'center'>";
     echo "<input type='submit' name='agregarGrupo' value='Agregar' class='submit'>";
     echo "</td></tr>";
     echo "</table>";
     echo "<input type='hidden' name='itemtype' value='Group'>";
     echo "<input type='hidden' name='peticion_id' value='" . $item->fields['id'] . "'>";
     //echo "</form>";
     Html::closeForm();
     echo "</div>";
     // Listado de Grupos
     echo "<div class='spaced'>";
     /*
           if ($canedit && count($used)) {
              $rand = mt_rand();
              Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
              echo "<input type='hidden' name='plugin_formcreator_forms_id' value='".$item->fields['id']."'>";
              $massiveactionparams = array('num_displayed' => count($used),
                                'container'     => 'mass'.__CLASS__.$rand);
              Html::showMassiveActions($massiveactionparams);
           }*/
     if ($canedit && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => count($used));
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && count($used)) {
         $header_begin .= "<th width='10'>";
         $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_end .= "</th>";
     }
     $header_end .= "<th>" . Group::getTypeName(1) . "</th>";
     echo $header_begin . $header_top . $header_end;
     $group = new Group();
     if (!empty($groups)) {
         Session::initNavigateListItems('PluginFormcreatorForm', sprintf(__('%1$s = %2$s'), $item::getTypeName(1), $item->getName()));
         foreach ($groups as $data) {
             if (!$group->getFromDB($data["id"])) {
                 continue;
             }
             Session::addToNavigateListItems('PluginFormcreatorForm', $data["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit && count($used)) {
                 echo "<td width='10'>";
                 // echo __CLASS__;
                 Html::showMassiveActionCheckBox('PluginFormcreatorForm_Item', $data["linkID"]);
                 echo "</td>";
             }
             $link = $data["completename"];
             if ($_SESSION["glpiis_ids_visible"]) {
                 $link = sprintf(__('%1$s (%2$s)'), $link, $data["id"]);
             }
             $href = "<a href='" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["id"] . "'>" . $link . "</a>";
             echo "<td>" . $group->getLink() . "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
     } else {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='5' class='center'>" . __('None') . "</td></tr>";
     }
     echo "</table>";
     if ($canedit && count($used)) {
//.........這裏部分代碼省略.........
開發者ID:OscarLoayzaB,項目名稱:formcreator,代碼行數:101,代碼來源:formgroup.class.php

示例14: prepareRun

 function prepareRun($taskjobs_id)
 {
     global $DB;
     $task = new PluginFusioninventoryTask();
     $job = new PluginFusioninventoryTaskjob();
     $joblog = new PluginFusioninventoryTaskjoblog();
     $jobstate = new PluginFusioninventoryTaskjobstate();
     $agent = new PluginFusioninventoryAgent();
     $uniqid = uniqid();
     $job->getFromDB($taskjobs_id);
     $task->getFromDB($job->fields['plugin_fusioninventory_tasks_id']);
     $communication = $task->fields['communication'];
     $actions = importArrayFromDB($job->fields['action']);
     $definitions = importArrayFromDB($job->fields['definition']);
     $taskvalid = 0;
     $computers = array();
     foreach ($actions as $action) {
         $itemtype = key($action);
         $items_id = current($action);
         switch ($itemtype) {
             case 'Computer':
                 $computers[] = $items_id;
                 break;
             case 'Group':
                 $computer_object = new Computer();
                 //find computers by user associated with this group
                 $group_users = new Group_User();
                 $group = new Group();
                 $group->getFromDB($items_id);
                 $members = array();
                 $computers_a_1 = array();
                 $computers_a_2 = array();
                 //array_keys($group_users->find("groups_id = '$items_id'"));
                 $members = $group_users->getGroupUsers($items_id);
                 foreach ($members as $member) {
                     $computers = $computer_object->find("users_id = '{$member['id']}'");
                     foreach ($computers as $computer) {
                         $computers_a_1[] = $computer['id'];
                     }
                 }
                 //find computers directly associated with this group
                 $computers = $computer_object->find("groups_id = '{$items_id}'");
                 foreach ($computers as $computer) {
                     $computers_a_2[] = $computer['id'];
                 }
                 //merge two previous array and deduplicate entries
                 $computers = array_unique(array_merge($computers_a_1, $computers_a_2));
                 break;
             case 'PluginFusioninventoryDeployGroup':
                 $group = new PluginFusioninventoryDeployGroup();
                 $group->getFromDB($items_id);
                 switch ($group->getField('type')) {
                     case 'STATIC':
                         $query = "SELECT items_id\n                     FROM glpi_plugin_fusioninventory_deploygroups_staticdatas\n                     WHERE groups_id = '{$items_id}'\n                     AND itemtype = 'Computer'";
                         $res = $DB->query($query);
                         while ($row = $DB->fetch_assoc($res)) {
                             $computers[] = $row['items_id'];
                         }
                         break;
                     case 'DYNAMIC':
                         $query = "SELECT fields_array\n                     FROM glpi_plugin_fusioninventory_deploygroups_dynamicdatas\n                     WHERE groups_id = '{$items_id}'\n                     LIMIT 1";
                         $res = $DB->query($query);
                         $row = $DB->fetch_assoc($res);
                         if (isset($_GET)) {
                             $get_tmp = $_GET;
                         }
                         if (isset($_SESSION["glpisearchcount"]['Computer'])) {
                             unset($_SESSION["glpisearchcount"]['Computer']);
                         }
                         if (isset($_SESSION["glpisearchcount2"]['Computer'])) {
                             unset($_SESSION["glpisearchcount2"]['Computer']);
                         }
                         $_GET = importArrayFromDB($row['fields_array']);
                         $_GET["glpisearchcount"] = count($_GET['field']);
                         if (isset($_GET['field2'])) {
                             $_GET["glpisearchcount2"] = count($_GET['field2']);
                         }
                         $pfSearch = new PluginFusioninventorySearch();
                         Search::manageGetValues('Computer');
                         $glpilist_limit = $_SESSION['glpilist_limit'];
                         $_SESSION['glpilist_limit'] = 999999999;
                         $result = $pfSearch->constructSQL('Computer', $_GET);
                         $_SESSION['glpilist_limit'] = $glpilist_limit;
                         while ($data = $DB->fetch_array($result)) {
                             $computers[] = $data['id'];
                         }
                         if (count($get_tmp) > 0) {
                             $_GET = $get_tmp;
                         }
                         break;
                 }
                 break;
         }
     }
     $c_input = array();
     $c_input['plugin_fusioninventory_taskjobs_id'] = $taskjobs_id;
     $c_input['state'] = 0;
     $c_input['plugin_fusioninventory_agents_id'] = 0;
     $c_input['execution_id'] = $task->fields['execution_id'];
     $pfCollect = new PluginFusioninventoryCollect();
//.........這裏部分代碼省略.........
開發者ID:paisdelconocimiento,項目名稱:glpi-smartcities,代碼行數:101,代碼來源:collect.class.php

示例15: showGroupsAssociated

 /**
  * show groups asociated
  *
  * @param $type      integer : user type
  * @param $canedit   boolean : can edit ?
  *
  * @return nothing display
  **/
 function showGroupsAssociated($type, $canedit)
 {
     global $CFG_GLPI;
     $groupicon = self::getActorIcon('group', $type);
     $group = new Group();
     if (isset($this->groups[$type]) && count($this->groups[$type])) {
         foreach ($this->groups[$type] as $d) {
             $k = $d['groups_id'];
             echo "{$groupicon}&nbsp;";
             if ($group->getFromDB($k)) {
                 echo $group->getLink(array('comments' => true));
             }
             if ($canedit) {
                 echo "&nbsp;";
                 Html::showSimpleForm($this->getFormURL(), 'delete_group', _x('button', 'Delete permanently'), array('id' => $d['id'], $this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png");
             }
             echo '<br>';
         }
     }
 }
開發者ID:gaforeror,項目名稱:glpi,代碼行數:28,代碼來源:commonitilobject.class.php


注:本文中的Group::getFromDB方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。