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


PHP groups_get_members函数代码示例

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


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

示例1: _getGroupMembers

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

示例2: groups_create_automatic_grouping

/**
 * Distributes students into groups randomly and creates a grouping with those 
 * groups.
 * 
 * You need to call groups_seed_random_number_generator() at some point in your 
 * script before calling this function. 
 * 
 * Note that this function does not distribute teachers into groups - this still 
 * needs to be done manually. 
 * 
 * @param int $courseid The id of the course that the grouping should belong to
 * @param int $nostudentspergroup The number of students to put in each group - 
 * this can be set to false if you prefer to specify the number of groups 
 * instead
 * @param int $nogroups The number of groups - this can be set to false if you 
 * prefer to specify the number of student in each group. If both are specified 
 * then $nostudentspergroup takes precedence. If neither is
 * specified then the function does nothing and returns false. 
 * @param boolean $distribevenly If $noofstudentspergroup is specified, then 
 * if this is set to true, any leftover students are distributed evenly among 
 * the groups, whereas if it is set to false then they are put in a separate 
 * group. 
 * @param object $groupsettings The default settings to give each group. 
 * This should contain prefix and defaultgroupdescription fields. The groups 
 * are named with the prefix followed by 1, 2, etc. and given the
 * default group description set. 
 * @param int $groupid If this is not set to false, then only students in the 
 * specified group are distributed into groups, not all the students enrolled on 
 * the course. 
 * @param boolean $alphabetical If this is set to true, then the students are 
 * not distributed randomly but in alphabetical order of last name. 
 * @return int The id of the grouping
 */
function groups_create_automatic_grouping($courseid, $nostudentspergroup, $nogroups, $distribevenly, $groupingsettings, $groupid = false, $alphabetical = false)
{
    if (!$nostudentspergroup and !$noteacherspergroup and !$nogroups) {
        $groupingid = false;
    } else {
        // Set $userids to the list of students that we want to put into groups
        // in the grouping
        if (!$groupid) {
            $users = get_course_students($courseid);
            $userids = groups_users_to_userids($users);
        } else {
            $userids = groups_get_members($groupid);
        }
        // Distribute the users into sets according to the parameters specified
        $userarrays = groups_distribute_in_random_sets($userids, $nostudentspergroup, $nogroups, $distribevenly, !$alphabetical);
        if (!$userarrays) {
            $groupingid = false;
        } else {
            // Create the grouping that the groups we create will go into
            $groupingid = groups_create_grouping($courseid, $groupingsettings);
            // Get the prefix for the names of each group and default group
            // description to give each group
            if (!$groupingsettings->prefix) {
                $prefix = get_string('defaultgroupprefix', 'groups');
            } else {
                $prefix = $groupingsettings->prefix;
            }
            if (!$groupingsettings->defaultgroupdescription) {
                $defaultgroupdescription = '';
            } else {
                $defaultgroupdescription = $groupingsettings->defaultgroupdescription;
            }
            // Now create a group for each set of students, add the group to the
            // grouping and then add the students
            $i = 1;
            foreach ($userarrays as $userids) {
                $groupsettings->name = $prefix . ' ' . $i;
                $groupsettings->description = $defaultgroupdescription;
                $i++;
                $groupid = groups_create_group($courseid, $groupsettings);
                $groupadded = groups_add_group_to_grouping($groupid, $groupingid);
                if (!$groupid or !$groupadded) {
                    $groupingid = false;
                } else {
                    if ($userids) {
                        foreach ($userids as $userid) {
                            $usersadded = groups_add_member($groupid, $userid);
                            // If unsuccessful just carry on I guess
                        }
                    }
                }
            }
        }
    }
    return $groupingid;
}
开发者ID:veritech,项目名称:pare-project,代码行数:89,代码来源:automaticgroupinglib.php

示例3: test_add_member

 function test_add_member()
 {
     // NOTE, interface change on add_member, remove_member.
     $this->assertTrue(groups_add_member($this->groupid, $this->userid));
     $this->assertTrue(groups_is_member($this->groupid, $this->userid));
     $this->assertTrue($userids = groups_get_members($this->groupid));
     //...
     $this->assertTrue($groupids = groups_get_groups_for_user($this->userid, $this->courseid));
     //...
     $this->assertTrue(1 == groups_count_group_members($this->groupid));
     //Utillib.
 }
