Applied fixes from FlintCI and Codacy

pull/2525/head
Nosolored 8 years ago
parent 69545e0f74
commit c32cb1fa0f
  1. 2
      certificates/index.php
  2. 2
      main/exercise/fill_blanks.class.php
  3. 6
      main/gradebook/gradebook_display_certificate.php
  4. 4
      main/gradebook/lib/fe/displaygradebook.php
  5. 34
      plugin/customcertificate/resources/css/certificate.css
  6. 38
      plugin/customcertificate/resources/css/form.css
  7. 136
      plugin/customcertificate/resources/js/certificate.js
  8. 21
      plugin/customcertificate/src/CustomCertificatePlugin.php
  9. 152
      plugin/customcertificate/src/index.php
  10. 1002
      plugin/customcertificate/src/print_certificate.php

@ -28,7 +28,7 @@ if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate
$extraFieldValue->saveFieldValues($params);
}
}
$url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/print_certificate.php'.
'?student_id='.$infoCertificate['user_id'].
'&course_code='.$infoCertificate['course_code'].

@ -559,7 +559,7 @@ class FillBlanks extends Question
[
'class' => 'selectpicker',
'data-width' => $width,
'id' => $labelId
'id' => $labelId,
],
false
);

@ -130,8 +130,8 @@ switch ($action) {
case 'export_all_certificates':
$courseCode = api_get_course_id();
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' &&
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 )
{
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1
) {
$url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/print_certificate.php?export_all=1';
} else {
if (api_is_student_boss()) {
@ -143,7 +143,7 @@ switch ($action) {
$userList = UserManager::getUsersByOfficialCode($filterOfficialCodeGet);
}
}
Category::exportAllCertificates($categoryId, $userList);
}
header('Location: '.$url);

@ -465,8 +465,8 @@ class DisplayGradebook
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
$courseCode = api_get_course_id();
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' &&
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 )
{
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1
) {
$actionsRight .= '<a href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/index.php?'.$my_api_cidreq.'&origin=gradebook&selectcat='.$catobj->get_id().'">'.
Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM).'</a>';
} else {

@ -1,17 +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;}
body {background-repeat:no-repeat; margin:0; padding: 0;}
td { font-family:arial, sans-serif; font-size:18px; }
.logo { height: 150px; vertical-align: middle; }
.content-table { height: 480px; padding: 10px 25px; vertical-align:middle;}
.content-student { text-align:center;}
.course { padding-top: 10px; text-align:center; vertical-align: middle;}
.modality { text-align:center; }
.course-date { text-align:center; }
.expediction { font-size: 18px; padding: 20px 0; text-align:right;}
.seals { font-size: 16px; text-align:center;}
.logo-seals { height: 100px; text-align:center; vertical-align: middle;}
@page caraA { height: 210mm; margin:0; padding:0; page-break-before:always;}
.caraA {box-decoration-break: slice; page: caraA}
@page caraB { background:#FFFFFF; }
.caraB {box-decoration-break: slice; page: caraB}
.contents-learnpath td {background: #FFFFFF; font-size: 12px; height: 160mm; padding: 10px; vertical-align: top;}
ol {margin: 0; padding:0;}

@ -1,22 +1,18 @@
.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; }
.form-control-cert {
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
color: #555;
font-size: 14px;
line-height: 1.42857143;
padding: 6px 12px;
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; }

@ -1,70 +1,66 @@
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();
});
function dateCertificateSwitchRadioButton2(){
var inputDateStart = document.getElementById("date_start");
var inputDateEnd = document.getElementById("date_end");
inputDateStart.value = "";
inputDateEnd.value = "";
inputDateStart.setAttribute("disabled","disabled");
inputDateEnd.setAttribute("disabled","disabled");
}
function dateCertificateSwitchRadioButton1(){
var inputDateStart = document.getElementById("date_start");
var inputDateEnd = document.getElementById("date_end");
inputDateStart.removeAttribute("disabled");
inputDateEnd.removeAttribute("disabled");
}
function dateCertificateSwitchRadioButton0(){
var inputDateStart = document.getElementById("date_start");
var inputDateEnd = document.getElementById("date_end");
inputDateStart.value = "";
inputDateEnd.value = "";
inputDateStart.setAttribute("disabled","disabled");
inputDateEnd.setAttribute("disabled","disabled");
}
function typeDateExpedictionSwitchRadioButton(){
var inputType = document.getElementsByName("type_date_expediction");
var type;
for (var i=0;i<inputType.length;i++){
if ( inputType[i].checked ) {
type = parseInt(inputType[i].value);
}
}
var inputDay = document.getElementById("day");
var inputMonth = document.getElementById("month");
var inputYear = document.getElementById("year");
if (type === 2) {
inputDay.removeAttribute("disabled");
inputMonth.removeAttribute("disabled");
inputYear.removeAttribute("disabled");
} else {
inputDay.setAttribute("disabled","disabled");
inputMonth.setAttribute("disabled","disabled");
inputYear.setAttribute("disabled","disabled");
}
}
function contentsTypeSwitchRadioButton(){
var inputType = document.getElementsByName("contents_type");
var type;
for (var i=0;i<inputType.length;i++){
if ( inputType[i].checked ) {
type = parseInt(inputType[i].value);
}
}
var inputContents = document.getElementById("contents");
if (type === 2) {
inputContents.removeAttribute("disabled");
} else {
inputContents.setAttribute("disabled","disabled");
}
}
$(document).ready(function() {
$( ".datepicker" ).datepicker();
});

