Browse Source

Initial commit

MOODLE_29_STABLE
Sesostris Vieira 11 years ago
parent
commit
5a44d1f4c7
  1. 33
      block_get_certificate.php
  2. 58
      index.php
  3. 9
      lang/en/block_get_certificate.php
  4. 9
      lang/pt_br/block_get_certificate.php
  5. BIN
      pix/print.gif
  6. 21
      printstyle.css
  7. 19
      version.php
  8. 37
      view.php

33
block_get_certificate.php

@ -0,0 +1,33 @@
<?php //Updated for use with Certificate v3+ Chardelle Busch
class block_get_certificate extends block_base {
function init() {
$this->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 = '<p>'.get_string('getcertificate', 'block_get_certificate').'</p>';
$url = new moodle_url('/blocks/get_certificate/index.php');
$this->content->text .= '<center><form class="loginform" name="cert" method="post" action="'. $url . '">';
$this->content->text .= '<input type="submit" value="'.get_string('getbutton', 'block_get_certificate').'"/></form>';
$this->content->text .= '</center>';
$this->content->footer = '';
return $this->content;
}
function instance_allow_config() {
return false;
}
}

58
index.php

@ -0,0 +1,58 @@
<?php
require_once("../../config.php");
global $DB;
// Prepare page
$context = get_context_instance(CONTEXT_SYSTEM);
$PAGE->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();

9
lang/en/block_get_certificate.php

@ -0,0 +1,9 @@
<?php
$string['title'] = 'Get Certificates';
$string['pluginname'] = 'Get Certificate';
$string['getcertificate'] = "To get certificates of completed courses, click at 'Get certificates' button bellow.";
$string['getbutton'] = 'Get certificates';
$string['couselistannounce'] = 'List of courses with avaiable certificate.';
$string['timecreated'] = 'Date/hour of printing';
$string['print'] = 'Print';
$string['usernotowner'] = 'The requested certificate does not belong to you. It is not allowed to print certificates to another user.';

9
lang/pt_br/block_get_certificate.php

@ -0,0 +1,9 @@
<?php
$string['title'] = 'Obter Certificados';
$string['pluginname'] = 'Obter Certificados';
$string['getcertificate'] = "Para obter o certificado de cursos já concluídos, clique no botão 'Obter certificados' abaixo";
$string['getbutton'] = 'Obter certificados';
$string['couselistannounce'] = 'Lista dos cursos com certificado disponível.';
$string['timecreated'] = 'Data/hora de emissão';
$string['print'] = 'Imprimir';
$string['usernotowner'] = 'O certificado solicitado não pertence a você. Não é permitido que terceiros emitam o certificado de outros alunos.';

BIN
pix/print.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

21
printstyle.css

@ -0,0 +1,21 @@
@media print {
body {
background:#FFFFFF;
}
#header, #header-home {
display: none;
}
#footer {
display: none;
}
.navbar {
display:none;
}
.printicon {
display:none;
}
}

19
version.php

@ -0,0 +1,19 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
$plugin->version = 2009072901;

37
view.php

@ -0,0 +1,37 @@
<?php
require_once("../../config.php");
global $DB;
// Prepare page
$context = get_context_instance(CONTEXT_SYSTEM);
$PAGE->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();
Loading…
Cancel
Save