本文整理汇总了PHP中Group::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::add方法的具体用法?PHP Group::add怎么用?PHP Group::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_add
public function do_add() {
$txt = Loader::helper('text');
$valt = Loader::helper('validation/token');
$gName = $txt->sanitize($_POST['gName']);
$gDescription = $_POST['gDescription'];
if (!$gName) {
$this->error->add(t("Name required."));
}
if (!$valt->validate('add_or_update_group')) {
$this->error->add($valt->getErrorMessage());
}
$g1 = Group::getByName($gName);
if ($g1 instanceof Group) {
if ((!is_object($g)) || $g->getGroupID() != $g1->getGroupID()) {
$this->error->add(t('A group named "%s" already exists', $g1->getGroupName()));
}
}
if (!$this->error->has()) {
$g = Group::add($gName, $_POST['gDescription']);
$this->checkExpirationOptions($g);
$this->redirect('/dashboard/users/groups', 'group_added');
}
}
示例2: attemptAuthentication
protected function attemptAuthentication()
{
$user = parent::attemptAuthentication();
$userInfo = \UserInfo::getByID($user->getUserID());
$extractor = $this->getExtractor();
$roles = $extractor->getExtra('roles');
// sync groups with roles
if (is_array($roles)) {
$groupIds = array();
foreach ($roles as $role) {
$roleApplicationCode = $role['role_application']['application_code'];
if ($roleApplicationCode == \Config::get('auth.worldskills.roles_application_code')) {
$roleName = $role['name'];
// check for entity role and append entity name
if (isset($role['ws_entity'])) {
$roleName = $roleName . ' - ' . $role['ws_entity']['name']['text'];
}
// check if group exists
$group = \Group::getByName($roleName);
if (!is_object($group)) {
// add missing groups
$group = \Group::add($roleName, '');
}
$groupIds[] = $group->getGroupID();
}
}
// remove duplicate groups
$groupIds = array_unique($groupIds);
// update groups of user
$userInfo->updateGroups($groupIds);
}
// login user again to make sure groups are reloaded
return \User::loginByUserID($user->getUserID());
}
示例3: add
/**
* {@inheritdoc}
*/
public function add(array $children)
{
$allowed = ['loader' => null, 'field' => null];
if (array_diff_key($children, $allowed)) {
throw new \InvalidArgumentException("Only 'loader' and 'field' keys are available.");
}
return parent::add($children);
}
示例4: testUserPointActionWithGroup
public function testUserPointActionWithGroup()
{
$g = \Group::add('Test Group', 'Test Group Description');
Action::add('test_action', t('Test Action'), 4, $g);
$action = Action::getByHandle('test_action');
/* @var $action \Concrete\Core\User\Point\Action\Action */
$this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Action\\Action', $action);
$this->assertEquals(4, $action->getUserPointActionDefaultPoints());
$this->assertInstanceOf('\\Concrete\\Core\\User\\Group\\Group', $action->getUserPointActionBadgeGroupObject());
$this->assertEquals($g->getGroupID(), $action->getUserPointActionBadgeGroupObject()->getGroupID());
}
示例5: doAddGroup
public function doAddGroup()
{
$group = new StdClass();
$group->number = Data::get('number', '', Data::STR);
$group->letter = Data::get('letter', '', Data::STR);
$a = (object) array('success' => false, 'message' => '');
if ($group->id = Group::add($group)) {
$a->message = 'Класс успешно добавлен!';
$a->object = $group;
$a->success = true;
} else {
$a->message = 'Ошибка при добавлении класса';
}
return $a;
}
示例6: do_add
public function do_add()
{
$txt = $this->app->make('helper/text');
$valt = $this->app->make('helper/validation/token');
$gName = $txt->sanitize($this->request->post('gName'));
$gDescription = $this->request->post('gDescription');
if (!$gName) {
$this->error->add(t("Name required."));
}
if (!$valt->validate('add_or_update_group')) {
$this->error->add($valt->getErrorMessage());
}
if ($this->request->post('gIsBadge')) {
if (!$this->post('gBadgeDescription')) {
$this->error->add(t('You must specify a description for this badge. It will be displayed publicly.'));
}
}
$parentGroup = null;
if ($this->request->post('gParentNodeID')) {
$parentGroupNode = TreeNode::getByID($this->request->post('gParentNodeID'));
if ($parentGroupNode instanceof GroupTreeNode) {
$parentGroup = $parentGroupNode->getTreeNodeGroupObject();
}
}
if (is_object($parentGroup)) {
$pp = new \Permissions($parentGroup);
if (!$pp->canAddSubGroup()) {
$this->error->add(t('You do not have permission to add a group beneath %s', $parentGroup->getGroupDisplayName()));
}
}
if (!$this->error->has()) {
$g = ConcreteGroup::add($gName, $this->request->post('gDescription'), $parentGroup);
$this->checkExpirationOptions($g);
$this->checkBadgeOptions($g);
$this->checkAutomationOptions($g);
$this->redirect('/dashboard/users/groups', 'group_added');
}
$this->view();
}
示例7: array
include ROOT . '/lib/includeForAjax.php';
requireStrictRoute();
$response = array();
$response['error'] = 0;
$response['message'] = '';
$name = $_POST['name'];
if(empty($name)) {
$response['error'] = -1;
$response['message'] = _t('잘못된 접근입니다.');
} else {
if (!isAdmin()) {
$response['error'] = 1;
$response['message'] = _t('관리자만이 이 기능을 사용할 수 있습니다.');
} else {
requireComponent('Bloglounge.Data.Groups');
if(!Group::add($name)) {
$response['error'] = 2;
$response['message'] = _t('그룹추가를 실패하였습니다.');
} else {
$response['message'] = $name;
}
}
}
func::printRespond($response);
?>
示例8: installGroups
private function installGroups()
{
/*
* It looks like you can't associate groups with a package, so whatever
* you install here will remain after you uninstall
*/
$bpAdmins = Group::getByName("Boilerplate Admins");
if (!is_object($bpAdmins)) {
$bpAdmins = Group::add("Boilerplate Admins", "Sample group for the boilerplate package.");
}
}
示例9: Group
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
*/
include '../inc/includes.php';
Session::checkRight("group", READ);
if (empty($_GET["id"])) {
$_GET["id"] = "";
}
$group = new Group();
if (isset($_POST["add"])) {
$group->check(-1, CREATE, $_POST);
if ($newID = $group->add($_POST)) {
Event::log($newID, "groups", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
if ($_SESSION['glpibackcreated']) {
Html::redirect($group->getFormURL() . "?id=" . $newID);
}
}
Html::back();
} else {
if (isset($_POST["purge"])) {
$group->check($_POST["id"], PURGE);
if ($group->isUsed() && empty($_POST["forcepurge"])) {
Html::header($group->getTypeName(1), $_SERVER['PHP_SELF'], "admin", "group", str_replace('glpi_', '', $group->getTable()));
$group->showDeleteConfirmForm($_SERVER['PHP_SELF']);
Html::footer();
} else {
$group->delete($_POST, 1);
示例10: die
if (Tools::getValue('action') == 'loadFilterInfo') {
die($obj->loadFilterInfo(Tools::getValue('idfilter')));
}
if (Tools::getValue('action') == 'deleteFilter') {
die($obj->deleteFilter(Tools::getValue('idfilter')));
}
if (Tools::getValue('action') == 'newGroup') {
$grp = new Group();
$name = array();
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
$name[$language['id_lang']] = Tools::getValue('name');
}
$grp->name = $name;
$grp->price_display_method = 0;
$grp->add();
echo (int) $grp->id;
exit;
}
if (Tools::getValue('action') == 'addGroup') {
$sql = $obj->getQuery($_POST, true);
if (!$sql) {
die(false);
}
$rows = Db::getInstance()->ExecuteS($sql);
if (!is_array($rows)) {
die(false);
}
if (Tools::getValue('mode') == 'rep') {
foreach ($rows as $row) {
Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . (int) $row[$obj->ll(47)]);
示例11: customerImportOne
protected function customerImportOne($info, $default_language_id, $id_lang, $shop_is_feature_active, $force_ids, $validateOnly = false)
{
AdminImportController::setDefaultValues($info);
if ($force_ids && isset($info['id']) && (int) $info['id']) {
$customer = new Customer((int) $info['id']);
} else {
if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
$customer = new Customer((int) $info['id']);
} else {
$customer = new Customer();
}
}
$customer_exist = false;
$autodate = true;
if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id']) && Validate::isLoadedObject($customer)) {
$current_id_customer = (int) $customer->id;
$current_id_shop = (int) $customer->id_shop;
$current_id_shop_group = (int) $customer->id_shop_group;
$customer_exist = true;
$customer_groups = $customer->getGroups();
$addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
}
// Group Importation
if (isset($info['group']) && !empty($info['group'])) {
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
$group = trim($group);
if (empty($group)) {
continue;
}
$id_group = false;
if (is_numeric($group) && $group) {
$my_group = new Group((int) $group);
if (Validate::isLoadedObject($my_group)) {
$customer_groups[] = (int) $group;
}
continue;
}
$my_group = Group::searchByName($group);
if (isset($my_group['id_group']) && $my_group['id_group']) {
$id_group = (int) $my_group['id_group'];
}
if (!$id_group) {
$my_group = new Group();
$my_group->name = array($id_lang => $group);
if ($id_lang != $default_language_id) {
$my_group->name = $my_group->name + array($default_language_id => $group);
}
$my_group->price_display_method = 1;
if (!$validateOnly) {
$my_group->add();
if (Validate::isLoadedObject($my_group)) {
$id_group = (int) $my_group->id;
}
}
}
if ($id_group) {
$customer_groups[] = (int) $id_group;
}
}
} elseif (empty($info['group']) && isset($customer->id) && $customer->id) {
$customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP'));
}
if (isset($info['date_add']) && !empty($info['date_add'])) {
$autodate = false;
}
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
if ($customer->passwd) {
$customer->passwd = Tools::encrypt($customer->passwd);
}
$id_shop_list = explode($this->multiple_value_separator, $customer->id_shop);
$customers_shop = array();
$customers_shop['shared'] = array();
$default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
if ($shop_is_feature_active && $id_shop_list) {
foreach ($id_shop_list as $id_shop) {
if (empty($id_shop)) {
continue;
}
$shop = new Shop((int) $id_shop);
$group_shop = $shop->getGroup();
if ($group_shop->share_customer) {
if (!in_array($group_shop->id, $customers_shop['shared'])) {
$customers_shop['shared'][(int) $id_shop] = $group_shop->id;
}
} else {
$customers_shop[(int) $id_shop] = $group_shop->id;
}
}
} else {
$default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
$default_shop->getGroup();
$customers_shop[$default_shop->id] = $default_shop->getGroup()->id;
}
//set temporary for validate field
$customer->id_shop = $default_shop->id;
$customer->id_shop_group = $default_shop->getGroup()->id;
if (isset($info['id_default_group']) && !empty($info['id_default_group']) && !is_numeric($info['id_default_group'])) {
$info['id_default_group'] = trim($info['id_default_group']);
$my_group = Group::searchByName($info['id_default_group']);
if (isset($my_group['id_group']) && $my_group['id_group']) {
//.........这里部分代码省略.........
示例12: 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;
//.........这里部分代码省略.........
示例13: add_group
public static function add_group()
{
if (Auth::check()) {
$name = $_POST['name'];
$status = $_POST['status'];
if (isset($name) && isset($status) && (!empty($name) && !empty($status))) {
$getResponse = get_object_vars(Group::where("group_name='{$name}'"));
if (!$getResponse['data']) {
$ob = new Group();
$ob->group_name = $name;
$ob->statut = $status;
if ($ob->add()) {
echo "ok";
} else {
echo "Erreur au niveau du modification";
}
}
}
} else {
$redirection = Config::get('app.base_url') . Config::get('panel.route') . "/users";
header("Location: {$redirection}");
}
}
示例14: t
}
if (!$valt->validate('add_or_update_group')) {
$error[] = $valt->getErrorMessage();
}
$g1 = Group::getByName($gName);
if ($g1 instanceof Group) {
if ((!is_object($g)) || $g->getGroupID() != $g1->getGroupID()) {
$error[] = t('A group named "%s" already exists', $g1->getGroupName());
}
}
if (count($error) == 0) {
if ($_POST['add']) {
$g = Group::add($gName, $_POST['gDescription']);
checkExpirationOptions($g);
$this->controller->redirect('/dashboard/users/groups?created=1');
} else if (is_object($g)) {
$g->update($gName, $_POST['gDescription']);
checkExpirationOptions($g);
$this->controller->redirect('/dashboard/users/groups?updated=1');
}
exit;
}
}
if ($_GET['created']) {
$message = t("Group Created.");
} else if ($_GET['updated']) {
示例15: function
$roomArray = Room::Search($building, $day, $hour, $size, $computer, $beamer, $pool, $looseSeating, $video);
echo json_encode($roomArray);
});
// === GROUPS ===
$app->put('/groups', function ($request, $response, $args) {
$put = json_decode($request->getBody());
// make it a PHP associative array
$putArray = get_object_vars($put);
$members = array();
$tmpMembers = $putArray['users'];
foreach ($tmpMembers as $tmpmember) {
$member = get_object_vars($tmpmember);
$members[] = new User($member['mtklNr'], '', '', '');
}
$group = new Group(null, $putArray['name'], $putArray['owner'], $members, $putArray['groupImage']);
$group->add();
echo json_encode($group);
});
$app->get('/groups', function ($request, $response, $args) {
$groups = Group::getAllGroups();
echo json_encode($groups);
});
$app->get('/groups/{id}', function ($request, $response, $args) {
$group = Group::getGroupById($args['id']);
echo json_encode($group);
});
$app->get('/groups/{id}/meetings', function ($request, $response, $args) {
$meetings = Group::getAllMeetingsOfGroup($args['id']);
echo json_encode($meetings);
});
$app->post('/groups/{id}', function ($request, $response, $args) {