Skip to content

Commit

Permalink
Merge branch 'MDL-26647-master' of git://github.com/sammarshallou/moodle
Browse files Browse the repository at this point in the history
Conflicts:
	lib/db/upgrade.php
	report/completion/index.php
	report/progress/index.php
	version.php
  • Loading branch information
stronk7 committed Nov 11, 2011
2 parents 032bfca + b849c21 commit 8ac9d33
Show file tree
Hide file tree
Showing 32 changed files with 499 additions and 166 deletions.
5 changes: 3 additions & 2 deletions admin/roles/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -996,13 +996,14 @@ abstract class role_assign_user_selector_base extends user_selector_base {
*/
public function __construct($name, $options) {
global $CFG;
parent::__construct($name, $options);
$this->roleid = $options['roleid'];
if (isset($options['context'])) {
$this->context = $options['context'];
} else {
$this->context = get_context_instance_by_id($options['contextid']);
}
$options['accesscontext'] = $this->context;
parent::__construct($name, $options);
$this->roleid = $options['roleid'];
require_once($CFG->dirroot . '/group/lib.php');
}

Expand Down
21 changes: 18 additions & 3 deletions admin/settings/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,24 @@
'mycourses' => get_string('mycourses'),
'groups' => get_string('groups'))));

$temp->add(new admin_setting_configmulticheckbox('extrauserselectorfields',
get_string('extrauserselectorfields', 'admin'), get_string('configextrauserselectorfields', 'admin'), array('email' => '1'),
array('email' => get_string('email'), 'idnumber' => get_string('idnumber'), 'username' => get_string('username'), )));
// Select fields to display as part of user identity (only to those
// with moodle/site:viewuseridentity).
// Options include fields from the user table that might be helpful to
// distinguish when adding or listing users ('I want to add the John
// Smith from Science faculty').
// Username is not included as an option because in some sites, it might
// be a security problem to reveal usernames even to trusted staff.
// Custom user profile fields are not currently supported.
$temp->add(new admin_setting_configmulticheckbox('showuseridentity',
get_string('showuseridentity', 'admin'),
get_string('showuseridentity_desc', 'admin'), array('email' => 1), array(
'idnumber' => get_string('idnumber'),
'email' => get_string('email'),
'phone1' => get_string('phone'),
'phone2' => get_string('phone2'),
'department' => get_string('department'),
'institution' => get_string('institution'),
)));
$temp->add(new admin_setting_configcheckbox('enablegravatar', get_string('enablegravatar', 'admin'), get_string('enablegravatar_help', 'admin'), 0));
}

Expand Down
56 changes: 41 additions & 15 deletions admin/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$delete = optional_param('delete', 0, PARAM_INT);
$confirm = optional_param('confirm', '', PARAM_ALPHANUM); //md5 confirmation hash
$confirmuser = optional_param('confirmuser', 0, PARAM_INT);
$sort = optional_param('sort', 'name', PARAM_ALPHA);
$sort = optional_param('sort', 'name', PARAM_ALPHANUM);
$dir = optional_param('dir', 'ASC', PARAM_ALPHA);
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 30, PARAM_INT); // how many per page
Expand Down Expand Up @@ -117,11 +117,13 @@
echo $OUTPUT->header();

// Carry on with the user listing

$columns = array("firstname", "lastname", "email", "city", "country", "lastaccess");
$context = context_system::instance();
$extracolumns = get_extra_user_fields($context);
$columns = array_merge(array('firstname', 'lastname'), $extracolumns,
array('city', 'country', 'lastaccess'));

