MDL-14424 - approval icon is bigger again, it is possible to sort by Approved status now; merged from MOODLE_19_STABLE

This commit is contained in:
skodak
2008-04-19 20:48:48 +00:00
parent 33b8ead904
commit bb5740f4c8
3 changed files with 24 additions and 12 deletions
+1
View File
@@ -13,6 +13,7 @@ $string['allowcomments'] = 'Allow comments?';
$string['allowratings'] = 'Allow posts to be rated?';
$string['alttext'] = 'Alternative text';
$string['approve'] = 'Approve';
$string['approved'] = 'Approved';
$string['ascending'] = 'Ascending';
$string['asearchtemplate'] = 'Advanced search template';
$string['atmaxentry'] = 'You have entered the maximum number of entries allowed!';
+5 -1
View File
@@ -28,6 +28,7 @@ define ('DATA_PERPAGE_SINGLE', 1);
define ('DATA_FIRSTNAME', -1);
define ('DATA_LASTNAME', -2);
define ('DATA_APPROVED', -3);
class data_field_base { /// Base class for Database Field Types (see field/*/field.class.php)
@@ -981,7 +982,7 @@ function data_print_template($template, $records, $data, $search='',$page=0, $re
$patterns[]='##approve##';
if (has_capability('mod/data:approve', $context) && ($data->approval) && (!$record->approved)){
$replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;approve='.$record->id.'&amp;sesskey='.sesskey().'"><img src="'.$CFG->pixpath.'/i/approve.gif" class="iconsmall" alt="'.get_string('approve').'" /></a>';
$replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;approve='.$record->id.'&amp;sesskey='.sesskey().'"><img src="'.$CFG->pixpath.'/i/approve.gif" class="icon" alt="'.get_string('approve').'" /></a>';
} else {
$replacement[] = '';
}
@@ -1070,6 +1071,9 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order='
}
$options[DATA_FIRSTNAME] = get_string('authorfirstname', 'data');
$options[DATA_LASTNAME] = get_string('authorlastname', 'data');
if ($data->approval and has_capability('mod/data:approve', $context)) {
$options[DATA_APPROVED] = get_string('approved', 'data');
}
echo '<select name="sort" id="pref_sortby"><option value="0">'.get_string('dateentered','data').'</option>';
foreach ($options as $key => $name) {
if ($key == $sort) {
+18 -11
View File
@@ -369,7 +369,9 @@
} else {
/// Approve any requested records
if ($approve && confirm_sesskey() && has_capability('mod/data:approve', $context)) {
$approvecap = has_capability('mod/data:approve', $context);
if ($approve && confirm_sesskey() && $approvecap) {
if ($approverecord = get_record('data_records', 'id', $approve)) { // Need to check this is valid
if ($approverecord->dataid == $data->id) { // Must be from this database
$newrecord->id = $approverecord->id;
@@ -391,9 +393,8 @@
$requiredentries_allowed = false;
}
/// We need to examine the whole dataset to produce the correct paging
if ((!has_capability('mod/data:managetemplates', $context)) && ($data->approval)) {
/// setup group and approve restrictions
if (!$approvecap && $data->approval) {
if (isloggedin()) {
$approveselect = ' AND (r.approved=1 OR r.userid='.$USER->id.') ';
} else {
@@ -412,14 +413,20 @@
$ilike = sql_ilike(); //Be case-insensitive
/// Find the field we are sorting on
if ($sort == DATA_FIRSTNAME or $sort == DATA_LASTNAME or empty($sort)) {
if ($sort <= 0) {
if ($sort == DATA_LASTNAME) {
$ordering = "u.lastname $order, u.firstname $order";
} else if ($sort == DATA_FIRSTNAME) {
$ordering = "u.firstname $order, u.lastname $order";
} else {
$ordering = "r.timecreated $order";
switch ($sort) {
case DATA_LASTNAME:
$ordering = "u.lastname $order, u.firstname $order";
break;
case DATA_FIRSTNAME:
$ordering = "u.firstname $order, u.lastname $order";
break;
case DATA_APPROVED:
$ordering = "r.approved $order, r.timecreated $order";
break;
default:
$ordering = "r.timecreated $order";
}
$what = ' DISTINCT r.id, r.approved, r.timecreated, r.timemodified, r.userid, u.firstname, u.lastname';