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


PHP ismember函数代码示例

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


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

示例1: chat_check_text_access

/**
* this function handles the access policy to contents indexed as searchable documents. If this 
* function does not exist, the search engine assumes access is allowed.
* When this point is reached, we already know that : 
* - user is legitimate in the surrounding context
* - user may be guest and guest access is allowed to the module
* - the function may perform local checks within the module information logic
* @param path the access path to the module script code
* @param itemtype the information subclassing (usefull for complex modules, defaults to 'standard')
* @param this_id the item id within the information class denoted by entry_type. In chats, this id 
* points out a session history which is a close sequence of messages.
* @param user the user record denoting the user who searches
* @param group_id the current group used by the user when searching
* @uses CFG
* @return true if access is allowed, false elsewhere
*/
function chat_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id)
{
    global $CFG;
    include_once "{$CFG->dirroot}/{$path}/lib.php";
    list($chat_id, $sessionstart, $sessionend) = split('-', $this_id);
    // get the chat session and all related stuff
    $chat = get_record('chat', 'id', $chat_id);
    $context = get_record('context', 'id', $context_id);
    $cm = get_record('course_modules', 'id', $context->instanceid);
    // $cm = get_coursemodule_from_instance('chat', $chat->id, $chat->course);
    // $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : hidden chat ";
        }
        return false;
    }
    //group consistency check : checks the following situations about groups
    // trap if user is not same group and groups are separated
    $course = get_record('course', 'id', $chat->course);
    if (groupmode($course, $cm) == SEPARATEGROUPS && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : chat element is in separated group ";
        }
        return false;
    }
    //ownership check : checks the following situations about user
    // trap if user is not owner and has cannot see other's entries
    // TODO : typically may be stored into indexing cache
    if (!has_capability('mod/chat:readlog', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : cannot read past sessions ";
        }
        return false;
    }
    return true;
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:53,代码来源:chat_document.php

示例2: data_check_text_access

