本文整理汇总了PHP中Group_User::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Group_User::add方法的具体用法?PHP Group_User::add怎么用?PHP Group_User::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group_User
的用法示例。
在下文中一共展示了Group_User::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: syncLdapGroups
/**
* Synchronise LDAP group of the user
**/
function syncLdapGroups()
{
global $DB;
// input["_groups"] not set when update from user.form or preference
if (isset($this->fields["authtype"]) && isset($this->input["_groups"]) && ($this->fields["authtype"] == Auth::LDAP || Auth::isAlternateAuth($this->fields['authtype']))) {
if (isset($this->fields["id"]) && $this->fields["id"] > 0) {
$authtype = Auth::getMethodsByID($this->fields["authtype"], $this->fields["auths_id"]);
if (count($authtype)) {
// Clean groups
$this->input["_groups"] = array_unique($this->input["_groups"]);
// Delete not available groups like to LDAP
$query = "SELECT `glpi_groups_users`.`id`,\n `glpi_groups_users`.`groups_id`,\n `glpi_groups_users`.`is_dynamic`\n FROM `glpi_groups_users`\n LEFT JOIN `glpi_groups`\n ON (`glpi_groups`.`id` = `glpi_groups_users`.`groups_id`)\n WHERE `glpi_groups_users`.`users_id` = '" . $this->fields["id"] . "'";
$result = $DB->query($query);
$groupuser = new Group_User();
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_assoc($result)) {
if (in_array($data["groups_id"], $this->input["_groups"])) {
// Delete found item in order not to add it again
unset($this->input["_groups"][array_search($data["groups_id"], $this->input["_groups"])]);
} else {
if ($data['is_dynamic']) {
$groupuser->delete(array('id' => $data["id"]));
}
}
}
}
//If the user needs to be added to one group or more
if (count($this->input["_groups"]) > 0) {
foreach ($this->input["_groups"] as $group) {
$groupuser->add(array('users_id' => $this->fields["id"], 'groups_id' => $group, 'is_dynamic' => 1));
}
unset($this->input["_groups"]);
}
}
}
}
}
示例2: generate_entity
/** Generate bigdump : generate items for an entity
*
* @param $ID_entity entity ID
**/
function generate_entity($ID_entity) {
global $MAX, $DB, $percent, $FIRST, $LAST, $MAX_KBITEMS_BY_CAT, $MAX_DISK,
$DOCUMENTS, $NET_PORT, $NET_LOC;
regenerateTreeCompleteName("glpi_entities");
$current_year = date("Y");
// DOMAIN
$items = array("SP2MI", "CAMPUS"," IUT86", "PRESIDENCE", "CEAT", "D'omaine");
$dp = new Domain();
$FIRST["domain"] = getMaxItem("glpi_domains")+1;
for ($i=0 ; $i<$MAX['domain'] ; $i++) {
if (isset($items[$i])) {
$val = $items[$i];
} else {
$val = "domain $ID_entity '$i";
}
$dp->add(toolbox::addslashes_deep(array('name' => $val,
'entities_id' => $ID_entity,
'is_recursive' => 1,
'comment' => "comment $val")));
}
$LAST["domain"] = getMaxItem("glpi_domains");
// STATUS
$items = array("Reparation", "En stock", "En fonction", "Retour SAV", "En attente d'");
$dp = new State();
$FIRST["state"] = getMaxItem("glpi_states")+1;
for ($i=0 ; $i<$MAX['state'] ; $i++) {
if (isset($items[$i])) {
$val = $items[$i];
} else {
$val = "State $ID_entity '$i";
}
$state_id = $dp->add(toolbox::addslashes_deep(array('name' => $val,
'entities_id' => $ID_entity,
'is_recursive' => 1,
'comment' => "comment $val")));
// generate sub status
for ($j=0 ; $j<$MAX['state'] ; $j++) {
$val2 = "Sub $val $j";
$dp->add(toolbox::addslashes_deep(array('name' => $val2,
'entities_id' => $ID_entity,
'is_recursive' => 1,
'states_id' => $state_id,
'comment' => "comment $val")));
}
}
$LAST["state"] = getMaxItem("glpi_states");
// glpi_groups
$FIRST["groups"] = getMaxItem("glpi_groups")+1;
$group = new Group();
for ($i=0 ; $i<$MAX['groups'] ; $i++) {
$gID = $group->add(toolbox::addslashes_deep(
array('entities_id' => $ID_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;
//.........这里部分代码省略.........
示例3: sprintf
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, CREATE, $_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");
示例4: foreach
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$comp = new Computer();
if ($comp->getFromDB($key) && $comp->fields["entities_id"] == $_SESSION["glpiactive_entity"]) {
$inst->add(array('computers_id' => $key, 'softwareversions_id' => $_POST["softwareversions_id"]));
}
}
}
break;
case "add_group":
$groupuser = new Group_User();
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$input = array('groups_id' => $_POST["groups_id"], 'users_id' => $key);
if ($groupuser->can(-1, 'w', $input)) {
$groupuser->add($input);
}
}
}
break;
case "add_userprofile":
$right = new Profile_User();
if (isset($_POST['profiles_id']) && $_POST['profiles_id'] > 0 && isset($_POST['entities_id']) && $_POST['entities_id'] >= 0) {
$input['entities_id'] = $_POST['entities_id'];
$input['profiles_id'] = $_POST['profiles_id'];
$input['is_recursive'] = $_POST['is_recursive'];
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$input['users_id'] = $key;
$right->add($input);
}