$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!';
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)
$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.'&approve='.$record->id.'&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.'&approve='.$record->id.'&sesskey='.sesskey().'"><img src="'.$CFG->pixpath.'/i/approve.gif" class="icon" alt="'.get_string('approve').'" /></a>';
} else {
$replacement[] = '';
}
}
$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) {
} 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;
$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 {
$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 == 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";
+ if ($sort <= 0) {
+
+ 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';