Browse Source

Acrescimo de algumas informações do certificado e melhorias no HTML

MOODLE_34_STABLE
Sesostris Vieira 11 years ago
parent
commit
a672ba3860
  1. 34
      block_verify_certificate.php
  2. 62
      index.php
  3. 2
      lang/de/block_verify_certificate.php
  4. 2
      lang/en/block_verify_certificate.php
  5. 2
      lang/pt_br/block_verify_certificate.php

34
block_verify_certificate.php

@ -9,27 +9,27 @@ class block_verify_certificate extends block_base {
function applicable_formats() { function applicable_formats() {
return array('all' => true); return array('all' => true);
} }
function get_content() { function get_content() {
if ($this->content !== NULL) { if ($this->content !== NULL) {
return $this->content; return $this->content;
} }
$this->content = new stdClass; $this->content = new stdClass;
$this->content->text = '<p>'.get_string('entercode', 'certificate').'</p>'; $this->content->text = '<p>'.get_string('entercode', 'certificate').'</p>';
$url = new moodle_url('/blocks/verify_certificate/index.php'); $url = new moodle_url('/blocks/verify_certificate/index.php');
$this->content->text .= '<center><form class="loginform" name="cert" method="post" action="'. $url . '">'; $this->content->text .= '<center><form class="loginform" name="cert" method="post" action="'. $url . '">';
$this->content->text .= '<input type="text" name="certnumber" id=name="certnumber" size="10" value="" />'; $this->content->text .= '<input type="text" name="certnumber" id="certnumber" size="10" value="" />';
$this->content->text .= '<input type="submit" value="'.get_string('validate', 'certificate').'"/></form>'; $this->content->text .= '<input type="submit" value="'.get_string('validate', 'certificate').'"/></form>';
$this->content->text .= '<center>'; $this->content->text .= '<center>';
$this->content->footer = ''; $this->content->footer = '';
return $this->content; return $this->content;
} }
function instance_allow_config() {
return false;
}
function instance_allow_config() {
return false;
}
} }
?>

62
index.php

