After Width: | Height: | Size: 843 B |
After Width: | Height: | Size: 843 B |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.0 KiB |
@ -0,0 +1,33 @@ |
||||
CustomCertificate plugin |
||||
=============== |
||||
Este plugin da la posibilidad al administrador de disponer de una herramienta de certificados alternativa |
||||
a la que tiene por defecto la plataforma Chamilo. |
||||
|
||||
**Instrucciones de puesta en funcionamiento** |
||||
|
||||
- Subir la carpeta **customcertificate** a la carpeta plugin de chamilo. |
||||
- Habilitar el plugin en la administración de Chamilo. |
||||
- Indicar 'menu_administrator' en la configuración de la región del plugin. |
||||
|
||||
**accesos a la herramienta** |
||||
|
||||
- Desde la pantalla de Administración para configurar el certificado por defecto. |
||||
- Desde las herramientas del curso, para la configuración del diploma especifico. |
||||
|
||||
**Importante a tener en cuenta** |
||||
|
||||
Por defecto los certificados utilizados serán los de la plataforma chamilo. Para habilitar el certificado alternativo |
||||
en un curso se debe entrar en la configuración del curso y habilitar en la pestaña de "certificados personalizado" la |
||||
casilla de verificación de "Habilitar en el curso el certificado alternativo". |
||||
Si se desea usar el certificado por defecto se deberá mostrar la segunda casilla de verificación. |
||||
|
||||
**Problema visualización icono de herramienta** |
||||
|
||||
El icono de la herramienta aparecerá en pantalla de los cursos con el resto de herramientas |
||||
Si no se visualiza el icono en el cursos correctamente y sale el icono de plugin genérico: |
||||
- Copiar los iconos de la carpeta resources/img/64 dentro de /main/img/icons/64 |
||||
- Copiar el icono de la carpeta resources/img/22 dentro de /main/img |
||||
|
||||
Credits |
||||
------- |
||||
Contributed by [Nosolored](https://www.nosolored.com/). |
@ -0,0 +1,10 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
* |
||||
* @author Jose Angel Ruiz <desarrollo@nosolored.com> |
||||
*/ |
||||
require_once __DIR__.'/../../main/inc/global.inc.php'; |
@ -0,0 +1,66 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Plugin database installation script. Can only be executed if included |
||||
* inside another script loading global.inc.php. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
/** |
||||
* Check if script can be called. |
||||
*/ |
||||
if (!function_exists('api_get_path')) { |
||||
die('This script must be loaded through the Chamilo plugin installer sequence'); |
||||
} |
||||
|
||||
$entityManager = Database::getManager(); |
||||
$pluginSchema = new \Doctrine\DBAL\Schema\Schema(); |
||||
$connection = $entityManager->getConnection(); |
||||
$platform = $connection->getDatabasePlatform(); |
||||
|
||||
if ($pluginSchema->hasTable(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE)) { |
||||
return; |
||||
} |
||||
|
||||
//Create tables |
||||
$certificateTable = $pluginSchema->createTable(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE); |
||||
$certificateTable->addColumn('id', \Doctrine\DBAL\Types\Type::INTEGER, ['autoincrement' => true, 'unsigned' => true]); |
||||
$certificateTable->addColumn('access_url_id', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('c_id', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('session_id', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('content_course', \Doctrine\DBAL\Types\Type::TEXT); |
||||
$certificateTable->addColumn('contents_type', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('contents', \Doctrine\DBAL\Types\Type::TEXT); |
||||
$certificateTable->addColumn('date_change', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('date_start', \Doctrine\DBAL\Types\Type::DATETIME); |
||||
$certificateTable->addColumn('date_end', \Doctrine\DBAL\Types\Type::DATETIME); |
||||
$certificateTable->addColumn('type_date_expediction', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('place', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('day', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('month', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('year', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('logo_left', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('logo_center', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('logo_right', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('seal', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('signature1', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('signature2', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('signature3', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('signature4', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('signature_text1', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('signature_text2', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('signature_text3', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('signature_text4', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('background', \Doctrine\DBAL\Types\Type::STRING); |
||||
$certificateTable->addColumn('margin_left', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('margin_right', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('certificate_default', \Doctrine\DBAL\Types\Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addIndex(['c_id', 'session_id']); |
||||
$certificateTable->setPrimaryKey(['id']); |
||||
|
||||
$queries = $pluginSchema->toSql($platform); |
||||
|
||||
foreach ($queries as $query) { |
||||
Database::query($query); |
||||
} |
@ -0,0 +1,3 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
require_once 'config.php'; |
@ -0,0 +1,15 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* This script is included by main/admin/settings.lib.php and generally |
||||
* includes things to execute in the main database (settings_current table). |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
require_once __DIR__.'/config.php'; |
||||
|
||||
if (!api_is_platform_admin()) { |
||||
die('You must have admin permissions to install plugins'); |
||||
} |
||||
|
||||
CustomCertificatePlugin::create()->install(); |
@ -0,0 +1,69 @@ |
||||
<?php |
||||
$strings['plugin_title'] = "Custom certificate"; |
||||
$strings['plugin_comment'] = "This plugin allows you to create custom certificates for each course."; |
||||
$strings['enable_plugin_customcertificate'] = "Enable plugin"; |
||||
$strings['customcertificate_course_enable'] = "Custom certificate enable in course"; |
||||
$strings['use_certificate_default'] = "Use default custom certificate"; |
||||
$strings['ToolDisabled'] = "The tool is disabled from the administration"; |
||||
$strings['OnlyAdminPlatform'] = "Tool only for administrators"; |
||||
$strings['OnlyAdminPlatformOrTeacher'] = "Tool only for administrators and teachers"; |
||||
$strings['TrainingEntity'] = "Training entity"; |
||||
$strings['DescriptionFront'] = "Description front"; |
||||
$strings['DescriptionRear'] = "Description rear"; |
||||
$strings['Certify'] = "Certify"; |
||||
$strings['CertificateType'] = "Certificate type"; |
||||
$strings['CertifyThat'] = "CERTIFY THAT"; |
||||
$strings['StudentCourseInfo'] = 'Student and Course data'; |
||||
$strings['StudentData'] = "Student data"; |
||||
$strings['CourseData'] = "Course data"; |
||||
$strings['Modality'] = "Modality"; |
||||
$strings['Contents'] = "Contents"; |
||||
$strings['ContentsToShow'] = "Contents to show"; |
||||
$strings['ContentsCourseDescription'] = 'Use section "Course description"> "Contents"'; |
||||
$strings['ContentsIndexLearnpath'] = "Use learnpath index"; |
||||
$strings['ContentsCustom'] = "Use custom content"; |
||||
$strings['Dates'] = "Dates"; |
||||
$strings['CourseDeliveryDates'] = "Course delivery dates"; |
||||
$strings['Custom'] = "Custom"; |
||||
$strings['UseDateSessionAccess'] = "Use access dates to the session"; |
||||
$strings['ExpectionPlace'] = "Expection place"; |
||||
$strings['DateExpediction'] = "Expediction date"; |
||||
$strings['UseDateEndAccessSession'] = "Use end date of session access"; |
||||
$strings['UseDateDownloadCertificate'] = "Use certificate download date"; |
||||
$strings['UseCustomDate'] = "Use custom date"; |
||||
$strings['LogosSeal'] = "Logos / Seals"; |
||||
$strings['LogoLeft'] = "Logo left"; |
||||
$strings['LogoCenter'] = "Logo center"; |
||||
$strings['LogoRight'] = "Logo right"; |
||||
$strings['Seal'] = "Seal"; |
||||
$strings['Signature1'] = "Signature 1"; |
||||
$strings['Signature2'] = "Signature 2"; |
||||
$strings['Signature3'] = "Signature 3"; |
||||
$strings['Signature4'] = "Signature 4"; |
||||
$strings['SignatureText1'] = "Signature text 1"; |
||||
$strings['SignatureText2'] = "Signature text 2"; |
||||
$strings['SignatureText3'] = "Signature text 3"; |
||||
$strings['SignatureText4'] = "Signature text 4"; |
||||
$strings['OtherOptions'] = "Others options"; |
||||
$strings['MarginRight'] = "Margin right"; |
||||
$strings['MarginLeft'] = "Margin left"; |
||||
$strings['SetDefaultTemplate'] = "Set template by default"; |
||||
$strings['MessageDefaultTemplate'] = "Save this default customization for courses and sessions without defined certificates"; |
||||
$strings['None'] = "None"; |
||||
$strings['ErrorTemplateCertificate'] = "There is no template defined for the certificate. There is no template by default."; |
||||
$strings['DateStartEnd'] = "With Start date and End date: "; |
||||
$strings['ExpedictionIn'] = "Expediction in"; |
||||
$strings['Signatures'] = "Signatures"; |
||||
$strings['BackgroundCertificate'] = "Background image of the certificate"; |
||||
$strings['Background'] = "Background"; |
||||
$strings['CertificateSetting'] = "Certificate setting"; |
||||
$strings['ToolDisabledCourse'] = "Tool disabled in course setting"; |
||||
$strings['ToolUseDefaultSettingCourse'] = "Tool configured to use the default certificate. <br> |
||||
You can edit it from the Administration screen -> Plugins -> Custom Certificate. <br> |
||||
Or if you want you can disable the option to use certificate by default in the plugin configuration in the course"; |
||||
$strings['CertificateSettingDefault'] = "Default certificate settings"; |
||||
$strings['InfoFromDefaultCertificate'] = "The content of the certificate is based on the default certificate. |
||||
The modifications you make will not affect the default certificate."; |
||||
$strings['to'] = " to "; |
||||
$strings['formatDownloadDate'] = " to %sth %s, %s"; |
||||
$strings['PrintCertificate'] = "Print certificate"; |
@ -0,0 +1,70 @@ |
||||
<?php |
||||
$strings['plugin_title'] = "Certificado personalizado"; |
||||
$strings['plugin_comment'] = "Este plugin permite crear certificados personalizados por curso."; |
||||
$strings['enable_plugin_customcertificate'] = "Activar plugin"; |
||||
$strings['customcertificate_course_enable'] = "Habilitar en el curso el certificado alternativo"; |
||||
$strings['use_certificate_default'] = "Usar el certificado personalizado por defecto"; |
||||
$strings['ToolDisabled'] = "La herramienta está deshabilitada desde la administración"; |
||||
$strings['OnlyAdminPlatform'] = "Herramienta exclusiva para administradores"; |
||||
$strings['OnlyAdminPlatformOrTeacher'] = "Herramienta para administradores y profesores"; |
||||
$strings['TrainingEntity'] = "Entidad formadora"; |
||||
$strings['DescriptionFront'] = "Descripción principal"; |
||||
$strings['DescriptionRear'] = "Descripción trasera"; |
||||
$strings['Certify'] = "Certifica"; |
||||
$strings['CertificateType'] = "Tipo certificado"; |
||||
$strings['CertifyThat'] = "CERTIFICA QUE"; |
||||
$strings['StudentCourseInfo'] = 'Datos del alumno y curso'; |
||||
$strings['StudentData'] = "Datos estudiante"; |
||||
$strings['CourseData'] = "Datos curso"; |
||||
$strings['Modality'] = "Modalidad"; |
||||
$strings['Contents'] = "Contenidos"; |
||||
$strings['ContentsToShow'] = "Contenidos a mostrar"; |
||||
$strings['ContentsCourseDescription'] = 'Usar apartado "Descripcion del curso" > "Contenidos"'; |
||||
$strings['ContentsIndexLearnpath'] = "Usar indice de lecciones"; |
||||
$strings['ContentsCustom'] = "Usar contenido personalizado"; |
||||
$strings['Dates'] = "Fechas"; |
||||
$strings['CourseDeliveryDates'] = "Fechas de impartición del curso"; |
||||
$strings['Custom'] = "Personalizado"; |
||||
$strings['UseDateSessionAccess'] = "Usar fechas de acceso a la sesión"; |
||||
$strings['ExpectionPlace'] = "Lugar expedición"; |
||||
$strings['DateExpediction'] = "Fecha expedición"; |
||||
$strings['UseDateEndAccessSession'] = "Usar fecha fin de acceso de la sesión"; |
||||
$strings['UseDateDownloadCertificate'] = "Usar fecha de descarga del certificado"; |
||||
$strings['UseCustomDate'] = "Usar fechas personalizadas"; |
||||
$strings['LogosSeal'] = "Logos / Sellos"; |
||||
$strings['LogoLeft'] = "Logo izquierda"; |
||||
$strings['LogoCenter'] = "Logo central"; |
||||
$strings['LogoRight'] = "Logo derecha"; |
||||
$strings['Seal'] = "Sello"; |
||||
$strings['Signature1'] = "Firma 1"; |
||||
$strings['Signature2'] = "Firma 2"; |
||||
$strings['Signature3'] = "Firma 3"; |
||||
$strings['Signature4'] = "Firma 4"; |
||||
$strings['SignatureText1'] = "Texto firma 1"; |
||||
$strings['SignatureText2'] = "Texto firma 2"; |
||||
$strings['SignatureText3'] = "Texto firma 3"; |
||||
$strings['SignatureText4'] = "Texto firma 4"; |
||||
$strings['OtherOptions'] = "Otras opciones"; |
||||
$strings['MarginRight'] = "Margen derecho"; |
||||
$strings['MarginLeft'] = "Margen izquierdo"; |
||||
$strings['SetDefaultTemplate'] = "Establecer plantilla por defecto"; |
||||
$strings['MessageDefaultTemplate'] = "Guardar esta personalización por defecto para cursos y sesiones sin certificados definidos"; |
||||
$strings['None'] = "Ninguno"; |
||||
$strings['ErrorTemplateCertificate'] = "No hay una plantilla definida para el certificado. No existe plantilla por defecto."; |
||||
$strings['DateStartEnd'] = "Con Fecha de inicio y Fecha fin: "; |
||||
$strings['ExpedictionIn'] = "Expedido en"; |
||||
$strings['Signatures'] = "Firmas"; |
||||
$strings['BackgroundCertificate'] = "Imagen de fondo del certificado"; |
||||
$strings['Background'] = "Fondo"; |
||||
$strings['CertificateSetting'] = "Configuración Certificado"; |
||||
$strings['ToolDisabledCourse'] = "Herramienta desabilitada en el curso"; |
||||
$strings['ToolUseDefaultSettingCourse'] = "Herramienta configurada para usar el certificado por defecto.<br> |
||||
Podrá editarlo desde la pantalla de Administración -> Plugins -> Certificado personalizado.<br> |
||||
O si lo desea puede desactivar la opción de usar certificado por defecto en la configuración del plugin en el curso"; |
||||
$strings['CertificateSettingDefault'] = "Configuración del certificado por defecto"; |
||||
$strings['InfoFromDefaultCertificate'] = "El contenido del certificado está basado en el certificado por defecto. |
||||
Las modificaciones que realice no afectará al certificado por defecto."; |
||||
$strings['to'] = " a "; |
||||
$strings['formatDownloadDate'] = " a %s de %s de %s"; |
||||
$strings['MessageUpdate'] = "El proceso de actualización ha terminado"; |
||||
$strings['PrintCertificate'] = "Imprimir certificado"; |
@ -0,0 +1,16 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script is a configuration file for the date plugin. |
||||
* You can use it as a master for other platform plugins (course plugins are slightly different). |
||||
* These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins). |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
|
||||
/** |
||||
* Plugin details (must be present). |
||||
*/ |
||||
require_once __DIR__.'/config.php'; |
||||
$plugin_info = CustomCertificatePlugin::create()->get_info(); |
@ -0,0 +1,17 @@ |
||||
body {background-repeat:no-repeat !important; margin:0; padding: 0;} |
||||
td { font-family:arial, sans-serif; font-size:18px; } |
||||
td.logo { height: 150px; vertical-align: middle; } |
||||
td.content-table { height: 480px; padding: 10px 25px; vertical-align:middle;} |
||||
td.content-student { text-align:center; /*padding: 10px 0;*/ } |
||||
td.course { text-align:center; /*height: 200px;*/ vertical-align: middle; padding-top: 10px;} |
||||
td.modality { text-align:center; } |
||||
td.course-date { text-align:center; } |
||||
td.expediction { text-align:right; font-size: 18px; padding: 20px 0;} |
||||
td.seals { text-align:center; font-size: 16px;} |
||||
td.logo-seals { text-align:center; height: 100px; vertical-align: middle;} |
||||
@page caraA { margin:0; padding:0; page-break-before:always; height: 210mm;} |
||||
.caraA {box-decoration-break: slice; page: caraA} |
||||
@page caraB { background:#FFFFFF; } |
||||
.caraB {box-decoration-break: slice; page: caraB} |
||||
.contents-learnpath td {font-size: 12px; background: #FFFFFF; padding: 10px; height: 160mm; vertical-align: top;} |
||||
ol {margin: 0; padding:0;} |
@ -0,0 +1,22 @@ |
||||
.form-control-cert { |
||||
height: 34px; |
||||
padding: 6px 12px; |
||||
font-size: 14px; |
||||
line-height: 1.42857143; |
||||
color: #555; |
||||
background-color: #fff; |
||||
background-image: none; |
||||
border: 1px solid #ccc; |
||||
border-radius: 4px; |
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); |
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.075); |
||||
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s; |
||||
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; |
||||
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; |
||||
} |
||||
.certificado-text-label { |
||||
font-weight: 700; |
||||
margin: 0 10px 0 10px; |
||||
} |
||||
input:disabled { background: #eee; } |
||||
label { font-size: 13px; } |
After Width: | Height: | Size: 843 B |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.0 KiB |
@ -0,0 +1,70 @@ |
||||
function date_certificate_switch_radio_button_2(){ |
||||
var input_date_start = document.getElementById("date_start"); |
||||
var input_date_end = document.getElementById("date_end"); |
||||
input_date_start.value = ""; |
||||
input_date_end.value = ""; |
||||
input_date_start.setAttribute("disabled","disabled"); |
||||
input_date_end.setAttribute("disabled","disabled"); |
||||
} |
||||
|
||||
function date_certificate_switch_radio_button_1(){ |
||||
var input_date_start = document.getElementById("date_start"); |
||||
var input_date_end = document.getElementById("date_end"); |
||||
input_date_start.removeAttribute("disabled"); |
||||
input_date_end.removeAttribute("disabled"); |
||||
} |
||||
|
||||
function date_certificate_switch_radio_button_0(){ |
||||
var input_date_start = document.getElementById("date_start"); |
||||
var input_date_end = document.getElementById("date_end"); |
||||
input_date_start.value = ""; |
||||
input_date_end.value = ""; |
||||
input_date_start.setAttribute("disabled","disabled"); |
||||
input_date_end.setAttribute("disabled","disabled"); |
||||
} |
||||
|
||||
function type_date_expediction_switch_radio_button(){ |
||||
var input_type = document.getElementsByName("type_date_expediction"); |
||||
var type; |
||||
for (var i=0;i<input_type.length;i++){ |
||||
if ( input_type[i].checked ) { |
||||
type = input_type[i].value; |
||||
} |
||||
} |
||||
var input_day = document.getElementById("day"); |
||||
var input_month = document.getElementById("month"); |
||||
var input_year = document.getElementById("year"); |
||||
if (type == 2) { |
||||
input_day.removeAttribute("disabled"); |
||||
input_month.removeAttribute("disabled"); |
||||
input_year.removeAttribute("disabled"); |
||||
} else { |
||||
input_day.setAttribute("disabled","disabled"); |
||||
input_month.setAttribute("disabled","disabled"); |
||||
input_year.setAttribute("disabled","disabled"); |
||||
} |
||||
} |
||||
|
||||
function contents_type_switch_radio_button(){ |
||||
var input_type = document.getElementsByName("contents_type"); |
||||
var type; |
||||
for (var i=0;i<input_type.length;i++){ |
||||
if ( input_type[i].checked ) { |
||||
type = input_type[i].value; |
||||
} |
||||
} |
||||
var input_contents = document.getElementById("contents"); |
||||
if (type == 2) { |
||||
input_contents.removeAttribute("disabled"); |
||||
} else { |
||||
input_contents.setAttribute("disabled","disabled"); |
||||
} |
||||
} |
||||
|
||||
$(document).ready(function() { |
||||
CKEDITOR.on("instanceReady", function (e) { |
||||
showTemplates(); |
||||
}); |
||||
|
||||
$( ".datepicker" ).datepicker(); |
||||
}); |
@ -0,0 +1,238 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Plugin class for the CustomCertificate plugin. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
* |
||||
* @author Jose Angel Ruiz <desarrollo@nosolored.com> |
||||
*/ |
||||
class CustomCertificatePlugin extends Plugin |
||||
{ |
||||
const TABLE_CUSTOMCERTIFICATE = 'plugin_customcertificate'; |
||||
public $isCoursePlugin = true; |
||||
|
||||
// When creating a new course this settings are added to the course |
||||
public $course_settings = [ |
||||
[ |
||||
'name' => 'customcertificate_course_enable', |
||||
'type' => 'checkbox', |
||||
], |
||||
[ |
||||
'name' => 'use_certificate_default', |
||||
'type' => 'checkbox', |
||||
] |
||||
]; |
||||
|
||||
protected function __construct() |
||||
{ |
||||
parent::__construct( |
||||
'1.0', |
||||
'Jose Angel Ruiz - NoSoloRed (original author)', |
||||
[ |
||||
'enable_plugin_customcertificate' => 'boolean', |
||||
] |
||||
); |
||||
|
||||
$this->isAdminPlugin = true; |
||||
} |
||||
|
||||
/** |
||||
* @return CustomCertificatePlugin |
||||
*/ |
||||
public static function create() |
||||
{ |
||||
static $result = null; |
||||
|
||||
return $result ? $result : $result = new self(); |
||||
} |
||||
|
||||
/** |
||||
* This method creates the tables required to this plugin. |
||||
*/ |
||||
public function install() |
||||
{ |
||||
//Installing course settings |
||||
$this->install_course_fields_in_all_courses(); |
||||
|
||||
$tablesToBeCompared = [self::TABLE_CUSTOMCERTIFICATE]; |
||||
$em = Database::getManager(); |
||||
$cn = $em->getConnection(); |
||||
$sm = $cn->getSchemaManager(); |
||||
$tables = $sm->tablesExist($tablesToBeCompared); |
||||
|
||||
if ($tables) { |
||||
return false; |
||||
} |
||||
|
||||
$srcfile1 = __DIR__.'/../resources/img/64/customcertificate.png'; |
||||
$srcfile2 = __DIR__.'/../resources/img/64/customcertificate_na.png'; |
||||
$srcfile3 = __DIR__.'/../resources/img/22/customcertificate.png'; |
||||
$dstfile1 = __DIR__.'/../../../main/img/icons/64/customcertificate.png'; |
||||
$dstfile2 = __DIR__.'/../../../main/img/icons/64/customcertificate_na.png'; |
||||
$dstfile3 = __DIR__.'/../../../main/img/customcertificate.png'; |
||||
$dstfile4 = __DIR__.'/../../../main/img/icons/22/customcertificate.png'; |
||||
copy($srcfile1, $dstfile1); |
||||
copy($srcfile2, $dstfile2); |
||||
copy($srcfile3, $dstfile3); |
||||
copy($srcfile3, $dstfile4); |
||||
|
||||
require_once api_get_path(SYS_PLUGIN_PATH).'customcertificate/database.php'; |
||||
} |
||||
|
||||
/** |
||||
* This method drops the plugin tables. |
||||
*/ |
||||
public function uninstall() |
||||
{ |
||||
// Deleting course settings. |
||||
$this->uninstall_course_fields_in_all_courses($this->course_settings); |
||||
|
||||
$tablesToBeDeleted = [self::TABLE_CUSTOMCERTIFICATE]; |
||||
foreach ($tablesToBeDeleted as $tableToBeDeleted) { |
||||
$table = Database::get_main_table($tableToBeDeleted); |
||||
$sql = "DROP TABLE IF EXISTS $table"; |
||||
Database::query($sql); |
||||
} |
||||
$this->manageTab(false); |
||||
} |
||||
|
||||
/** |
||||
* This method update the previous plugin tables. |
||||
*/ |
||||
public function update() |
||||
{ |
||||
$oldCertificateTable = 'gradebook_certificate_alternative'; |
||||
$base = api_get_path(WEB_UPLOAD_PATH); |
||||
if (Database::num_rows(Database::query("SHOW TABLES LIKE '$oldCertificateTable'")) == 1) { |
||||
$sql = "SELECT * FROM $oldCertificateTable"; |
||||
$res = Database::query($sql); |
||||
while ($row = Database::fetch_assoc($res)) { |
||||
$pathOrigin = $base.'certificates/'.$row['id'].'/'; |
||||
$params = [ |
||||
'access_url_id' => api_get_current_access_url_id(), |
||||
'c_id' => $row['c_id'], |
||||
'session_id' => $row['session_id'], |
||||
'content_course' => $row['content_course'], |
||||
'contents_type' => intval($row['contents_type']), |
||||
'contents' => $row['contents'], |
||||
'date_change' => intval($row['date_change']), |
||||
'date_start' => $row['date_start'], |
||||
'date_end' => $row['date_end'], |
||||
'place' => $row['place'], |
||||
'type_date_expediction' => intval($row['type_date_expediction']), |
||||
'day' => $row['day'], |
||||
'month' => $row['month'], |
||||
'year' => $row['year'], |
||||
'logo_left' => $row['logo_left'], |
||||
'logo_center' => $row['logo_center'], |
||||
'logo_right' => $row['logo_right'], |
||||
'seal' => $row['seal'], |
||||
'signature1' => $row['signature1'], |
||||
'signature2' => $row['signature2'], |
||||
'signature3' => $row['signature3'], |
||||
'signature4' => $row['signature4'], |
||||
'signature_text1' => $row['signature_text1'], |
||||
'signature_text2' => $row['signature_text2'], |
||||
'signature_text3' => $row['signature_text3'], |
||||
'signature_text4' => $row['signature_text4'], |
||||
'background' => $row['background'], |
||||
'margin_left' => intval($row['margin']), |
||||
'margin_right' => 0, |
||||
'certificate_default' => 0, |
||||
]; |
||||
|
||||
Database::insert(self::TABLE_CUSTOMCERTIFICATE, $params); |
||||
$certificateId = Database::insert_id(); |
||||
|
||||
//Image manager |
||||
$pathDestiny = $base.'certificates/'.$certificateId.'/'; |
||||
|
||||
if (!file_exists($pathDestiny)) { |
||||
mkdir($pathDestiny, api_get_permissions_for_new_directories(), true); |
||||
} |
||||
|
||||
$imgList = [ |
||||
'logo_left', |
||||
'logo_center', |
||||
'logo_right', |
||||
'seal', |
||||
'signature1', |
||||
'signature2', |
||||
'signature3', |
||||
'signature4', |
||||
'background', |
||||
]; |
||||
foreach ($imgList as $value) { |
||||
if (!empty($row[$value])) { |
||||
copy( |
||||
$pathOrigin.$row[$value], |
||||
$pathDestiny.$row[$value] |
||||
); |
||||
} |
||||
} |
||||
|
||||
if ($row['certificate_default'] == 1) { |
||||
$params['c_id'] = 0; |
||||
$params['session_id'] = 0; |
||||
$params['certificate_default'] = 1; |
||||
Database::insert(self::TABLE_CUSTOMCERTIFICATE, $params); |
||||
$certificateId = Database::insert_id(); |
||||
$pathOrigin = $base.'certificates/default/'; |
||||
$pathDestiny = $base.'certificates/'.$certificateId.'/'; |
||||
foreach ($imgList as $value) { |
||||
if (!empty($row[$value])) { |
||||
copy( |
||||
$pathOrigin.$row[$value], |
||||
$pathDestiny.$row[$value] |
||||
); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
$sql = "DROP TABLE IF EXISTS $oldCertificateTable"; |
||||
Database::query($sql); |
||||
|
||||
echo $this->get_lang('MessageUpdate'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Get certificate data. |
||||
* |
||||
* @param Certificate $id The certificate |
||||
* |
||||
* @return array |
||||
*/ |
||||
public function getCertificateData($id) |
||||
{ |
||||
if (empty($id)) { |
||||
return false; |
||||
} |
||||
|
||||
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
||||
$categoryTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); |
||||
$sql = "SELECT cer.user_id AS user_id, cat.session_id AS session_id, cat.course_code AS course_code |
||||
FROM $certificateTable cer |
||||
INNER JOIN $categoryTable cat |
||||
ON (cer.cat_id = cat.id) |
||||
WHERE cer.id = $id"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) > 0) { |
||||
$row = Database::fetch_assoc($rs); |
||||
$courseCode = $row['course_code']; |
||||
$sessionId = $row['session_id']; |
||||
$userId = $row['user_id']; |
||||
if (api_get_course_setting('customcertificate_course_enable', $courseCode) == 1) { |
||||
return [ |
||||
'course_code' => $courseCode, |
||||
'session_id' => $sessionId, |
||||
'user_id' => $userId, |
||||
]; |
||||
} |
||||
} |
||||
return []; |
||||
} |
||||
} |
@ -0,0 +1,503 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use Chamilo\CourseBundle\Entity\CLpCategory; |
||||
use ChamiloSession as Session; |
||||
|
||||
if (intval($_GET['default']) == 1) { |
||||
$cidReset = true; |
||||
} |
||||
|
||||
$course_plugin = 'customcertificate'; |
||||
require_once __DIR__.'/../config.php'; |
||||
|
||||
api_block_anonymous_users(); |
||||
$plugin = CustomCertificatePlugin::create(); |
||||
$enable = $plugin->get('enable_plugin_customcertificate') == 'true'; |
||||
$tblProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); |
||||
|
||||
if (!$enable) { |
||||
api_not_allowed(true, $plugin->get_lang('ToolDisabled')); |
||||
} |
||||
|
||||
if (intval($_GET['default']) == 1) { |
||||
$courseId = 0; |
||||
$courseCode = ''; |
||||
$sessionId = 0; |
||||
$enableCourse = false; |
||||
$useDefault = true; |
||||
} else { |
||||
$courseId = api_get_course_int_id(); |
||||
$courseCode = api_get_course_id(); |
||||
$sessionId = api_get_session_id(); |
||||
$enableCourse = api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 ? true : false; |
||||
$useDefault = api_get_course_setting('use_certificate_default', $courseCode) == 1 ? true : false; |
||||
} |
||||
$accessUrlId = api_get_current_access_url_id(); |
||||
|
||||
$userList = array(); |
||||
if (empty($_GET['export_all'])) { |
||||
if (!isset($_GET['student_id'])) { |
||||
$studentId = api_get_user_id(); |
||||
} else { |
||||
$studentId = intval($_GET['student_id']); |
||||
} |
||||
$userList[] = api_get_user_info($studentId); |
||||
} else { |
||||
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
||||
$categoryTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); |
||||
$sql = "SELECT cer.user_id AS user_id |
||||
FROM $certificateTable cer |
||||
INNER JOIN $categoryTable cat |
||||
ON (cer.cat_id = cat.id) |
||||
WHERE cat.course_code = '$courseCode' AND cat.session_id = $sessionId"; |
||||
$rs = Database::query($sql); |
||||
while ($row = Database::fetch_assoc($rs)) { |
||||
$userList[] = api_get_user_info($row['user_id']); |
||||
} |
||||
} |
||||
|
||||
$sessionInfo = []; |
||||
if ($sessionId > 0) { |
||||
$sessionInfo = SessionManager::fetch($sessionId); |
||||
} |
||||
|
||||
$table = Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE); |
||||
$useDefault = false; |
||||
$base = api_get_path(WEB_UPLOAD_PATH).'certificates/'; |
||||
|
||||
// Get info certificate |
||||
$infoCertificate = Database::select( |
||||
'*', |
||||
$table, |
||||
['where'=> ['access_url_id = ? AND c_id = ? AND session_id = ?' => [$accessUrlId, $courseId, $sessionId]]], |
||||
'first' |
||||
); |
||||
|
||||
if (!is_array($infoCertificate)) { |
||||
$infoCertificate = array(); |
||||
} |
||||
|
||||
if (empty($infoCertificate)) { |
||||
$infoCertificate = Database::select( |
||||
'*', |
||||
Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE), |
||||
['where'=> ['access_url_id = ? AND certificate_default = ? ' => [$accessUrlId, 1]]], |
||||
'first' |
||||
); |
||||
|
||||
if (!is_array($infoCertificate)) { |
||||
$infoCertificate = array(); |
||||
} |
||||
|
||||
if (empty($infoCertificate)) { |
||||
Display::display_header($plugin->get_lang('PrintCertificate')); |
||||
echo Display::return_message($plugin->get_lang('ErrorTemplateCertificate'), 'error'); |
||||
Display::display_footer(); |
||||
exit; |
||||
} else { |
||||
$useDefault = true; |
||||
$path = $base.$infoCertificate['id'].'/'; |
||||
} |
||||
} else { |
||||
$path = $base.$infoCertificate['id'].'/'; |
||||
} |
||||
|
||||
$workSpace = intval(297 - $infoCertificate['margin_left'] - $infoCertificate['margin_right']); |
||||
$widthCell = intval($workSpace / 6); |
||||
$htmlText = ''; |
||||
$htmlText .= '<link rel="stylesheet" |
||||
type="text/css" |
||||
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css" |
||||
>'; |
||||
$htmlText .= '<link rel="stylesheet" |
||||
type="text/css" |
||||
href="'.api_get_path(WEB_CSS_PATH).'editor.css" |
||||
>'; |
||||
$htmlText .= '<body>'; |
||||
foreach ($userList as $userInfo) { |
||||
$studentId = $userInfo['user_id']; |
||||
|
||||
if (empty($infoCertificate['background'])) { |
||||
$htmlText .= '<div class="caraA" style="padding:0; page-break-before:always;" margin:0; padding:0;>'; |
||||
} else { |
||||
$urlBackground = $path.$infoCertificate['background']; |
||||
$htmlText .= '<div class="caraA" |
||||
style="background-image:url('.$urlBackground.') no-repeat; background-image-resize:6;" |
||||
margin:0; |
||||
padding:0; |
||||
>'; |
||||
} |
||||
|
||||
if (!empty($infoCertificate['logo_left'])) { |
||||
$logoLeft = '<img |
||||
style="max-height: 150px; max-width: '.(2 * $widthCell).'mm;" |
||||
src="'.$path.$infoCertificate['logo_left'].'" |
||||
/>'; |
||||
} else { |
||||
$logoLeft = ''; |
||||
} |
||||
|
||||
if (!empty($infoCertificate['logo_center'])) { |
||||
$logoCenter = '<img |
||||
style="max-height: 150px; max-width: '.intval($workSpace - (2 * $widthCell)).'mm;" |
||||
src="'.$path.$infoCertificate['logo_center'].'" |
||||
/>'; |
||||
} else { |
||||
$logoCenter = ''; |
||||
} |
||||
|
||||
if (!empty($infoCertificate['logo_right'])) { |
||||
$logoRight = '<img |
||||
style="max-height: 150px; max-width: '.(2 * $widthCell).'mm;" |
||||
src="'.$path.$infoCertificate['logo_right'].'" |
||||
/>'; |
||||
} else { |
||||
$logoRight = ''; |
||||
} |
||||
|
||||
$htmlText .= '<table |
||||
width="'.$workSpace.'mm" |
||||
style=" |
||||
margin-left:'.$infoCertificate['margin_left'].'mm; |
||||
margin-right:'.$infoCertificate['margin_right'].'mm; |
||||
" |
||||
border="0" |
||||
>'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td colspan="4" class="logo">'.$logoLeft.'</td>'; |
||||
$htmlText .= '<td colspan="4" class="logo" style="text-align:center;">'.$logoCenter.'</td>'; |
||||
$htmlText .= '<td colspan="4" class="logo" style="text-align:right;">'.$logoRight.'</td>'; |
||||
$htmlText .= '</tr>'; |
||||
|
||||
$all_user_info = DocumentManager::get_all_info_to_certificate( |
||||
$studentId, |
||||
$courseCode, |
||||
true |
||||
); |
||||
|
||||
$myContentHtml = $infoCertificate['content_course']; |
||||
$myContentHtml = str_replace(chr(13).chr(10).chr(13).chr(10),chr(13).chr(10), $myContentHtml); |
||||
$info_to_be_replaced_in_content_html = $all_user_info[0]; |
||||
$info_to_replace_in_content_html = $all_user_info[1]; |
||||
$myContentHtml = str_replace( |
||||
$info_to_be_replaced_in_content_html, |
||||
$info_to_replace_in_content_html, |
||||
$myContentHtml |
||||
); |
||||
|
||||
$startDate = ''; |
||||
$endDate = ''; |
||||
switch ($infoCertificate['date_change']) { |
||||
case 0: |
||||
if (!empty($sessionInfo['access_start_date'])) { |
||||
$startDate = date("d/m/Y", strtotime(api_get_local_time($sessionInfo['access_start_date']))); |
||||
} |
||||
if (!empty($sessionInfo['access_end_date'])) { |
||||
$endDate = date("d/m/Y", strtotime(api_get_local_time($sessionInfo['access_end_date']))); |
||||
} |
||||
break; |
||||
case 1: |
||||
$startDate = date("d/m/Y", strtotime($infoCertificate['date_start'])); |
||||
$endDate = date("d/m/Y", strtotime($infoCertificate['date_end'])); |
||||
break; |
||||
} |
||||
|
||||
$myContentHtml = str_replace( |
||||
'((start_date))', |
||||
$startDate, |
||||
$myContentHtml |
||||
); |
||||
|
||||
$myContentHtml = str_replace( |
||||
'((end_date))', |
||||
$endDate, |
||||
$myContentHtml |
||||
); |
||||
|
||||
$dateExpediction = ''; |
||||
if ($infoCertificate['type_date_expediction'] != 3) { |
||||
$dateExpediction .= $plugin->get_lang('ExpedictionIn').' '.$infoCertificate['place']; |
||||
if ($infoCertificate['type_date_expediction'] == 1) { |
||||
$dateExpediction .= $plugin->get_lang('to').api_format_date(time(), DATE_FORMAT_LONG); |
||||
} elseif ($infoCertificate['type_date_expediction'] == 2) { |
||||
$dateFormat = $plugin->get_lang('formatDownloadDate'); |
||||
if (!empty($infoCertificate['day']) && |
||||
!empty($infoCertificate['month']) && |
||||
!empty($infoCertificate['year']) |
||||
) { |
||||
$dateExpediction .= sprintf( |
||||
$dateFormat, |
||||
$infoCertificate['day'], |
||||
$infoCertificate['month'], |
||||
$infoCertificate['year'] |
||||
); |
||||
} else { |
||||
$dateExpediction .= sprintf( |
||||
$dateFormat, |
||||
'......', |
||||
'....................', |
||||
'............' |
||||
); |
||||
} |
||||
} else { |
||||
$dateInfo = api_get_local_time($sessionInfo['access_end_date']); |
||||
$dateExpediction .= $plugin->get_lang('to').api_format_date($dateInfo, DATE_FORMAT_LONG); |
||||
} |
||||
} |
||||
|
||||
$myContentHtml = str_replace( |
||||
'((date_expediction))', |
||||
$dateExpediction, |
||||
$myContentHtml |
||||
); |
||||
|
||||
$myContentHtml = strip_tags( |
||||
$myContentHtml, |
||||
'<p><b><strong><table><tr><td><th><tbody><span><i><li><ol><ul><dd><dt><dl><br><hr><img><a><div>' |
||||
); |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td colspan="12" class="content-table">'; |
||||
$htmlText .= '<table width="100%">'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td colspan="12" class="content-student">'; |
||||
$htmlText .= $myContentHtml; |
||||
$htmlText .= '</td>'; |
||||
$htmlText .= '</tr>'; |
||||
|
||||
$htmlText .= '</table>'; |
||||
$htmlText .= '</td>'; |
||||
$htmlText .= '</tr>'; |
||||
|
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td colspan="2" class="seals" style="width:'.$widthCell.'mm"> |
||||
'.((!empty($infoCertificate['signature_text1'])) ? $infoCertificate['signature_text1'] : ''). |
||||
'</td> |
||||
<td colspan="2" class="seals" style="width:'.$widthCell.'mm"> |
||||
'.((!empty($infoCertificate['signature_text2'])) ? $infoCertificate['signature_text2'] : ''). |
||||
'</td> |
||||
<td colspan="2" class="seals" style="width:'.$widthCell.'mm"> |
||||
'.((!empty($infoCertificate['signature_text3'])) ? $infoCertificate['signature_text3'] : ''). |
||||
'</td> |
||||
<td colspan="2" class="seals" style="width:'.$widthCell.'mm"> |
||||
'.((!empty($infoCertificate['signature_text4'])) ? $infoCertificate['signature_text4'] : ''). |
||||
'</td> |
||||
<td colspan="4" class="seals" style="width:'.(2 * $widthCell).'mm"> |
||||
'.((!empty($infoCertificate['seal'])) ? $plugin->get_lang('Seal') : ''). |
||||
'</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm"> |
||||
'.((!empty($infoCertificate['signature1'])) |
||||
? '<img style="max-height: 100px; max-width: '.$widthCell.'mm;" |
||||
src="'.$path.$infoCertificate['signature1'].'" |
||||
/>' |
||||
: ''). |
||||
'</td> |
||||
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm"> |
||||
'.((!empty($infoCertificate['signature2'])) |
||||
? '<img style="max-height: 100px; '.$widthCell.'mm;" |
||||
src="'.$path.$infoCertificate['signature2'].'" |
||||
/>' |
||||
: ''). |
||||
'</td> |
||||
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm"> |
||||
'.((!empty($infoCertificate['signature3'])) |
||||
? '<img style="max-height: 100px; '.$widthCell.'mm;" |
||||
src="'.$path.$infoCertificate['signature3'].'" |
||||
/>' |
||||
: ''). |
||||
'</td> |
||||
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm"> |
||||
'.((!empty($infoCertificate['signature4'])) |
||||
? '<img style="max-height: 100px; '.$widthCell.'mm;" |
||||
src="'.$path.$infoCertificate['signature4'].'" |
||||
/>' |
||||
: ''). |
||||
'</td> |
||||
<td colspan="4" class="logo-seals" style="width:'.(2 * $widthCell).'mm"> |
||||
'.((!empty($infoCertificate['seal'])) |
||||
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;" |
||||
src="'.$path.$infoCertificate['seal'].'" |
||||
/>' |
||||
: ''). |
||||
'</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '</table>'; |
||||
$htmlText .= '</div>'; |
||||
|
||||
// Rear certificate |
||||
$htmlText .= '<div class="caraB" style="page-break-before:always;" margin:0; padding:0;>'; |
||||
|
||||
if ($infoCertificate['contents_type'] == 0) { |
||||
|
||||
$contentsDescription = CourseDescription::get_data_by_description_type(3, $courseId, 0); |
||||
|
||||
$domd = new DOMDocument(); |
||||
libxml_use_internal_errors(true); |
||||
$domd->loadHTML($contentsDescription['description_content']); |
||||
libxml_use_internal_errors(false); |
||||
|
||||
$domx = new DOMXPath($domd); |
||||
$items = $domx->query("//li[@style]"); |
||||
foreach($items as $item) { |
||||
$item->removeAttribute("style"); |
||||
} |
||||
|
||||
$items = $domx->query("//span[@style]"); |
||||
foreach($items as $item) { |
||||
$item->removeAttribute("style"); |
||||
} |
||||
|
||||
$output = $domd->saveHTML(); |
||||
|
||||
$htmlText .= getIndexFiltered($output); |
||||
} |
||||
|
||||
if ($infoCertificate['contents_type'] == 1) { |
||||
$items = array(); |
||||
$categoriesTempList = learnpath::getCategories($courseId); |
||||
$categoryTest = new CLpCategory(); |
||||
$categoryTest->setId(0); |
||||
$categoryTest->setName($plugin->get_lang('WithOutCategory')); |
||||
$categoryTest->setPosition(0); |
||||
$categories = array( |
||||
$categoryTest |
||||
); |
||||
if (!empty($categoriesTempList)) { |
||||
$categories = array_merge($categories, $categoriesTempList); |
||||
} |
||||
|
||||
foreach ($categories as $item) { |
||||
$categoryId = $item->getId(); |
||||
|
||||
if (!learnpath::categoryIsVisibleForStudent($item, api_get_user_entity($studentId))) { |
||||
continue; |
||||
} |
||||
|
||||
$sql = "SELECT 1 |
||||
FROM $tblProperty |
||||
WHERE tool = 'learnpath_category' |
||||
AND ref = $categoryId |
||||
AND visibility = 0 |
||||
AND (session_id = $sessionId OR session_id IS NULL)"; |
||||
$res = Database::query($sql); |
||||
if (Database::num_rows($res) > 0) { |
||||
continue; |
||||
} |
||||
|
||||
$list = new LearnpathList( |
||||
$studentId, |
||||
$courseCode, |
||||
$sessionId, |
||||
null, |
||||
false, |
||||
$categoryId |
||||
); |
||||
|
||||
$flat_list = $list->get_flat_list(); |
||||
|
||||
if (empty($flat_list)) { |
||||
continue; |
||||
} |
||||
|
||||
if (count($categories) > 1 && count($flat_list) > 0) { |
||||
if ($item->getName() != $plugin->get_lang('WithOutCategory')) { |
||||
$items[] = '<h4 style="margin:0">'.$item->getName().'</h4>'; |
||||
} |
||||
} |
||||
|
||||
foreach ($flat_list as $learnpath) { |
||||
$lpId = $learnpath['lp_old_id']; |
||||
//echo $lpId."<br>"; |
||||
$sql = "SELECT 1 |
||||
FROM $tblProperty |
||||
WHERE tool = 'learnpath' |
||||
AND ref = $lpId AND visibility = 0 |
||||
AND (session_id = $sessionId OR session_id IS NULL)"; |
||||
$res = Database::query($sql); |
||||
if (Database::num_rows($res) > 0) { |
||||
continue; |
||||
} |
||||
$lpName = $learnpath['lp_name']; |
||||
$items[] = $lpName.'<br>'; |
||||
} |
||||
$items[] = '<br>'; |
||||
} |
||||
|
||||
if (count($items) > 0) { |
||||
$htmlText .= '<table width="100%" class="contents-learnpath">'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td>'; |
||||
$i = 0; |
||||
foreach ($items as $value) { |
||||
if ($i == 50) { |
||||
$htmlText .= '</td><td>'; |
||||
} |
||||
$htmlText .= $value; |
||||
$i++; |
||||
} |
||||
$htmlText .= '</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '</table>'; |
||||
} |
||||
$htmlText .= '</td></table>'; |
||||
} |
||||
|
||||
if ($infoCertificate['contents_type'] == 2) { |
||||
$htmlText .= '<table width="100%" class="contents-learnpath">'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td>'; |
||||
$myContentHtml = strip_tags( |
||||
$infoCertificate['contents'], |
||||
'<p><b><strong><table><tr><td><th><span><i><li><ol><ul>'. |
||||
'<dd><dt><dl><br><hr><img><a><div><h1><h2><h3><h4><h5><h6>' |
||||
); |
||||
$htmlText .= $myContentHtml; |
||||
$htmlText .= '</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '</table>'; |
||||
} |
||||
$htmlText .= '</div>'; |
||||
} |
||||
$htmlText .= '</body>'; |
||||
$fileName = 'certificate_'.date("Ymd_His"); |
||||
$params = array( |
||||
'filename' => $fileName, |
||||
'pdf_title' => "Certificate", |
||||
'pdf_description' => '', |
||||
'format' => 'A4-L', |
||||
'orientation' => 'L', |
||||
'left' => 15, |
||||
'top' => 15, |
||||
'bottom' => 0, |
||||
); |
||||
|
||||
$pdf = new PDF($params['format'], $params['orientation'], $params); |
||||
$pdf->content_to_pdf($htmlText, '', $fileName, null, 'I', false, null, false, true, false); |
||||
|
||||
function getIndexFiltered($indice){ |
||||
$txt = strip_tags($indice, "<b><strong><i>"); |
||||
$txt = str_replace(chr(13).chr(10).chr(13).chr(10),chr(13).chr(10), $txt); |
||||
$lines = explode(chr(13).chr(10), $txt); |
||||
$n = count($lines); |
||||
for ($x=0; $x<47; $x++) { |
||||
$text1 .= $lines[$x].chr(13).chr(10); |
||||
} |
||||
|
||||
for ($x=47; $x<94; $x++) { |
||||
$text2 .= $lines[$x].chr(13).chr(10); |
||||
} |
||||
|
||||
$showLeft = str_replace(chr(13).chr(10), "<br/>", $text1); |
||||
$showRight = str_replace(chr(13).chr(10), "<br/>", $text2); |
||||
$result = '<table width="100%">'; |
||||
$result .= '<tr>'; |
||||
$result .= '<td style="width:50%;vertical-align:top;padding-left:15px; font-size:12px;">'.$showLeft.'</td>'; |
||||
$result .= '<td style="vertical-align:top; font-size:12px;">'.$showRight.'</td>'; |
||||
$result .= '<tr>'; |
||||
$result .= '</table>'; |
||||
|
||||
return $result; |
||||
} |
||||
|
@ -0,0 +1,34 @@ |
||||
<?php |
||||
/** |
||||
* This script initiates a customcertificate plugin. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
$course_plugin = 'customcertificate'; |
||||
require_once __DIR__.'/config.php'; |
||||
|
||||
$plugin = CustomCertificatePlugin::create(); |
||||
$enable = $plugin->get('enable_plugin_customcertificate') == 'true'; |
||||
|
||||
if ($enable) { |
||||
if (api_is_platform_admin() || api_is_teacher()) { |
||||
$url = 'src/index.php?'; |
||||
$url .= (isset($_GET['cidReq']) ? api_get_cidreq() : 'default=1'); |
||||
header('Location: '.$url); |
||||
exit; |
||||
} else { |
||||
$session = api_get_session_entity(api_get_session_id()); |
||||
$_course = api_get_course_info(); |
||||
$webCoursePath = api_get_path(WEB_COURSE_PATH); |
||||
$url = $webCoursePath.$_course['path'].'/index.php'.($session ? '?id_session='.$session->getId() : ''); |
||||
|
||||
Display::addFlash( |
||||
Display::return_message($plugin->get_lang('OnlyAdminPlatform')) |
||||
); |
||||
|
||||
header('Location: '.$url); |
||||
exit; |
||||
} |
||||
} else { |
||||
api_not_allowed(true, $plugin->get_lang('ToolDisabled')); |
||||
} |
@ -0,0 +1,12 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script is included by main/admin/settings.lib.php when unselecting a plugin |
||||
* and is meant to remove things installed by the install.php script in both |
||||
* the global database and the courses tables. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
require_once __DIR__.'/config.php'; |
||||
CustomCertificatePlugin::create()->uninstall(); |
@ -0,0 +1,14 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* This script is meant to update previous version the plugin. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
require_once __DIR__.'/config.php'; |
||||
|
||||
if (!api_is_platform_admin()) { |
||||
die('You must have admin permissions to install plugins'); |
||||
} |
||||
|
||||
CustomCertificatePlugin::create()->update(); |