foreach ($columns as $column) {
$string[$column] = get_string("$column");
$string[$column] = get_user_field_name($column);
if ($sort != $column) {
$columnicon = "";
if ($column == "lastaccess") {
Expand All @@ -147,7 +149,8 @@
}

list($extrasql, $params) = $ufiltering->get_sql_filter();
$users = get_users_listing($sort, $dir, $page*$perpage, $perpage, '', '', '', $extrasql, $params);
$users = get_users_listing($sort, $dir, $page*$perpage, $perpage, '', '', '',
$extrasql, $params, $context);
$usercount = get_users(false);
$usersearchcount = get_users(false, '', true, null, "", '', '', '', '', '*', $extrasql, $params);

Expand Down Expand Up @@ -208,8 +211,27 @@
}

$table = new html_table();
$table->head = array ($fullnamedisplay, $email, $city, $country, $lastaccess, "", "", "");
$table->align = array ("left", "left", "left", "left", "left", "center", "center", "center");
$table->head = array ();
$table->align = array();
$table->head[] = $fullnamedisplay;
$table->align[] = 'left';
foreach ($extracolumns as $field) {
$table->head[] = ${$field};
$table->align[] = 'left';
}
$table->head[] = $city;
$table->align[] = 'left';
$table->head[] = $country;
$table->align[] = 'left';
$table->head[] = $lastaccess;
$table->align[] = 'left';
$table->head[] = "";
$table->align[] = 'center';
$table->head[] = "";
$table->align[] = 'center';
$table->head[] = "";
$table->align[] = 'center';

$table->width = "95%";
foreach ($users as $user) {
if (isguestuser($user)) {
Expand Down Expand Up @@ -272,14 +294,18 @@
}
$fullname = fullname($user, true);

$table->data[] = array ("<a href=\"../user/view.php?id=$user->id&amp;course=$site->id\">$fullname</a>",
"$user->email",
"$user->city",
"$user->country",
$strlastaccess,
$editbutton,
$deletebutton,
$confirmbutton);
$row = array ();
$row[] = "<a href=\"../user/view.php?id=$user->id&amp;course=$site->id\">$fullname</a>";
foreach ($extracolumns as $field) {
$row[] = $user->{$field};
}
$row[] = $user->city;
$row[] = $user->country;
$row[] = $strlastaccess;
$row[] = $editbutton;
$row[] = $deletebutton;
$row[] = $confirmbutton;
$table->data[] = $row;
}
}