/**
* this function handles the access policy to contents indexed as searchable documents. If this 
* function does not exist, the search engine assumes access is allowed.
* When this point is reached, we already know that : 
* - user is legitimate in the surrounding context
* - user may be guest and guest access is allowed to the module
* - the function may perform local checks within the module information logic
* @param string $path the access path to the module script code
* @param string $itemtype the information subclassing (usefull for complex modules, defaults to 'standard')
* @param int $this_id the item id within the information class denoted by itemtype. In databases, this id 
* points out an indexed data record page.
* @param object $user the user record denoting the user who searches
* @param int $group_id the current group used by the user when searching
* @uses $CFG, $DB
* @return true if access is allowed, false elsewhere
*/
function data_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id)
{
    global $CFG, $DB;
    // get the database object and all related stuff
    if ($itemtype == 'record') {
        $record = $DB->get_record('data_records', array('id' => $this_id));
    } elseif ($itemtype == 'comment') {
        $comment = $DB->get_record('data_comments', array('id' => $this_id));
        $record = $DB->get_record('data_records', array('id' => $comment->recordid));
    } else {
        // we do not know what type of information is required
        return false;
    }
    $data = $DB->get_record('data', array('id' => $record->dataid));
    $context = $DB->get_record('context', array('id' => $context_id));
    $cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
    if (empty($cm)) {
        return false;
    }
    // Shirai 20090530 - MDL19342 - course module might have been delete
    if (!$cm->visible && !has_capability('moodle/course:viewhiddenactivities', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : hidden database ";
        }
        return false;
    }
    //group consistency check : checks the following situations about groups
    // trap if user is not same group and groups are separated
    $course = $DB->get_record('course', 'id', $data->course);
    if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
        $groupmode = $cm->groupmode;
    } else {
        $groupmode = $course->groupmode;
    }
    if ($groupmode == SEPARATEGROUPS && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : separated group owned resource ";
        }
        return false;
    }
    //ownership check : checks the following situations about user
    // trap if user is not owner and has cannot see other's entries
    if ($itemtype == 'record') {
        if ($user->id != $record->userid && !has_capability('mod/data:viewentry', $context) && !has_capability('mod/data:manageentries', $context)) {
            if (!empty($CFG->search_access_debug)) {
                echo "search reject : not owned resource ";
            }
            return false;
        }
    }
    //approval check
    // trap if unapproved and has not approval capabilities
    // TODO : report a potential capability lack of : mod/data:approve
    $approval = $DB->get_field('data_records', 'approved', array('id' => $record->id));
    if (!$approval && !has_capability('mod/data:manageentries', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : unapproved resource ";
        }
        return false;
    }
    //minimum records to view check
    // trap if too few records
    // TODO : report a potential capability lack of : mod/data:viewhiddenentries
    $recordsAmount = $DB->count_records('data_records', array('dataid' => $data->id));
    if ($data->requiredentriestoview > $recordsAmount && !has_capability('mod/data:manageentries', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : not enough records to view ";
        }
        return false;
    }
    //opening periods check
    // trap if user has not capability to see hidden records and date is out of opening range
    // TODO : report a potential capability lack of : mod/data:viewhiddenentries
    $now = usertime(time());
    if ($data->timeviewfrom > 0) {
        if ($now < $data->timeviewfrom && !has_capability('mod/data:manageentries', $context)) {
            if (!empty($CFG->search_access_debug)) {
                echo "search reject : still not open activity ";
            }
            return false;
        }
    }
    if ($data->timeviewto > 0) {
        if ($now > $data->timeviewto && !has_capability('mod/data:manageentries', $context)) {
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:data_document.php

示例3: choice_show_results

function choice_show_results($choice, $course, $cm, $forcepublish = '')
{
    global $CFG, $COLUMN_HEIGHT, $USER;
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    print_heading(get_string("responses", "choice"));
    if (empty($forcepublish)) {
        //alow the publish setting to be overridden
        $forcepublish = $choice->publish;
    }
    $groupmode = groupmode($course, $cm);
    if ($groupmode > 0) {
        $currentgroup = get_current_group($course->id);
    } else {
        $currentgroup = 0;
    }
    $users = get_users_by_capability($context, 'mod/choice:choose', 'u.id, u.picture, u.firstname, u.lastname, u.idnumber', 'u.firstname ASC', '', '', $currentgroup, '', false, true);
    if (!$users) {
        print_heading(get_string("nousersyet"));
    }
    $answers = array();
    if ($allresponses = get_records("choice_answers", "choiceid", $choice->id)) {
        foreach ($allresponses as $aa) {
            //TODO: rewrite with SQL
            if ($groupmode and $currentgroup) {
                if (ismember($currentgroup, $aa->userid)) {
                    $answers[$aa->userid] = $aa;
                }
            } else {
                $answers[$aa->userid] = $aa;
            }
        }
    }
    $timenow = time();
    foreach ($choice->option as $optionid => $text) {
        $useranswer[$optionid] = array();
    }
    if (!empty($users)) {
        foreach ($users as $user) {
            if (!empty($user->id) and !empty($answers[$user->id])) {
                $answer = $answers[$user->id];
                $useranswer[(int) $answer->optionid][] = $user;
            } else {
                $useranswer[0][] = $user;
            }
        }
    }
    foreach ($choice->option as $optionid => $text) {
        if (!$choice->option[$optionid]) {
            unset($useranswer[$optionid]);
            // Throw away any data that doesn't apply
        }
    }
    ksort($useranswer);
    switch ($forcepublish) {
        case CHOICE_PUBLISH_NAMES:
            $tablewidth = (int) (100.0 / count($useranswer));
            if (has_capability('mod/choice:readresponses', $context)) {
                echo '<div id="tablecontainer">';
                echo '<form id="attemptsform" method="post" action="' . $_SERVER['PHP_SELF'] . '" onsubmit="var menu = document.getElementById(\'menuaction\'); return (menu.options[menu.selectedIndex].value == \'delete\' ? \'' . addslashes(get_string('deleteattemptcheck', 'quiz')) . '\' : true);">';
                echo '<div>';
                echo '<input type="hidden" name="id" value="' . $cm->id . '" />';
                echo '<input type="hidden" name="mode" value="overview" />';
            }
            echo "<table cellpadding=\"5\" cellspacing=\"10\" class=\"results names\">";
            echo "<tr>";
            $count = 0;
            $columncount = array();
            // number of votes in each column
            foreach ($useranswer as $optionid => $userlist) {
                $columncount[$optionid] = 0;
                // init counters
                if ($optionid) {
                    echo "<th class=\"col{$count} header\" style=\"width:{$tablewidth}%\" scope=\"col\">";
                } else {
                    if ($choice->showunanswered) {
                        echo "<th class=\"col{$count} header\" style=\"width:{$tablewidth}%\" scope=\"col\">";
                    } else {
                        continue;
                    }
                }
                echo format_string(choice_get_option_text($choice, $optionid));
                echo "</th>";
                $count++;
            }
            echo "</tr><tr>";
            $count = 0;
            foreach ($useranswer as $optionid => $userlist) {
                if ($optionid) {
                    echo "<td class=\"col{$count} data\" style=\"width:{$tablewidth}%;\">";
                } else {
                    if ($choice->showunanswered) {
                        echo "<td class=\"col{$count} data\" style=\"width:{$tablewidth}%;\">";
                    } else {
                        continue;
                    }
                }
                // added empty row so that when the next iteration is empty,
                // we do not get <table></table> erro from w3c validator
                // MDL-7861
                echo "<table class=\"choiceresponse\"><tr><td></td></tr>";
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:lib.php

示例4: error

     // fix for MDL-9268
     if (!($group = groups_get_group($filterselect))) {
         //TODO:check.
         error('Incorrect group id specified');
     }
     if (!($course = get_record('course', 'id', $group->courseid))) {
         error('Incorrect course id specified');
     }
     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
     $courseid = $course->id;
     require_login($course);
     if (!has_capability('moodle/blog:view', $coursecontext)) {
         error('You do not have the required permissions to view blogs in this course/group');
     }
     if (groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
         if (!ismember($filterselect)) {
             error('You are not a member of this course group');
         }
     }
     break;
 case 'user':
     if ($CFG->bloglevel < BLOG_USER_LEVEL) {
         error('Blogs is not enabled');
     }
     if (!($user = get_record('user', 'id', $filterselect))) {
         error('Incorrect user id');
     }
     if ($user->deleted) {
         print_header();
         print_heading(get_string('userdeleted'));
         print_footer();
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:index.php

示例5: get_group_teachers

/**
 * Returns list of all the teachers who can access a group
 *
 * @uses $CFG
 * @param int $courseid The course in question.
 * @param int $groupid The group in question.
 * @return object
 */
function get_group_teachers($courseid, $groupid)
{
    /// Returns a list of all the teachers who can access a group
    if ($teachers = get_course_teachers($courseid)) {
        foreach ($teachers as $key => $teacher) {
            if ($teacher->editall) {
                // These can access anything
                continue;
            }
            if ($teacher->authority > 0 and ismember($groupid, $teacher->id)) {
                // Specific group teachers
                continue;
            }
            unset($teachers[$key]);
        }
    }
    return $teachers;
}
开发者ID:veritech,项目名称:pare-project,代码行数:26,代码来源:deprecatedlib.php

示例6: error

// Group ID
if (!($cm = get_coursemodule_from_id('survey', $id))) {
    error("Course Module ID was incorrect");
}
if (!($course = get_record("course", "id", $cm->course))) {
    error("Course is misconfigured");
}
require_login($course->id, false, $cm);
$groupmode = groupmode($course, $cm);
// Groups are being used
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!has_capability('mod/survey:readresponses', $context)) {
    if ($type != "student.png" or $sid != $USER->id) {
        error("Sorry, you aren't allowed to see this.");
    } else {
        if ($groupmode and !ismember($group)) {
            error("Sorry, you aren't allowed to see this.");
        }
    }
}
if (!($survey = get_record("survey", "id", $cm->instance))) {
    error("Survey ID was incorrect");
}
/// Check to see if groups are being used in this survey
if ($groupmode and $group) {
    $users = get_group_users($group);
} else {
    $users = get_course_users($course->id);
    $group = false;
}
$stractual = get_string("actual", "survey");
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:graph.php

示例7: wiki_user_can_access_student_wiki

function wiki_user_can_access_student_wiki(&$wiki, $userid, &$course)
{
    global $USER;
    /// Get the groupmode. It's been added to the wiki object.
    $groupmode = groupmode($course, $wiki);
    $usersgroup = mygroupid($course->id);
    $isteacher = wiki_is_teacher($wiki, $USER->id);
    /// If this user is allowed to access this wiki then return TRUE.
    /// *** THIS COULD BE A PROBLEM, IF STUDENTS COULD EVER BE PART OF MORE THAN ONE GROUP ***
    /// A user can access a student wiki, if:
    ///     - it is their wiki,
    ///     - group mode is VISIBLEGROUPS,
    ///     - group mode is SEPARATEGROUPS, and the user is a member of the requested user's group,
    ///     - they are an editing teacher or administrator,
    ///     - they are a non-editing teacher not assigned to a specific group,
    ///     - they are a non-editing teacher and group mode is NOGROUPS.
    ///     - they are an administrator (mostly for site-level wikis).
    if ($userid and $USER->id == $userid or $groupmode == VISIBLEGROUPS or $groupmode == SEPARATEGROUPS and ismember($usersgroup, $userid) or wiki_is_teacheredit($wiki, $USER->id) or wiki_is_teacher($wiki, $USER->id) and (!$usersgroup or $groupmode == NOGROUPS)) {
        $can_access = true;
    } else {
        $can_access = false;
    }
    return $can_access;
}
开发者ID:veritech,项目名称:pare-project,代码行数:24,代码来源:lib.php

示例8: mygroupid

        $mygroupid = mygroupid($course->id);
        //only useful if 0, otherwise it's an array now
        if ($groupmode == SEPARATEGROUPS) {
            require_login();
            if ((empty($mygroupid) and $discussion->groupid == -1) || (ismember($discussion->groupid) || $mygroupid == $discussion->groupid)) {
                // $canreply = true;
            } elseif ($discussion->groupid == -1) {
                $canreply = false;
            } else {
                print_heading("Sorry, you can't see this discussion because you are not in this group");
                print_footer($course);
                die;
            }
        } else {
            if ($groupmode == VISIBLEGROUPS) {
                $canreply = empty($mygroupid) && $discussion->groupid == -1 || (ismember($discussion->groupid) || $mygroupid == $discussion->groupid);
            }
        }
    }
} else {
    // allow guests to see the link
    $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
    if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) {
        // User is a guest here!
        $canreply = true;
    }
}
/// Print the controls across the top
echo '<table width="100%" class="discussioncontrols"><tr><td>';
// groups selector not needed here
echo "</td><td>";
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:discuss.php

示例9: blog_user_can_view_user_post

/**
 * Checks to see if a user can view the blogs of another user.
 * Only blog level is checked here, the capabilities are enforced
 * in blog/index.php
 */
function blog_user_can_view_user_post($targetuserid, $blogEntry = null)
{
    global $CFG, $USER;
    if (empty($CFG->bloglevel)) {
        return false;
        // blog system disabled
    }
    if (!empty($USER->id) and $USER->id == $targetuserid) {
        return true;
        // can view own posts in any case
    }
    $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
    if (has_capability('moodle/blog:manageentries', $sitecontext)) {
        return true;
        // can manage all posts
    }
    // coming for 1 post, make sure it's not a draft
    if ($blogEntry and $blogEntry->publishstate == 'draft') {
        return false;
        // can not view draft of others
    }
    // coming for 1 post, make sure user is logged in, if not a public blog
    if ($blogEntry && $blogEntry->publishstate != 'public' && !isloggedin()) {
        return false;
    }
    switch ($CFG->bloglevel) {
        case BLOG_GLOBAL_LEVEL:
            return true;
            break;
        case BLOG_SITE_LEVEL:
            if (!empty($USER->id)) {
                // not logged in viewers forbidden
                return true;
            }
            return false;
            break;
        case BLOG_COURSE_LEVEL:
            $mycourses = array_keys(get_my_courses($USER->id));
            $usercourses = array_keys(get_my_courses($targetuserid));
            $shared = array_intersect($mycourses, $usercourses);
            if (!empty($shared)) {
                return true;
            }
            return false;
            break;
        case BLOG_GROUP_LEVEL:
            $mycourses = array_keys(get_my_courses($USER->id));
            $usercourses = array_keys(get_my_courses($targetuserid));
            $shared = array_intersect($mycourses, $usercourses);
            foreach ($shared as $courseid) {
                $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
                if (has_capability('moodle/site:accessallgroups', $coursecontext) or groupmode($courseid) != SEPARATEGROUPS) {
                    return true;
                } else {
                    if ($usergroups = user_group($courseid, $targetuserid)) {
                        foreach ($usergroups as $usergroup) {
                            if (ismember($usergroup->id)) {
                                return true;
                            }
                        }
                    }
                }
            }
            return false;
            break;
        case BLOG_USER_LEVEL:
        default:
            $personalcontext = get_context_instance(CONTEXT_USER, $targetuserid);
            return has_capability('moodle/user:readuserblogs', $personalcontext);
            break;
    }
}
开发者ID:veritech,项目名称:pare-project,代码行数:77,代码来源:lib.php

示例10: foreach

    $dcount = 0;
    foreach ($discussions as $discussion) {
        $dcount++;
        print_progress($dcount, $dtotal);
        if ($discussion->course != $currcourse) {
            /// Discussions are ordered by course, so we only need to get any course's users once.
            $currcourse = $discussion->course;
            $users = get_course_users($currcourse, '', '', 'u.id,u.confirmed');
        }
        /// If this course has users, and posts more than a day old, mark them for each user.
        if ($users && ($posts = get_records_select('forum_posts', 'discussion = ' . $discussion->id . ' AND ' . $dateafter . ' < modified AND modified < ' . $onedayago, '', 'id,discussion,modified'))) {
            foreach ($users as $user) {
                /// If its a group discussion, make sure the user is in the group.
                if ($discussion->groupid) {
                    if (!isset($groups[$discussion->groupid][$user->id])) {
                        $groups[$discussion->groupid][$user->id] = ismember($discussion->groupid, $user->id);
                    }
                }
                if (!$discussion->groupid || !empty($groups[$discussion->groupid][$user->id])) {
                    foreach ($posts as $post) {
                        print_progress($dcount, $dtotal);
                        forum_tp_mark_post_read($user->id, $post, $discussion->forum);
                    }
                }
            }
        }
    }
    print_progress($dcount, $dtotal, 0);
}
delete_records('config', 'name', 'upgrade', 'value', 'forumread');
notify('Log upgrading was successful!', 'notifysuccess');
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:upgradeforumread.php

示例11: workshop_get_recent_mod_activity

function workshop_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, $workshop = "0", $user = "", $groupid = "")
{
    // Returns all workshop posts since a given time.  If workshop is specified then
    // this restricts the results
    global $CFG;
    if ($workshop) {
        $workshopselect = " AND cm.id = '{$workshop}'";
    } else {
        $workshopselect = "";
    }
    if ($user) {
        $userselect = " AND u.id = '{$user}'";
    } else {
        $userselect = "";
    }
    $posts = get_records_sql("SELECT s.*, u.firstname, u.lastname,\n            u.picture, cm.instance, w.name, cm.section\n            FROM {$CFG->prefix}workshop_submissions s,\n            {$CFG->prefix}user u,\n            {$CFG->prefix}course_modules cm,\n            {$CFG->prefix}workshop w\n            WHERE s.timecreated  > '{$sincetime}' {$workshopselect}\n            AND s.userid = u.id {$userselect}\n            AND w.course = '{$courseid}' \n            AND cm.instance = w.id\n            AND cm.course = w.course\n            AND s.workshopid = w.id\n            ORDER BY s.id");
    if (empty($posts)) {
        return;
    }
    foreach ($posts as $post) {
        if (empty($groupid) || ismember($groupid, $post->userid)) {
            $tmpactivity = new Object();
            $tmpactivity->type = "workshop";
            $tmpactivity->defaultindex = $index;
            $tmpactivity->instance = $post->instance;
            $tmpactivity->name = $post->name;
            $tmpactivity->section = $post->section;
            $tmpactivity->content->id = $post->id;
            $tmpactivity->content->title = $post->title;
            $tmpactivity->user->userid = $post->userid;
            $tmpactivity->user->fullname = fullname($post);
            $tmpactivity->user->picture = $post->picture;
            $tmpactivity->timestamp = $post->timecreated;
            $activities[] = $tmpactivity;
            $index++;
        }
    }
    return;
}
开发者ID:veritech,项目名称:pare-project,代码行数:39,代码来源:lib.php