@ -1,5 +1,6 @@
<?php <?php
require_once("../../config.php"); require_once("../../config.php");
require_once("$CFG->dirroot/enrol/locallib.php");
global $DB; global $DB;
@ -22,12 +23,13 @@ global $DB;
// Print results // Print results
echo $OUTPUT->box_start('generalbox boxaligncenter'); echo $OUTPUT->box_start('generalbox boxaligncenter');
if (!$issues = $DB->get_records('certificate_issues', array('code' => $code))) { if (!$issues = $DB->get_records('certificate_issues', array('code' => $code))) {
echo get_string('notfound', 'block_verify_certificate'); echo get_string('notfound', 'block_verify_certificate');
} else { } else {
echo "<a title=\""; print_string('printerfriendly', 'certificate'); echo '<a title="' . get_string('printerfriendly', 'certificate') . '" href="#" onclick="window.print()">';
echo "\" href=\"#\" onclick=\"window.print ()\"><div class=\"printicon\">"; echo '<div class="printicon">';
echo "<img src=\"print.gif\" height=\"16\" width=\"16\" border=\"0\"></img></a></div>"; echo '<img src="print.gif" height="16" width="16" border="0"/></a></div>';
/// Print Section /// Print Section
foreach ($issues as $issue) { foreach ($issues as $issue) {
if (!$certificate = $DB->get_record('certificate', array('id'=> $issue->certificateid))) { if (!$certificate = $DB->get_record('certificate', array('id'=> $issue->certificateid))) {
@ -39,16 +41,60 @@ global $DB;
if (!$user = $DB->get_record('user', array('id'=> $issue->userid))) { if (!$user = $DB->get_record('user', array('id'=> $issue->userid))) {
print_error('user is unreachable'); print_error('user is unreachable');
} }
$enrol_manager = new course_enrolment_manager($PAGE, $course);
$user_enrols = $enrol_manager->get_user_enrolments($user->id);
$start_date = 0;
$end_date = 0;
foreach ($user_enrols as $enrol) {
if ($enrol->timestart > 0) {
$start_date = $enrol->timestart;
}
if ($enrol->timeend > 0) {
$end_date = $enrol->timeend;
}
}
if (($start_date > 0 and $end_date > 0)) {
$fmt = '%d/%m/%Y'; // Default format
if ($certificate->datefmt == 1) {
$fmt = '%B %d, %Y';
$certificatedate = userdate($ts, '%B %d, %Y') . " a " . userdate($te, '%B %d, %Y');
} else if ($certificate->datefmt == 2) {
$suffix = certificate_get_ordinal_number_suffix(userdate($ts, '%d'));
$fmt = '%B %d' . $suffix . ', %Y';
$certificatedate = userdate($ts, '%B %d' . $suffix . ', %Y') . " a " . userdate($te, '%B %d' . $suffix . ', %Y');
} else if ($certificate->datefmt == 3) {
$fmt = '%d %B %Y';
$certificatedate = userdate($ts, '%d %B %Y') . " a " . userdate($te, '%d %B %Y');
} else if ($certificate->datefmt == 4) {
$fmt = '%B %Y';
$certificatedate = userdate($ts, '%B %Y') . " a " . userdate($te, '%B %Y');
} else if ($certificate->datefmt == 5) {
$fmt = get_string('strftimedate', 'langconfig');
$certificatedate = userdate($ts, get_string('strftimedate', 'langconfig')) . " a " . userdate($te, get_string('strftimedate', 'langconfig'));
}
$start_date = userdate($start_date, $fmt);
$end_date = userdate($end_date, $fmt);
} else {
$start_date = '';
$end_date = '';
}
$certificatedate = userdate($issue->timecreated); $certificatedate = userdate($issue->timecreated);
echo '<p>' . get_string('certificate', 'block_verify_certificate') . ' ' . $issue->code . '</p>'; echo '<p>' . get_string('certificate', 'block_verify_certificate') . " <strong>{$issue->code}</strong></p>";
echo '<p><b>' . get_string('to', 'block_verify_certificate') . ': </b>' . fullname($user) . '<br />'; echo '<p><strong>' . get_string('to', 'block_verify_certificate') . ': </strong>' . fullname($user) . '</p>';
echo '<p><b>' . get_string('course', 'block_verify_certificate') . ': </b>' . $course->fullname . '<br />'; echo '<p><strong>' . get_string('course', 'block_verify_certificate') . ": </strong>{$course->fullname}</p>";
echo '<p><b>' . get_string('date', 'block_verify_certificate') . ': </b>' . $certificatedate . '<br /></p>'; echo '<p><strong>' . get_string('date', 'block_verify_certificate') . ": </strong>$certificatedate</p>";
echo '<p><strong>' . get_string('enrol_period', 'block_verify_certificate') . ": </strong>$start_date - $end_date</p>";
if ($certificate->printhours) {
echo '<p><strong>' . get_string('printhours', 'block_verify_certificate') . ": </strong>{$certificate->printhours}</p>";
}
if ($certificate->customtext !== '') { if ($certificate->customtext !== '') {
echo '<p><b>' . get_string('customtext', 'block_verify_certificate') . ': </b><br/></p>'; echo '<p><strong>' . get_string('customtext', 'block_verify_certificate') . ':</strong></p>';
echo $certificate->customtext; echo $certificate->customtext;
} }
} }
} }
echo $OUTPUT->box_end(); echo $OUTPUT->box_end();
echo $OUTPUT->footer(); echo $OUTPUT->footer();

2
lang/de/block_verify_certificate.php

@ -9,3 +9,5 @@ $string['course'] = 'Kurs';
$string['date'] = 'Am'; $string['date'] = 'Am';
$string['grade'] = 'Bewertung'; $string['grade'] = 'Bewertung';
$string['customtext'] = 'Kurs details'; $string['customtext'] = 'Kurs details';
$string['enrol_period'] = 'Einschreiben Zeitraum';
$string['printhours'] = 'Stunden';

2
lang/en/block_verify_certificate.php

@ -9,3 +9,5 @@ $string['course'] = 'Course';
$string['date'] = 'On'; $string['date'] = 'On';
$string['grade'] = 'Grade'; $string['grade'] = 'Grade';
$string['customtext'] = 'Course details'; $string['customtext'] = 'Course details';
$string['enrol_period'] = 'Enroll period';
$string['printhours'] = 'Hours';

2
lang/pt_br/block_verify_certificate.php

@ -9,3 +9,5 @@ $string['course'] = 'Curso';
$string['date'] = 'Data'; $string['date'] = 'Data';
$string['grade'] = 'Nota'; $string['grade'] = 'Nota';
$string['customtext'] = 'Programa do curso'; $string['customtext'] = 'Programa do curso';
$string['enrol_period'] = 'Período de realização';
$string['printhours'] = 'Carga horária';

Loading…
Cancel
Save