@ -22,7 +22,7 @@ class CustomCertificatePlugin extends Plugin
[
'name' => 'use_certificate_default',
'type' => 'checkbox',
]
],
];
protected function __construct()
@ -145,14 +145,14 @@ class CustomCertificatePlugin extends Plugin
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',
@ -172,7 +172,7 @@ class CustomCertificatePlugin extends Plugin
);
}
}
if ($row['certificate_default'] == 1) {
$params['c_id'] = 0;
$params['session_id'] = 0;
@ -191,11 +191,11 @@ class CustomCertificatePlugin extends Plugin
}
}
}
$sql = "DROP TABLE IF EXISTS $oldCertificateTable";
Database::query($sql);
echo $this->get_lang('MessageUpdate');
echo get_lang('MessageUpdate');
}
}
@ -212,7 +212,7 @@ class CustomCertificatePlugin extends Plugin
return false;
}
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$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
@ -229,10 +229,11 @@ class CustomCertificatePlugin extends Plugin
return [
'course_code' => $courseCode,
'session_id' => $sessionId,
'user_id' => $userId,
'user_id' => $userId,
];
}
}
return [];
}
}

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
if (intval($_GET['default']) == 1) {
$cidReset = true;
}
@ -62,7 +60,7 @@ if ($enable) {
$infoCertificate = Database::select(
'*',
$table,
['where'=> ['access_url_id = ? AND c_id = ? AND session_id = ?' => [$accessUrlId, $courseId, $sessionId]]],
['where' => ['access_url_id = ? AND c_id = ? AND session_id = ?' => [$accessUrlId, $courseId, $sessionId]]],
'first'
);
if (!is_array($infoCertificate)) {
@ -74,9 +72,9 @@ if ($enable) {
'post',
api_get_self().$urlParams,
null,
array('class' => 'form-vertical')
['class' => 'form-vertical']
);
if (isset($_POST['formSent']) && $_POST['formSent'] == 1 && $form->validate()) {
if ($form->validate()) {
$formValues = $form->getSubmitValues();
if (empty($formValues['contents'])) {
$contents = '';
@ -86,8 +84,8 @@ if ($enable) {
$check = Security::check_token('post');
if ($check) {
$date_start = str_replace('/', '-', $_POST['date_start']);
$date_end = str_replace('/', '-', $_POST['date_end']);
$date_start = str_replace('/', '-', $formValues['date_start']);
$date_end = str_replace('/', '-', $formValues['date_end']);
$params = [
'access_url_id' => api_get_current_access_url_id(),
'c_id' => $formValues['c_id'],
@ -100,19 +98,19 @@ if ($enable) {
'date_end' => date("Y-m-d", strtotime($date_end)),
'place' => $formValues['place'],
'type_date_expediction' => intval($formValues['type_date_expediction']),
'day' => Database::escape_string($_POST['day']),
'month' => Database::escape_string($_POST['month']),
'year' => Database::escape_string($_POST['year']),
'day' => $formValues['day'],
'month' => $formValues['month'],
'year' => $formValues['year'],
'signature_text1' => $formValues['signature_text1'],
'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']),
'certificate_default' => 0
'certificate_default' => 0,
];
if (intval($_POST['default_certificate'] == 1)) {
if (intval($formValues['default_certificate'] == 1)) {
$params['certificate_default'] = 1;
}
@ -320,13 +318,13 @@ if ($enable) {
}
// Certificate Default
if (intval($_POST['use_default'] == 1)) {
if (intval($formValues['use_default'] == 1)) {
$base = api_get_path(SYS_UPLOAD_PATH);
$infoCertificateDefault = Database::select(
'*',
$table,
['where'=> ['certificate_default = ? ' => 1]],
['where' => ['certificate_default = ? ' => 1]],
'first'
);
@ -447,12 +445,12 @@ if ($enable) {
$infoCertificate = Database::select(
'*',
$table,
['where'=> ['access_url_id = ? AND certificate_default = ? ' => [$accessUrlId, 1]]],
['where' => ['access_url_id = ? AND certificate_default = ? ' => [$accessUrlId, 1]]],
'first'
);
if (!is_array($infoCertificate)) {
$infoCertificate = array();
$infoCertificate = [];
}
if (!empty($infoCertificate)) {
$useDefault = true;
@ -467,7 +465,7 @@ if ($enable) {
);
echo Display::toolbarAction(
'toolbar-document',
array($actionsLeft)
[$actionsLeft]
);
if ($useDefault && $courseId > 0) {
@ -543,7 +541,7 @@ if ($enable) {
'',
get_lang('ContentsCourseDescription'),
0,
['id' => 'contents_type_0', 'onclick' => 'javascript: contents_type_switch_radio_button();']
['id' => 'contents_type_0', 'onclick' => 'javascript: contentsTypeSwitchRadioButton();']
);
$group[] = $element;
@ -554,7 +552,7 @@ if ($enable) {
'',
get_lang('ContentsIndexLearnpath'),
1,
['id' => 'contents_type_1', 'onclick' => 'javascript: contents_type_switch_radio_button();']
['id' => 'contents_type_1', 'onclick' => 'javascript: contentsTypeSwitchRadioButton();']
);
$group[] = $element;
@ -564,7 +562,7 @@ if ($enable) {
'',
get_lang('ContentsCustom'),
2,
['id' => 'contents_type_2', 'onclick' => 'javascript: contents_type_switch_radio_button();']
['id' => 'contents_type_2', 'onclick' => 'javascript: contentsTypeSwitchRadioButton();']
);
$group[] = $element;
@ -610,7 +608,7 @@ if ($enable) {
'',
get_lang('UseDateSessionAccess'),
0,
['id' => 'contents_type_0', 'onclick' => 'javascript: date_certificate_switch_radio_button_0();']
['id' => 'contents_type_0', 'onclick' => 'javascript: dateCertificateSwitchRadioButton0();']
);
$group[] = $option1;
@ -620,7 +618,7 @@ if ($enable) {
'',
get_lang('None'),
2,
['id' => 'contents_type_2', 'onclick' => 'javascript: date_certificate_switch_radio_button_2();']
['id' => 'contents_type_2', 'onclick' => 'javascript: dateCertificateSwitchRadioButton2();']
);
$group[] = $option2;
@ -630,7 +628,7 @@ if ($enable) {
'',
get_lang('Custom'),
1,
['id' => 'contents_type_1', 'onclick' => 'javascript: date_certificate_switch_radio_button_1();']
['id' => 'contents_type_1', 'onclick' => 'javascript: dateCertificateSwitchRadioButton1();']
);
$group[] = $option3;
@ -678,7 +676,7 @@ if ($enable) {
'place',
get_lang('ExpectionPlace'),
false,
array('id' => 'place', 'cols-size' => [2, 5, 5], 'autofocus')
['id' => 'place', 'cols-size' => [2, 5, 5], 'autofocus']
);
$group = [];
@ -690,8 +688,8 @@ if ($enable) {
0,
[
'id' => 'type_date_expediction_0',
'onclick' => 'javascript: date_certificate_switch_radio_button_0();',
(($sessionId == 0) ? 'disabled' : '')
'onclick' => 'javascript: dateCertificateSwitchRadioButton0();',
(($sessionId == 0) ? 'disabled' : ''),
]
);
$group[] = $option1;
@ -704,7 +702,7 @@ if ($enable) {
1,
[
'id' => 'type_date_expediction_1',
'onclick' => 'javascript: type_date_expediction_switch_radio_button();',
'onclick' => 'javascript: typeDateExpedictionSwitchRadioButton();',
]
);
$group[] = $option2;
@ -717,7 +715,7 @@ if ($enable) {
3,
[
'id' => 'type_date_expediction_3',
'onclick' => 'javascript: type_date_expediction_switch_radio_button();',
'onclick' => 'javascript: typeDateExpedictionSwitchRadioButton();',
]
);
$group[] = $option4;
@ -730,7 +728,7 @@ if ($enable) {
2,
[
'id' => 'type_date_expediction_2',
'onclick' => 'javascript: type_date_expediction_switch_radio_button();',
'onclick' => 'javascript: typeDateExpedictionSwitchRadioButton();',
]
);
$group[] = $option3;
@ -795,12 +793,12 @@ if ($enable) {
$form->addFile(
'logo_left',
get_lang('LogoLeft'),
array(
[
'id' => 'logo_left',
'class' => 'picture-form',
'crop_image' => true,
'crop_scalable' => 'true'
)
'crop_scalable' => 'true',
]
);
$form->addProgress();
if (!empty($infoCertificate['logo_left'])) {
@ -825,12 +823,12 @@ if ($enable) {
$form->addFile(
'logo_center',
get_lang('LogoCenter'),
array(
[
'id' => 'logo_center',
'class' => 'picture-form',
'crop_image' => true,
'crop_scalable' => 'true'
)
'crop_scalable' => 'true',
]
);
$form->addProgress();
if (!empty($infoCertificate['logo_center'])) {
@ -855,12 +853,12 @@ if ($enable) {
$form->addFile(
'logo_right',
get_lang('LogoRight'),
array(
[
'id' => 'logo_right',
'class' => 'picture-form',
'crop_image' => true,
'crop_scalable' => 'true'
)
'crop_scalable' => 'true',
]
);
$form->addProgress();
if (!empty($infoCertificate['logo_right'])) {
@ -884,12 +882,12 @@ if ($enable) {
$form->addFile(
'seal',
get_lang('Seal'),
array(
[
'id' => 'seal',
'class' => 'picture-form',
'crop_image' => true,
'crop_scalable' => 'true'
)
'crop_scalable' => 'true',
]
);
$form->addProgress();
if (!empty($infoCertificate['seal'])) {
@ -917,17 +915,17 @@ if ($enable) {
'signature_text1',
get_lang('SignatureText1'),
false,
array('cols-size' => [2, 10, 0], 'autofocus')
['cols-size' => [2, 10, 0], 'autofocus']
);
$form->addFile(
'signature1',
get_lang('Signature1'),
array(
[
'id' => 'signature1',
'class' => 'picture-form',
'crop_image' => true,
'crop_scalable' => 'true'
)
'crop_scalable' => 'true',
]
);
$form->addProgress();
if (!empty($infoCertificate['signature1'])) {
@ -953,17 +951,17 @@ if ($enable) {
'signature_text2',
get_lang('SignatureText2'),
false,
array('cols-size' => [2, 10, 0], 'autofocus')
['cols-size' => [2, 10, 0], 'autofocus']
);
$form->addFile(
'signature2',
get_lang('Signature2'),
array(
[
'id' => 'signature2',
'class' => 'picture-form',
'crop_image' => true,
'crop_scalable' => 'true'
)
'crop_scalable' => 'true',
]
);
$form->addProgress();
if (!empty($infoCertificate['signature2'])) {
@ -989,17 +987,17 @@ if ($enable) {
'signature_text3',
get_lang('SignatureText3'),
false,
array('cols-size' => [2, 10, 0], 'autofocus')
['cols-size' => [2, 10, 0], 'autofocus']
);
$form->addFile(
'signature3',
get_lang('Signature3'),
array(
[
'id' => 'signature3',
'class' => 'picture-form',
'crop_image' => true,
'crop_scalable' => 'true'
)
'crop_scalable' => 'true',
]
);
$form->addProgress();
if (!empty($infoCertificate['signature3'])) {
@ -1025,17 +1023,17 @@ if ($enable) {
'signature_text4',
get_lang('SignatureText4'),
false,
array('cols-size' => [2, 10, 0], 'autofocus')
['cols-size' => [2, 10, 0], 'autofocus']
);
$form->addFile(
'signature4',
get_lang('Signature4'),
array(
[
'id' => 'signature4',
'class' => 'picture-form',
'crop_image' => true,
'crop_scalable' => 'true'
)
'crop_scalable' => 'true',
]
);
$form->addProgress();
if (!empty($infoCertificate['signature4'])) {
@ -1062,12 +1060,12 @@ if ($enable) {
$form->addFile(
'background',
get_lang('Background'),
array(
[
'id' => 'background',
'class' => 'picture-form',
'crop_image' => true,
'crop_ratio' => '297 / 210'
)
'crop_ratio' => '297 / 210',
]
);
$form->addProgress();
if (!empty($infoCertificate['background'])) {
@ -1101,14 +1099,14 @@ if ($enable) {
'margin_left',
get_lang('MarginLeft'),
$marginOptions,
array('cols-size' => [4, 8, 0])
['cols-size' => [4, 8, 0]]
);
$form->addElement(
'select',
'margin_right',
get_lang('MarginRight'),
$marginOptions,
array('cols-size' => [4, 8, 0])
['cols-size' => [4, 8, 0]]
);
$form->addElement('html', '</fieldset>');
$form->addElement('html', '</div>');
@ -1143,13 +1141,13 @@ if ($enable) {
'session_id' => $sessionId,
]
);
echo '<div class="page-create">
<div class="row" style="overflow:hidden">
<div id="doc_form" class="col-md-12">
'.$form->returnForm().'
</div>
</div>
</div>';
echo '<div class="page-create">';
echo '<div class="row" style="overflow:hidden">';
echo '<div id="doc_form" class="col-md-12">';
echo $form->returnForm();
echo '</div>';
echo '</div>';
echo '</div>';
Display::display_footer();
} else {
$session = api_get_session_entity(api_get_session_id());
@ -1171,20 +1169,23 @@ if ($enable) {
function uploadImageCertificate(
$certId,
$file = null,
$source_file = null,
$sourceFile = null,
$cropParameters = '',
$default = false
) {
if (empty($certId)) {
return false;
}
$delete = empty($file);
if (empty($source_file)) {
$source_file = $file;
if (empty($sourceFile)) {
$sourceFile = $file;
}
$base = api_get_path(SYS_UPLOAD_PATH);
$path = $base.'certificates/'.$certId.'/';
if ($default) {
$path = $base.'certificates/default/';
}
@ -1193,14 +1194,17 @@ function uploadImageCertificate(
if (!file_exists($path)) {
mkdir($path, api_get_permissions_for_new_directories(), true);
}
// Exit if only deletion has been requested. Return an empty picture name.
if ($delete) {
return '';
}
$allowedTypes = api_get_supported_image_extensions();
$file = str_replace('\\', '/', $file);
$filename = (($pos = strrpos($file, '/')) !== false) ? substr($file, $pos + 1) : $file;
$extension = strtolower(substr(strrchr($filename, '.'), 1));
if (!in_array($extension, $allowedTypes)) {
return false;
}
@ -1210,10 +1214,10 @@ function uploadImageCertificate(
$filename = $certId.'_'.$filename;
//Crop the image to adjust 1:1 ratio
$image = new Image($source_file);
$image = new Image($sourceFile);
$image->crop($cropParameters);
$origin = new Image($source_file); // This is the original picture.
$origin = new Image($sourceFile); // This is the original picture.
$origin->send_image($path.$filename);
$result = $origin;

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save