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


PHP group_create函数代码示例

本文整理汇总了PHP中group_create函数的典型用法代码示例。如果您正苦于以下问题:PHP group_create函数的具体用法?PHP group_create怎么用?PHP group_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: user_create

function user_create($Username, $Password)
{
    global $pdo;
    if (user_exists($Username)) {
        return false;
    }
    $stmt = $pdo->prepare('
		INSERT INTO `users`
		(
			`username`
			, `password`
		) VALUES (
			:username
			, :password
		)');
    $stmt->bindValue(':username', s($Username));
    $stmt->bindValue(':password', user_hash($Password, $Username));
    $stmt->execute();
    $uid = $pdo->lastInsertId();
    $stmt->closeCursor();
    // Create a group for the new user
    lib('Group');
    $gid = group_create(s($Username), 'user');
    group_add($gid, $uid);
    return $uid;
}
开发者ID:ss23,项目名称:Pass-Store,代码行数:26,代码来源:User.php

示例2: test_notifications

 public function test_notifications()
 {
     global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_log;
     include_once $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx;
     include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
     include_once $phpbb_root_path . 'includes/functions_content.' . $phpEx;
     set_config(false, false, false, $this->config);
     $this->container->set('groupposition.legend', new \phpbb\groupposition\legend($this->db, $this->user));
     $this->container->set('groupposition.teampage', new \phpbb\groupposition\teampage($this->db, $this->user, $this->cache->get_driver()));
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $phpbb_log = new \phpbb\log\null();
     // Now on to the actual test
     $group_id = false;
     group_create($group_id, GROUP_OPEN, 'test', 'test group', array());
     // Add user 2 as group leader
     group_user_add($group_id, 2, false, false, false, true, false);
     // Add user 3 as pending
     group_user_add($group_id, 3, false, false, false, false, true);
     $this->assert_notifications(array(array('item_id' => 3, 'item_parent_id' => $group_id, 'user_id' => 2, 'notification_read' => 0, 'notification_data' => array('group_name' => 'test'))), array('user_id' => 2));
     // Approve user 3 joining the group
     group_user_attributes('approve', $group_id, array(3));
     // user 3 pending notification should have been deleted
     $this->assert_notifications(array(), array('user_id' => 2));
     $this->assert_notifications(array(array('item_id' => $group_id, 'user_id' => 3, 'notification_read' => 0, 'notification_data' => array('group_name' => 'test'))), array('user_id' => 3));
 }
开发者ID:Voxel37,项目名称:phpbb,代码行数:25,代码来源:group_request_test.php

示例3: creategroup_submit

function creategroup_submit(Pieform $form, $values)
{
    global $USER;
    global $SESSION;
    list($grouptype, $jointype) = explode('.', $values['grouptype']);
    $values['public'] = isset($values['public']) ? $values['public'] : 0;
    $values['usersautoadded'] = isset($values['usersautoadded']) ? $values['usersautoadded'] : 0;
    $id = group_create(array('name' => $values['name'], 'description' => $values['description'], 'grouptype' => $grouptype, 'category' => empty($values['category']) ? null : intval($values['category']), 'jointype' => $jointype, 'public' => intval($values['public']), 'usersautoadded' => intval($values['usersautoadded']), 'members' => array($USER->get('id') => 'admin'), 'viewnotify' => intval($values['viewnotify'])));
    $USER->reset_grouproles();
    $SESSION->add_ok_msg(get_string('groupsaved', 'group'));
    redirect('/group/view.php?id=' . $id);
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:12,代码来源:create.php

示例4: editgroup_submit

function editgroup_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $group_data, $publicallowed;
    $values['public'] = isset($values['public']) ? $values['public'] : 0;
    $values['usersautoadded'] = isset($values['usersautoadded']) ? $values['usersautoadded'] : 0;
    $newvalues = array('name' => $group_data->name == $values['name'] ? $values['name'] : trim($values['name']), 'description' => $values['description'], 'grouptype' => $values['grouptype'], 'category' => empty($values['category']) ? null : intval($values['category']), 'open' => intval($values['open']), 'controlled' => intval($values['controlled']), 'request' => intval($values['request']), 'usersautoadded' => intval($values['usersautoadded']), 'public' => $publicallowed ? intval($values['public']) : 0, 'viewnotify' => intval($values['viewnotify']), 'submittableto' => intval($values['submittableto']), 'allowarchives' => intval(!empty($values['allowarchives']) ? $values['allowarchives'] : 0), 'editroles' => $values['editroles'], 'hidden' => intval($values['hidden']), 'hidemembers' => intval(!empty($values['hidemembersfrommembers']) || !empty($values['hidemembers'])), 'hidemembersfrommembers' => intval($values['hidemembersfrommembers']), 'groupparticipationreports' => intval($values['groupparticipationreports']), 'invitefriends' => intval($values['invitefriends']), 'suggestfriends' => intval($values['suggestfriends']), 'editwindowstart' => db_format_timestamp($values['editwindowstart']), 'editwindowend' => db_format_timestamp($values['editwindowend']), 'sendnow' => intval($values['sendnow']), 'feedbacknotify' => intval($values['feedbacknotify']));
    if (get_config('cleanurls') && isset($values['urlid']) && '' !== (string) $values['urlid']) {
        $newvalues['urlid'] = $values['urlid'];
    }
    db_begin();
    if (!$group_data->id) {
        $newvalues['members'] = array($USER->get('id') => 'admin');
        $group_data->id = group_create($newvalues);
        $USER->reset_grouproles();
    }
    // Now update the description with any embedded image info
    $newvalues['description'] = EmbeddedImage::prepare_embedded_images($newvalues['description'], 'group', $group_data->id, $group_data->id);
    $newvalues['id'] = $group_data->id;
    unset($newvalues['members']);
    group_update((object) $newvalues);
    $SESSION->add_ok_msg(get_string('groupsaved', 'group'));
    db_commit();
    // Reload $group_data->urlid or else the redirect will fail
    if (get_config('cleanurls') && (!isset($values['urlid']) || $group_data->urlid != $values['urlid'])) {
        $group_data->urlid = get_field('group', 'urlid', 'id', $group_data->id);
    }
    redirect(group_homepage_url($group_data));
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:28,代码来源:edit.php

示例5: sync_groups


//.........这里部分代码省略.........
     }
     if (get_config('auth_ldap_debug_sync_cron')) {
         log_debug("Found LDAP groups  : ");
         var_dump($groups);
     }
     $nbadded = 0;
     foreach ($groups as $group) {
         $nomatch = false;
         log_debug("Processing group '{$group}'");
         if (!ldap_sync_filter_name($group, $includelist, $excludelist)) {
             continue;
         }
         if (get_config('auth_ldap_debug_sync_cron')) {
             log_debug("processing group  : ");
             var_dump($group);
         }
         $ldapusers = array();
         if ($syncbyattribute) {
             $ldapusers = array_merge($ldapusers, $this->get_users_having_attribute_value($group));
         }
         if ($syncbyclass) {
             $ldapusers = array_merge($ldapusers, $this->ldap_get_group_members($group));
         }
         // test whether this group exists within the institution
         // group.shortname is limited to 255 characters. Unlikely anyone will hit this, but why not?
         $shortname = substr($group, 0, 255);
         if (!($dbgroup = get_record('group', 'shortname', $shortname, 'institution', $this->institution))) {
             if (!$docreate) {
                 log_debug('autocreation is off so skipping Mahara not existing group ' . $group);
                 continue;
             }
             if (count($ldapusers) == 0) {
                 log_debug('will not autocreate an empty Mahara group ' . $group);
                 continue;
             }
             try {
                 log_info('creating group ' . $group);
                 // Make sure the name is unique (across all institutions)
                 // group.name only allows 128 characters. In the event of
                 // really long group names, we'll arbitrarily truncate them
                 $basename = $this->institution . ' : ' . $group;
                 $name = substr($basename, 0, 128);
                 $n = 0;
                 while (record_exists('group', 'name', $name)) {
                     $n++;
                     $tail = " {$n}";
                     $name .= substr($basename, 0, 128 - strlen($tail)) . $tail;
                 }
                 $dbgroup = array();
                 $dbgroup['name'] = $name;
                 $dbgroup['institution'] = $this->institution;
                 $dbgroup['shortname'] = $shortname;
                 $dbgroup['grouptype'] = $grouptype;
                 // default standard (change to course)
                 $dbgroup['controlled'] = 1;
                 //definitively
                 $nbadded++;
                 if (!$dryrun) {
                     $groupid = group_create($dbgroup);
                 }
             } catch (Exception $ex) {
                 log_warn($ex->getMessage());
                 continue;
             }
         } else {
             $groupid = $dbgroup->id;
             log_debug('group exists ' . $group);
         }
         // now it does  exist see what members should be added/removed
         if (get_config('auth_ldap_debug_sync_cron')) {
             log_debug($group . ' : ');
             var_dump($ldapusers);
         }
         // Puts the site's "admin" user into the group as a group admin
         $members = array('1' => 'admin');
         //must be set otherwise fatal error group_update_members: no group admins listed for group
         foreach ($ldapusers as $username) {
             if (isset($currentmembers[$username])) {
                 $id = $currentmembers[$username]->id;
                 $members[$id] = 'member';
             }
         }
         if (get_config('auth_ldap_debug_sync_cron')) {
             log_debug('new members list : ' . count($members));
             var_dump($members);
         }
         unset($ldapusers);
         //try to save memory before memory consuming call to API
         $result = $dryrun ? false : group_update_members($groupid, $members);
         if ($result) {
             log_info(" ->   added : {$result['added']} removed : {$result['removed']} updated : {$result['updated']}");
         } else {
             log_debug('->  no change for ' . $group);
         }
         unset($members);
         //break;
     }
     log_info('---------- finished groupsync auth instance ' . $this->instanceid . ' at ' . date('r', time()) . ' ----------');
     return true;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:101,代码来源:lib.php

示例6: group_update

/**
 * Update details of an existing group.
 *
 * @param array $new New values for the group table.
 * @param bool  $create Create the group if it doesn't exist yet
 */
function group_update($new, $create = false)
{
    if (!empty($new->id)) {
        $old = get_record_select('group', 'id = ? AND deleted = 0', array($new->id));
    } else {
        if (!empty($new->institution) && isset($new->shortname) && strlen($new->shortname)) {
            $old = get_record_select('group', 'shortname = ? AND institution = ? AND deleted = 0', array($new->shortname, $new->institution));
            if (!$old && $create) {
                return group_create((array) $new);
            }
        }
    }
    if (!$old) {
        throw new NotFoundException("group_update: group not found");
    }
    if (!empty($old->institution) && $old->institution != 'mahara') {
        // Api-controlled group; check permissions.
        global $USER;
        if (!$USER->can_edit_institution($old->institution)) {
            throw new AccessDeniedException("group_update: cannot update a group in this institution");
        }
    }
    if (isset($new->submittableto) && empty($new->submittableto) || !isset($new->submittableto) && empty($old->submittableto)) {
        $new->allowarchives = 0;
    }
    // Institution and shortname cannot be updated (yet)
    unset($new->institution);
    unset($new->shortname);
    foreach (array('id', 'grouptype', 'public', 'request', 'submittableto', 'allowarchives', 'editroles', 'hidden', 'hidemembers', 'hidemembersfrommembers', 'groupparticipationreports') as $f) {
        if (!isset($new->{$f})) {
            $new->{$f} = $old->{$f};
        }
    }
    if (isset($new->jointype)) {
        log_warn("group_update: ignoring supplied jointype");
        unset($new->jointype);
    }
    // If the caller isn't trying to enable open/controlled, use the old values
    if (!isset($new->open)) {
        $new->open = empty($new->controlled) && $old->jointype == 'open';
    }
    if (!isset($new->controlled)) {
        $new->controlled = empty($new->open) && $old->jointype == 'controlled';
    }
    if ($new->open) {
        if ($new->controlled) {
            throw new InvalidArgumentException("group_update: a group cannot have both open and controlled membership");
        }
        $new->request = 0;
        $new->jointype = 'open';
    } else {
        if ($new->controlled) {
            $new->jointype = 'controlled';
        } else {
            $new->jointype = 'approve';
        }
    }
    unset($new->open);
    unset($new->controlled);
    // Ensure only one of invitefriends,suggestfriends gets enabled.
    if (!empty($new->invitefriends)) {
        $new->suggestfriends = 0;
    } else {
        if (!isset($new->invitefriends)) {
            $new->invitefriends = (int) ($old->invitefriends && empty($new->suggestfriends));
        }
    }
    if (!isset($new->suggestfriends)) {
        $new->suggestfriends = $old->suggestfriends;
    }
    $diff = array_diff_assoc((array) $new, (array) $old);
    if (empty($diff)) {
        return null;
    }
    db_begin();
    if (isset($new->members)) {
        group_update_members($new->id, $new->members);
        unset($new->members);
    }
    update_record('group', $new, 'id');
    // Add users who have requested membership of a group that's becoming
    // open
    if ($old->jointype != 'open' && $new->jointype == 'open') {
        $userids = get_column_sql('
            SELECT u.id
            FROM {usr} u JOIN {group_member_request} r ON u.id = r.member
            WHERE r.group = ? AND u.deleted = 0', array($new->id));
        if ($userids) {
            foreach ($userids as $uid) {
                group_add_user($new->id, $uid);
            }
        }
    }
    // Invitations to controlled groups are allowed, but if the admin is
//.........这里部分代码省略.........
开发者ID:vohung96,项目名称:mahara,代码行数:101,代码来源:group.php

示例7: main


//.........这里部分代码省略.........
                            }
                        }
                    } else {
                        if ($avatar_select && $config['allow_avatar_local']) {
                            // check avatar gallery
                            if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) {
                                $submit_ary['avatar_type'] = AVATAR_GALLERY;
                                list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select);
                                $submit_ary['avatar'] = $category . '/' . $avatar_select;
                            }
                        } else {
                            if ($delete) {
                                $submit_ary['avatar'] = '';
                                $submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0;
                            }
                        }
                    }
                    if (isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']) || $group_row['group_avatar'] != $submit_ary['avatar']) || $delete) {
                        if (isset($group_row['group_avatar']) && $group_row['group_avatar']) {
                            avatar_delete($group_row['group_avatar']);
                        }
                    }
                    if (!sizeof($error)) {
                        // Only set the rank, colour, etc. if it's changed or if we're adding a new
                        // group. This prevents existing group members being updated if no changes
                        // were made.
                        $group_attributes = array();
                        $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit');
                        foreach ($test_variables as $test) {
                            if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) {
                                $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
                            }
                        }
                        if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) {
                            $group_perm_from = request_var('group_perm_from', 0);
                            // Copy permissions?
                            if ($group_perm_from && $action == 'add') {
                                // From the mysql documentation:
                                // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
                                // Due to this we stay on the safe side if we do the insertion "the manual way"
                                // Copy permisisons from/to the acl groups table (only group_id gets changed)
                                $sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
									FROM ' . ACL_GROUPS_TABLE . '
									WHERE group_id = ' . $group_perm_from;
                                $result = $db->sql_query($sql);
                                $groups_sql_ary = array();
                                while ($row = $db->sql_fetchrow($result)) {
                                    $groups_sql_ary[] = array('group_id' => (int) $group_id, 'forum_id' => (int) $row['forum_id'], 'auth_option_id' => (int) $row['auth_option_id'], 'auth_role_id' => (int) $row['auth_role_id'], 'auth_setting' => (int) $row['auth_setting']);
                                }
                                $db->sql_freeresult($result);
                                // Now insert the data
                                if (sizeof($groups_sql_ary)) {
                                    switch (SQL_LAYER) {
                                        case 'mysql':
                                        case 'mysql4':
                                        case 'mysqli':
                                            $db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $groups_sql_ary));
                                            break;
                                        default:
                                            foreach ($groups_sql_ary as $ary) {
                                                $db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
                                            }
                                            break;
                                    }
                                }
                                $auth->acl_clear_prefetch();
