Removed 'File' column when downloading report

This commit is contained in:
Mark Nelson 2016-08-24 17:06:45 +08:00
parent 787746e4a8
commit e4db1591dd
2 changed files with 24 additions and 12 deletions

View file

@ -60,22 +60,34 @@ class report_table extends \table_sql {
* @param int $customcertid
* @param \stdClass $cm the course module
* @param bool $groupmode are we in group mode?
* @param string|null $download The file type, null if we are not downloading
*/
public function __construct($customcertid, $cm, $groupmode) {
public function __construct($customcertid, $cm, $groupmode, $download = null) {
parent::__construct('mod_customcert_report_table');
$this->define_columns(array(
$columns = array(
'fullname',
'timecreated',
'code',
'download'
));
$this->define_headers(array(
'code'
);
$headers = array(
get_string('fullname'),
get_string('receiveddate', 'customcert'),
get_string('code', 'customcert'),
get_string('file')
));
get_string('code', 'customcert')
);
// Check if we were passed a filename, which means we want to download it.
if ($download) {
$this->is_downloading($download, 'customcert-report');
}
if (!$this->is_downloading()) {
$columns[] = 'download';
$headers[] = get_string('file');
}
$this->define_columns($columns);
$this->define_headers($headers);
$this->collapsible(false);
$this->sortable(true);
$this->no_sorting('code');

View file

@ -25,7 +25,7 @@
require_once('../../config.php');
$id = required_param('id', PARAM_INT);
$download = optional_param('download', '', PARAM_ALPHA);
$download = optional_param('download', null, PARAM_ALPHA);
$downloadcert = optional_param('downloadcert', '', PARAM_BOOL);
if ($downloadcert) {
$userid = required_param('userid', PARAM_INT);
@ -59,10 +59,10 @@ if ($groupmode = groups_get_activity_groupmode($cm)) {
groups_get_activity_group($cm, true);
}
$table = new \mod_customcert\report_table($customcert->id, $cm, $groupmode);
$table = new \mod_customcert\report_table($customcert->id, $cm, $groupmode, $download);
$table->define_baseurl($pageurl);
if ($table->is_downloading($download, 'customcert-report')) {
if ($table->is_downloading()) {
$table->download();
exit();
}