Minor - format code, remove php warnings

pull/2539/head
jmontoyaa 8 years ago
parent a2c87e0168
commit ae3abaf322
  1. 1
      main/inc/lib/message.lib.php
  2. 18
      plugin/customcertificate/src/CustomCertificatePlugin.php
  3. 1707
      plugin/customcertificate/src/index.php
  4. 107
      plugin/customcertificate/src/print_certificate.php

@ -292,6 +292,7 @@ class MessageManager
";
$result = Database::query($sql);
return Database::num_rows($result) > 0;
}

@ -32,7 +32,7 @@ class CustomCertificatePlugin extends Plugin
{
parent::__construct(
'1.0',
'Jose Angel Ruiz - NoSoloRed (original author)',
'Jose Angel Ruiz - NoSoloRed (original author), Julio Montoya',
[
'enable_plugin_customcertificate' => 'boolean',
]
@ -82,7 +82,7 @@ class CustomCertificatePlugin extends Plugin
public function uninstall()
{
// Deleting course settings.
$this->uninstall_course_fields_in_all_courses($this->course_settings);
$this->uninstall_course_fields_in_all_courses();
$tablesToBeDeleted = [self::TABLE_CUSTOMCERTIFICATE];
foreach ($tablesToBeDeleted as $tableToBeDeleted) {
@ -138,10 +138,9 @@ class CustomCertificatePlugin extends Plugin
'certificate_default' => 0,
];
Database::insert(self::TABLE_CUSTOMCERTIFICATE, $params);
$certificateId = Database::insert_id();
$certificateId = Database::insert(self::TABLE_CUSTOMCERTIFICATE, $params);
//Image manager
// Image manager
$pathDestiny = $base.'certificates/'.$certificateId.'/';
if (!file_exists($pathDestiny)) {
@ -172,8 +171,7 @@ class CustomCertificatePlugin extends Plugin
$params['c_id'] = 0;
$params['session_id'] = 0;
$params['certificate_default'] = 1;
Database::insert(self::TABLE_CUSTOMCERTIFICATE, $params);
$certificateId = Database::insert_id();
$certificateId = Database::insert(self::TABLE_CUSTOMCERTIFICATE, $params);
$pathOrigin = $base.'certificates/default/';
$pathDestiny = $base.'certificates/'.$certificateId.'/';
foreach ($imgList as $value) {
@ -205,7 +203,7 @@ class CustomCertificatePlugin extends Plugin
{
$id = (int) $id;
if (empty($id)) {
return false;
return [];
}
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
@ -237,9 +235,8 @@ class CustomCertificatePlugin extends Plugin
* Check if it redirects.
*
* @param certificate $certificate
* @param int $id
* @param int $certId
*
* @return array
*/
public function redirectCheck($certificate, $certId)
{
@ -268,6 +265,7 @@ class CustomCertificatePlugin extends Plugin
'&course_code='.$infoCertificate['course_code'].
'&session_id='.$infoCertificate['session_id'];
header('Location: '.$url);
exit;
}
}
}

File diff suppressed because it is too large Load Diff

@ -45,10 +45,10 @@ if (empty($_GET['export_all'])) {
} 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)
$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)) {
@ -102,13 +102,13 @@ if (empty($infoCertificate)) {
$workSpace = intval(297 - $infoCertificate['margin_left'] - $infoCertificate['margin_right']);
$widthCell = intval($workSpace / 6);
$htmlText = '';
$htmlText .= '
<link rel="stylesheet"
type="text/css"
$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"
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_CSS_PATH).'editor.css">';
$htmlText .= '<body>';
foreach ($userList as $userInfo) {
@ -118,46 +118,46 @@ foreach ($userList as $userInfo) {
$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;
$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;"
$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;"
$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;"
$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;
"
$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>';
@ -266,48 +266,48 @@ foreach ($userList as $userInfo) {
$htmlText .= '<tr>';
$htmlText .= '<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text1'])) ? $infoCertificate['signature_text1'] : '').
'</td>
'</td>
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text2'])) ? $infoCertificate['signature_text2'] : '').
'</td>
'</td>
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text3'])) ? $infoCertificate['signature_text3'] : '').
'</td>
'</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">
'</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;"
? '<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;"
? '<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;"
? '<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;"
? '<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;"
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['seal'].'" />'
: '').
'</td>';
@ -359,11 +359,11 @@ foreach ($userList as $userInfo) {
continue;
}
$sql = "SELECT 1
FROM $tblProperty
WHERE tool = 'learnpath_category'
AND ref = $categoryId
AND visibility = 0
$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) {
@ -393,10 +393,10 @@ foreach ($userList as $userInfo) {
foreach ($flat_list as $learnpath) {
$lpId = $learnpath['lp_old_id'];
$sql = "SELECT 1
FROM $tblProperty
WHERE tool = 'learnpath'
AND ref = $lpId AND visibility = 0
$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) {
@ -464,11 +464,12 @@ function getIndexFiltered($index)
$txt = strip_tags($index, "<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);
$text1 = '';
for ($x = 0; $x < 47; $x++) {
$text1 .= $lines[$x].chr(13).chr(10);
}
$text2 = '';
for ($x = 47; $x < 94; $x++) {
$text2 .= $lines[$x].chr(13).chr(10);
}

Loading…
Cancel
Save