开发者ID:yunsite,项目名称:gloryroad,代码行数:67,代码来源:acp_groups.php

示例8: group_received_create

 function group_received_create()
 {
     if (group_create(stripslashes($_POST['name']), manage_setting_get_received('default_group'))) {
         $_POST = array();
     }
 }
开发者ID:Nazg-Gul,项目名称:gate,代码行数:6,代码来源:group.php

示例9: groups

 /**
  * Correct the system groups
  */
 function groups(&$error, $selected)
 {
     global $db;
     $data = $group_rows = $existing_groups = array();
     get_group_rows($data, $group_rows, $existing_groups);
     foreach ($group_rows as $name) {
         // Skip ones that are in the default install and are in the existing permissions
         if (isset($this->db_cleaner->data->groups[$name]) && in_array($name, $existing_groups)) {
             continue;
         }
         if (isset($selected[$name])) {
             if (isset($this->db_cleaner->data->groups[$name]) && !in_array($name, $existing_groups)) {
                 // Add it with the default settings we've got...
                 $group_id = false;
                 group_create($group_id, $this->db_cleaner->data->groups[$name]['group_type'], $name, $this->db_cleaner->data->groups[$name]['group_desc'], array('group_colour' => $this->db_cleaner->data->groups[$name]['group_colour'], 'group_legend' => $this->db_cleaner->data->groups[$name]['group_legend'], 'group_avatar' => $this->db_cleaner->data->groups[$name]['group_avatar'], 'group_max_recipients' => $this->db_cleaner->data->groups[$name]['group_max_recipients']));
             } else {
                 if (!isset($this->db_cleaner->data->groups[$name]) && in_array($name, $existing_groups)) {
                     if (!function_exists('group_delete')) {
                         include PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT;
                     }
                     // Remove it
                     $db->sql_query('SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_name = \'' . $db->sql_escape($name) . '\'');
                     $group_id = $db->sql_fetchfield('group_id');
                     group_delete($group_id, $name);
                 }
             }
         }
     }
 }
