当前位置: 首页>>代码示例>>PHP>>正文


PHP Group_User::getGroupUsers方法代码示例

本文整理汇总了PHP中Group_User::getGroupUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP Group_User::getGroupUsers方法的具体用法?PHP Group_User::getGroupUsers怎么用?PHP Group_User::getGroupUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Group_User的用法示例。


在下文中一共展示了Group_User::getGroupUsers方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAllUsers

 /**
  * get users linked to an object including groups ones
  *
  * @since version 0.85
  *
  * @param $type type to search (see constants)
  *
  * @return array
  **/
 function getAllUsers($type)
 {
     $users = array();
     foreach ($this->getUsers($type) as $link) {
         $users[$link['users_id']] = $link['users_id'];
     }
     foreach ($this->getGroups($type) as $link) {
         $gusers = Group_User::getGroupUsers($link['groups_id']);
         foreach ($gusers as $user) {
             $users[$user['id']] = $user['id'];
         }
     }
     return $users;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:23,代码来源:commonitilobject.class.php

示例2: post_addItem

 function post_addItem()
 {
     global $CFG_GLPI;
     // Log this event
     $username = 'anonymous';
     if (isset($_SESSION["glpiname"])) {
         $username = $_SESSION["glpiname"];
     }
     Event::log($this->fields['id'], "ticket", 4, "tracking", sprintf(__('%1$s adds the item %2$s'), $username, $this->fields['id']));
     if (isset($this->input["_followup"]) && is_array($this->input["_followup"]) && strlen($this->input["_followup"]['content']) > 0) {
         $fup = new TicketFollowup();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
         if (isset($this->input["_followup"]['content']) && strlen($this->input["_followup"]['content']) > 0) {
             $toadd["content"] = $this->input["_followup"]['content'];
         }
         if (isset($this->input["_followup"]['is_private'])) {
             $toadd["is_private"] = $this->input["_followup"]['is_private'];
         }
         $toadd['_no_notif'] = true;
         $fup->add($toadd);
     }
     if (isset($this->input["plan"]) && count($this->input["plan"]) || isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
         $task = new TicketTask();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id'], "actiontime" => $this->input["actiontime"]);
         if (isset($this->input["plan"]) && count($this->input["plan"])) {
             $toadd["plan"] = $this->input["plan"];
         }
         if (isset($_SESSION['glpitask_private'])) {
             $toadd['is_private'] = $_SESSION['glpitask_private'];
         }
         $toadd['_no_notif'] = true;
         $task->add($toadd);
     }
     $ticket_ticket = new Ticket_Ticket();
     // From interface
     if (isset($this->input['_link'])) {
         $this->input['_link']['tickets_id_1'] = $this->fields['id'];
         // message if ticket's ID doesn't exist
         if (!empty($this->input['_link']['tickets_id_2'])) {
             if ($ticket_ticket->can(-1, 'w', $this->input['_link'])) {
                 $ticket_ticket->add($this->input['_link']);
             } else {
                 Session::addMessageAfterRedirect(__('Unknown ticket'), false, ERROR);
             }
         }
     }
     // From mailcollector : do not check rights
     if (isset($this->input["_linkedto"])) {
         $input2['tickets_id_1'] = $this->fields['id'];
         $input2['tickets_id_2'] = $this->input["_linkedto"];
         $input2['link'] = Ticket_Ticket::LINK_TO;
         $ticket_ticket->add($input2);
     }
     // Manage SLA Level : add actions
     if (isset($this->input["slas_id"]) && $this->input["slas_id"] > 0 && isset($this->input["slalevels_id"]) && $this->input["slalevels_id"] > 0) {
         $calendars_id = Entity::getUsedConfig('calendars_id', $this->fields['entities_id']);
         $sla = new SLA();
         if ($sla->getFromDB($this->input["slas_id"])) {
             $sla->setTicketCalendar($calendars_id);
             // Add first level in working table
             if ($this->input["slalevels_id"] > 0) {
                 $sla->addLevelToDo($this);
             }
             // Replay action in case of open date is set before now
         }
         SlaLevel_Ticket::replayForTicket($this->getID());
     }
     parent::post_addItem();
     //Action for send_validation rule
     if (isset($this->input["_add_validation"])) {
         $validations_to_send = array();
         if (!is_array($this->input["_add_validation"])) {
             $this->input["_add_validation"] = array($this->input["_add_validation"]);
         }
         foreach ($this->input["_add_validation"] as $validation) {
             switch ($validation) {
                 case 'requester_supervisor':
                     if (isset($this->input['_groups_id_requester']) && $this->input['_groups_id_requester']) {
                         $users = Group_User::getGroupUsers($this->input['_groups_id_requester'], "is_manager='1'");
                         foreach ($users as $data) {
                             $validations_to_send[] = $data['id'];
                         }
                     }
                     break;
                 case 'assign_supervisor':
                     if (isset($this->input['_groups_id_assign']) && $this->input['_groups_id_assign']) {
                         $users = Group_User::getGroupUsers($this->input['_groups_id_assign'], "is_manager='1'");
                         foreach ($users as $data) {
                             $validations_to_send[] = $data['id'];
                         }
                     }
                     break;
//.........这里部分代码省略.........
开发者ID:gaforeror,项目名称:glpi,代码行数:101,代码来源:ticket.class.php

示例3: manageValidationAdd

 /**
  * Manage Validation add from input
  *
  * @since version 0.85
  *
  * @param $input array : input array
  *
  * @return nothing
  **/
 function manageValidationAdd($input)
 {
     //Action for send_validation rule
     if (isset($input["_add_validation"])) {
         if (isset($input['entities_id'])) {
             $entid = $input['entities_id'];
         } else {
             if (isset($this->fields['entities_id'])) {
                 $entid = $this->fields['entities_id'];
             } else {
                 return false;
             }
         }
         $validations_to_send = array();
         if (!is_array($input["_add_validation"])) {
             $input["_add_validation"] = array($input["_add_validation"]);
         }
         foreach ($input["_add_validation"] as $key => $validation) {
             switch ($validation) {
                 case 'requester_supervisor':
                     if (isset($input['_groups_id_requester']) && $input['_groups_id_requester']) {
                         $users = Group_User::getGroupUsers($input['_groups_id_requester'], "is_manager='1'");
                         foreach ($users as $data) {
                             $validations_to_send[] = $data['id'];
                         }
                     }
                     // Add to already set groups
                     foreach ($this->getGroups(CommonITILActor::REQUESTER) as $d) {
                         $users = Group_User::getGroupUsers($d['groups_id'], "is_manager='1'");
                         foreach ($users as $data) {
                             $validations_to_send[] = $data['id'];
                         }
                     }
                     break;
                 case 'assign_supervisor':
                     if (isset($input['_groups_id_assign']) && $input['_groups_id_assign']) {
                         $users = Group_User::getGroupUsers($input['_groups_id_assign'], "is_manager='1'");
                         foreach ($users as $data) {
                             $validations_to_send[] = $data['id'];
                         }
                     }
                     foreach ($this->getGroups(CommonITILActor::ASSIGN) as $d) {
                         $users = Group_User::getGroupUsers($d['groups_id'], "is_manager='1'");
                         foreach ($users as $data) {
                             $validations_to_send[] = $data['id'];
                         }
                     }
                     break;
                 default:
                     // Group case from rules
                     if ($key === 'group') {
                         foreach ($validation as $groups_id) {
                             $validation_right = 'validate_incident';
                             if (isset($input['type']) && $input['type'] == Ticket::DEMAND_TYPE) {
                                 $validation_right = 'validate_request';
                             }
                             $opt = array('groups_id' => $groups_id, 'right' => $validation_right, 'entity' => $entid);
                             $data_users = TicketValidation::getGroupUserHaveRights($opt);
                             foreach ($data_users as $user) {
                                 $validations_to_send[] = $user['id'];
                             }
                         }
                     } else {
                         $validations_to_send[] = $validation;
                     }
             }
         }
         // Validation user added on ticket form
         if (isset($input['users_id_validate'])) {
             if (array_key_exists('groups_id', $input['users_id_validate'])) {
                 foreach ($input['users_id_validate'] as $key => $validation_to_add) {
                     if (is_numeric($key)) {
                         $validations_to_send[] = $validation_to_add;
                     }
                 }
             } else {
                 foreach ($input['users_id_validate'] as $key => $validation_to_add) {
                     if (is_numeric($key)) {
                         $validations_to_send[] = $validation_to_add;
                     }
                 }
             }
         }
         // Keep only one
         $validations_to_send = array_unique($validations_to_send);
         $validation = new TicketValidation();
         if (count($validations_to_send)) {
             $values = array();
             $values['tickets_id'] = $this->fields['id'];
             if (isset($input['id']) && $input['id'] != $this->fields['id']) {
                 $values['_ticket_add'] = true;
//.........这里部分代码省略.........
开发者ID:glpi-project,项目名称:glpi,代码行数:101,代码来源:ticket.class.php

示例4: getAgentsFromActors

 /**
  * Get Computers from Actors defined in taskjobs
  * TODO: this method should be rewritten to call directly a getAgents() method in the
  * corresponding itemtype classes.
  */
 public function getAgentsFromActors($actors = array())
 {
     $agents = array();
     $computers = array();
     $computer = new Computer();
     $agent = new PluginFusioninventoryAgent();
     $pfToolbox = new PluginFusioninventoryToolbox();
     foreach ($actors as $actor) {
         $itemtype = key($actor);
         $itemid = $actor[$itemtype];
         $item = getItemForItemtype($itemtype);
         $dbresult = $item->getFromDB($itemid);
         // If this item doesn't exists, we continue to the next actor item.
         // TODO: remove this faulty actor from the list of job actor.
         if ($dbresult === false) {
             continue;
         }
         switch ($itemtype) {
             case 'Computer':
                 $computers[$itemid] = 1;
                 break;
             case 'PluginFusioninventoryDeployGroup':
                 $group_targets = $pfToolbox->executeAsFusioninventoryUser('PluginFusioninventoryDeployGroup::getTargetsForGroup', array($itemid));
                 foreach ($group_targets as $computerid) {
                     $computers[$computerid] = 1;
                 }
                 break;
             case 'Group':
                 //find computers by user associated with this group
                 $group_users = new Group_User();
                 $members = array();
                 //array_keys($group_users->find("groups_id = '$items_id'"));
                 $members = $group_users->getGroupUsers($itemid);
                 foreach ($members as $member) {
                     $computers_from_user = $computer->find("users_id = '{$member['id']}'");
                     foreach ($computers_from_user as $computer_entry) {
                         $computers[$computer_entry['id']] = 1;
                     }
                 }
                 //find computers directly associated with this group
                 $computer_from_group = $computer->find("groups_id = '{$itemid}'");
                 foreach ($computer_from_group as $computer_entry) {
                     $computers[$computer_entry['id']] = 1;
                 }
                 break;
                 /**
                  * TODO: The following should be replaced with Dynamic groups
                  */
             /**
              * TODO: The following should be replaced with Dynamic groups
              */
             case 'PluginFusioninventoryAgent':
                 switch ($itemid) {
                     case "dynamic":
                         break;
                     case "dynamic-same-subnet":
                         break;
                     default:
                         $agents[$itemid] = 1;
                         break;
                 }
                 break;
         }
     }
     //Get agents from the computer's ids list
     foreach ($agent->getAgentsFromComputers(array_keys($computers)) as $agent_entry) {
         $agents[$agent_entry['id']] = 1;
     }
     // Return the list of agent's ids.
     // (We used hash keys to avoid duplicates in the list)
     return array_keys($agents);
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:77,代码来源:task.class.php

示例5: sendAddGroupUsersForm

 /**
  * Recieve 'All users of a group' data from self::showAddGroupUsersForm and save them to session and DB
  *
  * @since 9.1
  *
  * @param $params (array) : must contais form data (typically $_REQUEST)
  */
 static function sendAddGroupUsersForm($params = array())
 {
     $current_group =& $_SESSION['glpi_plannings']['plannings']["group_" . $params['groups_id'] . "_users"];
     $current_group = array('display' => true, 'type' => 'group_users');
     $users = Group_User::getGroupUsers($params['groups_id']);
     $index_color = count($_SESSION['glpi_plannings']['plannings']);
     $group_user_index = 0;
     foreach ($users as $user_data) {
         // do not add an already set user
         if (!isset($_SESSION['glpi_plannings']['plannings']['user_' . $user_data['id']])) {
             $current_group['users']['user_' . $user_data['id']] = array('color' => self::$palette_bg[$_SESSION['glpi_plannings_color_index']], 'display' => true, 'type' => 'user');
             $_SESSION['glpi_plannings_color_index']++;
         }
     }
     self::savePlanningsInDB();
 }
开发者ID:korial29,项目名称:glpi,代码行数:23,代码来源:planning.class.php

示例6: sendAddGroupUsersForm

 /**
  * Recieve 'All users of a group' data from self::showAddGroupUsersForm and save them to session and DB
  *
  * @since 9.1
  *
  * @param $params (array) : must contais form data (typically $_REQUEST)
  */
 static function sendAddGroupUsersForm($params = array())
 {
     $current_group =& $_SESSION['glpi_plannings']['plannings']["group_" . $params['groups_id'] . "_users"];
     $current_group = array('display' => true, 'type' => 'group_users');
     $users = Group_User::getGroupUsers($params['groups_id'], "`glpi_users`.`is_active` = 1\n                                          AND NOT `glpi_users`.`is_deleted`\n                                          AND (`glpi_users`.`begin_date` IS NULL\n                                             OR `glpi_users`.`begin_date` < NOW())\n                                          AND (`glpi_users`.`end_date` IS NULL\n                                             OR `glpi_users`.`end_date` > NOW())");
     $index_color = count($_SESSION['glpi_plannings']['plannings']);
     $group_user_index = 0;
     foreach ($users as $user_data) {
         // do not add an already set user
         if (!isset($_SESSION['glpi_plannings']['plannings']['user_' . $user_data['id']])) {
             $current_group['users']['user_' . $user_data['id']] = array('color' => self::getPaletteColor('bg', $_SESSION['glpi_plannings_color_index']), 'display' => true, 'type' => 'user');
             $_SESSION['glpi_plannings_color_index']++;
         }
     }
     self::savePlanningsInDB();
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:23,代码来源:planning.class.php

示例7: prepareRun

 function prepareRun($taskjob_id, $definitions_filter = NULL)
 {
     global $DB;
     $task = new PluginFusioninventoryTask();
     $job = new PluginFusioninventoryTaskjob();
     $joblog = new PluginFusioninventoryTaskjoblog();
     $jobstate = new PluginFusioninventoryTaskjobstate();
     $agent = new PluginFusioninventoryAgent();
     $agentmodule = new PluginFusioninventoryAgentmodule();
     $job->getFromDB($taskjob_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':
                 if ($this->definitionFiltered("Computer", $definitions_filter)) {
                     break;
                 }
                 $computers[] = $items_id;
                 break;
             case 'Group':
                 if ($this->definitionFiltered("Group", $definitions_filter)) {
                     break;
                 }
                 $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']}' " . " AND `is_deleted`='0' AND `is_template`='0'");
                     foreach ($computers as $computer) {
                         $computers_a_1[] = $computer['id'];
                     }
                 }
                 //find computers directly associated with this group
                 $computers = $computer_object->find("groups_id = '{$items_id}' " . " AND `is_deleted`='0' AND `is_template`='0'");
                 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':
                         if ($this->definitionFiltered("PluginFusioninventoryDeployGroupStatic", $definitions_filter)) {
                             break;
                         }
                         $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':
                         if ($this->definitionFiltered("PluginFusioninventoryDeployGroupDynamic", $definitions_filter)) {
                             break;
                         }
                         //$definitions_filter is NULL = update by crontask !
                         if ($definitions_filter != NULL) {
                             $where = " AND `can_update_group`='1'";
                         } else {
                             $where = "";
                         }
                         $query = "SELECT fields_array\n                     FROM glpi_plugin_fusioninventory_deploygroups_dynamicdatas\n                     WHERE groups_id = '{$items_id}' {$where}\n                     LIMIT 1";
                         $res = $DB->query($query);
                         $row = $DB->fetch_assoc($res);
                         //No dynamic groups have been found : break
                         if ($DB->numrows($res) == 0) {
                             break;
                         }
                         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();
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:101,代码来源:deploycommon.class.php

示例8: getWidgetContentForItem

 function getWidgetContentForItem($widgetId)
 {
     global $CFG_GLPI, $DB;
     if (empty($this->form)) {
         $this->init();
     }
     switch ($widgetId) {
         case $this->getType() . "1":
             $plugin = new Plugin();
             if ($plugin->isActivated("tasklists")) {
                 $widget = new PluginMydashboardDatatable();
                 $headers = array(__('Name'), __('Priority'), _n('Context', 'Contexts', 1, 'tasklists'), __('User'), __('Percent done'), __('Due date'), __('Action'));
                 $query = "SELECT `glpi_plugin_tasklists_tasks`.*,`glpi_plugin_tasklists_tasktypes`.`completename` as 'type' \n                            FROM `glpi_plugin_tasklists_tasks`\n                            LEFT JOIN `glpi_plugin_tasklists_tasktypes` ON (`glpi_plugin_tasklists_tasks`.`plugin_tasklists_tasktypes_id` = `glpi_plugin_tasklists_tasktypes`.`id`) \n                            WHERE NOT `glpi_plugin_tasklists_tasks`.`is_deleted`\n                                 AND `glpi_plugin_tasklists_tasks`.`state` < 2 ";
                 $query .= getEntitiesRestrictRequest('AND', 'glpi_plugin_tasklists_tasks');
                 $query .= "ORDER BY `glpi_plugin_tasklists_tasks`.`priority`DESC ";
                 $tasks = array();
                 if ($result = $DB->query($query)) {
                     if ($DB->numrows($result)) {
                         while ($data = $DB->fetch_array($result)) {
                             //$groups = Group_User::getGroupUsers($data['groups_id']);
                             $groupusers = Group_User::getGroupUsers($data['groups_id']);
                             $groups = array();
                             foreach ($groupusers as $groupuser) {
                                 $groups[] = $groupuser["id"];
                             }
                             if ($data['visibility'] == 1 && $data['users_id'] == Session::getLoginUserID() || $data['visibility'] == 2 && ($data['users_id'] == Session::getLoginUserID() || in_array(Session::getLoginUserID(), $groups)) || $data['visibility'] == 3) {
                                 $ID = $data['id'];
                                 $rand = mt_rand();
                                 $url = Toolbox::getItemTypeFormURL("PluginTasklistsTask") . "?id=" . $data['id'];
                                 $tasks[$data['id']][0] = "<a id='task" . $data["id"] . $rand . "' target='_blank' href='{$url}'>" . $data['name'] . "</a>";
                                 $tasks[$data['id']][0] .= Html::showToolTip($data['comment'], array('applyto' => 'task' . $data["id"] . $rand, 'display' => false));
                                 $bgcolor = $_SESSION["glpipriority_" . $data['priority']];
                                 $tasks[$data['id']][1] = "<div class='center' style='background-color:{$bgcolor};'>" . CommonITILObject::getPriorityName($data['priority']) . "</div>";
                                 $tasks[$data['id']][2] = $data['type'];
                                 $tasks[$data['id']][3] = getUserName($data['users_id']);
                                 $tasks[$data['id']][4] = Dropdown::getValueWithUnit($data['percent_done'], "%");
                                 $due_date = $data['due_date'];
                                 $display = Html::convDate($data['due_date']);
                                 if ($due_date <= date('Y-m-d') && !empty($due_date)) {
                                     $display = "<div class='deleted'>" . Html::convDate($data['due_date']) . "</div>";
                                 }
                                 $tasks[$data['id']][5] = $display;
                                 $tasks[$data['id']][6] = "<div align='center'>";
                                 if (Session::haveRight("plugin_tasklists", UPDATE)) {
                                     $tasks[$data['id']][6] .= "<a class='pointer' onclick=\" submitGetLink('" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/front/task.form.php', {'done': 'done', 'id': '" . $data['id'] . "', '_glpi_csrf_token': '" . Session::getNewCSRFToken() . "', '_glpi_simple_form': '1'});\"><img src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/ok.png' title='" . __('Mark as done', 'tasklists') . "'></a>";
                                 }
                                 if (Session::haveRight("plugin_tasklists", UPDATENOTE)) {
                                     $link = "&nbsp;<a href=\"javascript:" . Html::jsGetElementbyID('comment' . $rand) . ".dialog('open');\">";
                                     $link .= "<img class='pointer' src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/plus.png' title='" . __('Add comment', 'tasklists') . "'>";
                                     $link .= "</a>";
                                     $link .= Ajax::createIframeModalWindow('comment' . $rand, $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/comment.form.php?id=" . $ID, array('title' => __('Add comment', 'tasklists'), 'reloadonclose' => false, 'width' => 1100, 'display' => false, 'height' => 300));
                                     $tasks[$data['id']][6] .= $link;
                                 }
                                 $tasks[$data['id']][6] .= "</div>";
                             }
                         }
                     }
                 }
                 $widget->setTabDatas($tasks);
                 $widget->setTabNames($headers);
                 $widget->setOption("bSort", false);
                 $widget->toggleWidgetRefresh();
                 $link = "<div align='right'><a class='vsubmit' href=\"javascript:" . Html::jsGetElementbyID('task') . ".dialog('open');\">";
                 $link .= __('Add task', 'tasklists');
                 $link .= "</a></div>";
                 $link .= Ajax::createIframeModalWindow('task', $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/task.form.php", array('title' => __('Add task', 'tasklists'), 'reloadonclose' => false, 'width' => 1180, 'display' => false, 'height' => 600));
                 $widget->appendWidgetHtmlContent($link);
                 $widget->setWidgetTitle(__("Tasks list", 'tasklists'));
                 return $widget;
             } else {
                 $widget = new PluginMydashboardDatatable();
                 $widget->setWidgetTitle(__("Tasks list", 'tasklists'));
                 return $widget;
             }
             break;
     }
 }
开发者ID:InfotelGLPI,项目名称:tasklists,代码行数:77,代码来源:dashboard.class.php

示例9: checkAvailability

 /**
  * Show the availability of a user
  *
  * @since version 0.83
  *
  * @param $params   array of params
  *    must contain :
  *          - begin: begin date to check (default '')
  *          - end: end date to check (default '')
  *          - itemtype : User or Object type (Ticket...)
  *          - foreign key field of the itemtype to define which item to used
  *    optional :
  *          - limitto : limit display to a specific user
  *
  * @return Nothing (display function)
  **/
 static function checkAvailability($params = array())
 {
     global $CFG_GLPI, $DB;
     if (!isset($params['itemtype'])) {
         return false;
     }
     if (!($item = getItemForItemtype($params['itemtype']))) {
         return false;
     }
     if (!isset($params[$item->getForeignKeyField()]) || !$item->getFromDB($params[$item->getForeignKeyField()])) {
         return false;
     }
     // No limit by default
     if (!isset($params['limitto'])) {
         $params['limitto'] = 0;
     }
     if (isset($params['begin']) && !empty($params['begin'])) {
         $begin = $params['begin'];
     } else {
         $begin = date("Y-m-d");
     }
     if (isset($params['end']) && !empty($params['end'])) {
         $end = $params['end'];
     } else {
         $end = date("Y-m-d");
     }
     if ($end < $begin) {
         $end = $begin;
     }
     $realbegin = $begin . " " . $CFG_GLPI["planning_begin"];
     $realend = $end . " " . $CFG_GLPI["planning_end"];
     $users = array();
     switch ($item->getType()) {
         case 'User':
             $users[$item->getID()] = $item->getName();
             break;
         default:
             if (Toolbox::is_a($item, 'CommonITILObject')) {
                 foreach ($item->getUsers(CommonITILActor::ASSIGN) as $data) {
                     $users[$data['users_id']] = getUserName($data['users_id']);
                 }
                 foreach ($item->getGroups(CommonITILActor::ASSIGN) as $data) {
                     foreach (Group_User::getGroupUsers($data['groups_id']) as $data2) {
                         $users[$data2['id']] = formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"]);
                     }
                 }
             }
             break;
     }
     asort($users);
     // Use get method to check availability
     echo "<div class='center'><form method='GET' name='form' action='planning.php'>\n";
     echo "<table class='tab_cadre_fixe'>";
     $colspan = 5;
     if (count($users) > 1) {
         $colspan++;
     }
     echo "<tr class='tab_bg_1'><th colspan='{$colspan}'>" . __('Availability') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Start') . "</td>\n";
     echo "<td>";
     Html::showDateField("begin", array('value' => $begin, 'maybeempty' => false));
     echo "</td>\n";
     echo "<td>" . __('End') . "</td>\n";
     echo "<td>";
     Html::showDateField("end", array('value' => $end, 'maybeempty' => false));
     echo "</td>\n";
     if (count($users) > 1) {
         echo "<td width='40%'>";
         $data = array(0 => __('All'));
         $data += $users;
         Dropdown::showFromArray('limitto', $data, array('width' => '100%', 'value' => $params['limitto']));
         echo "</td>";
     }
     echo "<td class='center'>";
     echo "<input type='hidden' name='" . $item->getForeignKeyField() . "' value=\"" . $item->getID() . "\">";
     echo "<input type='hidden' name='itemtype' value=\"" . $item->getType() . "\">";
     echo "<input type='submit' class='submit' name='checkavailability' value=\"" . _sx('button', 'Search') . "\">";
     echo "</td>\n";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:planning.class.php

示例10: 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


注:本文中的Group_User::getGroupUsers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。