From 121945ad0211d4598b0d30084b80c42ca875f776 Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Mon, 12 May 2014 20:58:48 -0300 Subject: [PATCH] =?UTF-8?q?Op=C3=A7=C3=A3o=20de=20imprimir=20campos=20de?= =?UTF-8?q?=20perfil=20na=20valida=C3=A7=C3=A3o=20do=20certificado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- block_verify_certificate.php | 10 ++++++++-- index.php | 14 +++++++++++++- lang/de/block_verify_certificate.php | 2 ++ lang/en/block_verify_certificate.php | 2 ++ lang/pt_br/block_verify_certificate.php | 2 ++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/block_verify_certificate.php b/block_verify_certificate.php index ff28d38..1474807 100644 --- a/block_verify_certificate.php +++ b/block_verify_certificate.php @@ -11,10 +11,10 @@ class block_verify_certificate extends block_base { } function get_content() { - if ($this->content !== NULL) { return $this->content; } + $fieldid = implode(',', $this->config->fieldid); $this->content = new stdClass; $this->content->text = '

'.get_string('entercode', 'certificate').'

'; @@ -22,6 +22,7 @@ class block_verify_certificate extends block_base { $this->content->text .= '
'; $this->content->text .= ''; + $this->content->text .= ""; $this->content->text .= '
'; $this->content->text .= '
'; $this->content->footer = ''; @@ -29,7 +30,12 @@ class block_verify_certificate extends block_base { return $this->content; } +/* function has_config() { + return true; + } +*/ + function instance_allow_config() { - return false; + return true; } } diff --git a/index.php b/index.php index 19b6f9c..d1575b0 100644 --- a/index.php +++ b/index.php @@ -1,14 +1,19 @@ dirroot/enrol/locallib.php"); +require_once("$CFG->libdir/blocklib.php"); +require_once("$CFG->dirroot/user/profile/lib.php"); global $DB; $code = required_param('certnumber', PARAM_ALPHANUM); // certificate code to verify + $fieldid = required_param('list', PARAM_SEQUENCE); + $fieldid = explode(',', $fieldid); + $profile_fields = $DB->get_records_list('user_info_field', 'id', $fieldid); $PAGE->set_pagelayout('standard'); $strverify = get_string('verifycertificate', 'block_verify_certificate'); - $PAGE->set_url('/blocks/verify_certificate/index.php', array('certnumber' => $id)); + $PAGE->set_url('/blocks/verify_certificate/index.php', array('certnumber' => $code)); $context = get_context_instance(CONTEXT_SYSTEM); $PAGE->set_context($context); @@ -42,6 +47,8 @@ global $DB; print_error('user is unreachable'); } + profile_load_data($user); + $enrol_manager = new course_enrolment_manager($PAGE, $course); $user_enrols = $enrol_manager->get_user_enrolments($user->id); $start_date = 0; @@ -83,6 +90,11 @@ global $DB; $certificatedate = userdate($issue->timecreated); echo '

' . get_string('certificate', 'block_verify_certificate') . " {$issue->code}

"; echo '

' . get_string('to', 'block_verify_certificate') . ': ' . fullname($user) . '

'; + foreach ($profile_fields as $field) { + $fieldname = "profile_field_{$field->shortname}"; + $fieldvalue = $user->$fieldname; + echo "

{$field->name}: {$fieldvalue}"; + } echo '

' . get_string('course', 'block_verify_certificate') . ": {$course->fullname}

"; echo '

' . get_string('date', 'block_verify_certificate') . ": $certificatedate

"; echo '

' . get_string('enrol_period', 'block_verify_certificate') . ": $start_date - $end_date

"; diff --git a/lang/de/block_verify_certificate.php b/lang/de/block_verify_certificate.php index 81dec6c..378b1cd 100644 --- a/lang/de/block_verify_certificate.php +++ b/lang/de/block_verify_certificate.php @@ -11,3 +11,5 @@ $string['grade'] = 'Bewertung'; $string['customtext'] = 'Kurs details'; $string['enrol_period'] = 'Einschreiben Zeitraum'; $string['printhours'] = 'Stunden'; +$string['chooseprofilefields'] = 'Wählen Sie Profilfelder angezeigt'; +$string['nofields'] = 'Kein ProfilFeld definiert'; diff --git a/lang/en/block_verify_certificate.php b/lang/en/block_verify_certificate.php index 1d055b5..9c1c5b7 100644 --- a/lang/en/block_verify_certificate.php +++ b/lang/en/block_verify_certificate.php @@ -11,3 +11,5 @@ $string['grade'] = 'Grade'; $string['customtext'] = 'Course details'; $string['enrol_period'] = 'Enroll period'; $string['printhours'] = 'Hours'; +$string['chooseprofilefields'] = 'Choose profilefields to display'; +$string['nofields'] = 'No profilefields defined'; diff --git a/lang/pt_br/block_verify_certificate.php b/lang/pt_br/block_verify_certificate.php index c3d80ac..bab77d5 100644 --- a/lang/pt_br/block_verify_certificate.php +++ b/lang/pt_br/block_verify_certificate.php @@ -11,3 +11,5 @@ $string['grade'] = 'Nota'; $string['customtext'] = 'Programa do curso'; $string['enrol_period'] = 'Período de realização'; $string['printhours'] = 'Carga horária'; +$string['chooseprofilefields'] = 'Escolha os campos de perfil para mostrar'; +$string['nofields'] = 'Nenhum campo de perfil definido';