开发者ID:napus,项目名称:support-toolkit,代码行数:32,代码来源:database_cleaner_controller.php

示例10: main


//.........这里部分代码省略.........
                                                if ($config['avatar_min_width'] || $config['avatar_min_height']) {
                                                    if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) {
                                                        $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']);
                                                    }
                                                }
                                            }
                                            if (!sizeof($error)) {
                                                $submit_ary['avatar_width'] = $data['width'];
                                                $submit_ary['avatar_height'] = $data['height'];
                                            }
                                        }
                                    }
                                }
                            }
                            if (isset($submit_ary['avatar']) && $submit_ary['avatar'] && !isset($group_row['group_avatar']) || $delete) {
                                if (isset($group_row['group_avatar']) && $group_row['group_avatar']) {
                                    avatar_delete('group', $group_row, true);
                                }
                            }
                            if (!check_form_key('ucp_groups')) {
                                $error[] = $user->lang['FORM_INVALID'];
                            }
                            if (!sizeof($error)) {
                                // Only set the rank, colour, etc. if it's changed or if we're adding a new
                                // group. This prevents existing group members being updated if no changes
                                // were made.
                                $group_attributes = array();
                                $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit', 'max_recipients');
                                foreach ($test_variables as $test) {
                                    if ($action == 'add' || isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test]) {
                                        $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
                                    }
                                }
                                if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) {
                                    $cache->destroy('sql', GROUPS_TABLE);
                                    $message = $action == 'edit' ? 'GROUP_UPDATED' : 'GROUP_CREATED';
                                    trigger_error($user->lang[$message] . $return_page);
                                }
                            }
                            if (sizeof($error)) {
                                $group_rank = $submit_ary['rank'];
                                $group_desc_data = array('text' => $group_desc, 'allow_bbcode' => $allow_desc_bbcode, 'allow_smilies' => $allow_desc_smilies, 'allow_urls' => $allow_desc_urls);
                            }
                        } else {
                            if (!$group_id) {
                                $group_name = utf8_normalize_nfc(request_var('group_name', '', true));
                                $group_desc_data = array('text' => '', 'allow_bbcode' => true, 'allow_smilies' => true, 'allow_urls' => true);
                                $group_rank = 0;
                                $group_type = GROUP_OPEN;
                            } else {
                                $group_desc_data = generate_text_for_edit($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_options']);
                                $group_rank = $group_row['group_rank'];
                            }
                        }
                        $sql = 'SELECT *
							FROM ' . RANKS_TABLE . '
							WHERE rank_special = 1
							ORDER BY rank_title';
                        $result = $db->sql_query($sql);
                        $rank_options = '<option value="0"' . (!$group_rank ? ' selected="selected"' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>';
                        while ($row = $db->sql_fetchrow($result)) {
                            $selected = $group_rank && $row['rank_id'] == $group_rank ? ' selected="selected"' : '';
                            $rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
                        }
                        $db->sql_freeresult($result);
                        $type_free = $group_type == GROUP_FREE ? ' checked="checked"' : '';
开发者ID:html,项目名称:PI,代码行数:67,代码来源:ucp_groups.php

示例11: main


//.........这里部分代码省略.........
                                    }
                                    if (!sizeof($error)) {
                                        $submit_ary['avatar_width'] = $data['width'];
                                        $submit_ary['avatar_height'] = $data['height'];
                                    }
                                }
                            }
                        }
                    }
                    if (isset($submit_ary['avatar']) && $submit_ary['avatar'] && !isset($group_row['group_avatar']) || $delete) {
                        if (isset($group_row['group_avatar']) && $group_row['group_avatar']) {
                            avatar_delete('group', $group_row, true);
                        }
                    }
                    // Validate the length of "Maximum number of allowed recipients per private message" setting.
                    // We use 16777215 as a maximum because it matches MySQL unsigned mediumint maximum value
                    // which is the lowest amongst DBMSes supported by phpBB3
                    if ($max_recipients_error = validate_data($submit_ary, array('max_recipients' => array('num', false, 0, 16777215)))) {
                        // Replace "error" string with its real, localised form
                        $error = array_merge($error, array_map(array(&$user, 'lang'), $max_recipients_error));
                    }
                    if (!sizeof($error)) {
                        // Only set the rank, colour, etc. if it's changed or if we're adding a new
                        // group. This prevents existing group members being updated if no changes
                        // were made.
                        $group_attributes = array();
                        $test_variables = array('rank' => 'int', 'colour' => 'string', 'avatar' => 'string', 'avatar_type' => 'int', 'avatar_width' => 'int', 'avatar_height' => 'int', 'receive_pm' => 'int', 'legend' => 'int', 'message_limit' => 'int', 'max_recipients' => 'int', 'founder_manage' => 'int', 'skip_auth' => 'int');
                        foreach ($test_variables as $test => $type) {
                            if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) {
                                settype($submit_ary[$test], $type);
                                $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
                            }
                        }
                        if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) {
                            $group_perm_from = request_var('group_perm_from', 0);
                            // Copy permissions?
                            // If the user has the a_authgroups permission and at least one additional permission ability set the permissions are fully transferred.
                            // We do not limit on one auth category because this can lead to incomplete permissions being tricky to fix for the admin, roles being assigned or added non-default permissions.
                            // Since the user only has the option to copy permissions from non leader managed groups this seems to be a good compromise.
                            if ($group_perm_from && $action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) {
                                $sql = 'SELECT group_founder_manage
									FROM ' . GROUPS_TABLE . '
									WHERE group_id = ' . $group_perm_from;
                                $result = $db->sql_query($sql);
                                $check_row = $db->sql_fetchrow($result);
                                $db->sql_freeresult($result);
                                // Check the group if non-founder
                                if ($check_row && ($user->data['user_type'] == USER_FOUNDER || $check_row['group_founder_manage'] == 0)) {
                                    // From the mysql documentation:
                                    // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
                                    // Due to this we stay on the safe side if we do the insertion "the manual way"
                                    // Copy permisisons from/to the acl groups table (only group_id gets changed)
                                    $sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
										FROM ' . ACL_GROUPS_TABLE . '
										WHERE group_id = ' . $group_perm_from;
                                    $result = $db->sql_query($sql);
                                    $groups_sql_ary = array();
                                    while ($row = $db->sql_fetchrow($result)) {
                                        $groups_sql_ary[] = array('group_id' => (int) $group_id, 'forum_id' => (int) $row['forum_id'], 'auth_option_id' => (int) $row['auth_option_id'], 'auth_role_id' => (int) $row['auth_role_id'], 'auth_setting' => (int) $row['auth_setting']);
                                    }
                                    $db->sql_freeresult($result);
                                    // Now insert the data
                                    $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
                                    $auth->acl_clear_prefetch();
                                }
                            }
开发者ID:ubick,项目名称:lorekeepers.org,代码行数:67,代码来源:acp_groups.php

示例12: display_options


//.........这里部分代码省略.........
						continue;
					}

					$template->assign_block_vars('section.items', array(
						'NAME'			=> $name,
						'FIELD_NAME'	=> $name,
						'MISSING'		=> (!in_array($name, $existing_groups)) ? true : false,
					));
				}

			break;

			case 6:

				// Add/remove selected system groups
				if ($apply_changes)
				{
					$group_rows = $existing_groups = array();
					get_group_rows($cleaner, $group_rows, $existing_groups);
					foreach ($group_rows as $name)
					{
						// Skip ones that are in the default install and are in the existing permissions
						if (isset($cleaner->groups[$name]) && in_array($name, $existing_groups))
						{
							continue;
						}

						if (isset($selected[$name]))
						{
							if (isset($cleaner->groups[$name]) && !in_array($name, $existing_groups))
							{
								// Add it with the default settings we've got...
								$group_id = false;
								group_create($group_id, $cleaner->groups[$name]['group_type'], $name, $cleaner->groups[$name]['group_desc'], array('group_colour' => $cleaner->groups[$name]['group_colour'], 'group_legend' => $cleaner->groups[$name]['group_legend'], 'group_avatar' => $cleaner->groups[$name]['group_avatar'], 'group_max_recipients' => $cleaner->groups[$name]['group_max_recipients']));
							}
							else if (!isset($cleaner->groups[$name]) && in_array($name, $existing_groups))
							{
								// Remove it
								$db->sql_query('SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_name = \'' . $name . '\'');
								$group_id = $db->sql_fetchfield('group_id');
								group_delete($group_id, $name);
							}
						}
					}
				}

				// Ask if they would like to reset the modules (handled in the template)
				$template->assign_vars(array(
					'S_MODULE_OPTIONS'		=> true,
					'S_NO_INSTRUCTIONS'		=> true,
				));

			break;

			case 7 :

				// Reset the modules if they wanted to
				if (isset($_POST['yes']) && $apply_changes)
				{
					// Remove existing modules
					$db->sql_query('DELETE FROM ' . MODULES_TABLE);

					// Add the modules
					$db->sql_multi_insert(MODULES_TABLE, $cleaner->modules);

					$template->assign_var('SUCCESS_MESSAGE', $user->lang['RESET_MODULE_SUCCESS']);
开发者ID:sietf,项目名称:sietf.org,代码行数:67,代码来源:database_cleaner.php

示例13: uploadcsv_submit

/**
 * Add the users to the system. Make sure that they have to change their
 * password on next login also.
 */
function uploadcsv_submit(Pieform $form, $values)
{
    global $SESSION, $CSVDATA, $FORMAT, $UPDATES, $USER;
    $formatkeylookup = array_flip($FORMAT);
    $institution = $values['institution'];
    if ($values['updategroups']) {
        log_info('Updating groups from the CSV file');
    } else {
        log_info('Inserting groups from the CSV file');
    }
    db_begin();
    $addedgroups = array();
    foreach ($CSVDATA as $record) {
        $group = new StdClass();
        $group->name = $record[$formatkeylookup['displayname']];
        $group->shortname = $record[$formatkeylookup['shortname']];
        $group->institution = $institution;
        $group->grouptype = $record[$formatkeylookup['roles']];
        foreach ($FORMAT as $field) {
            if ($field == 'displayname' || $field == 'shortname' || $field == 'roles') {
                continue;
            }
            if ($field == 'submitpages') {
                $group->submittableto = $record[$formatkeylookup[$field]];
                continue;
            }
            $group->{$field} = $record[$formatkeylookup[$field]];
        }
        if (!$values['updategroups'] || !isset($UPDATES[$group->shortname])) {
            $group->members = array($USER->id => 'admin');
            $group->id = group_create((array) $group);
            $addedgroups[] = $group;
            log_debug('added group ' . $group->name);
        } else {
            if (isset($UPDATES[$group->shortname])) {
                $shortname = $group->shortname;
                $updates = group_update($group);
                if (empty($updates)) {
                    unset($UPDATES[$shortname]);
                } else {
                    if (isset($updates['name'])) {
                        $updates['displayname'] = $updates['name'];
                        unset($updates['name']);
                    }
                    $UPDATES[$shortname] = $updates;
                    log_debug('updated group ' . $group->name . ' (' . implode(', ', array_keys((array) $updates)) . ')');
                }
            }
        }
    }
    db_commit();
    $SESSION->add_ok_msg(get_string('csvfileprocessedsuccessfully', 'admin'));
    if ($UPDATES) {
        $updatemsg = smarty_core();
        $updatemsg->assign('added', count($addedgroups));
        $updatemsg->assign('updates', $UPDATES);
        $SESSION->add_info_msg($updatemsg->fetch('admin/groups/csvupdatemessage.tpl'), false);
    } else {
        $SESSION->add_ok_msg(get_string('numbernewgroupsadded', 'admin', count($addedgroups)));
    }
    redirect('/admin/groups/uploadcsv.php');
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:66,代码来源:uploadcsv.php

示例14: create_test_group

 /**
  * Create a group that can be used in a test.
  *
  * @param array $groupdata data about the group to create - this can take anything that {@link group_create} can take.
  *              If null then a group called 'groupX' will be created, where X is the number of groups created so far.
  *              These will be automatically cleaned up in tearDown, so make sure you call parent::tearDown().
  * @return int new group id.
  */
 protected function create_test_group($groupdata = null)
 {
     $testdata = array('name' => 'group' . count($this->testgroups), 'grouptype' => 'test' . count($this->testusers) . '@localhost');
     $combineddata = array_merge($testdata, (array) $groupdata);
     if (array_key_exists($combineddata['name'], $this->testgroups)) {
         throw new MaharaUnitTextException("MaharaUnitTest::create_test_group called with duplicate name {$combineddata['name']}");
     }
     try {
         $newgroupid = group_create($combineddata);
         $this->testgroups[$combineddata['name']] = $newgroupid;
         return $newgroupid;
     } catch (Exception $e) {
         throw new MaharaUnitTestException("MaharaUnitTest::create_test_group call caught an exception creating a group: " . $e->getMessage());
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:23,代码来源:phpunit.php

示例15: mahara_group_update_group_members

 function mahara_group_update_group_members($client)
 {
     //Set test data
     $dbuser1 = $this->create_user1_for_update();
     $dbuser2 = $this->create_user2_for_update();
     //Test data
     //a full group: group1
     $group1 = new stdClass();
     $group1->name = 'The test group 1 - create';
     $group1->shortname = 'testgroupshortname1';
     $group1->description = 'a description for test group 1';
     $group1->institution = 'mahara';
     $group1->grouptype = 'standard';
     $group1->open = 1;
     $group1->request = 0;
     $group1->controlled = 0;
     $group1->submitpages = 0;
     $group1->public = 0;
     $group1->usersautoadded = 0;
     $group1->members = array($dbuser1->id => 'admin', $dbuser2->id => 'admin');
     //a small group: group2
     $group2 = new stdClass();
     $group2->shortname = 'testgroupshortname2';
     $group2->name = 'The test group 2 - create';
     $group2->description = 'a description for test group 2';
     $group2->institution = 'mahara';
     $group2->grouptype = 'standard';
     $group2->open = 1;
     $group2->request = 0;
     $group2->controlled = 0;
     $group2->submitpages = 0;
     $group2->public = 0;
     $group2->usersautoadded = 0;
     $group2->members = array($dbuser1->id => 'admin');
     //do not run the test if group1 or group2 already exists
     foreach (array($group1->shortname, $group2->shortname) as $shortname) {
         $existinggroup = get_record('group', 'shortname', $shortname, 'institution', 'mahara');
         if (!empty($existinggroup)) {
             group_delete($existinggroup->id);
         }
     }
     // setup test groups
     $groupid1 = group_create((array) $group1);
     $groupid2 = group_create((array) $group2);
     $this->created_groups[] = $groupid1;
     $this->created_groups[] = $groupid2;
     $dbgroup1 = get_record('group', 'shortname', $group1->shortname, 'institution', 'mahara');
     $dbgroup2 = get_record('group', 'shortname', $group2->shortname, 'institution', 'mahara');
     //update the test data
     $group1 = new stdClass();
     $group1->id = $dbgroup1->id;
     $group1->shortname = 'testgroupshortname1';
     $group1->institution = 'mahara';
     $group1->members = array(array('id' => $dbuser1->id, 'action' => 'remove'));
     //a small group: group2
     $group2 = new stdClass();
     $group2->shortname = 'testgroupshortname2';
     $group2->institution = 'mahara';
     $group2->members = array(array('username' => $dbuser2->username, 'role' => 'admin', 'action' => 'add'));
     $groups = array($group1, $group2);
     //update the users by web service
     $function = 'mahara_group_update_group_members';
     $params = array('groups' => $groups);
     $client->call($function, $params);
     $dbgroup1 = get_record('group', 'id', $groupid1);
     $dbgroupmembers1 = get_records_array('group_member', 'group', $dbgroup1->id);
     $dbgroup2 = get_record('group', 'id', $groupid2);
     $dbgroupmembers2 = get_records_array('group_member', 'group', $dbgroup2->id);
     //compare DB group with the test data
     // current user added as admin
     $this->assertEquals(count($dbgroupmembers1), 1);
     // current user added as admin
     $this->assertEquals(count($dbgroupmembers2), 2);
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:74,代码来源:WebServiceGroupTest.php


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