本文整理汇总了PHP中Group_User::getUserGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP Group_User::getUserGroups方法的具体用法?PHP Group_User::getUserGroups怎么用?PHP Group_User::getUserGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group_User
的用法示例。
在下文中一共展示了Group_User::getUserGroups方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: executeActions
/**
* @param $output
* @param $params
**/
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "send":
$ticket = new Ticket();
if ($ticket->getFromDB($output['id'])) {
NotificationEvent::raiseEvent('recall', $ticket);
}
break;
case "add_validation":
if (isset($output['_add_validation']) && !is_array($output['_add_validation'])) {
$output['_add_validation'] = array($output['_add_validation']);
}
switch ($action->fields['field']) {
case 'users_id_validate_requester_supervisor':
$output['_add_validation'][] = 'requester_supervisor';
break;
case 'users_id_validate_assign_supervisor':
$output['_add_validation'][] = 'assign_supervisor';
break;
case 'groups_id_validate':
$output['_add_validation']['group'][] = $action->fields["value"];
break;
case 'users_id_validate':
$output['_add_validation'][] = $action->fields["value"];
break;
case 'validation_percent':
$output[$action->fields["field"]] = $action->fields["value"];
break;
default:
$output['_add_validation'][] = $action->fields["value"];
break;
}
break;
case "assign":
$output[$action->fields["field"]] = $action->fields["value"];
// Special case of users_id_requester
if ($action->fields["field"] === '_users_id_requester') {
// Add groups of requester
if (!isset($output['_groups_id_of_requester'])) {
$output['_groups_id_of_requester'] = array();
}
foreach (Group_User::getUserGroups($action->fields["value"]) as $g) {
$output['_groups_id_of_requester'][$g['id']] = $g['id'];
}
}
break;
case "append":
$actions = $this->getActions();
$value = $action->fields["value"];
if (isset($actions[$action->fields["field"]]["appendtoarray"]) && isset($actions[$action->fields["field"]]["appendtoarrayfield"])) {
$value = $actions[$action->fields["field"]]["appendtoarray"];
$value[$actions[$action->fields["field"]]["appendtoarrayfield"]] = $action->fields["value"];
}
$output[$actions[$action->fields["field"]]["appendto"]][] = $value;
// Special case of users_id_requester
if ($action->fields["field"] === '_users_id_requester') {
// Add groups of requester
if (!isset($output['_groups_id_of_requester'])) {
$output['_groups_id_of_requester'] = array();
}
foreach (Group_User::getUserGroups($action->fields["value"]) as $g) {
$output['_groups_id_of_requester'][$g['id']] = $g['id'];
}
}
break;
case 'fromuser':
if ($action->fields['field'] == 'locations_id' && isset($output['users_locations'])) {
$output['locations_id'] = $output['users_locations'];
}
break;
case 'fromitem':
if ($action->fields['field'] == 'locations_id' && isset($output['items_locations'])) {
$output['locations_id'] = $output['items_locations'];
}
if ($action->fields['field'] == 'groups_id' && isset($output['items_groups'])) {
$output['groups_id'] = $output['items_groups'];
}
break;
case 'compute':
// Value could be not set (from test)
$urgency = isset($output['urgency']) ? $output['urgency'] : 3;
$impact = isset($output['impact']) ? $output['impact'] : 3;
// Apply priority_matrix from config
$output['priority'] = Ticket::computePriority($urgency, $impact);
break;
case "affectbyip":
case "affectbyfqdn":
case "affectbymac":
if (!isset($output["entities_id"])) {
$output["entities_id"] = $params["entities_id"];
}
if (isset($this->regex_results[0])) {
$regexvalue = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
//.........这里部分代码省略.........
示例3: foreach
if (isset($_GET['entities_id']) && isset($_GET['is_recursive'])) {
$user->loadMinimalSession($_GET['entities_id'], $_GET['is_recursive']);
}
//// check if the request is valid: rights on uID / gID
// First check mine : user then groups
$ismine = false;
if ($user->getID() == $_GET["uID"]) {
$ismine = true;
}
// Check groups if have right to see
if (!$ismine && $_GET["gID"] !== 0) {
if ($_GET["gID"] === 'mine') {
$ismine = true;
} else {
$entities = Profile_User::getUserEntitiesForRight($user->getID(), Planning::READGROUP);
$groups = Group_User::getUserGroups($user->getID());
foreach ($groups as $group) {
if ($_GET["gID"] == $group['id'] && in_array($group['entities_id'], $entities)) {
$ismine = true;
}
}
}
}
$canview = false;
// If not mine check global right
if (!$ismine) {
// First check user
$entities = Profile_User::getUserEntitiesForRight($user->getID(), Planning::READALL);
if ($_GET["uID"]) {
$userentities = Profile_User::getUserEntities($user->getID());
$intersect = array_intersect($entities, $userentities);
示例4: checkApprobationSolution
/**
* check right for Approve ticket Solution
* for an authenticated user and a particular user
*
* @param $users_id user id used for check ticket right
* @param $ticket ticket object
*
* @return array of hashtable
**/
static function checkApprobationSolution($users_id, Ticket $ticket)
{
if (!self::checkUserRights(Session::getLoginUserID(), 'update_ticket', 1, $ticket->getField('entities_id'))) {
return false;
}
if (!($ticket->fields["users_id_recipient"] === $users_id || $ticket->isUser(CommonITILActor::REQUESTER, $users_id) || sizeof(Group_User::getUserGroups($users_id) > 0) && $ticket->haveAGroup(CommonITILActor::REQUESTER, Group_User::getUserGroups($users_id)))) {
return false;
}
return true;
}
示例5: prepareInputDataForProcess
/**
* @see RuleCollection::prepareInputDataForProcess()
**/
function prepareInputDataForProcess($input, $params)
{
$input['mailcollector'] = $params['mailcollector'];
$input['_users_id_requester'] = $params['_users_id_requester'];
$fields = $this->getFieldsToLookFor();
//Add needed ticket datas for rules processing
if (isset($params['ticket']) && is_array($params['ticket'])) {
foreach ($params['ticket'] as $key => $value) {
if (in_array($key, $fields) && !isset($input[$key])) {
$input[$key] = $value;
}
}
}
//Add needed headers for rules processing
if (isset($params['headers']) && is_array($params['headers'])) {
foreach ($params['headers'] as $key => $value) {
if (in_array($key, $fields) && !isset($input[$key])) {
$input[$key] = $value;
}
}
}
//Add all user's groups
if (in_array('groups', $fields)) {
foreach (Group_User::getUserGroups($input['_users_id_requester']) as $group) {
$input['GROUPS'][] = $group['id'];
}
}
//Add all user's profiles
if (in_array('profiles', $fields)) {
foreach (Profile_User::getForUser($input['_users_id_requester']) as $profile) {
$input['PROFILES'][$profile['profiles_id']] = $profile['profiles_id'];
}
}
//If the criteria is "user has only one time the profile xxx"
if (in_array('unique_profile', $fields)) {
//Get all profiles
$profiles = Profile_User::getForUser($input['_users_id_requester']);
foreach ($profiles as $profile) {
if (Profile_User::haveUniqueRight($input['_users_id_requester'], $profile['profiles_id'])) {
$input['UNIQUE_PROFILE'][$profile['profiles_id']] = $profile['profiles_id'];
}
}
}
//Store the number of profiles of which the user belongs to
if (in_array('one_profile', $fields)) {
$profiles = Profile_User::getForUser($input['_users_id_requester']);
if (count($profiles) == 1) {
$tmp = array_pop($profiles);
$input['ONE_PROFILE'] = $tmp['profiles_id'];
}
}
//Store the number of profiles of which the user belongs to
if (in_array('known_domain', $fields)) {
if (preg_match("/@(.*)/", $input['from'], $results)) {
if (Entity::getEntityIDByDomain($results[1]) != -1) {
$input['KNOWN_DOMAIN'] = 1;
} else {
$input['KNOWN_DOMAIN'] = 0;
}
}
}
return $input;
}
示例6: checkGroupUserFromForm
static function checkGroupUserFromForm($formID)
{
//$formID = $_REQUEST['id'];
$grupos = Group_User::getUserGroups($_SESSION['glpiID']);
$gruposUsuario = array("0");
$found = 0;
foreach ($grupos as $grupo) {
if (in_array($grupo['id'], PluginFormcreatorForm::getGroupForm($formID))) {
$found = 1;
}
}
return $found;
}
示例7: prepareInputDataForProcess
/**
* @see RuleCollection::prepareInputDataForProcess()
**/
function prepareInputDataForProcess($input, $params)
{
// Pass x-priority header if exists
if (isset($input['_head']['x-priority'])) {
$input['_x-priority'] = $input['_head']['x-priority'];
}
$input['_groups_id_of_requester'] = array();
// Get groups of users
if (isset($input['_users_id_requester'])) {
foreach (Group_User::getUserGroups($input['_users_id_requester']) as $g) {
$input['_groups_id_of_requester'][$g['id']] = $g['id'];
}
}
return $input;
}
示例8: array
if (isset($timelevels[$key])) {
$timelevels[$key] += $time;
} else {
$timelevels[$key] = $time;
}
}
}
}
}
//Time of task by level group
$tickettechs = array();
$restrict = " `tickets_id` = " . $data["id"] . " \n AND actiontime > 0 ORDER BY date";
$tasks = getAllDatasFromTable("glpi_tickettasks", $restrict);
if (!empty($tasks)) {
foreach ($tasks as $task) {
foreach (Group_User::getUserGroups($task["users_id"]) as $usergroups) {
if (in_array($usergroups["id"], $ticketgroups)) {
if (isset($tickettechs[$usergroups["id"]])) {
$tickettechs[$usergroups["id"]] += $task["actiontime"];
} else {
$tickettechs[$usergroups["id"]] = $task["actiontime"];
}
}
}
}
}
$tasklevels = array();
if (!empty($mylevels) && !empty($tickettechs)) {
foreach ($mylevels as $key => $val) {
foreach ($tickettechs as $group => $time) {
if (is_array($val) && in_array($group, $val)) {
示例9: checkApprobationSolution
/**
* check right for Approve ticket Solution
* for an authenticated user and a particular user
*
* @param $users_id user id used for check ticket right
* @param $ticket ticket object
*
* @return array of hashtable
**/
static function checkApprobationSolution($users_id, Ticket $ticket)
{
if (!($ticket->fields["users_id_recipient"] === $users_id || $ticket->isUser(CommonITILActor::REQUESTER, $users_id) || sizeof(Group_User::getUserGroups($users_id) > 0) && $ticket->haveAGroup(CommonITILActor::REQUESTER, Group_User::getUserGroups($users_id)))) {
return false;
}
return true;
}
示例10: notMultiple
static function notMultiple($item)
{
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
$peConfig = new PluginEscalationConfig();
$unique_assigned = $peConfig->getValue("unique_assigned", $item->fields['entities_id']);
if ($unique_assigned == '1') {
$ticket_User = new Ticket_User();
$group_Ticket = new Group_Ticket();
$group_User = new Group_User();
if (isset($item->input['_itil_assign'])) {
if ($item->input['_itil_assign']['_type'] == 'user') {
$in_group = 0;
$a_groups = $group_Ticket->find("`type`='2'\n AND `tickets_id`='" . $item->fields['id'] . "'");
$groups = Group_User::getUserGroups($item->input['_itil_assign']['users_id']);
if (count($a_groups) > 0) {
foreach ($a_groups as $data) {
foreach ($groups as $dat) {
if ($dat['id'] == $data['groups_id']) {
$in_group = 1;
}
}
}
}
//if ($in_group == '0') {
// unset($item->input['_itil_assign']['users_id']);
//}
} else {
if ($item->input['_itil_assign']['_type'] == 'group') {
$a_groups = $group_Ticket->find("`type`='2'\n AND `tickets_id`='" . $item->getID() . "'");
if (count($a_groups) > 0) {
foreach ($a_groups as $data) {
$group_Ticket->delete($data);
}
}
$a_users = $ticket_User->find("`type`='2'\n AND `tickets_id`='" . $item->getID() . "'");
foreach ($a_users as $data) {
if (countElementsInTable($group_User->getTable(), "`users_id`='" . $data['users_id'] . "'\n AND `groups_id`='" . $item->input['_itil_assign']['groups_id'] . "'") == '0') {
$ticket_User->delete($data);
}
}
}
}
}
}
}
}
示例11: mt_rand
$link = "getDropdownUsers.php";
}
$rand = mt_rand();
$field_id = Html::cleanId("dropdown_" . $_POST["name"] . $rand);
$p = array('value' => 0, 'valuename' => Dropdown::EMPTY_VALUE, 'itemtype' => $_POST["idtable"], 'display_emptychoice' => true, 'displaywith' => array('otherserial', 'serial'));
if (isset($_POST['value'])) {
$p['value'] = $_POST['value'];
}
if (isset($_POST['entity_restrict'])) {
$p['entity_restrict'] = $_POST['entity_restrict'];
}
if (isset($_POST['condition'])) {
$p['condition'] = $_POST['condition'];
}
if ($_POST['idtable'] == 'Group') {
$groups = Group_User::getUserGroups(Session::getLoginUserID());
$user_groups = array();
foreach ($groups as $group) {
$user_groups[] = $group['id'];
}
$p['condition'] = Dropdown::addNewCondition("`id` IN ('" . implode("','", $user_groups) . "')");
}
echo Html::jsAjaxDropdown($_POST["name"], $field_id, $CFG_GLPI['root_doc'] . "/ajax/" . $link, $p);
if (!empty($_POST['showItemSpecificity'])) {
$params = array('items_id' => '__VALUE__', 'itemtype' => $_POST["idtable"]);
if (isset($_POST['entity_restrict'])) {
$params['entity_restrict'] = $_POST['entity_restrict'];
}
Ajax::updateItemOnSelectEvent($field_id, "showItemSpecificity_" . $_POST["name"] . "{$rand}", $_POST['showItemSpecificity'], $params);
echo "<br><span id='showItemSpecificity_" . $_POST["name"] . "{$rand}'> </span>\n";
}