示例12: get_and_set_current_group

/**
 * A combination function to make it easier for modules
 * to set up groups.
 *
 * It will use a given "groupid" parameter and try to use
 * that to reset the current group for the user.
 *
 * @uses VISIBLEGROUPS
 * @param course $course A {@link $COURSE} object
 * @param int $groupmode Either NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS
 * @param int $groupid Will try to use this optional parameter to
 *            reset the current group for the user
 * @return int|false Returns the current group id or false if error.
 */
function get_and_set_current_group($course, $groupmode, $groupid = -1)
{
    //TODO: ?? groups_has_permission($userid, $groupingid, $courseid, $groupid, $permissiontype);
    // Sets to the specified group, provided the current user has view permission
    if (!$groupmode) {
        // Groups don't even apply
        return false;
    }
    $currentgroupid = get_current_group($course->id);
    if ($groupid < 0) {
        // No change was specified
        return $currentgroupid;
    }
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    if ($groupid) {
        // Try to change the current group to this groupid
        if (groups_group_belongs_to_course($groupid, $course->id)) {
            // Exists  TODO:check.
            if (has_capability('moodle/site:accessallgroups', $context)) {
                // Sets current default group
                $currentgroupid = set_current_group($course->id, $groupid);
            } elseif ($groupmode == VISIBLEGROUPS) {
                // All groups are visible
                //if (ismember($group->id)){
                $currentgroupid = set_current_group($course->id, $groupid);
                //set this since he might post
                /*)}else {
                  $currentgroupid = $group->id;*/
            } elseif ($groupmode == SEPARATEGROUPS) {
                // student in separate groups switching
                if (ismember($groupid)) {
                    //check if is a member
                    $currentgroupid = set_current_group($course->id, $groupid);
                    //might need to set_current_group?
                } else {
                    notify('You do not belong to this group! (' . $groupid . ')', 'error');
                }
            }
        }
    } else {
        // When groupid = 0 it means show ALL groups
        // this is changed, non editting teacher needs access to group 0 as well,
        // for viewing work in visible groups (need to set current group for multiple pages)
        if (has_capability('moodle/site:accessallgroups', $context)) {
            // Sets current default group
            $currentgroupid = set_current_group($course->id, 0);
        } else {
            if ($groupmode == VISIBLEGROUPS) {
                // All groups are visible
                $currentgroupid = set_current_group($course->id, 0);
            }
        }
    }
    return $currentgroupid;
}
开发者ID:veritech,项目名称:pare-project,代码行数:69,代码来源:legacylib.php

