Skip to content

Commit

Permalink
data MDL-23488 made database activity respect availability and visibi…
Browse files Browse the repository at this point in the history
…lity dates

AMOS BEGIN
 CPY [expired,mod_choice],[expired,mod_data]
 CPY [notopenyet,mod_choice],[notopenyet,mod_data]
AMOS END
  • Loading branch information
Andrew Davis committed Jul 29, 2010
1 parent eb8d85c commit 2742ffe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mod/data/lang/en/data.php
Expand Up @@ -173,6 +173,7 @@
$string['chooseexportfields'] = 'Choose the fields you wish to export:';
$string['chooseexportformat'] = 'Choose the format you wish to export to:';
$string['chooseorupload'] = 'Choose file';
$string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available';
$string['importsuccess'] = 'The preset has been successfully applied.';
$string['insufficiententries'] = 'more entries needed to view this database';
$string['intro'] = 'Introduction';
Expand Down Expand Up @@ -242,6 +243,7 @@
$string['nosingletemplate'] = 'Single template is not yet defined';
$string['notapproved'] = 'Entry is not approved yet.';
$string['notinjectivemap'] = 'Not an injective map';
$string['notopenyet'] = 'Sorry, this activity is not available until {$a}';
$string['number'] = 'Number';
$string['numberrssarticles'] = 'RSS articles';
$string['numnotapproved'] = 'Pending';
Expand Down
6 changes: 6 additions & 0 deletions mod/data/lib.php
Expand Up @@ -1946,6 +1946,12 @@ function data_user_can_add_entry($data, $currentgroup, $groupmode) {
return false;
}

//if in the view only time window
$now = time();
if ($now>$data->timeviewfrom && $now<$data->timeviewto) {
return false;
}

if (!$groupmode or has_capability('moodle/site:accessallgroups', $context)) {
return true;
}
Expand Down
9 changes: 9 additions & 0 deletions mod/data/view.php
Expand Up @@ -368,6 +368,15 @@
}


//if data activity closed dont let students in
if (!has_capability('mod/data:manageentries', $context)) {
$timenow = time();
if (!empty($data->timeavailablefrom) && $data->timeavailablefrom > $timenow) {
print_error('notopenyet', 'data', null, userdate($data->timeavailablefrom));
} else if (!empty($data->timeavailableto) && $timenow > $data->timeavailableto) {
print_error('expired', 'data', null, userdate($data->timeavailableto));
}
}

/// Print the tabs

Expand Down

0 comments on commit 2742ffe

Please sign in to comment.