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


PHP groups_get_group_by_name函数代码示例

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


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

示例1: validation

 function validation($data, $files)
 {
     global $COURSE, $CFG;
     $errors = parent::validation($data, $files);
     $textlib = textlib_get_instance();
     $name = trim(stripslashes($data['name']));
     if ($data['id'] and $group = get_record('groups', 'id', $data['id'])) {
         if ($textlib->strtolower($group->name) != $textlib->strtolower($name)) {
             if (groups_get_group_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupnameexists', 'group', $name);
             }
         }
         if (!empty($CFG->enrol_manual_usepasswordpolicy) and $data['enrolmentkey'] != '' and $group->enrolmentkey !== $data['enrolmentkey']) {
             // enforce password policy only if changing password
             $errmsg = '';
             if (!check_password_policy($data['enrolmentkey'], $errmsg)) {
                 $errors['enrolmentkey'] = $errmsg;
             }
         }
     } else {
         if (groups_get_group_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupnameexists', 'group', $name);
         }
     }
     return $errors;
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:26,代码来源:group_form.php

示例2: validation

 function validation($data, $files)
 {
     global $COURSE;
     $errors = parent::validation($data, $files);
     $name = trim(stripslashes($data['name']));
     if ($data['id'] and $group = get_record('groups', 'id', $data['id'])) {
         if ($group->name != $name) {
             if (groups_get_group_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupnameexists', 'group', $name);
             }
         }
     } else {
         if (groups_get_group_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupnameexists', 'group', $name);
         }
     }
     return $errors;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:18,代码来源:group_form.php

示例3: blended_update_grouping

function blended_update_grouping($courseid, $teamname, $mem, $groupingid, $ya, $groupid = null)
{
    if ($groupid == null) {
        $group_id = groups_get_group_by_name($courseid, $teamname);
        if ($group_id != false) {
            blended_update_group($courseid, $teamname, $mem, $group_id, $ya);
        }
        if ($group_id == false) {
            $id_group = blended_add_new_group($courseid, $teamname, $mem, $groupingid, $ya);
            return $id_group;
        }
    } else {
        if ($groupid != false) {
            blended_update_group($courseid, $teamname, $mem, $groupid, $ya);
        }
        if ($groupid == false) {
            $id_group = blended_add_new_group($courseid, $teamname, $mem, $groupingid, $ya);
            return $id_group;
        }
    }
}
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:21,代码来源:deprecated_lib.php

示例4: validation

 function validation($data, $files)
 {
     global $COURSE;
     $errors = parent::validation($data, $files);
     $description = $data['description'];
     if (strlen($description) > self::DESCRIPTION_MAXLEN) {
         $errors['description'] = get_string('maxcharlenreached', 'mod_groupselect');
     }
     $password = $data['password'];
     if (strlen($password) > self::PASSWORD_MAXLEN) {
         $errors['password'] = get_string('maxcharlenreached', 'mod_groupselect');
     }
     $groupname = $data['groupname'];
     if (strlen($groupname) > self::GROUP_NAME_MAXLEN) {
         $errors['groupname'] = get_string('maxcharlenreached', 'mod_groupselect');
     }
     if (groups_get_group_by_name($COURSE->id, $groupname)) {
         $errors['groupname'] = get_string('groupnameexists', 'group', $groupname);
     }
     return $errors;
 }
开发者ID:BLC-HTWChur,项目名称:moodle-mod_groupselect,代码行数:21,代码来源:create_form.php

示例5: validation

 function validation($data)
 {
     global $COURSE;
     $errors = array();
     $name = stripslashes($data['name']);
     if ($data['id'] and $group = get_record('groups', 'id', $data['id'])) {
         if ($group->name != $name) {
             if (groups_get_group_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupnameexists', 'group', $name);
             }
         }
     } else {
         if (groups_get_group_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupnameexists', 'group', $name);
         }
     }
     if (count($errors) > 0) {
         return $errors;
     } else {
         return true;
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:22,代码来源:group_form.php

示例6: validate_end_result

 /**
  * Validate that our constant expect end result is reached
  */
 private function validate_end_result()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/lib/grouplib.php';
     // Validate group creation.
     $groupid = groups_get_group_by_name(SITEID, 'testusersetname');
     $this->assertNotEquals(false, $groupid);
     // Validate user-group assignment.
     $userid = $DB->get_field('user', 'id', array('username' => 'testuserusername'));
     $this->assertTrue(groups_is_member($groupid, $userid));
     // Validate grouping creation.
     $groupingid = groups_get_grouping_by_name(SITEID, 'testusersetname');
     $this->assertNotEquals(false, $groupingid);
     // Validate group-grouping assignment.
     $this->assertTrue($DB->record_exists('groupings_groups', array('groupingid' => $groupingid, 'groupid' => $groupid)));
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:19,代码来源:elis_userset_site_groups_test.php

示例7: time

         } else {
             $newgroup->courseid = $id;
         }
     }
     //if courseid is set
     if (isset($newgroup->courseid)) {
         $newgroup->courseid = (int) $newgroup->courseid;
         $newgroup->timecreated = time();
         $linenum++;
         $groupname = $newgroup->name;
         $newgrpcoursecontext = get_context_instance(CONTEXT_COURSE, $newgroup->courseid);
         ///Users cannot upload groups in courses they cannot update.
         if (!has_capability('moodle/course:managegroups', $newgrpcoursecontext)) {
             echo $OUTPUT->notification(get_string('nopermissionforcreation', 'group', $groupname));
         } else {
             if ($groupid = groups_get_group_by_name($newgroup->courseid, $groupname) || !($newgroup->id = groups_create_group($newgroup))) {
                 //Record not added - probably because group is already registered
                 //In this case, output groupname from previous registration
                 if ($groupid) {
                     echo $OUTPUT->notification("{$groupname} :" . get_string('groupexistforcourse', 'error', $groupname));
                 } else {
                     echo $OUTPUT->notification(get_string('groupnotaddederror', 'error', $groupname));
                 }
             } else {
                 echo $OUTPUT->notification(get_string('groupaddedsuccesfully', 'group', $groupname));
             }
         }
     }
     //close courseid validity check
     unset($newgroup);
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:index.php

示例8: mass_enroll_group_exists

/**
 * @param string $name group name
 * @param int $courseid course
 * @return string or false 
 */
function mass_enroll_group_exists($name, $courseid) {
    return groups_get_group_by_name($courseid, $name);
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:8,代码来源:lib.php

示例9: test_groups_get_group_by_name

 public function test_groups_get_group_by_name()
 {
     $this->resetAfterTest(true);
     $generator = $this->getDataGenerator();
     // Create a course category and course.
     $cat = $generator->create_category(array('parent' => 0));
     $course = $generator->create_course(array('category' => $cat->id));
     $name1 = 'Name 1';
     $name2 = 'Name 2';
     // Test with an empty and a null idnumber.
     $this->assertFalse(groups_get_group_by_name($course->id, ''));
     $this->assertFalse(groups_get_group_by_name($course->id, null));
     // Even when a group exists.
     $generator->create_group(array('courseid' => $course->id));
     $this->assertFalse(groups_get_group_by_name($course->id, ''));
     $this->assertFalse(groups_get_group_by_name($course->id, null));
     // Test with a valid name, but one that doesn't exist yet.
     $this->assertFalse(groups_get_group_by_name($course->id, $name1));
     $this->assertFalse(groups_get_group_by_name($course->id, $name2));
     // We should now have a valid group returned by the name search.
     $group1 = $generator->create_group(array('courseid' => $course->id, 'name' => $name1));
     $this->assertEquals($group1->id, groups_get_group_by_name($course->id, $name1));
     $this->assertFalse(groups_get_group_by_name($course->id, $name2));
     // We should now have a two valid groups returned by the name search.
     $group2 = $generator->create_group(array('courseid' => $course->id, 'name' => $name2));
     $this->assertEquals($group1->id, groups_get_group_by_name($course->id, $name1));
     $this->assertEquals($group2->id, groups_get_group_by_name($course->id, $name2));
     // Delete a group.
     $this->assertTrue(groups_delete_group($group1));
     $this->assertFalse(groups_get_group_by_name($course->id, $name1));
     $this->assertEquals($group2->id, groups_get_group_by_name($course->id, $name2));
     /*
      * Group idnumbers are unique within a course so test that we don't
      * retrieve groups for the first course.
      */
     // Create a second course.
     $course = $generator->create_course(array('category' => $cat->id));
     // An empty name should always return a false value.
     $this->assertFalse(groups_get_group_by_name($course->id, ''));
     $this->assertFalse(groups_get_group_by_name($course->id, null));
     // Our existing names shouldn't be returned here as we're in a different course.
     $this->assertFalse(groups_get_group_by_name($course->id, $name1));
     $this->assertFalse(groups_get_group_by_name($course->id, $name2));
     // We should be able to reuse the idnumbers again since this is a different course.
     $group1 = $generator->create_group(array('courseid' => $course->id, 'name' => $name1));
     $this->assertEquals($group1->id, groups_get_group_by_name($course->id, $name1));
     $group2 = $generator->create_group(array('courseid' => $course->id, 'name' => $name2));
     $this->assertEquals($group2->id, groups_get_group_by_name($course->id, $name2));
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:49,代码来源:grouplib_test.php

示例10: options_from_csv

function options_from_csv($groupreg, $courseid, $csv)
{
    // Set new option_repeats as count(csv-lines)
    $option_repeats = count($csv);
    // Initialize settings
    $groupreg->option = array();
    $groupreg->limit = array();
    $groupreg->grouping = array();
    $groupreg->optionid = array();
    $groupreg->option_repeats = $option_repeats;
    foreach ($csv as $row) {
        // get group id
        $groupname = trim(filter_var($row['name']));
        // TODO attention: Duplicate group names will lead to unexpected behavior!
        $option = groups_get_group_by_name($courseid, $groupname);
        // maxanswer
        $limit = intval($row['maxanswers']);
        // grouping
        $grouping = isset($row['grouping']) ? filter_var($row['grouping']) : '';
        // default optionid = 0
        $optionid = 0;
        array_push($groupreg->option, $option);
        array_push($groupreg->limit, $limit);
        array_push($groupreg->grouping, $grouping);
        array_push($groupreg->optionid, $optionid);
    }
    return $groupreg;
}
开发者ID:martinliao,项目名称:mod-groupreg,代码行数:28,代码来源:csvlib.php

示例11: object

         $grouping = new object();
         $grouping->courseid = $COURSE->id;
         $grouping->name = $groupingname;
         if (!($grouping->id = groups_create_grouping(addslashes_recursive($grouping)))) {
             $error = 'Can not create grouping';
             //should not happen
             $failed = true;
         }
         $createdgrouping = $grouping->id;
     } else {
         $grouping = groups_get_grouping($data->grouping);
     }
 }
 // Save the groups data
 foreach ($groups as $key => $group) {
     if (groups_get_group_by_name($courseid, $group['name'])) {
         $error = get_string('groupnameexists', 'group', $group['name']);
         $failed = true;
         break;
     }
     $newgroup = new object();
     $newgroup->courseid = $data->courseid;
     $newgroup->name = $group['name'];
     if (!($groupid = groups_create_group(addslashes_recursive($newgroup)))) {
         $error = 'Can not create group!';
         // should not happen
         $failed = true;
         break;
     }
     $createdgroups[] = $groupid;
     foreach ($group['members'] as $user) {
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:autogroup.php

示例12: cluster_groups_update_grouping_closure

/**
 * Updates all parent cluster's groupings with the existence of a group for this cluster
 *
 * @param    int      $clusterid         The cluster to check the parents for
 * @param    boolean  $include_children  If true, make child cluster-groups trickle up the tree
 * @return   boolean                     Returns true to satisfy event handlers
 */
function cluster_groups_update_grouping_closure($clusterid, $include_children = false)
{
    global $CFG, $CURMAN;
    if (empty($CFG->enablegroupings) || empty($CURMAN->config->cluster_groupings) || !cluster_groups_grouping_allowed($clusterid)) {
        return true;
    }
    $cluster = new cluster($clusterid);
    //get the group id for this cluster
    if ($groupid = groups_get_group_by_name(SITEID, $cluster->name)) {
        //go through the chain of parent clusters
        while (!empty($cluster->parent)) {
            $cluster = new cluster($cluster->parent);
            //add this to grouping if applicable
            $grouping = groups_get_grouping_by_name(SITEID, $cluster->name);
            if ($grouping = groups_get_grouping($grouping)) {
                groups_assign_grouping($grouping->id, $groupid);
                //recurse into children if possible
                if ($include_children) {
                    //get all child clusters
                    $child_cluster_ids = cluster_groups_get_child_clusters($cluster->id);
                    foreach ($child_cluster_ids as $child_cluster_id) {
                        //children only
                        if ($child_cluster_id != $cluster->id) {
                            $child_cluster = new cluster($child_cluster_id);
                            //make sure the group exists
                            if ($child_groupid = groups_get_group_by_name(SITEID, $child_cluster->name) and cluster_groups_cluster_allows_groups($child_cluster->id)) {
                                groups_assign_grouping($grouping->id, $child_groupid);
                            }
                        }
                    }
                }
            }
        }
    }
    return true;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:43,代码来源:lib.php

示例13: get_context_instance

                 $newgroup->courseid = $mycourse->id;
             } else {
                 //else use use current id
                 $newgroup->courseid = $id;
             }
         }
         //if courseid is set
         if (isset($newgroup->courseid)) {
             $linenum++;
             $groupname = $newgroup->name;
             $newgrpcoursecontext = get_context_instance(CONTEXT_COURSE, $newgroup->courseid);
             ///Users cannot upload groups in courses they cannot update.
             if (!has_capability('moodle/course:managegroups', $newgrpcoursecontext) or !is_enrolled($newgrpcoursecontext) and !has_capability('moodle/course:view', $newgrpcoursecontext)) {
                 echo $OUTPUT->notification(get_string('nopermissionforcreation', 'group', $groupname));
             } else {
                 if ($groupid = groups_get_group_by_name($newgroup->courseid, $groupname)) {
                     echo $OUTPUT->notification("{$groupname} :" . get_string('groupexistforcourse', 'error', $groupname));
                 } else {
                     if (groups_create_group($newgroup)) {
                         echo $OUTPUT->notification(get_string('groupaddedsuccesfully', 'group', $groupname), 'notifysuccess');
                     } else {
                         echo $OUTPUT->notification(get_string('groupnotaddederror', 'error', $groupname));
                     }
                 }
             }
         }
         unset($newgroup);
     }
 }
 echo $OUTPUT->single_button($returnurl, get_string('continue'), 'get');
 echo $OUTPUT->footer();
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:import.php

示例14: notify

         $userserrors++;
         continue;
     }
 }
 for ($i = 0; $i < 5; $i++) {
     if ($addcourse[$i] && !$course[$i]) {
         notify(get_string('unknowncourse', 'error', $addcourse[$i]));
     }
 }
 for ($i = 0; $i < 5; $i++) {
     $groupid[$i] = 0;
     if ($addgroup[$i]) {
         if (!$course[$i]) {
             notify(get_string('coursegroupunknown', 'error', $addgroup[$i]));
         } else {
             if ($gid = groups_get_group_by_name($course[$i]->id, $addgroup[$i])) {
                 $groupid[$i] = $gid;
             } else {
                 notify(get_string('groupunknown', 'error', $addgroup[$i]));
             }
         }
     }
 }
 for ($i = 0; $i < 5; $i++) {
     /// Enrol into courses if necessary
     if ($course[$i]) {
         if (isset($addrole[$i])) {
             $coursecontext = get_context_instance(CONTEXT_COURSE, $course[$i]->id);
             if (!user_can_assign($coursecontext, $addrole[$i])) {
                 notify('--> Can not assign role in course');
                 //TODO: localize
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:uploaduser.php

示例15: userset_groups_update_grouping_closure

/**
 * Updates all parent cluster's groupings with the existence of a group for this cluster
 *
 * @param    int      $clusterid         The cluster to check the parents for
 * @param    boolean  $include_children  If true, make child cluster-groups trickle up the tree
 * @return   boolean                     Returns true to satisfy event handlers
 */
function userset_groups_update_grouping_closure($clusterid, $include_children = false)
{
    global $CFG;
    $enabled = get_config('elisprogram_usetgroups', 'userset_groupings');
    if (empty($enabled) || !userset_groups_grouping_allowed($clusterid)) {
        return true;
    }
    $cluster = new userset($clusterid);
    //get the group id for this cluster
    if ($groupid = groups_get_group_by_name(SITEID, $cluster->name)) {
        //go through the chain of parent clusters
        while (!empty($cluster->parent)) {
            $cluster = new userset($cluster->parent);
            //add this to grouping if applicable
            $grouping = groups_get_grouping_by_name(SITEID, $cluster->name);
            if ($grouping = groups_get_grouping($grouping)) {
                groups_assign_grouping($grouping->id, $groupid);
                //recurse into children if possible
                if ($include_children) {
                    //get all child clusters
                    $child_cluster_ids = userset_groups_get_child_usersets($cluster->id);
                    foreach ($child_cluster_ids as $child_cluster_id) {
                        //children only
                        if ($child_cluster_id != $cluster->id) {
                            $child_cluster = new userset($child_cluster_id);
                            //make sure the group exists
                            if ($child_groupid = groups_get_group_by_name(SITEID, $child_cluster->name) and userset_groups_userset_allows_groups($child_cluster->id)) {
                                groups_assign_grouping($grouping->id, $child_groupid);
                            }
                        }
                    }
                }
            }
        }
    }
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:44,代码来源:lib.php


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