开发者ID:veritech,项目名称:pare-project,代码行数:12,代码来源:test_basicgrouplib.php

示例4: dialogue_count_open

/**
 * Count the number of open conversations in a given dialogue for a given user
 *  
 * @param   object  $dialogue
 * @param   object  $user
 * @param   bool    $viewall if true count all closed records, not just those where user is initator or receipient
 * @param   int     $groupid    filter conversations by recipients in the group specified
 * @return  int     count of the records found
 */
function dialogue_count_open($dialogue, $user, $viewall = false, $groupid = 0)
{
    if ($viewall) {
        $userwhere = '';
    } else {
        $userwhere = ' (userid=' . $user->id . ' OR recipientid=' . $user->id . ') AND ';
    }
    if ($groupid) {
        $members = groups_get_members($groupid, 'u.id');
        if ($members) {
            $list = '( ' . implode(', ', array_keys($members)) . ' )';
        } else {
            $list = '( 0 ) ';
        }
        $where = " ( userid IN {$list} OR recipientid IN {$list} ) AND {$userwhere} closed = 0";
    } else {
        $where = " {$userwhere} closed = 0";
    }
    return count_records_select('dialogue_conversations', "dialogueid = {$dialogue->id} AND {$where} ");
}
开发者ID:netspotau,项目名称:moodle-mod_dialogue,代码行数:29,代码来源:locallib.php

示例5: dirname