示例13: referentiel_user_can_add_certificat

function referentiel_user_can_add_certificat($referentiel, $currentgroup, $groupmode)
{
    global $USER;
    global $CFG;
    if (!($cm = get_coursemodule_from_instance('referentiel', $referentiel->id, $referentiel->course))) {
        print_error('Course Module ID was incorrect');
    }
    $context = context_module::instance($cm->id);
    if (!has_capability('mod/referentiel:writecertificat', $context)) {
        return false;
    }
    if (!$groupmode or has_capability('moodle/site:accessallgroups', $context)) {
        return true;
    }
    if ($currentgroup) {
        return ismember($currentgroup);
    } else {
        //else it might be group 0 in visible mode
        if ($groupmode == VISIBLEGROUPS) {
            return true;
        } else {
            return false;
        }
    }
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:25,代码来源:lib.php

示例14: ismember

<?php

include $_SERVER["DOCUMENT_ROOT"] . "/44/func/mysql.php";
ismember();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標題文件</title>
<style>
a:hover {
	color:red;
}
a {
	color:blue;
}
table {
	border-collapse: collapse;
}
th, td {
	width: 140px;
}
</style>
</head>

<body>
<button onclick="location='/44/login/logout.php'">登出</button>
<?php 
echo getsession("account") . " #" . getsession("id") . " ~" . getsession("name");
?>
开发者ID:awei0905,项目名称:Elimination-Series,代码行数:31,代码来源:index.php

示例15: chat_check_text_access

/**
* this function handles the access policy to contents indexed as searchable documents. If this
* function does not exist, the search engine assumes access is allowed.
* When this point is reached, we already know that :
* - user is legitimate in the surrounding context
* - user may be guest and guest access is allowed to the module
* - the function may perform local checks within the module information logic
* @param string $path the access path to the module script code
* @param string $itemtype the information subclassing (usefull for complex modules, defaults to 'standard')
* @param int $this_id the item id within the information class denoted by entry_type. In chats, this id
* points out a session history which is a close sequence of messages.
* @param int $user the user record denoting the user who searches
* @param int $group_id the current group used by the user when searching
* @uses $CFG, $DB
* @return true if access is allowed, false elsewhere
*/
function chat_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id)
{
    global $CFG, $DB;
    include_once "{$CFG->dirroot}/{$path}/lib.php";
    list($chat_id, $sessionstart, $sessionend) = explode('-', $this_id);
    // get the chat session and all related stuff
    $chat = $DB->get_record('chat', array('id' => $chat_id));
    $context = $DB->get_record('context', array('id' => $context_id));
    $cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
    if (empty($cm)) {
        return false;
    }
    // Shirai 20090530 - MDL19342 - course module might have been delete
    if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : hidden chat ";
        }
        return false;
    }
    //group consistency check : checks the following situations about groups
    // trap if user is not same group and groups are separated
    $course = $DB->get_record('course', array('id' => $chat->course));
    if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
        $groupmode = $cm->groupmode;
    } else {
        $groupmode = $course->groupmode;
    }
    if ($groupmode == SEPARATEGROUPS && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : chat element is in separated group ";
        }
        return false;
    }
    //ownership check : checks the following situations about user
    // trap if user is not owner and has cannot see other's entries
    // TODO : typically may be stored into indexing cache
    if (!has_capability('mod/chat:readlog', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : cannot read past sessions ";
        }
        return false;
    }
    return true;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:60,代码来源:chat_document.php


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