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


PHP groups_create_group函数代码示例

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


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

示例1: create_groups

 /**
  * Create groups
  *
  * @param array $groups array of group description arrays (with keys groupname and courseid)
  * @return array of newly created groups
  * @since Moodle 2.2
  */
 public static function create_groups($groups)
 {
     global $CFG, $DB;
     require_once "{$CFG->dirroot}/group/lib.php";
     $params = self::validate_parameters(self::create_groups_parameters(), array('groups' => $groups));
     $transaction = $DB->start_delegated_transaction();
     $groups = array();
     foreach ($params['groups'] as $group) {
         $group = (object) $group;
         if (trim($group->name) == '') {
             throw new invalid_parameter_exception('Invalid group name');
         }
         if ($DB->get_record('groups', array('courseid' => $group->courseid, 'name' => $group->name))) {
             throw new invalid_parameter_exception('Group with the same name already exists in the course');
         }
         // now security checks
         $context = get_context_instance(CONTEXT_COURSE, $group->courseid);
         try {
             self::validate_context($context);
         } catch (Exception $e) {
             $exceptionparam = new stdClass();
             $exceptionparam->message = $e->getMessage();
             $exceptionparam->courseid = $group->courseid;
             throw new moodle_exception('errorcoursecontextnotvalid', 'webservice', '', $exceptionparam);
         }
         require_capability('moodle/course:managegroups', $context);
         // finally create the group
         $group->id = groups_create_group($group, false);
         $groups[] = (array) $group;
     }
     $transaction->allow_commit();
     return $groups;
 }
开发者ID:nicusX,项目名称:moodle,代码行数:40,代码来源:externallib.php

示例2: _createNewGroup

 private function _createNewGroup($groupObj)
 {
     global $CFG;
     require_once $CFG->dirroot . '/group/lib.php';
     return groups_create_group($groupObj);
     /* group/lib.php */
 }
开发者ID:frapersan,项目名称:group-magic,代码行数:7,代码来源:GroupMagic.php

示例3: test_group_matches

 function test_group_matches()
 {
     $groupinfo->name = 'Group Testname:' . $this->getLabel();
     $groupinfo->description = 'Group Test Description:' . $this->getLabel();
     $this->assertTrue($this->groupid = groups_create_group($this->courseid, $groupinfo));
     $this->assertTrue(groups_group_matches($this->courseid, $groupinfo->name, $groupinfo->description));
 }
开发者ID:veritech,项目名称:pare-project,代码行数:7,代码来源:test_basicgrouplib.php

