Browse Source

Merge pull request #211 from antonio-c-mariani/users_sort_order

Changing default users sort order to users_order_by_sql moodle function
MOODLE_31_STABLE
Dan Marsden 9 years ago
committed by GitHub
parent
commit
463bb8b264
  1. 4
      classes/report_page_params.php
  2. 11
      classes/structure.php
  3. 4
      classes/take_page_params.php
  4. 1
      locallib.php
  5. 9
      renderer.php
  6. 2
      report.php
  7. 2
      take.php

4
classes/report_page_params.php

@ -43,14 +43,14 @@ class mod_attendance_report_page_params extends mod_attendance_page_with_filter_
$this->group = $this->get_current_sesstype() > 0 ? $this->get_current_sesstype() : 0; $this->group = $this->get_current_sesstype() > 0 ? $this->get_current_sesstype() : 0;
} }
if (!isset($this->sort)) { if (!isset($this->sort)) {
$this->sort = ATT_SORT_LASTNAME; $this->sort = ATT_SORT_DEFAULT;
} }
} }
public function get_significant_params() { public function get_significant_params() {
$params = array(); $params = array();
if ($this->sort != ATT_SORT_LASTNAME) { if ($this->sort != ATT_SORT_DEFAULT) {
$params['sort'] = $this->sort; $params['sort'] = $this->sort;
} }

11
classes/structure.php

@ -549,10 +549,15 @@ class mod_attendance_structure {
// Fields we need from the user table. // Fields we need from the user table.
$userfields = user_picture::fields('u', array('username' , 'idnumber' , 'institution' , 'department')); $userfields = user_picture::fields('u', array('username' , 'idnumber' , 'institution' , 'department'));
if (isset($this->pageparams->sort) and ($this->pageparams->sort == ATT_SORT_FIRSTNAME)) { if (empty($this->pageparams->sort)) {
$orderby = "u.firstname ASC, u.lastname ASC, u.idnumber ASC, u.institution ASC, u.department ASC"; $this->pageparams->sort = ATT_SORT_DEFAULT;
}
if ($this->pageparams->sort == ATT_SORT_FIRSTNAME) {
$orderby = $DB->sql_fullname('u.firstname', 'u.lastname') . ', u.id';
} else if ($this->pageparams->sort == ATT_SORT_LASTNAME) {
$orderby = 'u.lastname, u.firstname, u.id';
} else { } else {
$orderby = "u.lastname ASC, u.firstname ASC, u.idnumber ASC, u.institution ASC, u.department ASC"; list($orderby, $sortparams) = users_order_by_sql('u');
} }
if ($page) { if ($page) {

4
classes/take_page_params.php

@ -50,7 +50,7 @@ class mod_attendance_take_page_params {
$this->group = 0; $this->group = 0;
} }
if (!isset($this->sort)) { if (!isset($this->sort)) {
$this->sort = ATT_SORT_LASTNAME; $this->sort = ATT_SORT_DEFAULT;
} }
$this->init_view_mode(); $this->init_view_mode();
$this->init_gridcols(); $this->init_gridcols();
@ -80,7 +80,7 @@ class mod_attendance_take_page_params {
if ($this->group) { if ($this->group) {
$params['group'] = $this->group; $params['group'] = $this->group;
} }
if ($this->sort != ATT_SORT_LASTNAME) { if ($this->sort != ATT_SORT_DEFAULT) {
$params['sort'] = $this->sort; $params['sort'] = $this->sort;
} }
if (isset($this->copyfrom)) { if (isset($this->copyfrom)) {

1
locallib.php

@ -35,6 +35,7 @@ define('ATT_VIEW_ALL', 5);
define('ATT_VIEW_NOTPRESENT', 6); define('ATT_VIEW_NOTPRESENT', 6);
define('ATT_VIEW_SUMMARY', 7); define('ATT_VIEW_SUMMARY', 7);
define('ATT_SORT_DEFAULT', 0);
define('ATT_SORT_LASTNAME', 1); define('ATT_SORT_LASTNAME', 1);
define('ATT_SORT_FIRSTNAME', 2); define('ATT_SORT_FIRSTNAME', 2);

9
renderer.php

@ -624,14 +624,13 @@ class mod_attendance_renderer extends plugin_renderer_base {
if ($data->pageparams->sort == ATT_SORT_LASTNAME) { if ($data->pageparams->sort == ATT_SORT_LASTNAME) {
$firstname = html_writer::link($data->url(array('sort' => ATT_SORT_FIRSTNAME)), get_string('firstname')); $firstname = html_writer::link($data->url(array('sort' => ATT_SORT_FIRSTNAME)), get_string('firstname'));
} else { $lastname = get_string('lastname');
} else if ($data->pageparams->sort == ATT_SORT_FIRSTNAME) {
$firstname = get_string('firstname'); $firstname = get_string('firstname');
}
if ($data->pageparams->sort == ATT_SORT_FIRSTNAME) {
$lastname = html_writer::link($data->url(array('sort' => ATT_SORT_LASTNAME)), get_string('lastname')); $lastname = html_writer::link($data->url(array('sort' => ATT_SORT_LASTNAME)), get_string('lastname'));
} else { } else {
$lastname = get_string('lastname'); $firstname = html_writer::link($data->url(array('sort' => ATT_SORT_FIRSTNAME)), get_string('firstname'));
$lastname = html_writer::link($data->url(array('sort' => ATT_SORT_LASTNAME)), get_string('lastname'));
} }
if ($CFG->fullnamedisplay == 'lastname firstname') { if ($CFG->fullnamedisplay == 'lastname firstname') {

2
report.php

@ -32,7 +32,7 @@ $from = optional_param('from', null, PARAM_ACTION);
$pageparams->view = optional_param('view', null, PARAM_INT); $pageparams->view = optional_param('view', null, PARAM_INT);
$pageparams->curdate = optional_param('curdate', null, PARAM_INT); $pageparams->curdate = optional_param('curdate', null, PARAM_INT);
$pageparams->group = optional_param('group', null, PARAM_INT); $pageparams->group = optional_param('group', null, PARAM_INT);
$pageparams->sort = optional_param('sort', null, PARAM_INT); $pageparams->sort = optional_param('sort', ATT_SORT_DEFAULT, PARAM_INT);
$pageparams->page = optional_param('page', 1, PARAM_INT); $pageparams->page = optional_param('page', 1, PARAM_INT);
$pageparams->perpage = get_config('attendance', 'resultsperpage'); $pageparams->perpage = get_config('attendance', 'resultsperpage');

2
take.php

@ -30,7 +30,7 @@ $pageparams = new mod_attendance_take_page_params();
$id = required_param('id', PARAM_INT); $id = required_param('id', PARAM_INT);
$pageparams->sessionid = required_param('sessionid', PARAM_INT); $pageparams->sessionid = required_param('sessionid', PARAM_INT);
$pageparams->grouptype = required_param('grouptype', PARAM_INT); $pageparams->grouptype = required_param('grouptype', PARAM_INT);
$pageparams->sort = optional_param('sort', null, PARAM_INT); $pageparams->sort = optional_param('sort', ATT_SORT_DEFAULT, PARAM_INT);
$pageparams->copyfrom = optional_param('copyfrom', null, PARAM_INT); $pageparams->copyfrom = optional_param('copyfrom', null, PARAM_INT);
$pageparams->viewmode = optional_param('viewmode', null, PARAM_INT); $pageparams->viewmode = optional_param('viewmode', null, PARAM_INT);
$pageparams->gridcols = optional_param('gridcols', null, PARAM_INT); $pageparams->gridcols = optional_param('gridcols', null, PARAM_INT);

Loading…
Cancel
Save