Minor - update from 1.11.x

pull/2744/head
Julio Montoya 7 years ago
parent 6126077066
commit 5c126f6759
  1. 27
      main/inc/lib/add_course.lib.inc.php
  2. 1
      plugin/customcertificate/config.php
  3. 1
      plugin/customcertificate/src/CustomCertificatePlugin.php
  4. 33
      plugin/customcertificate/src/index.php
  5. 150
      plugin/customcertificate/src/print_certificate.php
  6. 29
      plugin/notebookteacher/src/NotebookTeacherPlugin.php
  7. 2
      plugin/sepe/src/sepe_plugin.class.php
  8. 35
      plugin/test2pdf/src/test2pdf_plugin.class.php
  9. BIN
      public/img/lp_document.png
  10. BIN
      public/img/session_default.png

@ -926,33 +926,6 @@ class AddCourse
$courseManager = Container::$container->get('chamilo_core.entity.manager.course_manager');
/** @var \Chamilo\CoreBundle\Entity\Course $course */
$course = $courseManager->create();
// Here we must add 2 fields.
/*$course_id = Database::insert(
$TABLECOURSE,
[
'code' => $code,
'directory' => $directory,
'course_language' => $course_language,
'title' => $title,
'description' => get_lang('CourseDescription'),
'category_code' => $category_code,
'visibility' => $visibility,
'show_score' => 1,
'disk_quota' => intval($disk_quota),
'creation_date' => $time,
'expiration_date' => $expiration_date,
'last_edit' => $time,
'last_visit' => null,
'tutor_name' => $tutor_name,
'department_name' => $department_name,
'department_url' => $department_url,
'subscribe' => intval($subscribe),
'unsubscribe' => intval($unsubscribe),
'visual_code' => $visual_code,
]
);*/
$urlId = 1;
if (api_get_current_access_url_id() !== -1) {
$urlId = api_get_current_access_url_id();

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Config the plugin.
*

@ -259,7 +259,6 @@ class CustomCertificatePlugin extends Plugin
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true') {
$infoCertificate = self::getCertificateData($certId, $userId);
var_dump($infoCertificate);
if (!empty($infoCertificate)) {
if ($certificate->user_id == api_get_user_id() && !empty($certificate->certificate_data)) {
$certificateId = $certificate->certificate_data['id'];

@ -1,7 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
if (intval($_GET['default']) == 1) {
$isDefault = isset($_GET['default']) ? (int) $_GET['default'] : null;
if ($isDefault === 1) {
$cidReset = true;
}
@ -17,7 +19,7 @@ $enable = $plugin->get('enable_plugin_customcertificate') == 'true';
$accessUrlId = api_get_current_access_url_id();
$course_info = api_get_course_info();
if (intval($_GET['default']) == 1) {
if ($isDefault === 1) {
$courseId = 0;
$courseCode = '';
$sessionId = 0;
@ -72,15 +74,6 @@ $infoCertificate = Database::select(
],
'first'
);
if (!is_array($infoCertificate)) {
$infoCertificate = [
'type_date_expediction' => '',
'year' => '',
'month' => '',
'day' => '',
'date_change' => '',
];
}
$form = new FormValidator(
'formEdit',
@ -106,13 +99,13 @@ if ($form->validate()) {
'c_id' => $formValues['c_id'],
'session_id' => $formValues['session_id'],
'content_course' => $formValues['content_course'],
'contents_type' => intval($formValues['contents_type']),
'contents_type' => (int) $formValues['contents_type'],
'contents' => $contents,
'date_change' => intval($formValues['date_change']),
'date_start' => date("Y-m-d", strtotime($date_start)),
'date_end' => date("Y-m-d", strtotime($date_end)),
'place' => $formValues['place'],
'type_date_expediction' => intval($formValues['type_date_expediction']),
'type_date_expediction' => (int) $formValues['type_date_expediction'],
'day' => $formValues['day'],
'month' => $formValues['month'],
'year' => $formValues['year'],
@ -120,8 +113,8 @@ if ($form->validate()) {
'signature_text2' => $formValues['signature_text2'],
'signature_text3' => $formValues['signature_text3'],
'signature_text4' => $formValues['signature_text4'],
'margin_left' => intval($formValues['margin_left']),
'margin_right' => intval($formValues['margin_right']),
'margin_left' => (int) $formValues['margin_left'],
'margin_right' => (int) $formValues['margin_right'],
'certificate_default' => 0,
];
@ -215,7 +208,13 @@ if (empty($infoCertificate)) {
);
if (!is_array($infoCertificate)) {
$infoCertificate = [];
$infoCertificate = [
'type_date_expediction' => '',
'year' => '',
'month' => '',
'day' => '',
'date_change' => '',
];
}
if (!empty($infoCertificate)) {
$useDefault = true;
@ -245,7 +244,7 @@ $dir = '/';
$courseInfo = api_get_course_info();
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
$editorConfig = [
'ToolbarSet' => ($isAllowedToEdit ? 'Documents' : 'DocumentsStudent'),
'ToolbarSet' => $isAllowedToEdit ? 'Documents' : 'DocumentsStudent',
'Width' => '100%',
'Height' => '300',
'cols-size' => [0, 12, 0],

@ -5,7 +5,7 @@ use Chamilo\CourseBundle\Entity\CLpCategory;
$default = isset($_GET['default']) ? (int) $_GET['default'] : null;
if ($default == 1) {
if ($default === 1) {
$cidReset = true;
}
@ -41,6 +41,8 @@ if (empty($courseCode)) {
if (!empty($courseInfo)) {
$courseId = $courseInfo['real_id'];
}
} else {
$courseInfo = api_get_course_info($courseCode);
}
if (empty($sessionId)) {
@ -116,17 +118,21 @@ if (empty($infoCertificate)) {
$workSpace = intval(297 - $infoCertificate['margin_left'] - $infoCertificate['margin_right']);
$widthCell = intval($workSpace / 6);
$htmlText = '<html>';
$htmlText .= '
$htmlList = [];
$currentLocalTime = api_get_local_time();
foreach ($userList as $userInfo) {
$htmlText = '<html>';
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css">';
$htmlText .= '
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_CSS_PATH).'document.css">';
$htmlText .= '<body>';
foreach ($userList as $userInfo) {
$htmlText .= '<body>';
$studentId = $userInfo['user_id'];
if (empty($infoCertificate['background'])) {
@ -248,8 +254,10 @@ foreach ($userList as $userInfo) {
);
}
} else {
$dateInfo = api_get_local_time($sessionInfo['access_end_date']);
$dateExpediction .= $plugin->get_lang('to').api_format_date($dateInfo, DATE_FORMAT_LONG);
if (!empty($sessionInfo)) {
$dateInfo = api_get_local_time($sessionInfo['access_end_date']);
$dateExpediction .= $plugin->get_lang('to').api_format_date($dateInfo, DATE_FORMAT_LONG);
}
}
}
@ -284,52 +292,52 @@ foreach ($userList as $userInfo) {
$htmlText .= '<tr>';
$htmlText .= '<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text1'])) ? $infoCertificate['signature_text1'] : '').
'</td>
((!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>
((!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>
((!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>
((!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>';
'</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;"
((!empty($infoCertificate['signature1']))
? '<img style="max-height: 100px; max-width: '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature1'].'" />'
: '').
'</td>
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature2']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
((!empty($infoCertificate['signature2']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature2'].'" />'
: '').
'</td>
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature3']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
((!empty($infoCertificate['signature3']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature3'].'" />'
: '').
'</td>
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature4']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
((!empty($infoCertificate['signature4']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature4'].'" />'
: '').
'</td>
: '').
'</td>
<td colspan="4" class="logo-seals" style="width:'.(2 * $widthCell).'mm">'.
((!empty($infoCertificate['seal']))
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;"
((!empty($infoCertificate['seal']))
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['seal'].'" />'
: '').
'</td>';
: '').
'</td>';
$htmlText .= '</tr>';
$htmlText .= '</table>';
$htmlText .= '</div>';
@ -465,24 +473,50 @@ foreach ($userList as $userInfo) {
}
$htmlText .= '</div>';
}
$htmlText .= '</body></html>';
$fileName = 'certificate_'.$courseInfo['code'].'_'.$userInfo['complete_name'].'_'.$currentLocalTime;
$htmlList[$fileName] = $htmlText;
}
$fileList = [];
$archivePath = api_get_path(SYS_ARCHIVE_PATH).'certificates/';
if (!is_dir($archivePath)) {
mkdir($archivePath, api_get_permissions_for_new_directories());
}
foreach ($htmlList as $fileName => $content) {
$fileName = api_replace_dangerous_char($fileName);
$params = [
'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);
if (count($htmlList) == 1) {
$pdf->content_to_pdf($content, '', $fileName, null, 'D', false, null, false, false, false);
exit;
} else {
$filePath = $archivePath.$fileName.'.pdf';
$pdf->content_to_pdf($content, '', $fileName, null, 'F', true, $filePath, false, false, false);
$fileList[] = $filePath;
}
}
if (!empty($fileList)) {
$zipFile = $archivePath.'certificates_'.api_get_unique_id().'.zip';
$zipFolder = new PclZip($zipFile);
foreach ($fileList as $file) {
$zipFolder->add($file, PCLZIP_OPT_REMOVE_ALL_PATH);
}
$name = 'certificates_'.$courseInfo['code'].'_'.$currentLocalTime.'.zip';
DocumentManager::file_send_for_download($zipFile, true, $name);
exit;
}
$htmlText .= '</body></html>';
$fileName = 'certificate_'.date('Ymd_His');
$params = [
'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, 'D', false, null, false, false, false);
exit;
function getIndexFiltered($index)
{
@ -491,12 +525,16 @@ function getIndexFiltered($index)
$lines = explode(chr(13).chr(10), $txt);
$text1 = '';
for ($x = 0; $x < 47; $x++) {
$text1 .= $lines[$x].chr(13).chr(10);
if (isset($lines[$x])) {
$text1 .= $lines[$x].chr(13).chr(10);
}
}
$text2 = '';
for ($x = 47; $x < 94; $x++) {
$text2 .= $lines[$x].chr(13).chr(10);
if (isset($lines[$x])) {
$text2 .= $lines[$x].chr(13).chr(10);
}
}
$showLeft = str_replace(chr(13).chr(10), "<br/>", $text1);

@ -58,18 +58,23 @@ class NotebookTeacherPlugin extends Plugin
return false;
}
$srcfile1 = __DIR__.'/../resources/img/64/notebookteacher.png';
$srcfile2 = __DIR__.'/../resources/img/64/notebookteacher_na.png';
$srcfile3 = __DIR__.'/../resources/img/32/notebookteacher.png';
$srcfile4 = __DIR__.'/../resources/img/22/notebookteacher.png';
$dstfile1 = __DIR__.'/../../../main/img/icons/64/notebookteacher.png';
$dstfile2 = __DIR__.'/../../../main/img/icons/64/notebookteacher_na.png';
$dstfile3 = __DIR__.'/../../../main/img/icons/32/notebookteacher.png';
$dstfile4 = __DIR__.'/../../../main/img/notebookteacher.png';
copy($srcfile1, $dstfile1);
copy($srcfile2, $dstfile2);
copy($srcfile3, $dstfile3);
copy($srcfile4, $dstfile4);
$list = [
'/64/notebookteacher.png',
'/64/notebookteacher_na.png',
'/32/notebookteacher.png',
'/32/notebookteacher_na.png',
'/32/test2pdf_na.png',
'/22/notebookteacher.png',
];
foreach ($list as $file) {
$source = __DIR__.'/../resources/img/'.$file;
$destination = __DIR__.'/../../../main/img/icons/'.$file;
$res = @copy($source, $destination);
if (!$res) {
break;
}
}
require_once api_get_path(SYS_PLUGIN_PATH).'notebookteacher/database.php';
}

@ -80,7 +80,7 @@ class SepePlugin extends Plugin
$sm = $cn->getSchemaManager();
$tables = $sm->tablesExist($tablesToBeCompared);
if ($tables) {
if (empty($tables)) {
return false;
}

@ -39,19 +39,28 @@ class Test2pdfPlugin extends Plugin
//Installing course settings
$this->install_course_fields_in_all_courses();
$srcfile1 = __DIR__.'/../resources/img/64/test2pdf.png';
$srcfile2 = __DIR__.'/../resources/img/64/test2pdf_na.png';
$srcfile3 = __DIR__.'/../resources/img/22/test2pdf.png';
$dstfile1 = __DIR__.'/../../../main/img/icons/64/test2pdf.png';
$dstfile2 = __DIR__.'/../../../main/img/icons/64/test2pdf_na.png';
$dstfile3 = __DIR__.'/../../../main/img/test2pdf.png';
$res1 = @copy($srcfile1, $dstfile1);
$res2 = @copy($srcfile2, $dstfile2);
$res3 = @copy($srcfile3, $dstfile3);
if (!$res1 || !$res2 || !$res3) {
$warning = 'Test2PDF plugin icons could not be copied to main/img/ because of folder permissions. To fix, give web server user permissions to write to main/img/ before enabling this plugin.';
Display::addFlash($warning);
error_log($warning);
$list = [
'/64/test2pdf.png',
'/64/test2pdf_na.png',
'/32/test2pdf.png',
'/32/test2pdf_na.png',
'/22/test2pdf.png',
];
$res = true;
foreach ($list as $file) {
$source = __DIR__.'/../resources/img/'.$file;
$destination = __DIR__.'/../../../main/img/icons/'.$file;
$res = @copy($source, $destination);
if (!$res) {
break;
}
}
if (!$res) {
$warning = 'Test2PDF plugin icons could not be copied to main/img/ because of folder permissions.
To fix, give web server user permissions to write to main/img/ before enabling this plugin.';
Display::addFlash(Display::return_message($warning, 'warning'));
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 947 B

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Loading…
Cancel
Save