本文整理汇总了PHP中sql_fullname函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_fullname函数的具体用法?PHP sql_fullname怎么用?PHP sql_fullname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_fullname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_selection_data
function get_selection_data($ufiltering)
{
global $SESSION;
// get the SQL filter
$guest = get_guest();
$sqlwhere = $ufiltering->get_sql_filter("id<>{$guest->id} AND deleted <> 1");
$total = count_records_select('user', "id<>{$guest->id} AND deleted <> 1");
$acount = count_records_select('user', $sqlwhere);
$scount = count($SESSION->bulk_users);
$userlist = array('acount' => $acount, 'scount' => $scount, 'ausers' => false, 'susers' => false, 'total' => $total);
$userlist['ausers'] = get_records_select_menu('user', $sqlwhere, 'fullname', 'id,' . sql_fullname() . ' AS fullname', 0, MAX_BULK_USERS);
if ($scount) {
if ($scount < MAX_BULK_USERS) {
$in = implode(',', $SESSION->bulk_users);
} else {
$bulkusers = array_slice($SESSION->bulk_users, 0, MAX_BULK_USERS, true);
$in = implode(',', $bulkusers);
}
$userlist['susers'] = get_records_select_menu('user', "id IN ({$in})", 'fullname', 'id,' . sql_fullname() . ' AS fullname');
}
return $userlist;
}
示例2: get_course_students
/**
* Returns array of userinfo of all students in this course
* or on this site if courseid is id of site
*
* @uses $CFG
* @uses SITEID
* @param int $courseid The course in question.
* @param string $sort ?
* @param string $dir ?
* @param int $page ?
* @param int $recordsperpage ?
* @param string $firstinitial ?
* @param string $lastinitial ?
* @param ? $group ?
* @param string $search ?
* @param string $fields A comma separated list of fields to be returned from the chosen table.
* @param string $exceptions ?
* @return object
* @todo Finish documenting this function
*/
function get_course_students($courseid, $sort = 'ul.timeaccess', $dir = '', $page = '', $recordsperpage = '', $firstinitial = '', $lastinitial = '', $group = NULL, $search = '', $fields = '', $exceptions = '')
{
global $CFG;
if ($courseid == SITEID and $CFG->allusersaresitestudents) {
// return users with confirmed, undeleted accounts who are not site teachers
// the following is a mess because of different conventions in the different user functions
$sort = str_replace('s.timeaccess', 'lastaccess', $sort);
// site users can't be sorted by timeaccess
$sort = str_replace('timeaccess', 'lastaccess', $sort);
// site users can't be sorted by timeaccess
$sort = str_replace('u.', '', $sort);
// the get_user function doesn't use the u. prefix to fields
$fields = str_replace('u.', '', $fields);
if ($sort) {
$sort = $sort . ' ' . $dir;
}
// Now we have to make sure site teachers are excluded
if ($teachers = get_course_teachers(SITEID)) {
foreach ($teachers as $teacher) {
$exceptions .= ',' . $teacher->userid;
}
$exceptions = ltrim($exceptions, ',');
}
return get_users(true, $search, true, $exceptions, $sort, $firstinitial, $lastinitial, $page, $recordsperpage, $fields ? $fields : '*');
}
$LIKE = sql_ilike();
$fullname = sql_fullname('u.firstname', 'u.lastname');
$groupmembers = '';
// make sure it works on the site course
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$select = "c.contextlevel=" . CONTEXT_COURSE . " AND ";
// Must be on a course
if ($courseid != SITEID) {
// If not site, require specific course
$select .= "c.instanceid={$courseid} AND ";
}
$select .= "rc.capability='moodle/legacy:student' AND rc.permission=" . CAP_ALLOW . " AND ";
$select .= ' u.deleted = \'0\' ';
if (!$fields) {
$fields = 'u.id, u.confirmed, u.username, u.firstname, u.lastname, ' . 'u.maildisplay, u.mailformat, u.maildigest, u.email, u.city, ' . 'u.country, u.picture, u.idnumber, u.department, u.institution, ' . 'u.emailstop, u.lang, u.timezone, ul.timeaccess as lastaccess';
}
if ($search) {
$search = ' AND (' . $fullname . ' ' . $LIKE . '\'%' . $search . '%\' OR email ' . $LIKE . '\'%' . $search . '%\') ';
}
if ($firstinitial) {
$select .= ' AND u.firstname ' . $LIKE . '\'' . $firstinitial . '%\' ';
}
if ($lastinitial) {
$select .= ' AND u.lastname ' . $LIKE . '\'' . $lastinitial . '%\' ';
}
if ($group === 0) {
/// Need something here to get all students not in a group
return array();
} else {
if ($group !== NULL) {
$groupmembers = "INNER JOIN {$CFG->prefix}groups_members gm on u.id=gm.userid";
$select .= ' AND gm.groupid = \'' . $group . '\'';
}
}
if (!empty($exceptions)) {
$select .= ' AND u.id NOT IN (' . $exceptions . ')';
}
if ($sort) {
$sort = ' ORDER BY ' . $sort . ' ';
}
$students = get_records_sql("SELECT {$fields}\n FROM {$CFG->prefix}user u INNER JOIN\n {$CFG->prefix}role_assignments ra on u.id=ra.userid INNER JOIN\n {$CFG->prefix}role_capabilities rc ON ra.roleid=rc.roleid INNER JOIN\n {$CFG->prefix}context c ON c.id=ra.contextid LEFT OUTER JOIN\n {$CFG->prefix}user_lastaccess ul on ul.userid=ra.userid\n {$groupmembers}\n WHERE {$select} {$search} {$sort} {$dir}", $page, $recordsperpage);
return $students;
}
示例3: sql_fullname
$sqlwhere = "WHERE (glossaryid = '{$glossary->id}' OR sourceglossaryid = '{$glossary->id}') AND\n (ge.approved != 0 {$userid}) AND gec.entryid IS NULL";
$sqlorderby = ' ORDER BY concept';
} else {
$printpivot = 0;
$sqlselect = "SELECT ge.*, ce.entryid, c.name AS glossarypivot";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories ce, {$CFG->prefix}glossary_categories c";
$sqlwhere = "WHERE ge.id = ce.entryid AND ce.categoryid = '{$hook}' AND\n ce.categoryid = c.id AND ge.approved != 0 AND\n (ge.glossaryid = '{$glossary->id}' OR ge.sourceglossaryid = '{$glossary->id}') AND\n (ge.approved != 0 {$userid})";
$sqlorderby = ' ORDER BY c.name, ge.concept';
}
break;
case GLOSSARY_AUTHOR_VIEW:
$where = '';
if ($sqlsortkey == 'firstname') {
$usernamefield = sql_fullname('u.firstname', 'u.lastname');
} else {
$usernamefield = sql_fullname('u.lastname', 'u.firstname');
}
$where = "AND " . sql_substr() . "(upper({$usernamefield}),1," . $textlib->strlen($hook) . ") = '" . $textlib->strtoupper($hook) . "'";
if ($hook == 'ALL') {
$where = '';
}
$sqlselect = "SELECT ge.*, {$usernamefield} AS glossarypivot, 1 AS userispivot ";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u";
$sqlwhere = "WHERE ge.userid = u.id AND\n (ge.approved != 0 {$userid})\n {$where} AND \n (ge.glossaryid = '{$glossary->id}' OR ge.sourceglossaryid = '{$glossary->id}')";
$sqlorderby = "ORDER BY {$usernamefield} {$sqlsortorder}, ge.concept";
break;
case GLOSSARY_APPROVAL_VIEW:
$fullpivot = 0;
$printpivot = 0;
$where = '';
if ($hook != 'ALL' and $hook != 'SPECIAL') {
示例4: redirect
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
if (empty($SESSION->bulk_users)) {
redirect($return);
}
admin_externalpage_print_header();
//TODO: add support for large number of users
if ($confirm and confirm_sesskey()) {
$primaryadmin = get_admin();
$in = implode(',', $SESSION->bulk_users);
if ($rs = get_recordset_select('user', "id IN ({$in})")) {
while ($user = rs_fetch_next_record($rs)) {
if ($primaryadmin->id != $user->id and $USER->id != $user->id and delete_user($user)) {
unset($SESSION->bulk_users[$user->id]);
} else {
notify(get_string('deletednot', '', fullname($user, true)));
}
}
rs_close($rs);
}
redirect($return, get_string('changessaved'));
} else {
$in = implode(',', $SESSION->bulk_users);
$userlist = get_records_select_menu('user', "id IN ({$in})", 'fullname', 'id,' . sql_fullname() . ' AS fullname');
$usernames = implode(', ', $userlist);
$optionsyes = array();
$optionsyes['confirm'] = 1;
$optionsyes['sesskey'] = sesskey();
print_heading(get_string('confirmation', 'admin'));
notice_yesno(get_string('deletecheckfull', '', $usernames), 'user_bulk_delete.php', 'user_bulk.php', $optionsyes, NULL, 'post', 'get');
}
admin_externalpage_print_footer();
示例5: get_field
/**
* Creates known user filter if present
* @param string $fieldname
* @param boolean $advanced
* @return object filter
*/
function get_field($fieldname, $advanced)
{
global $USER, $CFG, $SITE;
switch ($fieldname) {
case 'username':
return new user_filter_text('username', get_string('username'), $advanced, 'username');
case 'realname':
return new user_filter_text('realname', get_string('fullname'), $advanced, sql_fullname());
case 'lastname':
return new user_filter_text('lastname', get_string('lastname'), $advanced, 'lastname');
case 'firstname':
return new user_filter_text('firstname', get_string('firstname'), $advanced, 'firstname');
case 'email':
return new user_filter_text('email', get_string('email'), $advanced, 'email');
case 'city':
return new user_filter_text('city', get_string('city'), $advanced, 'city');
case 'country':
return new user_filter_select('country', get_string('country'), $advanced, 'country', get_list_of_countries(), $USER->country);
case 'confirmed':
return new user_filter_yesno('confirmed', get_string('confirmed', 'admin'), $advanced, 'confirmed');
case 'profile':
return new user_filter_profilefield('profile', get_string('profile'), $advanced);
case 'courserole':
return new user_filter_courserole('courserole', get_string('courserole', 'filters'), $advanced);
case 'systemrole':
return new user_filter_globalrole('systemrole', get_string('globalrole', 'role'), $advanced);
case 'firstaccess':
return new user_filter_date('firstaccess', get_string('firstaccess', 'filters'), $advanced, 'firstaccess');
case 'lastaccess':
return new user_filter_date('lastaccess', get_string('lastaccess'), $advanced, 'lastaccess');
case 'lastlogin':
return new user_filter_date('lastlogin', get_string('lastlogin'), $advanced, 'lastlogin');
case 'timemodified':
return new user_filter_date('timemodified', get_string('lastmodified'), $advanced, 'timemodified');
case 'auth':
$plugins = get_list_of_plugins('auth');
$choices = array();
foreach ($plugins as $auth) {
$choices[$auth] = auth_get_plugin_title($auth);
}
return new user_filter_simpleselect('auth', get_string('authentication'), $advanced, 'auth', $choices);
case 'mnethostid':
// include all hosts even those deleted or otherwise problematic
if (!($hosts = get_records('mnet_host', '', '', 'id', 'id, wwwroot, name'))) {
$hosts = array();
}
$choices = array();
foreach ($hosts as $host) {
if ($host->id == $CFG->mnet_localhost_id) {
$choices[$host->id] = format_string($SITE->fullname) . ' (' . get_string('local') . ')';
} else {
if (empty($host->wwwroot)) {
// All hosts
continue;
} else {
$choices[$host->id] = $host->name . ' (' . $host->wwwroot . ')';
}
}
}
if ($usedhosts = get_fieldset_sql("SELECT DISTINCT mnethostid FROM {$CFG->prefix}user WHERE deleted=0")) {
foreach ($usedhosts as $hostid) {
if (empty($hosts[$hostid])) {
$choices[$hostid] = 'id: ' . $hostid . ' (' . get_string('error') . ')';
}
}
}
if (count($choices) < 2) {
return null;
// filter not needed
}
return new user_filter_simpleselect('mnethostid', 'mnethostid', $advanced, 'mnethostid', $choices);
default:
return null;
}
}
示例6: groups_get_users_not_in_group
/**
* Gets the users for a course who are not in a specified group
* @param int $groupid The id of the group
* @param string searchtext similar to searchtext in role assign, search
* @return array An array of the userids of the non-group members, or false if
* an error occurred.
* This function was changed to get_users_by_capability style
* mostly because of the searchtext requirement
*/
function groups_get_users_not_in_group($courseid, $groupid, $searchtext = '')
{
global $CFG;
$context = get_context_instance(CONTEXT_COURSE, $courseid);
if ($searchtext !== '') {
// Search for a subset of remaining users
$LIKE = sql_ilike();
$FULLNAME = sql_fullname();
$wheresearch = " AND u.id IN (SELECT id FROM {$CFG->prefix}user WHERE {$FULLNAME} {$LIKE} '%{$searchtext}%' OR email {$LIKE} '%{$searchtext}%' )";
} else {
$wheresearch = '';
}
$capability = 'moodle/course:view';
$doanything = false;
// find all possible "student" roles
if ($possibleroles = get_roles_with_capability($capability, CAP_ALLOW, $context)) {
if (!$doanything) {
if (!($sitecontext = get_context_instance(CONTEXT_SYSTEM))) {
return false;
// Something is seriously wrong
}
$doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext);
}
$validroleids = array();
foreach ($possibleroles as $possiblerole) {
if (!$doanything) {
if (isset($doanythingroles[$possiblerole->id])) {
// We don't want these included
continue;
}
}
if ($caps = role_context_capabilities($possiblerole->id, $context, $capability)) {
// resolved list
if (isset($caps[$capability]) && $caps[$capability] > 0) {
// resolved capability > 0
$validroleids[] = $possiblerole->id;
}
}
}
if (empty($validroleids)) {
return false;
}
$roleids = '(' . implode(',', $validroleids) . ')';
} else {
return false;
// No need to continue, since no roles have this capability set
}
/// Construct the main SQL
$select = " SELECT u.id, u.firstname, u.lastname";
$from = " FROM {$CFG->prefix}user u\n INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id\n INNER JOIN {$CFG->prefix}role r ON r.id = ra.roleid";
$where = " WHERE ra.contextid " . get_related_contexts_string($context) . "\n AND u.deleted = 0\n AND ra.roleid in {$roleids}\n AND u.id NOT IN (SELECT userid\n FROM {$CFG->prefix}groups_members\n WHERE groupid = {$groupid})\n {$wheresearch}";
$groupby = " GROUP BY u.id, u.firstname, u.lastname ";
return get_records_sql($select . $from . $where . $groupby);
}
示例7: getUserData
/**
* Returns information about the users.
* @param string $sqlwhere filter for the users
*/
function getUserData($sqlwhere)
{
return get_records_select_menu('user', $sqlwhere, 'fullname', 'id,' . sql_fullname() . ' AS fullname');
}
示例8: AND
if ($context->id != $frontpagectx->id) {
$where = "WHERE (r.contextid = {$context->id} OR r.contextid in {$listofcontexts})\n AND u.deleted = 0 {$selectrole}\n AND (ul.courseid = {$course->id} OR ul.courseid IS NULL)\n AND u.username != 'guest'\n {$adminroles}\n {$hiddensql} ";
$where .= get_course_lastaccess_sql($accesssince);
} else {
if ($roleid >= 0) {
$where = "WHERE (r.contextid = {$context->id} OR r.contextid in {$listofcontexts})\n AND u.deleted = 0 {$selectrole}\n AND u.username != 'guest'";
$where .= get_user_lastaccess_sql($accesssince);
} else {
$where = "WHERE u.deleted = 0\n AND u.username != 'guest'";
$where .= get_user_lastaccess_sql($accesssince);
}
}
$wheresearch = '';
if (!empty($search)) {
$LIKE = sql_ilike();
$fullname = sql_fullname('u.firstname', 'u.lastname');
$wheresearch .= ' AND (' . $fullname . ' ' . $LIKE . ' \'%' . $search . '%\' OR email ' . $LIKE . ' \'%' . $search . '%\' OR idnumber ' . $LIKE . ' \'%' . $search . '%\') ';
}
if ($currentgroup) {
// Displaying a group by choice
// FIX: TODO: This will not work if $currentgroup == 0, i.e. "those not in a group"
$from .= 'LEFT JOIN ' . $CFG->prefix . 'groups_members gm ON u.id = gm.userid ';
$where .= ' AND gm.groupid = ' . $currentgroup;
}
$totalcount = count_records_sql('SELECT COUNT(distinct u.id) ' . $from . $where);
// Each user could have > 1 role
if ($table->get_sql_where()) {
$where .= ' AND ' . $table->get_sql_where();
}
/// Always add r.hidden to sort in order to guarantee hiddens to "win"
/// in the resolution of duplicates later - MDL-13935
示例9: get_users_listing
/**
* shortdesc (optional)
*
* longdesc
*
* @uses $CFG
* @param string $sort ?
* @param string $dir ?
* @param int $categoryid ?
* @param int $categoryid ?
* @param string $search ?
* @param string $firstinitial ?
* @param string $lastinitial ?
* @returnobject {@link $USER} records
* @todo Finish documenting this function
*/
function get_users_listing($sort = 'lastaccess', $dir = 'ASC', $page = 0, $recordsperpage = 0, $search = '', $firstinitial = '', $lastinitial = '', $extraselect = '')
{
global $CFG;
$LIKE = sql_ilike();
$fullname = sql_fullname();
$select = "deleted <> '1'";
if (!empty($search)) {
$search = trim($search);
$select .= " AND ({$fullname} {$LIKE} '%{$search}%' OR email {$LIKE} '%{$search}%' OR username='{$search}') ";
}
if ($firstinitial) {
$select .= ' AND firstname ' . $LIKE . ' \'' . $firstinitial . '%\' ';
}
if ($lastinitial) {
$select .= ' AND lastname ' . $LIKE . ' \'' . $lastinitial . '%\' ';
}
if ($extraselect) {
$select .= " AND {$extraselect} ";
}
if ($sort) {
$sort = ' ORDER BY ' . $sort . ' ' . $dir;
}
/// warning: will return UNCONFIRMED USERS
return get_records_sql("SELECT id, username, email, firstname, lastname, city, country, lastaccess, confirmed, mnethostid\n FROM {$CFG->prefix}user\n WHERE {$select} {$sort}", $page, $recordsperpage);
}
示例10: message_search_users
/**
* Search through course users
*
* If $coursid specifies the site course then this function searches
* through all undeleted and confirmed users
*
* @uses $CFG, $USER
* @uses SITEID
* @param int $courseid The course in question.
* @param string $searchtext ?
* @param string $sort ?
* @param string $exceptions ?
* @return array An array of {@link $USER} records.
* @todo Finish documenting this function
*/
function message_search_users($courseid, $searchtext, $sort = '', $exceptions = '')
{
global $CFG, $USER;
$fullname = sql_fullname();
$LIKE = sql_ilike();
if (!empty($exceptions)) {
$except = ' AND u.id NOT IN (' . $exceptions . ') ';
} else {
$except = '';
}
if (!empty($sort)) {
$order = ' ORDER BY ' . $sort;
} else {
$order = '';
}
$select = 'u.deleted = \'0\' AND u.confirmed = \'1\'';
$fields = 'u.id, u.firstname, u.lastname, u.picture, u.imagealt, mc.id as contactlistid, mc.blocked';
if (!$courseid or $courseid == SITEID) {
return get_records_sql("SELECT {$fields}\n FROM {$CFG->prefix}user u\n LEFT OUTER JOIN {$CFG->prefix}message_contacts mc\n ON mc.contactid = u.id AND mc.userid = {$USER->id} \n WHERE {$select}\n AND ({$fullname} {$LIKE} '%{$searchtext}%')\n {$except} {$order}");
} else {
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$contextlists = get_related_contexts_string($context);
// everyone who has a role assignement in this course or higher
$users = get_records_sql("SELECT {$fields}\n FROM {$CFG->prefix}user u\n JOIN {$CFG->prefix}role_assignments ra\n ON ra.userid = u.id\n LEFT OUTER JOIN {$CFG->prefix}message_contacts mc\n ON mc.contactid = u.id AND mc.userid = {$USER->id} \n WHERE {$select}\n AND ra.contextid {$contextlists}\n AND ({$fullname} {$LIKE} '%{$searchtext}%')\n {$except} {$order}");
return $users;
}
}
示例11: search_sql
/**
* @param string $search the text to search for.
* @param string $u the table alias for the user table in the query being
* built. May be ''.
* @return string SQL component to go in the where clause of the query
*/
protected function search_sql($search, $u)
{
$tests = array();
if ($u) {
$u .= '.';
}
// If we have a $search string, put a field LIKE '$search%' condition on each field.
if ($search) {
$conditions = array(sql_fullname($u . 'firstname', $u . 'lastname'), $conditions[] = $u . 'lastname');
foreach ($this->extrafields as $field) {
$conditions[] = $u . $field;
}
$ilike = ' ' . sql_ilike();
if ($this->searchanywhere) {
$searchparam = '%' . $search . '%';
} else {
$searchparam = $search . '%';
}
foreach ($conditions as &$condition) {
$condition .= $ilike . "'{$searchparam}'";
}
$tests[] = '(' . implode(' OR ', $conditions) . ')';
}
// Add some additional sensible conditions
$tests[] = $u . "username != 'guest'";
$tests[] = $u . 'deleted = 0';
$tests[] = $u . 'confirmed = 1';
// If we are being asked to exclude any users, do that.
if (!empty($this->exclude)) {
$tests[] = $u . 'id NOT IN (' . implode(',', $this->exclude) . ')';
}
// If we are validating a set list of userids, add an id IN (...) test.
if (!empty($this->validatinguserids)) {
$tests[] = $u . 'id IN (' . implode(',', $this->validatinguserids) . ')';
}
if (empty($tests)) {
$tests[] = '1 = 1';
}
// Combing the conditions and return.
return implode(' AND ', $tests);
}
示例12: array
$view_i++;
$table->data[$view_i] = array();
$icons = '';
$icons .= '<a href="' . dirname($_SERVER['PHP_SELF']) . '/views_mod.php?courseid=' . $courseid . '&id=' . $view->id . '&sesskey=' . sesskey() . '&action=edit"><img src="' . $CFG->wwwroot . '/pix/t/edit.gif" class="iconsmall" alt="' . get_string("edit") . '" /></a> ';
$icons .= '<a href="' . dirname($_SERVER['PHP_SELF']) . '/views_mod.php?courseid=' . $courseid . '&id=' . $view->id . '&sesskey=' . sesskey() . '&action=delete&confirm=1"><img src="' . $CFG->wwwroot . '/pix/t/delete.gif" class="iconsmall" alt="" . get_string("delete"). ""/></a> ';
$table->data[$view_i]['name'] = '<a href="' . $CFG->wwwroot . '/blocks/exabis_eportfolio/shared_view.php?courseid=' . $courseid . '&access=id/' . $USER->id . '-' . $view->id . '">' . format_string($view->name) . "</a> (" . $icons . ") ";
if ($view->description) {
$table->data[$view_i]['name'] .= "<table width=\"98%\"><tr><td>" . format_text($view->description, FORMAT_HTML) . "</td></tr></table>";
}
$table->data[$view_i]['timemodified'] = userdate($view->timemodified);
$table->data[$view_i]['accessoptions'] = '';
if ($view->shareall) {
$table->data[$view_i]['accessoptions'] .= '<div>' . get_string("internalaccess", "block_exabis_eportfolio") . ':</div><div style="padding-left: 10px;">' . get_string("internalaccessall", "block_exabis_eportfolio") . '</div>';
} else {
// read users
$query = "select " . sql_fullname() . " AS name" . " from {$CFG->prefix}user u" . " JOIN {$CFG->prefix}block_exabeporviewshar vshar WHERE u.id=vshar.userid AND vshar.viewid='" . $view->id . "'" . " ORDER BY name";
$users = get_records_sql($query);
if ($users) {
foreach ($users as &$user) {
$user = $user->name;
}
$table->data[$view_i]['accessoptions'] .= '<div>' . get_string("internalaccessusers", "block_exabis_eportfolio") . ':</div><div style="padding-left: 10px;">' . join(', ', $users) . '</div>';
}
}
if ($view->externaccess) {
if ($table->data[$view_i]['accessoptions']) {
$style = 'padding-top: 10px;';
} else {
$style = '';
}
$url = block_exabis_eportfolio_get_external_view_url($view);
示例13: groups_get_users_not_in_group_by_role
/**
* Gets the users for a course who are not in a specified group, and returns
* them in an array organised by role. For the array format, see
* groups_get_members_by_role.
* @param int $groupid The id of the group
* @param string searchtext similar to searchtext in role assign, search
* @return array An array of role id or '*' => information about that role
* including a list of users
*/
function groups_get_users_not_in_group_by_role($courseid, $groupid, $searchtext = '', $sort = 'u.lastname ASC')
{
global $CFG;
$context = get_context_instance(CONTEXT_COURSE, $courseid);
if ($searchtext !== '') {
// Search for a subset of remaining users
$LIKE = sql_ilike();
$FULLNAME = sql_fullname();
$wheresearch = " AND u.id IN (SELECT id FROM {$CFG->prefix}user WHERE {$FULLNAME} {$LIKE} '%{$searchtext}%' OR email {$LIKE} '%{$searchtext}%' )";
} else {
$wheresearch = '';
}
/// Get list of allowed roles
if (!($validroleids = groups_get_possible_roles($context))) {
return;
}
$roleids = '(' . implode(',', $validroleids) . ')';
/// Construct the main SQL
$select = " SELECT r.id AS roleid,r.shortname AS roleshortname,r.name AS rolename,\n u.id AS userid, u.firstname, u.lastname";
$from = " FROM {$CFG->prefix}user u\n INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id\n INNER JOIN {$CFG->prefix}role r ON r.id = ra.roleid";
$where = " WHERE ra.contextid " . get_related_contexts_string($context) . "\n AND u.deleted = 0\n AND ra.roleid in {$roleids}\n AND u.id NOT IN (SELECT userid\n FROM {$CFG->prefix}groups_members\n WHERE groupid = {$groupid})\n {$wheresearch}";
$orderby = " ORDER BY {$sort}";
return groups_calculate_role_people(get_recordset_sql($select . $from . $where . $orderby), $context);
}
示例14: get_usage_ids_where_question_in_state
/**
* Get a list of usage ids where the question with slot $slot, and optionally
* also with question id $questionid, is in summary state $summarystate. Also
* return the total count of such states.
*
* Only a subset of the ids can be returned by using $orderby, $limitfrom and
* $limitnum. A special value 'random' can be passed as $orderby, in which case
* $limitfrom is ignored.
*
* @param int $slot The slot for the questions you want to konw about.
* @param int $questionid (optional) Only return attempts that were of this specific question.
* @param string $summarystate 'all', 'needsgrading', 'autograded' or 'manuallygraded'.
* @param string $orderby 'random', 'date', 'student' or 'idnumber'.
* @param int $page implements paging of the results.
* Ignored if $orderby = random or $pagesize is null.
* @param int $pagesize implements paging of the results. null = all.
*/
protected function get_usage_ids_where_question_in_state($summarystate, $slot, $questionid = null, $orderby = 'random', $page = 0, $pagesize = null)
{
global $CFG;
$dm = new question_engine_data_mapper();
if ($pagesize && $orderby != 'random') {
$limitfrom = $page * $pagesize;
} else {
$limitfrom = 0;
}
$qubaids = $this->get_qubaids_condition();
$params = array();
if ($orderby == 'date') {
list($statetest, $params) = $dm->in_summary_state_test('manuallygraded', false, 'mangrstate');
$orderby = "(\n SELECT MAX(sortqas.timecreated)\n FROM {question_attempt_steps} sortqas\n WHERE sortqas.questionattemptid = qa.id\n AND sortqas.state {$statetest}\n )";
} else {
if ($orderby == 'student' || $orderby == 'idnumber') {
$qubaids->from .= " JOIN {user} u ON quiza.userid = u.id ";
if ($orderby == 'student') {
$orderby = sql_fullname('u.firstname', 'u.lastname');
}
}
}
return $dm->load_questions_usages_where_question_in_state($qubaids, $summarystate, $slot, $questionid, $orderby, $params, $limitfrom, $pagesize);
}
示例15: redirect
break;
case 2:
redirect($CFG->wwwroot . '/admin/user/user_bulk_message.php');
break;
case 3:
redirect($CFG->wwwroot . '/admin/user/user_bulk_delete.php');
break;
case 4:
redirect($CFG->wwwroot . '/admin/user/user_bulk_display.php');
break;
default:
break;
}
// prepare user filter types
$filters[] = new user_filter_text('username', get_string('username'), 'username');
$filters[] = new user_filter_text('realname', get_string('fullname'), sql_fullname());
$filters[] = new user_filter_text('email', get_string('email'), 'email');
$filters[] = new user_filter_text('city', get_string('city'), 'city');
$filters[] = new user_filter_select('country', get_string('country'), 'country', get_list_of_countries());
$filters[] = new user_filter_yesno('confirmed', get_string('confirm'), 'confirmed');
$filters[] = new user_filter_profilefield('profile', get_string('profile'));
$filters[] = new user_filter_courserole('course', get_string('courserole', 'filters'));
$filters[] = new user_filter_globalrole('system', get_string('globalrole', 'role'));
$filters[] = new user_filter_date('date', get_string('date'), 'lastaccess', array('lastlogin' => get_string('lastlogin'), 'firstaccess' => get_string('firstaccess', 'filters'), 'lastaccess' => get_string('lastaccess'), 'timemodified' => get_string('lastmodified')));
// create the user filter form
$user_filter_form =& new user_filter_form(null, $filters);
// do output
admin_externalpage_setup('userbulk');
admin_externalpage_print_header();
// put the user filter form first
$user_filter_form->display();