Expand Down
20 changes: 13 additions & 7 deletions enrol/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ public function get_users($sort, $direction='ASC', $page=0, $perpage=25) {
$key = md5("$sort-$direction-$page-$perpage");
if (!array_key_exists($key, $this->users)) {
list($instancessql, $params, $filter) = $this->get_instance_sql();
$ufields = user_picture::fields('u', array('lastaccess', 'email'));
$extrafields = get_extra_user_fields($this->get_context());
$extrafields[] = 'lastaccess';
$ufields = user_picture::fields('u', $extrafields);
$sql = "SELECT DISTINCT $ufields, ul.timeaccess AS lastseen
FROM {user} u
JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid $instancessql)
Expand Down Expand Up @@ -279,10 +281,8 @@ public function get_potential_users($enrolid, $search='', $searchanywhere=false,
$tests = array("id <> :guestid", 'u.deleted = 0', 'u.confirmed = 1');
$params = array('guestid' => $CFG->siteguest);
if (!empty($search)) {
$conditions = array(
$DB->sql_concat('u.firstname', "' '", 'u.lastname'),
'u.email'
);
$conditions = get_extra_user_fields($this->get_context());
$conditions[] = $DB->sql_concat('u.firstname', "' '", 'u.lastname');
if ($searchanywhere) {
$searchparam = '%' . $search . '%';
} else {
Expand All @@ -298,7 +298,10 @@ public function get_potential_users($enrolid, $search='', $searchanywhere=false,
}
$wherecondition = implode(' AND ', $tests);

$ufields = user_picture::fields('u', array('username', 'lastaccess'));
$extrafields = get_extra_user_fields($this->get_context(), array('username', 'lastaccess'));
$extrafields[] = 'username';
$extrafields[] = 'lastaccess';
$ufields = user_picture::fields('u', $extrafields);

$fields = 'SELECT '.$ufields;
$countfields = 'SELECT COUNT(1)';
Expand Down Expand Up @@ -835,6 +838,7 @@ public function get_users_for_display(course_enrolment_manager $manager, $sort,
$canmanagegroups = has_capability('moodle/course:managegroups', $context);

$url = new moodle_url($pageurl, $this->get_url_params());
$extrafields = get_extra_user_fields($context);

$userdetails = array();
foreach ($users as $user) {
Expand All @@ -843,12 +847,14 @@ public function get_users_for_display(course_enrolment_manager $manager, $sort,
'courseid' => $courseid,
'picture' => new user_picture($user),
'firstname' => fullname($user, true),
'email' => $user->email,
'lastseen' => $strnever,
'roles' => array(),
'groups' => array(),
'enrolments' => array()
);
foreach ($extrafields as $field) {
$details[$field] = $user->{$field};
}

if ($user->lastaccess) {
$details['lastseen'] = format_time($now - $user->lastaccess);
Expand Down
7 changes: 7 additions & 0 deletions enrol/manual/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@
$search = optional_param('search', '', PARAM_RAW);
$page = optional_param('page', 0, PARAM_INT);
$outcome->response = $manager->get_potential_users($enrolid, $search, true, $page);
$extrafields = get_extra_user_fields($context);
foreach ($outcome->response['users'] as &$user) {
$user->picture = $OUTPUT->user_picture($user);
$user->fullname = fullname($user);
$fieldvalues = array();
foreach ($extrafields as $field) {
$fieldvalues[] = s($user->{$field});
unset($user->{$field});
}
$user->extrafields = implode(', ', $fieldvalues);
}
$outcome->success = true;
break;
Expand Down
4 changes: 2 additions & 2 deletions enrol/manual/yui/quickenrolment/quickenrolment.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
PICTURE : 'picture',
DETAILS : 'details',
FULLNAME : 'fullname',
EMAIL : 'email',
EXTRAFIELDS : 'extrafields',
OPTIONS : 'options',
ODD : 'odd',
EVEN : 'even',
Expand Down Expand Up @@ -344,7 +344,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
.append(create(user.picture)))
.append(create('<div class="'+CSS.DETAILS+'"></div>')
.append(create('<div class="'+CSS.FULLNAME+'">'+user.fullname+'</div>'))
.append(create('<div class="'+CSS.EMAIL+'">'+user.email+'</div>')))
.append(create('<div class="'+CSS.EXTRAFIELDS+'">'+user.extrafields+'</div>')))
.append(create('<div class="'+CSS.OPTIONS+'"></div>')
.append(create('<input type="button" class="'+CSS.ENROL+'" value="'+M.str.enrol.enrol+'" />')))
);
Expand Down
3 changes: 2 additions & 1 deletion enrol/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ class course_enrolment_table extends html_table implements renderable {
* @static
* @var array
*/
protected static $sortablefields = array('firstname', 'lastname', 'email');
protected static $sortablefields = array('firstname', 'lastname', 'idnumber', 'email',
'phone1', 'phone2', 'institution', 'department' );

/**
* Constructs the table
Expand Down
17 changes: 11 additions & 6 deletions enrol/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,18 @@


$renderer = $PAGE->get_renderer('core_enrol');
$userdetails = array (
'picture' => false,
'firstname' => get_string('firstname'),
'lastname' => get_string('lastname'),
);
$extrafields = get_extra_user_fields($context);
foreach ($extrafields as $field) {
$userdetails[$field] = get_user_field_name($field);
}

$fields = array(
'userdetails' => array (
'picture' => false,
'firstname' => get_string('firstname'),
'lastname' => get_string('lastname'),
'email' => get_string('email')
),
'userdetails' => $userdetails,
'lastseen' => get_string('lastaccess'),
'role' => get_string('roles', 'role'),
'group' => get_string('groups', 'group'),
Expand Down
Loading

0 comments on commit 8ac9d33

Please sign in to comment.