From 5a44d1f4c70a0a78c0200962464ace291fa2d821 Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Wed, 30 Apr 2014 14:45:52 -0300 Subject: [PATCH] Initial commit --- block_get_certificate.php | 33 +++++++++++++++ index.php | 58 +++++++++++++++++++++++++++ lang/en/block_get_certificate.php | 9 +++++ lang/pt_br/block_get_certificate.php | 9 +++++ pix/print.gif | Bin 0 -> 411 bytes printstyle.css | 21 ++++++++++ version.php | 19 +++++++++ view.php | 37 +++++++++++++++++ 8 files changed, 186 insertions(+) create mode 100644 block_get_certificate.php create mode 100644 index.php create mode 100644 lang/en/block_get_certificate.php create mode 100644 lang/pt_br/block_get_certificate.php create mode 100644 pix/print.gif create mode 100644 printstyle.css create mode 100644 version.php create mode 100644 view.php diff --git a/block_get_certificate.php b/block_get_certificate.php new file mode 100644 index 0000000..96dd1a7 --- /dev/null +++ b/block_get_certificate.php @@ -0,0 +1,33 @@ +title = get_string('title', 'block_get_certificate'); + } + + function applicable_formats() { + return array('all' => true); + } + + function get_content() { + + if ($this->content !== NULL) { + return $this->content; + } + + $this->content = new stdClass; + $this->content->text = '

'.get_string('getcertificate', 'block_get_certificate').'

'; + $url = new moodle_url('/blocks/get_certificate/index.php'); + $this->content->text .= '
'; + $this->content->text .= '
'; + $this->content->text .= '
'; + $this->content->footer = ''; + + return $this->content; + } + + function instance_allow_config() { + return false; + } +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..3e01fe1 --- /dev/null +++ b/index.php @@ -0,0 +1,58 @@ +set_pagelayout('standard'); +$PAGE->set_url('/blocks/get_certificate/index.php'); +$PAGE->set_context($context); + +// Check if user is logged and not guest +require_login(); +if (isguestuser()) { + die(); +} + +// Get data +$strtitle = get_string('title', 'block_get_certificate'); +$user = $USER; +$icon = $OUTPUT->pix_icon('print', get_string('print', 'block_get_certificate'), 'block_get_certificate'); + +$issues = $DB->get_records('certificate_issues', array('userid' => $user->id)); +$data = array(); + +foreach ($issues as $issue) { + $certificate = $DB->get_record('certificate', array('id' => $issue->certificateid)); + $course = $DB->get_record('course', array('id' => $certificate->course)); + $cm = get_coursemodule_from_instance('certificate', $certificate->id); +// $link = html_writer::link(new moodle_url('/mod/certificate/review.php', array('id'=>$cm->id, 'action'=>'get')), $icon); + $url = new moodle_url('/mod/certificate/review.php', array('id'=>$cm->id, 'action'=>'get')); + $action = new popup_action('click', $url, 'view'.$cm->id, array('height' => 600, 'width' => 800)); + $link = new action_link($url, $icon, $action); + $line = array($issue->code, userdate($issue->timecreated), $course->fullname, $OUTPUT->render($link)); + $data[] = $line; +} + +// Print the header +$PAGE->navbar->add($strtitle); +$PAGE->set_title($strtitle); +$PAGE->set_heading($strtitle); +$PAGE->requires->css('/blocks/get_certificate/printstyle.css'); +echo $OUTPUT->header(); + +// Print concluded courses +echo $OUTPUT->box_start('generalbox boxaligncenter'); +echo $OUTPUT->heading(get_string('couselistannounce', 'block_get_certificate')); + +$table = new html_table(); +$table->align = array('left', 'left', 'left', 'center'); +$table->width = '100%'; +$table->head = array(get_string('code', 'certificate'), get_string('timecreated', 'block_get_certificate'), get_string('course'), get_string('print', 'block_get_certificate')); + +$table->data = $data; +echo html_writer::table($table); + +echo $OUTPUT->box_end(); +echo $OUTPUT->footer(); diff --git a/lang/en/block_get_certificate.php b/lang/en/block_get_certificate.php new file mode 100644 index 0000000..9d522bd --- /dev/null +++ b/lang/en/block_get_certificate.php @@ -0,0 +1,9 @@ +dWoB%}sY;0@~l=D+lUA4W|?e_g%d$xkV z;Y2zx-RARVf3L8xzFDHuD=jbJ+}{9j
Nn4`6fjFq*|>od6jPEJ!HAt_qJ|7K=p z|NsBR#l__A_>tZJ7#JL%zrfAY%9%qTpwS. + +$plugin->version = 2009072901; + diff --git a/view.php b/view.php new file mode 100644 index 0000000..5923a32 --- /dev/null +++ b/view.php @@ -0,0 +1,37 @@ +set_pagelayout('standard'); +$PAGE->set_url('/blocks/get_certificate/index.php'); +$PAGE->set_context($context); + +// Check if user is logged and not guest +require_login(); +if (isguestuser()) { + die(); +} + +// Get data +$user = $USER; +$issueid = required_param('id', PARAM_INT); +$issue = $DB->get_record('certificate_issues', array('id'=>$issueid)); + +// Check if user is the owner of the requested certificate + +if ($issue->userid !== $user->id) { + print_error(get_string('usernotowner', 'block_get_certificate')); + die; +} + +$strtitle = 'coisa'; +// Print the header +$PAGE->navbar->add($strtitle); +$PAGE->set_title($strtitle); +$PAGE->set_heading($strtitle); +$PAGE->requires->css('/blocks/get_certificate/printstyle.css'); +echo $OUTPUT->header(); +echo $OUTPUT->footer();