示例4: create_object

 function create_object($args)
 {
     if (!isset($args['creator_id'])) {
         $args['creator_id'] = get_current_user_id();
     }
     $group_id = groups_create_group($args);
     groups_update_groupmeta($group_id, 'total_member_count', 1);
     groups_update_groupmeta($group_id, 'last_activity', bp_core_current_time());
     return $this->get_object_by_id($group_id);
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:10,代码来源:bp-factory.php

示例5: groups_hierarchy_create_group

/**
 * Function for creating groups with parents programmatically
 * @param array Args same as groups_create_group, but accepts a 'parent_id' param
 */
function groups_hierarchy_create_group($args = '')
{
    if ($group_id = groups_create_group($args)) {
        if (isset($args['parent_id'])) {
            $group = new BP_Groups_Hierarchy($group_id);
            $group->parent_id = (int) $args['parent_id'];
            $group->save();
        }
        return $group_id;
    }
    return false;
}
开发者ID:elderfd,项目名称:cfsf,代码行数:16,代码来源:bp-group-hierarchy-functions.php

示例6: local_syncgroups_do_sync

function local_syncgroups_do_sync($groups, $destinations, $trace)
{
    global $DB;
    foreach ($groups as $group) {
        $trace->output('Grupo: ' . $group->name);
        if (!($members = $DB->get_records_menu('groups_members', array('groupid' => $group->id), '', 'userid, id'))) {
            $trace->output('group with no members, skipping');
            continue;
        }
        foreach ($destinations as $dest) {
            $trace->output("Curso: {$dest->shortname}");
            if ($dgr = $DB->get_record('groups', array('courseid' => $dest->id, 'name' => $group->name), 'id, courseid, idnumber, name')) {
                $trace->output('grupo existente');
            } else {
                $trace->output("criado grupo");
                $dgr = new Stdclass();
                $dgr->courseid = $dest->id;
                $dgr->timecreated = time();
                $dgr->timemodified = $dgr->timecreated;
                $dgr->name = $group->name;
                $dgr->description = $group->description;
                $dgr->descriptionformat = $group->descriptionformat;
                if (!($dgr->id = groups_create_group($dgr))) {
                    print_error("?? erro ao criar grupo");
                }
            }
            $trace->output("inserindo membros: ");
            foreach ($members as $userid => $memberid) {
                if (!$DB->get_field('groups_members', 'id', array('groupid' => $dgr->id, 'userid' => $userid))) {
                    if ($DB->get_field('role_assignments', 'id', array('contextid' => $dest->context->id, 'userid' => $userid))) {
                        groups_add_member($dgr->id, $userid);
                        $trace->output('Usuário inserido no grupo: ' . $userid);
                    } else {
                        $trace->output("?? usuario id: {$userid} não inscrito no curso");
                    }
                }
            }
            $trace->output("removendo membros: ");
            $members_dest = $DB->get_records('groups_members', array('groupid' => $dgr->id), '', 'id, groupid, userid');
            foreach ($members_dest as $id => $usum) {
                if (!isset($members[$usum->userid])) {
                    groups_remove_member($dgr->id, $usum->userid);
                    $trace->output('Usuário removido do grupo: ' . $usum->userid);
                }
            }
        }
    }
    $trace->output('Concluído.');
    $trace->finished();
}
开发者ID:danielneis,项目名称:moodle-local_syncgroups,代码行数:50,代码来源:lib.php

示例7: create_group

 /**
  * This function creates a group with a particular name, adds it to the grouping,
  * and then adds the current user to that group.
  *
  * @param string $name The name to assign to the newly created group.
  * @return int The ID of the group that was group that was created.
  *
  */
 public function create_group($name)
 {
     global $DB, $USER;
     $sgs = new skills_group_setting($this->courseid);
     $group = new stdClass();
     if ($name === null || trim($name) == '') {
         $name = $this->name_empty_group();
     }
     $group->name = $name;
     $group->courseid = $this->courseid;
     $groupid = groups_create_group($group);
     groups_assign_grouping($sgs->get_grouping_id(), $groupid);
     groups_add_member($groupid, $USER->id);
     return $groupid;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:23,代码来源:skills_grouping.class.php

示例8: setUp

 /**
  * setUp/tearDown: Better in a constructor/destructor, but PHP4 doesn't do destructors :(
  */
 function setUp()
 {
     parent::setUp();
     if ($course = groups_get_course_info(1)) {
         $this->courseid = $course->id;
     }
     if ($user = groups_get_user(2)) {
         //Primary admin.
         $this->userid = $user->id;
     }
     $this->groupid = groups_create_group($this->courseid);
     $groupinfo = groups_set_default_group_settings();
     $bok = groups_set_group_settings($this->groupid, $groupinfo);
     $bok = groups_add_member($this->groupid, $this->userid);
 }
开发者ID:veritech,项目名称:pare-project,代码行数:18,代码来源:test_groupinglib.php

示例9: build

 /**
  * Create the fixture
  *
  * This method must be safe to call multiple times.
  *
  * @return void
  * @throws moodle_exception
  */
 public function build()
 {
     global $DB;
     if (!$this->exists()) {
         // Dependents
         $this->get_course()->build();
         $group = (object) $this->get_options();
         $group->courseid = $this->get_course()->get('id');
         // Helping...!?!
         if (!property_exists($group, 'name')) {
             $group->name = '';
         }
         $groupid = groups_create_group($group);
         $this->set_results($DB->get_record('groups', array('id' => $groupid), '*', MUST_EXIST));
     }
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:24,代码来源:group.php

示例10: create_groups

 /**
  * Create some groups
  * @param array|struct $params
  * @subparam string $params:group->groupname
  * @subparam integer $params:group->courseid
  * @return array $return
  * @subparam integer $return:groupid
  */
 static function create_groups($params)
 {
     global $USER;
     $groupids = array();
     if (has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_SYSTEM))) {
         foreach ($params as $groupparam) {
             $group = new stdClass();
             $group->courseid = clean_param($groupparam['courseid'], PARAM_INTEGER);
             $group->name = clean_param($groupparam['groupname'], PARAM_ALPHANUMEXT);
             $groupids[] = groups_create_group($group, false);
         }
         return $groupids;
     } else {
         throw new moodle_exception('wscouldnotcreategroupnopermission');
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:24,代码来源:external.php

示例11: fn_sg_create_group

/**
 * This function creates the course groups and associates with it the site group.
 *
 * @param int $groupid The site group id.
 * @param object $group The course group data.
 * @return boolean success.
 *
 */
function fn_sg_create_group($groupid, $group)
{
    /// This will generate another group create event. Will that be a problem?
    if (!($newid = groups_create_group($group))) {
        trigger_error('Could not create course group!');
        return false;
    }
    $sgrec = new Object();
    $sgrec->sitegroupid = $groupid;
    $sgrec->coursegroupid = $newid;
    $sgrec->courseid = $group->courseid;
    if (insert_record('block_fn_site_groups', $sgrec)) {
        return $newid;
    } else {
        return false;
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:25,代码来源:lib.php

示例12: SavePost

 public static function SavePost($post_id, $post, $update)
 {
     if (wp_is_post_revision($post_id) || $post->post_status != 'publish' || $post->post_type != 'namaste_course') {
         return;
     }
     $meta = get_post_meta($post_id, 'buddypress_id', true);
     if (empty($meta)) {
         $group_id = groups_create_group(array('creator_id' => get_current_user_id(), 'name' => $post->post_title, 'description' => 'Обсуждение курса ' . $post->post_title, 'enable_forum' => 1));
         update_post_meta($post_id, 'buddypress_id', $group_id);
         groups_edit_group_settings($group_id, 1, 'private', 'mods');
         $forum_id = bbp_insert_forum($forum_data = array('post_status' => bbp_get_private_status_id(), 'post_type' => bbp_get_forum_post_type(), 'post_author' => bbp_get_current_user_id(), 'post_content' => 'Обсуждение курса ' . $post->post_title, 'post_title' => $post->post_title), $forum_meta = array());
         bbp_update_group_forum_ids($group_id, (array) $forum_id);
         bbp_update_forum_group_ids($forum_id, (array) $group_id);
     }
     bbp_add_user_forum_subscription(bbp_get_current_user_id(), $forum_id);
     update_post_meta($forum_id, '_forum_course_id', $post_id);
 }
开发者ID:Bnei-Baruch,项目名称:mailchimpNamasteIntegration,代码行数:17,代码来源:CreateGroupAndForumForCourse.php

示例13: thatcamp_create_group_for_new_blog

/**
 * On blog creation, create a new group
 */
function thatcamp_create_group_for_new_blog($blog_id)
{
    // Assemble some data to create the group
    $create_args = array();
    // The group admin should be the blog admin. If no blog admin is found, default to Amanda (id 7)
    $blog_admin = get_user_by('email', get_blog_option($blog_id, 'admin_email'));
    $create_args['creator_id'] = is_a($blog_admin, 'WP_User') ? $blog_admin->ID : '7';
    $create_args['name'] = get_blog_option($blog_id, 'blogname');
    $create_args['description'] = $create_args['name'];
    $create_args['slug'] = sanitize_title($create_args['name']);
    $create_args['status'] = 'public';
    $create_args['enable_forum'] = false;
    $create_args['date_created'] = bp_core_current_time();
    $group_id = groups_create_group($create_args);
    groups_update_groupmeta($group_id, 'blog_id', $blog_id);
    groups_update_groupmeta($group_id, 'total_member_count', 1);
    groups_update_groupmeta($group_id, 'invite_status', 'members');
    return $group_id;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:22,代码来源:thatcamp-group-blogs.php

示例14: appear_add_instance

function appear_add_instance($data)
{
    global $DB, $CFG, $USER;
    $appear = new stdClass();
    $appear->course = $data->course;
    $appear->name = $data->name;
    $appear->intro = $data->intro;
    $appear->revision = $data->revision;
    $appear->timemodified = time();
    $appear->timecreated = time();
    $appear->timestart = $data->starttime;
    $appear->id = $DB->insert_record('appear', $appear);
    //creating group
    $group = new stdClass();
    $group->name = $data->name . '_group_' . $appear->id;
    $group->courseid = $data->course;
    $group->hidepicture = 0;
    $group->id = groups_create_group($group);
    // creating event subscription
    $sub = new stdClass();
    $sub->url = $CFG->wwwroot . '/mod/appear/view.php?id=' . $data->coursemodule;
    $sub->courseid = $data->course;
    $sub->groupid = $group->id;
    $sub->userid = $USER->id;
    $sub->pollinterval = 0;
    $subid = $DB->insert_record('event_subscriptions', $sub, true);
    // creating calender event
    $event = new stdClass();
    $event->name = $data->name;
    $event->description = '';
    $event->timestart = $data->starttime;
    $event->modulename = 'appear';
    $event->timeduration = 3600;
    $event->uuid = 'uuid';
    $event->subscriptionid = $subid;
    $event->userid = $USER->id;
    $event->groupid = $group->id;
    $event->courseid = $data->course;
    $event->eventtype = 'feedbackcloses';
    $eventobj = calendar_event::create($event, false);
    return $appear->id;
}
开发者ID:alokr912,项目名称:moodle-appear,代码行数:42,代码来源:lib.php

示例15: group_created

 /**
  * Group created
  *
  * @param \core\event\group_created $event
  * @return void
  */
 public static function group_created(\core\event\group_created $event)
 {
     global $DB;
     $group = $event->get_record_snapshot('groups', $event->objectid);
     $courseids = local_metagroups_parent_courses($group->courseid);
     foreach ($courseids as $courseid) {
         $course = get_course($courseid);
         // If parent course doesn't use groups, we can skip synchronization.
         if (groups_get_course_groupmode($course) == NOGROUPS) {
             continue;
         }
         if (!$DB->record_exists('groups', array('courseid' => $course->id, 'idnumber' => $group->id))) {
             $metagroup = new \stdClass();
             $metagroup->courseid = $course->id;
             $metagroup->idnumber = $group->id;
             $metagroup->name = $group->name;
             groups_create_group($metagroup, false, false);
         }
     }
 }
开发者ID:stanta,项目名称:moodle-local_metagroups,代码行数:26,代码来源:observers.php


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