Skip to content

Commit 69545e0

Browse files
committed
Plugin customcertificate
1 parent d1b0414 commit 69545e0

28 files changed

+2477
-18
lines changed

certificates/index.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@
1010
$action = isset($_GET['action']) ? $_GET['action'] : null;
1111
$certificate = new Certificate($_GET['id']);
1212

13+
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true') {
14+
$infoCertificate = CustomCertificatePlugin::getCertificateData(intval($_GET['id']));
15+
if (!empty($infoCertificate)) {
16+
if ($certificate->user_id == api_get_user_id() && !empty($certificate->certificate_data)) {
17+
$certificateId = $certificate->certificate_data['id'];
18+
$extraFieldValue = new ExtraFieldValue('user_certificate');
19+
$value = $extraFieldValue->get_values_by_handler_and_field_variable(
20+
$certificateId,
21+
'downloaded_at'
22+
);
23+
if (empty($value)) {
24+
$params = [
25+
'item_id' => $certificate->certificate_data['id'],
26+
'extra_downloaded_at' => api_get_utc_datetime(),
27+
];
28+
$extraFieldValue->saveFieldValues($params);
29+
}
30+
}
31+
32+
$url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/print_certificate.php'.
33+
'?student_id='.$infoCertificate['user_id'].
34+
'&course_code='.$infoCertificate['course_code'].
35+
'&session_id='.$infoCertificate['session_id'];
36+
header('Location: '.$url);
37+
exit;
38+
}
39+
}
40+
1341
switch ($action) {
1442
case 'export':
1543
$hideExportLink = api_get_setting('hide_certificate_export_link');

main/gradebook/gradebook_display_certificate.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,24 @@ function confirmation() {
128128
$content = $form->returnForm();
129129
break;
130130
case 'export_all_certificates':
131-
if (api_is_student_boss()) {
132-
$userGroup = new UserGroup();
133-
$userList = $userGroup->getGroupUsersByUser(api_get_user_id());
131+
$courseCode = api_get_course_id();
132+
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' &&
133+
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 )
134+
{
135+
$url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/print_certificate.php?export_all=1';
134136
} else {
135-
$userList = [];
136-
if (!empty($filterOfficialCodeGet)) {
137-
$userList = UserManager::getUsersByOfficialCode($filterOfficialCodeGet);
137+
if (api_is_student_boss()) {
138+
$userGroup = new UserGroup();
139+
$userList = $userGroup->getGroupUsersByUser(api_get_user_id());
140+
} else {
141+
$userList = [];
142+
if (!empty($filterOfficialCodeGet)) {
143+
$userList = UserManager::getUsersByOfficialCode($filterOfficialCodeGet);
144+
}
138145
}
146+
147+
Category::exportAllCertificates($categoryId, $userList);
139148
}
140-
141-
Category::exportAllCertificates($categoryId, $userList);
142149
header('Location: '.$url);
143150
exit;
144151
break;

main/gradebook/lib/fe/displaygradebook.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,17 @@ public static function header(
463463
// Right icons
464464
$actionsRight = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'.
465465
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
466-
$actionsRight .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat='.$catobj->get_id().'">'.
466+
$courseCode = api_get_course_id();
467+
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' &&
468+
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 )
469+
{
470+
$actionsRight .= '<a href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/index.php?'.$my_api_cidreq.'&origin=gradebook&selectcat='.$catobj->get_id().'">'.
467471
Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM).'</a>';
468-
472+
} else {
473+
$actionsRight .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat='.$catobj->get_id().'">'.
474+
Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM).'</a>';
475+
}
476+
469477
if (empty($categories)) {
470478
$actionsRight .= '<a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
471479
Display::return_icon('percentage.png', get_lang('EditAllWeights'), '', ICON_SIZE_MEDIUM).'</a>';

main/img/customcertificate.png

843 Bytes
Loading
843 Bytes
Loading
2.8 KB
Loading
2.96 KB
Loading

main/inc/lib/pdf.lib.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,17 @@ public function html_to_pdf(
344344
/**
345345
* Converts an html string to PDF.
346346
*
347-
* @param string $document_html valid html
348-
* @param string $css CSS content of a CSS file
349-
* @param string $pdf_name pdf name
350-
* @param string $course_code course code
351-
* (if you are using html that are located in the document tool you must provide this)
352-
* @param string $outputMode the MPDF output mode can be:
347+
* @param string $document_html valid html
348+
* @param string $css CSS content of a CSS file
349+
* @param string $pdf_name pdf name
350+
* @param string $course_code course code
351+
* (if you are using html that are located in the document tool you must provide this)
352+
* @param string $outputMode the MPDF output mode can be:
353353
* @param bool $saveInFile
354354
* @param string $fileToSave
355355
* @param bool $returnHtml
356356
* @param bool $addDefaultCss
357+
* @param bool $completeHeader
357358
*
358359
* 'I' (print on standard output),
359360
* 'D' (download file) (this is the default value),
@@ -371,7 +372,8 @@ public function content_to_pdf(
371372
$saveInFile = false,
372373
$fileToSave = null,
373374
$returnHtml = false,
374-
$addDefaultCss = false
375+
$addDefaultCss = false,
376+
$completeHeader = true
375377
) {
376378
$urlAppend = api_get_configuration_value('url_append');
377379

@@ -388,7 +390,7 @@ public function content_to_pdf(
388390
// Formatting the pdf
389391
$course_data = api_get_course_info($course_code);
390392

391-
self::format_pdf($course_data);
393+
self::format_pdf($course_data, $completeHeader);
392394

393395
$document_html = preg_replace($clean_search, '', $document_html);
394396

plugin/customcertificate/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CustomCertificate plugin
2+
===============
3+
Este plugin da la posibilidad al administrador de disponer de una herramienta de certificados alternativa
4+
a la que tiene por defecto la plataforma Chamilo.
5+
6+
**Instrucciones de puesta en funcionamiento**
7+
8+
- Subir la carpeta **customcertificate** a la carpeta plugin de chamilo.
9+
- Habilitar el plugin en la administraci&oacute;n de Chamilo.
10+
- Indicar 'menu_administrator' en la configuración de la región del plugin.
11+
12+
**accesos a la herramienta**
13+
14+
- Desde la pantalla de Administración para configurar el certificado por defecto.
15+
- Desde las herramientas del curso, para la configuración del diploma especifico.
16+
17+
**Importante a tener en cuenta**
18+
19+
Por defecto los certificados utilizados serán los de la plataforma chamilo. Para habilitar el certificado alternativo
20+
en un curso se debe entrar en la configuración del curso y habilitar en la pestaña de "certificados personalizado" la
21+
casilla de verificación de "Habilitar en el curso el certificado alternativo".
22+
Si se desea usar el certificado por defecto se deberá mostrar la segunda casilla de verificación.
23+
24+
**Problema visualización icono de herramienta**
25+
26+
El icono de la herramienta aparecer&aacute; en pantalla de los cursos con el resto de herramientas
27+
Si no se visualiza el icono en el cursos correctamente y sale el icono de plugin gen&eacute;rico:
28+
- Copiar los iconos de la carpeta resources/img/64 dentro de /main/img/icons/64
29+
- Copiar el icono de la carpeta resources/img/22 dentro de /main/img
30+
31+
Credits
32+
-------
33+
Contributed by [Nosolored](https://www.nosolored.com/).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/* For licensing terms, see /license.txt */
3+
/**
4+
* Config the plugin.
5+
*
6+
* @package chamilo.plugin.customcertificate
7+
*
8+
* @author Jose Angel Ruiz <desarrollo@nosolored.com>
9+
*/
10+
require_once __DIR__.'/../../main/inc/global.inc.php';

0 commit comments

Comments
 (0)