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


PHP groups_is_member函数代码示例

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


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

示例1: groups_remove_member

/**
 * Deletes the link between the specified user and group.
 * @param mixed $groupid  The group id or group object
 * @param mixed $userid   The user id or user object
 * @return boolean True if deletion was successful, false otherwise
 */
function groups_remove_member($grouporid, $userorid)
{
    global $DB;
    if (is_object($userorid)) {
        $userid = $userorid->id;
        $user = $userorid;
    } else {
        $userid = $userorid;
        $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
    }
    if (is_object($grouporid)) {
        $groupid = $grouporid->id;
        $group = $grouporid;
    } else {
        $groupid = $grouporid;
        $group = $DB->get_record('groups', array('id' => $groupid), '*', MUST_EXIST);
    }
    if (!groups_is_member($groupid, $userid)) {
        return true;
    }
    $DB->delete_records('groups_members', array('groupid' => $groupid, 'userid' => $userid));
    //update group info
    $DB->set_field('groups', 'timemodified', time(), array('id' => $groupid));
    //trigger groups events
    $eventdata = new stdClass();
    $eventdata->groupid = $groupid;
    $eventdata->userid = $userid;
    events_trigger('groups_member_removed', $eventdata);
    return true;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:36,代码来源:lib.php

示例2: get_enrolled_users

 /**
  * Get list of course participants.
  *
  * @param int $courseid
  * @param text $withcapability
  * @param int $groupid
  * @param bool $onlyactive
  * @return array of course participants
  */
 public static function get_enrolled_users($courseid, $withcapability = null, $groupid = null, $onlyactive = false)
 {
     global $DB, $CFG, $USER;
     // Do basic automatic PARAM checks on incoming data, using params description
     // If any problems are found then exceptions are thrown with helpful error messages
     $params = self::validate_parameters(self::get_enrolled_users_parameters(), array('courseid' => $courseid, 'withcapability' => $withcapability, 'groupid' => $groupid, 'onlyactive' => $onlyactive));
     $coursecontext = get_context_instance(CONTEXT_COURSE, $params['courseid']);
     if ($courseid == SITEID) {
         $context = get_context_instance(CONTEXT_SYSTEM);
     } else {
         $context = $coursecontext;
     }
     try {
         self::validate_context($context);
     } catch (Exception $e) {
         $exceptionparam = new stdClass();
         $exceptionparam->message = $e->getMessage();
         $exceptionparam->courseid = $params['courseid'];
         throw new moodle_exception(get_string('errorcoursecontextnotvalid', 'webservice', $exceptionparam));
     }
     if ($courseid == SITEID) {
         require_capability('moodle/site:viewparticipants', $context);
     } else {
         require_capability('moodle/course:viewparticipants', $context);
     }
     if ($withcapability) {
         require_capability('moodle/role:review', $coursecontext);
     }
     if ($groupid && groups_is_member($groupid)) {
         require_capability('moodle/site:accessallgroups', $coursecontext);
     }
     if ($onlyactive) {
         require_capability('moodle/course:enrolreview', $coursecontext);
     }
     list($sqlparams, $params) = get_enrolled_sql($coursecontext, $withcapability, $groupid, $onlyactive);
     $sql = "SELECT ue.userid, e.courseid, u.firstname, u.lastname, u.username, c.id as usercontextid\n                  FROM {user_enrolments} ue\n                  JOIN {enrol} e ON (e.id = ue.enrolid)\n                  JOIN {user} u ON (ue.userid = u.id)\n                  JOIN {context} c ON (u.id = c.instanceid AND contextlevel = " . CONTEXT_USER . ")\n                  WHERE e.courseid = :courseid AND ue.userid IN ({$sqlparams})\n                  GROUP BY ue.userid, e.courseid, u.firstname, u.lastname, u.username, c.id";
     $params['courseid'] = $courseid;
     $enrolledusers = $DB->get_records_sql($sql, $params);
     $result = array();
     $isadmin = is_siteadmin($USER);
     $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
     foreach ($enrolledusers as $enrolleduser) {
         $profilimgurl = moodle_url::make_pluginfile_url($enrolleduser->usercontextid, 'user', 'icon', NULL, '/', 'f1');
         $profilimgurlsmall = moodle_url::make_pluginfile_url($enrolleduser->usercontextid, 'user', 'icon', NULL, '/', 'f2');
         $resultuser = array('courseid' => $enrolleduser->courseid, 'userid' => $enrolleduser->userid, 'fullname' => fullname($enrolleduser), 'profileimgurl' => $profilimgurl->out(false), 'profileimgurlsmall' => $profilimgurlsmall->out(false));
         // check if we can return username
         if ($isadmin) {
             $resultuser['username'] = $enrolleduser->username;
         }
         // check if we can return first and last name
         if ($isadmin or $canviewfullnames) {
             $resultuser['firstname'] = $enrolleduser->firstname;
             $resultuser['lastname'] = $enrolleduser->lastname;
         }
         $result[] = $resultuser;
     }
     return $result;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:67,代码来源:externallib.php

示例3: validate

 /**
  * @return bool
  */
 public static function validate($params)
 {
     $dataformid = $params['dataformid'];
     $df = \mod_dataform_dataform::instance($dataformid);
     // Cannot add in a view that does not allow submission.
     if (!empty($params['viewid'])) {
         $view = $df->view_manager->get_view_by_id($params['viewid']);
         if (!$view or !$view->allows_submission()) {
             return false;
         }
     }
     // User at max entries (per interval).
     if ($df->user_at_max_entries(true)) {
         // No more entries for you (come back next interval or so).
         return false;
     }
     // Early entries.
     if ($df->is_early()) {
         $params['capabilities'] = array('mod/dataform:entryearlyadd');
         if (!parent::validate($params)) {
             return false;
         }
     }
     // Late entries.
     if ($df->is_past_due()) {
         $params['capabilities'] = array('mod/dataform:entrylateadd');
         if (!parent::validate($params)) {
             return false;
         }
     }
     $entry = !empty($params['entry']) ? $params['entry'] : \mod_dataform\pluginbase\dataformentry::blank_instance($df);
     // Own entry.
     if (\mod_dataform\pluginbase\dataformentry::is_own($entry)) {
         $params['capabilities'] = array('mod/dataform:entryownadd');
         return parent::validate($params);
     }
     // Group entry.
     if (\mod_dataform\pluginbase\dataformentry::is_grouped($entry)) {
         if (groups_is_member($entry->groupid)) {
             $params['capabilities'] = array('mod/dataform:entrygroupadd');
             return parent::validate($params);
         }
     }
     // Anonymous entry.
     if (\mod_dataform\pluginbase\dataformentry::is_anonymous($entry)) {
         if ((isguestuser() or !isloggedin()) and $df->anonymous) {
             return true;
         }
         $params['capabilities'] = array('mod/dataform:entryanonymousadd');
         return parent::validate($params);
     }
     // Any entry.
     if (\mod_dataform\pluginbase\dataformentry::is_others($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanyadd');
         return parent::validate($params);
     }
     return false;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:61,代码来源:entry_add.php

示例4: validate

 /**
  * @return bool
  */
 public static function validate($params)
 {
     $dataformid = $params['dataformid'];
     $df = \mod_dataform_dataform::instance($dataformid);
     // Cannot update in a view that does not allow submission.
     if (!empty($params['viewid'])) {
         $view = $df->view_manager->get_view_by_id($params['viewid']);
         if (!$view or !$view->allows_submission()) {
             return false;
         }
     }
     // Unspecified entry
     // if (empty($params['entry'])) {
     //    return self::has_capability('mod/dataform:entryanyupdate', $params);
     // }.
     // Early entries.
     if ($df->is_early()) {
         $params['capabilities'] = array('mod/dataform:entryearlyupdate');
         if (!parent::validate($params)) {
             return false;
         }
     }
     // Late entries.
     if ($df->is_past_due()) {
         $params['capabilities'] = array('mod/dataform:entrylateupdate');
         if (!parent::validate($params)) {
             return false;
         }
     }
     $entry = !empty($params['entry']) ? $params['entry'] : \mod_dataform\pluginbase\dataformentry::blank_instance($df);
     // Own entry.
     if (\mod_dataform\pluginbase\dataformentry::is_own($entry)) {
         $params['capabilities'] = array('mod/dataform:entryownupdate');
         return parent::validate($params);
     }
     // Group entry.
     if (\mod_dataform\pluginbase\dataformentry::is_grouped($entry)) {
         if (groups_is_member($entry->groupid)) {
             $params['capabilities'] = array('mod/dataform:entrygroupupdate');
             return parent::validate($params);
         }
     }
     // Anonymous entry.
     if (\mod_dataform\pluginbase\dataformentry::is_anonymous($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanonymousupdate');
         return parent::validate($params);
     }
     // Any entry.
     if (\mod_dataform\pluginbase\dataformentry::is_others($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanyupdate');
         return parent::validate($params);
     }
     return false;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:57,代码来源:entry_update.php

示例5: test_destroy

 public function test_destroy()
 {
     $fm = mr_fixture_manager::instance();
     $userid = $fm->get('user')->get('id');
     $groupid = $fm->get('group')->get('id');
     $this->assertFalse(groups_is_member($groupid, $userid));
     $gm = new mr_fixture_group_member($fm->get('group'), $fm->get('enroll'));
     $gm->build();
     $this->assertTrue(groups_is_member($groupid, $userid));
     $gm->destroy();
     $this->assertFalse(groups_is_member($groupid, $userid));
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:12,代码来源:testfixturegroupmember.php

示例6: groups_remove_member

/**
 * Deletes the link between the specified user and group.
 * @param int $groupid The group to delete the user from
 * @param int $userid The user to delete
 * @return boolean True if deletion was successful, false otherwise
 */
function groups_remove_member($groupid, $userid)
{
    if (!groups_group_exists($groupid)) {
        return false;
    }
    if (!groups_is_member($groupid, $userid)) {
        return true;
    }
    if (!delete_records('groups_members', 'groupid', $groupid, 'userid', $userid)) {
        return false;
    }
    //update group info
    set_field('groups', 'timemodified', time(), 'id', $groupid);
    return true;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:21,代码来源:lib.php

示例7: certificate_get_teachers

/**
 * Returns a list of teachers by group
 * for sending email alerts to teachers
 *
 * @param stdClass $certificate
 * @param stdClass $user
 * @param stdClass $course
 * @param stdClass $cm
 * @return array the teacher array
 */
function certificate_get_teachers($certificate, $user, $course, $cm)
{
    global $USER;
    $context = context_module::instance($cm->id);
    $potteachers = get_users_by_capability($context, 'mod/certificate:manage', '', '', '', '', '', '', false, false);
    if (empty($potteachers)) {
        return array();
    }
    $teachers = array();
    if (groups_get_activity_groupmode($cm, $course) == SEPARATEGROUPS) {
        // Separate groups are being used
        if ($groups = groups_get_all_groups($course->id, $user->id)) {
            // Try to find all groups
            foreach ($groups as $group) {
                foreach ($potteachers as $t) {
                    if ($t->id == $user->id) {
                        continue;
                        // do not send self
                    }
                    if (groups_is_member($group->id, $t->id)) {
                        $teachers[$t->id] = $t;
                    }
                }
            }
        } else {
            // user not in group, try to find teachers without group
            foreach ($potteachers as $t) {
                if ($t->id == $USER->id) {
                    continue;
                    // do not send self
                }
                if (!groups_get_all_groups($course->id, $t->id)) {
                    //ugly hack
                    $teachers[$t->id] = $t;
                }
            }
        }
    } else {
        foreach ($potteachers as $t) {
            if ($t->id == $USER->id) {
                continue;
                // do not send self
            }
            $teachers[$t->id] = $t;
        }
    }
    return $teachers;
}
开发者ID:ccle,项目名称:moodle-mod_certificate,代码行数:58,代码来源:locallib.php

示例8: validate

 /**
  * @return bool
  */
 public static function validate($params)
 {
     $dataformid = $params['dataformid'];
     $df = \mod_dataform_dataform::instance($dataformid);
     // Unspecified entry.
     if (empty($params['entry'])) {
         return self::has_capability('mod/dataform:entryanydelete', $params);
     }
     // Early entries.
     if ($df->is_early()) {
         $params['capabilities'] = array('mod/dataform:entryearlydelete');
         if (!parent::validate($params)) {
             return false;
         }
     }
     // Late entries.
     if ($df->is_past_due()) {
         $params['capabilities'] = array('mod/dataform:entrylatedelete');
         if (!parent::validate($params)) {
             return false;
         }
     }
     $entry = !empty($params['entry']) ? $params['entry'] : \mod_dataform\pluginbase\dataformentry::blank_instance($df);
     // Own entry.
     if (\mod_dataform\pluginbase\dataformentry::is_own($entry)) {
         $params['capabilities'] = array('mod/dataform:entryowndelete');
         return parent::validate($params);
     }
     // Group entry.
     if (\mod_dataform\pluginbase\dataformentry::is_grouped($entry)) {
         if (groups_is_member($entry->groupid)) {
             $params['capabilities'] = array('mod/dataform:entrygroupdelete');
             return parent::validate($params);
         }
     }
     // Anonymous entry.
     if (\mod_dataform\pluginbase\dataformentry::is_anonymous($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanonymousdelete');
         return parent::validate($params);
     }
     // Any entry.
     if (\mod_dataform\pluginbase\dataformentry::is_others($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanydelete');
         return parent::validate($params);
     }
     return false;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:50,代码来源:entry_delete.php

示例9: get_enrolled_users

 /**
  * Get list of course participants.
  *
  * @param int $courseid
  * @param text $withcapability
  * @param int $groupid
  * @param bool $onlyactive
  * @return array of course participants
  */
 public static function get_enrolled_users($courseid, $withcapability, $groupid, $onlyactive)
 {
     global $DB;
     // Do basic automatic PARAM checks on incoming data, using params description
     // If any problems are found then exceptions are thrown with helpful error messages
     $params = self::validate_parameters(self::get_enrolled_users_parameters(), array('courseid' => $courseid, 'withcapability' => $withcapability, 'groupid' => $groupid, 'onlyactive' => $onlyactive));
     $coursecontext = get_context_instance(CONTEXT_COURSE, $params['courseid']);
     if ($courseid == SITEID) {
         $context = get_context_instance(CONTEXT_SYSTEM);
     } else {
         $context = $coursecontext;
     }
     try {
         self::validate_context($context);
     } catch (Exception $e) {
         $exceptionparam = new stdClass();
         $exceptionparam->message = $e->getMessage();
         $exceptionparam->courseid = $params['courseid'];
         throw new moodle_exception(get_string('errorcoursecontextnotvalid', 'webservice', $exceptionparam));
     }
     if ($courseid == SITEID) {
         require_capability('moodle/site:viewparticipants', $context);
     } else {
         require_capability('moodle/course:viewparticipants', $context);
     }
     if ($withcapability) {
         require_capability('moodle/role:review', $coursecontext);
     }
     if ($groupid) {
         if (groups_is_member($groupid)) {
             require_capability('moodle/site:accessallgroups', $coursecontext);
         }
     }
     if ($onlyactive) {
         require_capability('moodle/course:enrolreview', $coursecontext);
     }
     list($sql, $params) = get_enrolled_sql($coursecontext, $withcapability, $groupid, $onlyactive);
     $sql = "SELECT DISTINCT ue.userid, e.courseid\n                  FROM {user_enrolments} ue\n                  JOIN {enrol} e ON (e.id = ue.enrolid)\n                 WHERE e.courseid = :courseid AND ue.userid IN ({$sql})";
     $params['courseid'] = $courseid;
     $enrolledusers = $DB->get_records_sql($sql, $params);
     $result = array();
     foreach ($enrolledusers as $enrolleduser) {
         $result[] = array('courseid' => $enrolleduser->courseid, 'userid' => $enrolleduser->userid);
     }
     return $result;
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:55,代码来源:externallib.php

示例10: groups_remove_member

/**
 * Deletes the link between the specified user and group.
 * @param int $groupid The group to delete the user from
 * @param int $userid The user to delete
 * @return boolean True if deletion was successful, false otherwise
 */
function groups_remove_member($groupid, $userid)
{
    if (!groups_group_exists($groupid)) {
        return false;
    }
    if (!groups_is_member($groupid, $userid)) {
        return true;
    }
    if (!delete_records('groups_members', 'groupid', $groupid, 'userid', $userid)) {
        return false;
    }
    //update group info
    set_field('groups', 'timemodified', time(), 'id', $groupid);
    //trigger groups events
    $eventdata = new object();
    $eventdata->groupid = $groupid;
    $eventdata->userid = $userid;
    events_trigger('groups_member_removed', $eventdata);
    return true;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:26,代码来源:lib.php

示例11: groups_remove_member

/**
 * Deletes the link between the specified user and group.
 * @param int $groupid The group to delete the user from
 * @param int $userid The user to delete
 * @return boolean True if deletion was successful, false otherwise
 */
function groups_remove_member($groupid, $userid)
{
    global $DB;
    if (!$DB->record_exists('user', array('id' => $userid))) {
        throw new moodle_exception('useriddoesntexist');
    }
    if (!groups_group_exists($groupid)) {
        throw new moodle_exception('cannotaddmembergroupiddoesntexist');
    }
    if (!groups_is_member($groupid, $userid)) {
        return true;
    }
    $DB->delete_records('groups_members', array('groupid' => $groupid, 'userid' => $userid));
    //update group info
    $DB->set_field('groups', 'timemodified', time(), array('id' => $groupid));
    //trigger groups events
    $eventdata = new object();
    $eventdata->groupid = $groupid;
    $eventdata->userid = $userid;
    events_trigger('groups_member_removed', $eventdata);
    return true;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:28,代码来源:lib.php

示例12: member_added

 /**
  * Event processor - cohort member added.
  * @param \core\event\cohort_member_added $event
  * @return bool
  */
 public static function member_added(\core\event\cohort_member_added $event)
 {
     global $DB, $CFG;
     require_once "{$CFG->dirroot}/group/lib.php";
     if (!enrol_is_enabled('cohort')) {
         return true;
     }
     // Does any enabled cohort instance want to sync with this cohort?
     $sql = "SELECT e.*, r.id as roleexists\n                  FROM {enrol} e\n             LEFT JOIN {role} r ON (r.id = e.roleid)\n                 WHERE e.customint1 = :cohortid AND e.enrol = 'cohort' AND e.status = :enrolstatus\n              ORDER BY e.id ASC";
     $params['cohortid'] = $event->objectid;
     $params['enrolstatus'] = ENROL_INSTANCE_ENABLED;
     if (!($instances = $DB->get_records_sql($sql, $params))) {
         return true;
     }
     $plugin = enrol_get_plugin('cohort');
     foreach ($instances as $instance) {
         if ($instance->status != ENROL_INSTANCE_ENABLED) {
             // No roles for disabled instances.
             $instance->roleid = 0;
         } else {
             if ($instance->roleid and !$instance->roleexists) {
                 // Invalid role - let's just enrol, they will have to create new sync and delete this one.
                 $instance->roleid = 0;
             }
         }
         unset($instance->roleexists);
         // No problem if already enrolled.
         $plugin->enrol_user($instance, $event->relateduserid, $instance->roleid, 0, 0, ENROL_USER_ACTIVE);
         // Sync groups.
         if ($instance->customint2) {
             if (!groups_is_member($instance->customint2, $event->relateduserid)) {
                 if ($group = $DB->get_record('groups', array('id' => $instance->customint2, 'courseid' => $instance->courseid))) {
                     groups_add_member($group->id, $event->relateduserid, 'enrol_cohort', $instance->id);
                 }
             }
         }
     }
     return true;
 }
开发者ID:stronk7,项目名称:moodle,代码行数:44,代码来源:locallib.php

示例13: get_graders

    /**
     * Returns a list of teachers that should be grading given submission
     *
     * @param object $user
     * @return array
     */
    function get_graders($user) {
        //potential graders
        $potgraders = get_users_by_capability($this->context, 'mod/assignment:grade', '', '', '', '', '', '', false, false);

        $graders = array();
        if (groups_get_activity_groupmode($this->cm) == SEPARATEGROUPS) {   // Separate groups are being used
            if ($groups = groups_get_all_groups($this->course->id, $user->id)) {  // Try to find all groups
                foreach ($groups as $group) {
                    foreach ($potgraders as $t) {
                        if ($t->id == $user->id) {
                            continue; // do not send self
                        }
                        if (groups_is_member($group->id, $t->id)) {
                            $graders[$t->id] = $t;
                        }
                    }
                }
            } else {
                // user not in group, try to find graders without group
                foreach ($potgraders as $t) {
                    if ($t->id == $user->id) {
                        continue; // do not send self
                    }
                    if (!groups_get_all_groups($this->course->id, $t->id)) { //ugly hack
                        $graders[$t->id] = $t;
                    }
                }
            }
        } else {
            foreach ($potgraders as $t) {
                if ($t->id == $user->id) {
                    continue; // do not send self
                }
                $graders[$t->id] = $t;
            }
        }
        return $graders;
    }
开发者ID:nuckey,项目名称:moodle,代码行数:44,代码来源:lib.php

示例14: forum_user_can_view_post

/**
 * checks to see if a user can view a particular post
 *
 * @global object
 * @global object
 * @uses CONTEXT_MODULE
 * @uses SEPARATEGROUPS
 * @param object $post
 * @param object $course
 * @param object $cm
 * @param object $forum
 * @param object $discussion
 * @param object $user
 */
function forum_user_can_view_post($post, $course, $cm, $forum, $discussion, $user=NULL){

    global $CFG, $USER;

    if (!$user){
        $user = $USER;
    }

    $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
    if (!has_capability('mod/forum:viewdiscussion', $modcontext)) {
        return false;
    }

// If it's a grouped discussion, make sure the user is a member
    if ($discussion->groupid > 0) {
        $groupmode = groups_get_activity_groupmode($cm);
        if ($groupmode == SEPARATEGROUPS) {
            return groups_is_member($discussion->groupid) || has_capability('moodle/site:accessallgroups', $modcontext);
        }
    }
    return true;
}
开发者ID:nfreear,项目名称:moodle,代码行数:36,代码来源:lib.php

示例15: forum_print_latest_discussions


//.........这里部分代码省略.........
            $canstart = enrol_selfenrol_available($course->id);
        }
    }
    if ($canstart) {
        echo '<div class="singlebutton forumaddnew">';
        echo "<form id=\"newdiscussionform\" method=\"get\" action=\"{$CFG->wwwroot}/mod/forum/post.php\">";
        echo '<div>';
        echo "<input type=\"hidden\" name=\"forum\" value=\"{$forum->id}\" />";
        switch ($forum->type) {
            case 'news':
            case 'blog':
                $buttonadd = get_string('addanewtopic', 'forum');
                break;
            case 'qanda':
                $buttonadd = get_string('addanewquestion', 'forum');
                break;
            default:
                $buttonadd = get_string('addanewdiscussion', 'forum');
                break;
        }
        echo '<input type="submit" value="' . $buttonadd . '" />';
        echo '</div>';
        echo '</form>';
        echo "</div>\n";
    } else {
        if (isguestuser() or !isloggedin() or $forum->type == 'news' or $forum->type == 'qanda' and !has_capability('mod/forum:addquestion', $context) or $forum->type != 'qanda' and !has_capability('mod/forum:startdiscussion', $context)) {
            // no button and no info
        } else {
            if ($groupmode and !has_capability('moodle/site:accessallgroups', $context)) {
                // inform users why they can not post new discussion
                if (!$currentgroup) {
                    echo $OUTPUT->notification(get_string('cannotadddiscussionall', 'forum'));
                } else {
                    if (!groups_is_member($currentgroup)) {
                        echo $OUTPUT->notification(get_string('cannotadddiscussion', 'forum'));
                    }
                }
            }
        }
    }
    // Get all the recent discussions we're allowed to see
    $getuserlastmodified = $displayformat == 'header';
    if (!($discussions = forum_get_discussions($cm, $sort, $fullpost, null, $maxdiscussions, $getuserlastmodified, $page, $perpage))) {
        echo '<div class="forumnodiscuss">';
        if ($forum->type == 'news') {
            echo '(' . get_string('nonews', 'forum') . ')';
        } else {
            if ($forum->type == 'qanda') {
                echo '(' . get_string('noquestions', 'forum') . ')';
            } else {
                echo '(' . get_string('nodiscussions', 'forum') . ')';
            }
        }
        echo "</div>\n";
        return;
    }
    // If we want paging
    if ($page != -1) {
        ///Get the number of discussions found
        $numdiscussions = forum_get_discussions_count($cm);
        ///Show the paging bar
        echo $OUTPUT->paging_bar($numdiscussions, $page, $perpage, "view.php?f={$forum->id}");
        if ($numdiscussions > 1000) {
            // saves some memory on sites with very large forums
            $replies = forum_count_discussion_replies($forum->id, $sort, $maxdiscussions, $page, $perpage);
        } else {
开发者ID:abhilash1994,项目名称:moodle,代码行数:67,代码来源:lib.php


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