require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once $CFG->libdir . '/formslib.php';
require_once $CFG->dirroot . '/local/forms.php';
$strheading = get_string('messagegroup', 'block_tao_team_groups');
$courseid = required_param('id', PARAM_INT);
$groupid = required_param('groupid', PARAM_INT);
if (!($COURSE = get_record('course', 'id', $courseid))) {
    error('Invalid course idnumber');
}
if (!empty($groupid) && !($group = get_record('groups', 'id', $groupid, 'courseid', $courseid))) {
    error('Invalid group id');
}
require_login();
print_header_simple($strheading, $strheading, build_navigation($strheading));
if (groups_is_member($groupid)) {
    $grpmembers = groups_get_members($groupid);
    if (count($grpmembers) > 1) {
        require_once $CFG->dirroot . '/local/forms.php';
        require_once $CFG->dirroot . '/message/lib.php';
        $messageform = new tao_group_message_send_form('', array('course' => $COURSE, 'group' => $group, 'count' => count($grpmembers) - 1));
        if ($data = $messageform->get_data()) {
            foreach ($grpmembers as $touser) {
                if ($touser->id != $USER->id) {
                    //don't send a message to yourself.
                    message_post_message($USER, $touser, $data->body, $data->format, 'direct');
                }
            }
            notify(get_string('groupmessagesent', 'block_tao_team_groups'), 'notifysuccess');
            print_continue($CFG->wwwroot . '/course/view.php?id=' . $COURSE->id);
        } else {
            if (!$messageform->is_cancelled()) {
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:messagegroup.php

示例6: build_logs_array

function build_logs_array($course, $user = 0, $date = 0, $order = "l.time ASC", $limitfrom = '', $limitnum = '', $modname = "", $modid = 0, $modaction = "", $groupid = 0)
{
    global $DB, $SESSION, $USER;
    // It is assumed that $date is the GMT time of midnight for that day,
    // and so the next 86400 seconds worth of logs are printed.
    /// Setup for group handling.
    /// If the group mode is separate, and this user does not have editing privileges,
    /// then only the user's group can be viewed.
    if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
        if (isset($SESSION->currentgroup[$course->id])) {
            $groupid = $SESSION->currentgroup[$course->id];
        } else {
            $groupid = groups_get_all_groups($course->id, $USER->id);
            if (is_array($groupid)) {
                $groupid = array_shift(array_keys($groupid));
                $SESSION->currentgroup[$course->id] = $groupid;
            } else {
                $groupid = 0;
            }
        }
    } else {
        if (!$course->groupmode) {
            $groupid = 0;
        }
    }
    $joins = array();
    $params = array();
    if ($course->id != SITEID || $modid != 0) {
        $joins[] = "l.course = :courseid";
        $params['courseid'] = $course->id;
    }
    if ($modname) {
        $joins[] = "l.module = :modname";
        $params['modname'] = $modname;
    }
    if ('site_errors' === $modid) {
        $joins[] = "( l.action='error' OR l.action='infected' )";
    } else {
        if ($modid) {
            $joins[] = "l.cmid = :modid";
            $params['modid'] = $modid;
        }
    }
    if ($modaction) {
        $firstletter = substr($modaction, 0, 1);
        if ($firstletter == '-') {
            $joins[] = $DB->sql_like('l.action', ':modaction', false, true, true);
            $params['modaction'] = '%' . substr($modaction, 1) . '%';
        } else {
            $joins[] = $DB->sql_like('l.action', ':modaction', false);
            $params['modaction'] = '%' . $modaction . '%';
        }
    }
    /// Getting all members of a group.
    if ($groupid and !$user) {
        if ($gusers = groups_get_members($groupid)) {
            $gusers = array_keys($gusers);
            $joins[] = 'l.userid IN (' . implode(',', $gusers) . ')';
        } else {
            $joins[] = 'l.userid = 0';
            // No users in groups, so we want something that will always be false.
        }
    } else {
        if ($user) {
            $joins[] = "l.userid = :userid";
            $params['userid'] = $user;
        }
    }
    if ($date) {
        $enddate = $date + 86400;
        $joins[] = "l.time > :date AND l.time < :enddate";
        $params['date'] = $date;
        $params['enddate'] = $enddate;
    }
    $selector = implode(' AND ', $joins);
    $totalcount = 0;
    // Initialise
    $result = array();
    $result['logs'] = get_logs($selector, $params, $order, $limitfrom, $limitnum, $totalcount);
    $result['totalcount'] = $totalcount;
    return $result;
}
开发者ID:numbas,项目名称:moodle,代码行数:82,代码来源:lib.php

示例7: get_group_members

 /**
  * Return all members for a group
  *
  * @param array $groupids array of group ids
  * @return array with  group id keys containing arrays of user ids
  * @since Moodle 2.2
  */
 public static function get_group_members($groupids)
 {
     $members = array();
     $params = self::validate_parameters(self::get_group_members_parameters(), array('groupids' => $groupids));
     foreach ($params['groupids'] as $groupid) {
         // validate params
         $group = groups_get_group($groupid, 'id, courseid, name, enrolmentkey', MUST_EXIST);
         // now security checks
         $context = context_course::instance($group->courseid, IGNORE_MISSING);
         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);
         $groupmembers = groups_get_members($group->id, 'u.id', 'lastname ASC, firstname ASC');
         $members[] = array('groupid' => $groupid, 'userids' => array_keys($groupmembers));
     }
     return $members;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:30,代码来源:externallib.php

示例8: certificate_get_issues

/**
 * Returns a list of issued certificates - sorted for report.
 *
 * @param int $certificateid
 * @param string $sort the sort order
 * @param bool $groupmode are we in group mode ?
 * @param stdClass $cm the course module
 * @param int $page offset
 * @param int $perpage total per page
 * @return stdClass the users
 */
function certificate_get_issues($certificateid, $sort = "ci.timecreated ASC", $groupmode, $cm, $page = 0, $perpage = 0)
{
    global $DB, $USER;
    $context = context_module::instance($cm->id);
    $conditionssql = '';
    $conditionsparams = array();
    // Get all users that can manage this certificate to exclude them from the report.
    $certmanagers = array_keys(get_users_by_capability($context, 'mod/certificate:manage', 'u.id'));
    $certmanagers = array_merge($certmanagers, array_keys(get_admins()));
    list($sql, $params) = $DB->get_in_or_equal($certmanagers, SQL_PARAMS_NAMED, 'cert');
    $conditionssql .= "AND NOT u.id {$sql} \n";
    $conditionsparams += $params;
    if ($groupmode) {
        $canaccessallgroups = has_capability('moodle/site:accessallgroups', $context);
        $currentgroup = groups_get_activity_group($cm);
        // If we are viewing all participants and the user does not have access to all groups then return nothing.
        if (!$currentgroup && !$canaccessallgroups) {
            return array();
        }
        if ($currentgroup) {
            if (!$canaccessallgroups) {
                // Guest users do not belong to any groups.
                if (isguestuser()) {
                    return array();
                }
                // Check that the user belongs to the group we are viewing.
                $usersgroups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid);
                if ($usersgroups) {
                    if (!isset($usersgroups[$currentgroup])) {
                        return array();
                    }
                } else {
                    // They belong to no group, so return an empty array.
                    return array();
                }
            }
            $groupusers = array_keys(groups_get_members($currentgroup, 'u.*'));
            if (empty($groupusers)) {
                return array();
            }
            list($sql, $params) = $DB->get_in_or_equal($groupusers, SQL_PARAMS_NAMED, 'grp');
            $conditionssql .= "AND u.id {$sql} ";
            $conditionsparams += $params;
        }
    }
    $page = (int) $page;
    $perpage = (int) $perpage;
    // Get all the users that have certificates issued, should only be one issue per user for a certificate
    $allparams = $conditionsparams + array('certificateid' => $certificateid);
    // The picture fields also include the name fields for the user.
    $picturefields = user_picture::fields('u', get_extra_user_fields($context));
    $users = $DB->get_records_sql("SELECT {$picturefields}, u.idnumber, ci.code, ci.timecreated\n                                     FROM {user} u\n                               INNER JOIN {certificate_issues} ci\n                                       ON u.id = ci.userid\n                                    WHERE u.deleted = 0\n                                      AND ci.certificateid = :certificateid {$conditionssql}\n                                 ORDER BY {$sort}", $allparams, $page * $perpage, $perpage);
    return $users;
}
开发者ID:ccle,项目名称:moodle-mod_certificate,代码行数:65,代码来源:locallib.php

示例9: iomadcertificate_get_issues

/**
 * Returns a list of issued iomadcertificates - sorted for report.
 *
 * @param int $iomadcertificateid
 * @param string $sort the sort order
 * @param bool $groupmode are we in group mode ?
 * @param stdClass $cm the course module
 * @param int $page offset
 * @param int $perpage total per page
 * @return stdClass the users
 */
function iomadcertificate_get_issues($iomadcertificateid, $sort = "ci.timecreated ASC", $groupmode, $cm, $page = 0, $perpage = 0)
{
    global $CFG, $DB;
    // get all users that can manage this iomadcertificate to exclude them from the report.
    $context = context_module::instance($cm->id);
    $conditionssql = '';
    $conditionsparams = array();
    if ($certmanagers = array_keys(get_users_by_capability($context, 'mod/iomadcertificate:manage', 'u.id'))) {
        list($sql, $params) = $DB->get_in_or_equal($certmanagers, SQL_PARAMS_NAMED, 'cert');
        $conditionssql .= "AND NOT u.id {$sql} \n";
        $conditionsparams += $params;
    }
    $restricttogroup = false;
    if ($groupmode) {
        $currentgroup = groups_get_activity_group($cm);
        if ($currentgroup) {
            $restricttogroup = true;
            $groupusers = array_keys(groups_get_members($currentgroup, 'u.*'));
            if (empty($groupusers)) {
                return array();
            }
        }
    }
    $restricttogrouping = false;
    // if groupmembersonly used, remove users who are not in any group
    if (!empty($CFG->enablegroupings) and $cm->groupmembersonly) {
        if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
            $restricttogrouping = true;
        } else {
            return array();
        }
    }
    if ($restricttogroup || $restricttogrouping) {
        if ($restricttogroup) {
            $allowedusers = $groupusers;
        } else {
            if ($restricttogroup && $restricttogrouping) {
                $allowedusers = array_intersect($groupusers, $groupingusers);
            } else {
                $allowedusers = $groupingusers;
            }
        }
        list($sql, $params) = $DB->get_in_or_equal($allowedusers, SQL_PARAMS_NAMED, 'grp');
        $conditionssql .= "AND u.id {$sql} \n";
        $conditionsparams += $params;
    }
    $page = (int) $page;
    $perpage = (int) $perpage;
    // Get all the users that have iomadcertificates issued, should only be one issue per user for a iomadcertificate
    $allparams = $conditionsparams + array('iomadcertificateid' => $iomadcertificateid);
    $users = $DB->get_records_sql("SELECT u.*, ci.code, ci.timecreated\n                                   FROM {user} u\n                                   INNER JOIN {iomadcertificate_issues} ci\n                                   ON u.id = ci.userid\n                                   WHERE u.deleted = 0\n                                   AND ci.iomadcertificateid = :iomadcertificateid\n                                   {$conditionssql}\n                                   ORDER BY {$sort}", $allparams, $page * $perpage, $perpage);
    return $users;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:64,代码来源:lib.php

示例10: get_group_members

 function get_group_members($group_id, $search = '')
 {
     $users = groups_get_members($group_id);
     $rdo = array();
     foreach ($users as $u) {
         if ($search) {
             if (stripos($u->username, $search) === false && stripos($u->firstname, $search) === false && stripos($u->lastname, $search) === false && stripos($u->idnumber, $search) === false) {
                 continue;
             }
         }
         $member['id'] = $u->id;
         $member['firstname'] = $u->firstname;
         $member['lastname'] = $u->lastname;
         $member['username'] = $u->username;
         $rdo[] = $member;
     }
     return $rdo;
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:18,代码来源:auth.php

示例11: bookmarks_get_groupmembers

/**
 *
 *
 *
 */
function bookmarks_get_groupmembers($groups)
{
    $userids = array();
    foreach ($groups as $groupid) {
        $members = groups_get_members($groupid);
        foreach ($members as $member) {
            $userids[] = $member->id;
        }
    }
    return $userids;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:16,代码来源:locallib.php

示例12: gradebook_item_update

 /**
  * Update grades in the gradebook.
  *
  * @param mixed $submission stdClass|null
  * @param mixed $grade stdClass|null
  * @return bool
  */
 protected function gradebook_item_update($submission = null, $grade = null)
 {
     global $CFG;
     require_once $CFG->dirroot . '/mod/assign/lib.php';
     // Do not push grade to gradebook if blind marking is active as
     // the gradebook would reveal the students.
     if ($this->is_blind_marking()) {
         return false;
     }
     // If marking workflow is enabled and grade is not released then remove any grade that may exist in the gradebook.
     if ($this->get_instance()->markingworkflow && !empty($grade) && $this->get_grading_status($grade->userid) != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
         // Remove the grade (if it exists) from the gradebook as it is not 'final'.
         $grade->grade = -1;
         $grade->feedbacktext = '';
     }
     if ($submission != null) {
         if ($submission->userid == 0) {
             // This is a group submission update.
             $team = groups_get_members($submission->groupid, 'u.id');
             foreach ($team as $member) {
                 $membersubmission = clone $submission;
                 $membersubmission->groupid = 0;
                 $membersubmission->userid = $member->id;
                 $this->gradebook_item_update($membersubmission, null);
             }
             return;
         }
         $gradebookgrade = $this->convert_submission_for_gradebook($submission);
     } else {
         $gradebookgrade = $this->convert_grade_for_gradebook($grade);
     }
     // Grading is disabled, return.
     if ($this->grading_disabled($gradebookgrade['userid'])) {
         return false;
     }
     $assign = clone $this->get_instance();
     $assign->cmidnumber = $this->get_course_module()->idnumber;
     // Set assign gradebook feedback plugin status (enabled and visible).
     $assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
     return assign_grade_item_update($assign, $gradebookgrade) == GRADE_UPDATE_OK;
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:48,代码来源:locallib.php

示例13: build_logs_array

function build_logs_array($course, $user = 0, $date = 0, $order = "l.time ASC", $limitfrom = '', $limitnum = '', $modname = "", $modid = 0, $modaction = "", $groupid = 0)
{
    // It is assumed that $date is the GMT time of midnight for that day,
    // and so the next 86400 seconds worth of logs are printed.
    /// Setup for group handling.
    /// If the group mode is separate, and this user does not have editing privileges,
    /// then only the user's group can be viewed.
    if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
        $groupid = get_current_group($course->id);
    } else {
        if (!$course->groupmode) {
            $groupid = 0;
        }
    }
    $joins = array();
    if ($course->id != SITEID || $modid != 0) {
        $joins[] = "l.course='{$course->id}'";
    }
    if ($modname) {
        $joins[] = "l.module = '{$modname}'";
    }
    if ('site_errors' === $modid) {
        $joins[] = "( l.action='error' OR l.action='infected' )";
    } else {
        if ($modid) {
            $joins[] = "l.cmid = '{$modid}'";
        }
    }
    if ($modaction) {
        $firstletter = substr($modaction, 0, 1);
        if (preg_match('/[[:alpha:]]/', $firstletter)) {
            $joins[] = "lower(l.action) LIKE '%" . strtolower($modaction) . "%'";
        } else {
            if ($firstletter == '-') {
                $joins[] = "lower(l.action) NOT LIKE '%" . strtolower(substr($modaction, 1)) . "%'";
            }
        }
    }
    /// Getting all members of a group.
    if ($groupid and !$user) {
        if ($gusers = groups_get_members($groupid)) {
            $gusers = array_keys($gusers);
            $joins[] = 'l.userid IN (' . implode(',', $gusers) . ')';
        } else {
            $joins[] = 'l.userid = 0';
            // No users in groups, so we want something that will always be false.
        }
    } else {
        if ($user) {
            $joins[] = "l.userid = '{$user}'";
        }
    }
    if ($date) {
        $enddate = $date + 86400;
        $joins[] = "l.time > '{$date}' AND l.time < '{$enddate}'";
    }
    $selector = implode(' AND ', $joins);
    $totalcount = 0;
    // Initialise
    $result = array();
    $result['logs'] = get_logs($selector, $order, $limitfrom, $limitnum, $totalcount);
    $result['totalcount'] = $totalcount;
    return $result;
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:64,代码来源:lib.php

示例14: query_db

 /**
  * Query the reader. Store results in the object for use by build_table.
  *
  * @param int $pagesize size of page for paginated displayed table.
  * @param bool $useinitialsbar do you want to use the initials bar.
  */
 public function query_db($pagesize, $useinitialsbar = true)
 {
     global $DB;
     $joins = array();
     $params = array();
     // If we filter by user id and module id we also need to filter by crud and edulevel to ensure DB index is engaged.
     $useextendeddbindex = !$this->filterparams->logreader instanceof logstore_legacy\log\store && !empty($this->filterparams->userid) && !empty($this->filterparams->modid);
     $groupid = 0;
     if (!empty($this->filterparams->courseid) && $this->filterparams->courseid != SITEID) {
         if (!empty($this->filterparams->groupid)) {
             $groupid = $this->filterparams->groupid;
         }
         $joins[] = "courseid = :courseid";
         $params['courseid'] = $this->filterparams->courseid;
     }
     if (!empty($this->filterparams->siteerrors)) {
         $joins[] = "( action='error' OR action='infected' OR action='failed' )";
     }
     if (!empty($this->filterparams->modid)) {
         list($actionsql, $actionparams) = $this->get_cm_sql();
         $joins[] = $actionsql;
         $params = array_merge($params, $actionparams);
     }
     if (!empty($this->filterparams->action) || $useextendeddbindex) {
         list($actionsql, $actionparams) = $this->get_action_sql();
         $joins[] = $actionsql;
         $params = array_merge($params, $actionparams);
     }
     // Getting all members of a group.
     if ($groupid and empty($this->filterparams->userid)) {
         if ($gusers = groups_get_members($groupid)) {
             $gusers = array_keys($gusers);
             $joins[] = 'userid IN (' . implode(',', $gusers) . ')';
         } else {
             $joins[] = 'userid = 0';
             // No users in groups, so we want something that will always be false.
         }
     } else {
         if (!empty($this->filterparams->userid)) {
             $joins[] = "userid = :userid";
             $params['userid'] = $this->filterparams->userid;
         }
     }
     if (!empty($this->filterparams->date)) {
         $joins[] = "timecreated > :date AND timecreated < :enddate";
         $params['date'] = $this->filterparams->date;
         $params['enddate'] = $this->filterparams->date + DAYSECS;
         // Show logs only for the selected date.
     }
     if (isset($this->filterparams->edulevel) && $this->filterparams->edulevel >= 0) {
         $joins[] = "edulevel = :edulevel";
         $params['edulevel'] = $this->filterparams->edulevel;
     } else {
         if ($useextendeddbindex) {
             list($edulevelsql, $edulevelparams) = $DB->get_in_or_equal(array(\core\event\base::LEVEL_OTHER, \core\event\base::LEVEL_PARTICIPATING, \core\event\base::LEVEL_TEACHING), SQL_PARAMS_NAMED, 'edulevel');
             $joins[] = "edulevel " . $edulevelsql;
             $params = array_merge($params, $edulevelparams);
         }
     }
     if (!$this->filterparams->logreader instanceof logstore_legacy\log\store) {
         // Filter out anonymous actions, this is N/A for legacy log because it never stores them.
         $joins[] = "anonymous = 0";
     }
     $selector = implode(' AND ', $joins);
     if (!$this->is_downloading()) {
         $total = $this->filterparams->logreader->get_events_select_count($selector, $params);
         $this->pagesize($pagesize, $total);
     } else {
         $this->pageable(false);
     }
     // Get the users and course data.
     $this->rawdata = $this->filterparams->logreader->get_events_select_iterator($selector, $params, $this->filterparams->orderby, $this->get_page_start(), $this->get_page_size());
     // Update list of users which will be displayed on log page.
     $this->update_users_used();
     // Get the events. Same query than before; even if it is not likely, logs from new users
     // may be added since last query so we will need to work around later to prevent problems.
     // In almost most of the cases this will be better than having two opened recordsets.
     $this->rawdata = $this->filterparams->logreader->get_events_select_iterator($selector, $params, $this->filterparams->orderby, $this->get_page_start(), $this->get_page_size());
     // Set initial bars.
     if ($useinitialsbar && !$this->is_downloading()) {
         $this->initialbars($total > $pagesize);
     }
 }
开发者ID:posttechguy,项目名称:moodle-tbst2-report_log,代码行数:89,代码来源:table_log.php

示例15: dialogue_get_conversations

/**
 * Get a set of dialogue conversations records for a given user
 * 
 * @param   object  $dialogue
 * @param   object  $user
 * @param   string  $condition to be included in WHERE clause to be used in sql
 * @param   string  $order by clause to be used in sql
 * @param   int     $groupid    of the group to filter conversations by (default: 0)
 * @return  array   recordset of conversations
 */
function dialogue_get_conversations($dialogue, $user, $condition = '', $order = '', $groupid = 0)
{
    global $CFG, $COURSE;
    if (!($cm = get_coursemodule_from_instance('dialogue', $dialogue->id, $COURSE->id))) {
        error('Course Module ID was incorrect');
    }
    if (!empty($condition)) {
        $condition = ' AND ' . $condition;
    }
    if (empty($order)) {
        $order = 'c.timemodified DESC';
    }
    if (has_capability('mod/dialogue:viewall', get_context_instance(CONTEXT_MODULE, $cm->id))) {
        $whereuser = '';
    } else {
        $whereuser = ' AND (c.userid = ' . $user->id . ' OR c.recipientid = ' . $user->id . ') ';
    }
    // ULPGC ecastro enforce groups use
    if ($groupid) {
        $members = groups_get_members($groupid, 'u.id');
        if ($members) {
            $list = '( ' . implode(', ', array_keys($members)) . ' )';
        } else {
            $list = '( 0 ) ';
        }
        $whereuser .= " AND (c.userid IN {$list} OR c.recipientid IN {$list} )";
    }
    $sql = "SELECT c.*, COUNT(e.id) AS total, COUNT(r.id) as readings " . "FROM {$CFG->prefix}dialogue_conversations c " . "LEFT JOIN {$CFG->prefix}dialogue_entries e ON e.conversationid = c.id " . "LEFT JOIN {$CFG->prefix}dialogue_read r ON r.entryid = e.id AND r.userid = {$user->id} " . "WHERE c.dialogueid = {$dialogue->id} {$whereuser} {$condition} " . "GROUP BY c.id, c.userid, c.dialogueid, c.recipientid, c.lastid, c.lastrecipientid, c.timemodified, c.closed, c.seenon, c.ctype, c.format, c.subject, c.groupid, c.grouping " . "ORDER BY {$order} ";
    $conversations = get_records_sql($sql);
    return $conversations;
}
开发者ID:netspotau,项目名称:moodle-mod_dialogue,代码行数:41,代码来源:lib.php


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