本文整理汇总了PHP中Group_User类的典型用法代码示例。如果您正苦于以下问题:PHP Group_User类的具体用法?PHP Group_User怎么用?PHP Group_User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Group_User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanDBonPurge
function cleanDBonPurge()
{
global $DB;
$gu = new Group_User();
$gu->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$gt = new Group_Ticket();
$gt->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$gp = new Group_Problem();
$gp->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$cg = new Change_Group();
$cg->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$query1 = "DELETE\n FROM `glpi_projecttaskteams`\n WHERE `items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = '" . __CLASS__ . "'";
$DB->query($query1);
$query1 = "DELETE\n FROM `glpi_projectteams`\n WHERE `items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = '" . __CLASS__ . "'";
$DB->query($query1);
$gki = new Group_KnowbaseItem();
$gki->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$gr = new Group_Reminder();
$gr->cleanDBonItemDelete($this->getType(), $this->fields['id']);
// Ticket rules use various _groups_id_*
Rule::cleanForItemAction($this, '_groups_id%');
Rule::cleanForItemCriteria($this, '_groups_id%');
// GROUPS for RuleMailcollector
Rule::cleanForItemCriteria($this, 'GROUPS');
// Set no group to consumables
$query = "UPDATE `glpi_consumables`\n SET `items_id` = '0'\n WHERE `items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = 'Group'";
$DB->query($query);
}
示例2: cleanDBonPurge
function cleanDBonPurge()
{
global $DB;
$gu = new Group_User();
$gu->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$gt = new Group_Ticket();
$gt->cleanDBonItemDelete($this->getType(), $this->fields['id']);
}
示例3: 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;
}
示例4: 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();
}
示例5: 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;
}
示例6: define
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
if (!isset($_POST["id"])) {
exit;
}
checkRight("group", "r");
$group = new Group();
if ($_POST["id"] > 0 && $group->can($_POST["id"], 'r')) {
switch ($_REQUEST['glpi_tab']) {
case -1:
Group_User::showForGroup($_POST['target'], $group);
$group->showItems();
$group->showLDAPForm($_POST['target'], $_POST["id"]);
Plugin::displayAction($group, $_REQUEST['glpi_tab']);
break;
case 2:
$group->showItems();
break;
case 3:
$group->showLDAPForm($_POST['target'], $_POST["id"]);
break;
default:
if (!Plugin::displayAction($group, $_REQUEST['glpi_tab'])) {
Group_User::showForGroup($_POST['target'], $group);
}
}
}
ajaxFooter();
示例7: generate_entity
//.........这里部分代码省略.........
'name' => "group d'$i",
'comment' => "comment group d'$i",
'is_assign' => 0)));
// Generate sub group
for ($j=0 ; $j<$MAX['groups'] ; $j++) {
$group->add(toolbox::addslashes_deep(
array('entities_id' => $ID_entity,
'name' => "subgroup d'$j",
'comment' => "comment subgroup d'$j of group $i",
'groups_id' => $gID,
'is_assign' => 0)));
}
}
$LAST["groups"] = getMaxItem("glpi_groups");
$FIRST["techgroups"] = $LAST["groups"]+1;
for ($i=0 ; $i<$MAX['groups'] ; $i++) {
$group->add(toolbox::addslashes_deep(
array('entities_id' => $ID_entity,
'name' => "tech group d'$i",
'comment' => "comment tech group d'$i")));
}
$LAST["techgroups"] = getMaxItem("glpi_groups");
regenerateTreeCompleteName("glpi_groups");
// glpi_users
$FIRST["users_sadmin"] = getMaxItem("glpi_users")+1;
$user = new User();
$gu = new Group_User();
for ($i=0 ; $i<$MAX['users_sadmin'] ; $i++) {
$users_id = $user->add(toolbox::addslashes_deep(
array('name' => "sadmin$i-$ID_entity",
'password' => "sadmin'$i",
'password2' => "sadmin'$i",
'phone' => "tel $i",
'phone2' => "tel2 $i",
'mobile' => "mobile $i",
'realname' => "sadmin '$i name",
'firstname' => "sadmin '$i firstname",
'comment' => "comment' $i",
'usertitles_id' => mt_rand(0,$MAX['user_title']),
'usercategories_id' => mt_rand(0,$MAX['user_type']),
'_profiles_id' => 4,
'_entities_id' => $ID_entity,
'_is_recursive' => 1
)));
$gu->add(array('users_id' => $users_id,
'groups_id' => mt_rand($FIRST['groups'], $LAST['groups'])));
$gu->add(array('users_id' => $users_id,
'groups_id' => mt_rand($FIRST['techgroups'], $LAST['techgroups'])));
}
$LAST["users_sadmin"] = getMaxItem("glpi_users");
$FIRST["users_admin"] = getMaxItem("glpi_users")+1;
for ($i=0 ; $i<$MAX['users_admin'] ; $i++) {
$users_id = $user->add(toolbox::addslashes_deep(
array('name' => "admin$i-$ID_entity",
'password' => "admin'$i",
示例8: deleteGroups
static function deleteGroups($user_ID, $only_dynamic = false)
{
global $DB;
$crit['users_id'] = $user_ID;
if ($only_dynamic) {
$crit['is_dynamic'] = '1';
}
$obj = new Group_User();
$obj->deleteByCriteria($crit);
}
示例9: 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();
}
示例10: 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;
}
示例11: manageDeletedUserInLdap
/**
* @param $users_id
**/
static function manageDeletedUserInLdap($users_id)
{
global $CFG_GLPI;
//User is present in DB but not in the directory : it's been deleted in LDAP
$tmp['id'] = $users_id;
$myuser = new User();
switch ($CFG_GLPI['user_deleted_ldap']) {
//DO nothing
default:
case 0:
break;
//Put user in dustbin
//Put user in dustbin
case 1:
$myuser->delete($tmp);
break;
//Delete all user dynamic habilitations and groups
//Delete all user dynamic habilitations and groups
case 2:
Profile_User::deleteRights($users_id, true);
Group_User::deleteGroups($users_id, true);
break;
//Deactivate the user
//Deactivate the user
case 3:
$tmp['is_active'] = 0;
$myuser->update($tmp);
break;
}
$changes[0] = '0';
$changes[1] = '';
$changes[2] = __('Deleted user in LDAP directory');
Log::history($users_id, 'User', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
}
示例12: Group_User
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since vesion 0.84
*/
include '../inc/includes.php';
Session::checkCentralAccess();
$group_user = new Group_User();
if (isset($_POST["add"])) {
$group_user->check(-1, 'w', $_POST);
if ($group_user->add($_POST)) {
Event::log($_POST["groups_id"], "groups", 4, "setup", sprintf(__('%s adds a user to a group'), $_SESSION["glpiname"]));
}
Html::back();
}
Html::displayErrorAndDie("lost");
示例13: 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;
//.........这里部分代码省略.........
示例14: 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();
//.........这里部分代码省略.........
示例15: manageDeletedUserInLdap
/**
* @param $users_id
**/
static function manageDeletedUserInLdap($users_id)
{
global $CFG_GLPI;
//The only case where users_id can be null if when a user has been imported into GLPi
//it's dn still exists, but doesn't match the connection filter anymore
//In this case, do not try to process the user
if (!$users_id) {
return true;
}
//User is present in DB but not in the directory : it's been deleted in LDAP
$tmp['id'] = $users_id;
$tmp['is_deleted_ldap'] = 1;
$myuser = new self();
$myuser->getFromDB($users_id);
//User is already considered as delete from ldap
if ($myuser->fields['is_deleted_ldap'] == 1) {
return;
}
switch ($CFG_GLPI['user_deleted_ldap']) {
//DO nothing
default:
case 0:
$myuser->update($tmp);
break;
//Put user in dustbin
//Put user in dustbin
case 1:
$myuser->delete($tmp);
break;
//Delete all user dynamic habilitations and groups
//Delete all user dynamic habilitations and groups
case 2:
Profile_User::deleteRights($users_id, true);
Group_User::deleteGroups($users_id, true);
$myuser->update($tmp);
break;
//Deactivate the user
//Deactivate the user
case 3:
$tmp['is_active'] = 0;
$myuser->update($tmp);
break;
//Deactivate the user+ Delete all user dynamic habilitations and groups
//Deactivate the user+ Delete all user dynamic habilitations and groups
case 4:
$tmp['is_active'] = 0;
$myuser->update($tmp);
Profile_User::deleteRights($users_id, true);
Group_User::deleteGroups($users_id, true);
break;
}
/*
$changes[0] = '0';
$changes[1] = '';
$changes[2] = __('Deleted user in LDAP directory');
Log::history($users_id, 'User', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);*/
}