Minor - format code, fix php variables

pull/2487/head
jmontoyaa 7 years ago
parent e1aa8f76f4
commit bd3ef61949
  1. 2
      main/gradebook/certificate_template/template.html
  2. 28
      main/gradebook/gradebook_display_certificate.php
  3. 9
      main/inc/lib/document.lib.php
  4. 2
      main/inc/lib/pdf.lib.php

@ -29,7 +29,7 @@
<img src="{REL_CODE_PATH}img/side-top-b.png" alt="Side top element b">
</td>
</tr>
</table>
</table>
</td>
</tr>
<tr>

@ -32,12 +32,12 @@ if (!api_is_allowed_to_edit() && !api_is_student_boss()) {
api_not_allowed(true);
}
$cat_id = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : null;
$categoryId = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : 0;
$action = isset($_GET['action']) && $_GET['action'] ? $_GET['action'] : null;
$filterOfficialCode = isset($_POST['filter']) ? Security::remove_XSS($_POST['filter']) : null;
$filterOfficialCodeGet = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
$url = api_get_self().'?'.api_get_cidreq().'&cat_id='.$cat_id.'&filter='.$filterOfficialCode;
$url = api_get_self().'?'.api_get_cidreq().'&cat_id='.$categoryId.'&filter='.$filterOfficialCode;
$courseInfo = api_get_course_info();
$filter = api_get_setting('certificate_filter_by_official_code');
@ -50,7 +50,7 @@ if ($filter === 'true') {
$form = new FormValidator(
'official_code_filter',
'POST',
api_get_self().'?'.api_get_cidreq().'&cat_id='.$cat_id
api_get_self().'?'.api_get_cidreq().'&cat_id='.$categoryId
);
$form->addElement('select', 'filter', get_lang('OfficialCode'), $options);
$form->addButton('submit', get_lang('Submit'));
@ -59,21 +59,21 @@ if ($filter === 'true') {
if ($form->validate()) {
$officialCode = $form->getSubmitValue('filter');
if ($officialCode == 'all') {
$certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
$certificate_list = GradebookUtils::get_list_users_certificates($categoryId);
} else {
$userList = UserManager::getUsersByOfficialCode($officialCode);
if (!empty($userList)) {
$certificate_list = GradebookUtils::get_list_users_certificates(
$cat_id,
$categoryId,
$userList
);
}
}
} else {
$certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
$certificate_list = GradebookUtils::get_list_users_certificates($categoryId);
}
} else {
$certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
$certificate_list = GradebookUtils::get_list_users_certificates($categoryId);
}
$content = '';
@ -93,7 +93,7 @@ switch ($action) {
}
$list = GradebookUtils::get_list_gradebook_certificates_by_user_id(
$value['user_id'],
$cat_id
$categoryId
);
foreach ($list as $valueCertificate) {
@ -137,7 +137,7 @@ switch ($action) {
}
}
Category::exportAllCertificates($cat_id, $userList);
Category::exportAllCertificates($categoryId, $userList);
break;
case 'generate_all_certificates':
$userList = CourseManager::get_user_list_from_course_code(
@ -150,12 +150,12 @@ switch ($action) {
if ($userInfo['status'] == INVITEE) {
continue;
}
Category::generateUserCertificate($cat_id, $userInfo['user_id']);
Category::generateUserCertificate($categoryId, $userInfo['user_id']);
}
}
break;
case 'delete_all_certificates':
Category::deleteAllCertificates($cat_id);
Category::deleteAllCertificates($categoryId);
break;
}
@ -190,7 +190,7 @@ if (!empty($content)) {
}
//@todo replace all this code with something like get_total_weight()
$cats = Category::load($cat_id, null, null, null, null, null, false);
$cats = Category::load($categoryId, null, null, null, null, null, false);
if (!empty($cats)) {
//with this fix the teacher only can view 1 gradebook
@ -286,7 +286,7 @@ if (count($certificate_list) == 0) {
$list = GradebookUtils::get_list_gradebook_certificates_by_user_id(
$value['user_id'],
$cat_id
$categoryId
);
foreach ($list as $valueCertificate) {
echo '<tr>';
@ -300,7 +300,7 @@ if (count($certificate_list) == 0) {
array('target' => '_blank', 'class' => 'btn btn-default')
);
echo $certificates;
echo '<a onclick="return confirmation();" href="gradebook_display_certificate.php?sec_token='.$token.'&'.api_get_cidreq().'&action=delete&cat_id='.$cat_id.'&certificate_id='.$valueCertificate['id'].'">
echo '<a onclick="return confirmation();" href="gradebook_display_certificate.php?sec_token='.$token.'&'.api_get_cidreq().'&action=delete&cat_id='.$categoryId.'&certificate_id='.$valueCertificate['id'].'">
'.Display::return_icon('delete.png', get_lang('Delete')).'
</a>';
echo '</td></tr>';

@ -1939,7 +1939,7 @@ class DocumentManager
$extraField = new ExtraField('user');
$extraFields = $extraField->get_all(['filter = ? AND visible_to_self = ?' => [1, 1]]);
//Student information
// Student information
$user_info = api_get_user_info($user_id);
$first_name = $user_info['firstname'];
$last_name = $user_info['lastname'];
@ -1970,7 +1970,6 @@ class DocumentManager
$url = api_get_path(WEB_PATH).'certificates/index.php?id='.$info_grade_certificate['id'];
$externalStyleFile = api_get_path(SYS_CSS_PATH).'themes/'.api_get_visual_theme().'/certificate.css';
$externalStyle = '';
if (is_file($externalStyleFile)) {
$externalStyle = file_get_contents($externalStyleFile);
}
@ -1995,7 +1994,7 @@ class DocumentManager
$externalStyle
);
$info_to_be_replaced_in_content_html = array(
$tags = array(
'((user_firstname))',
'((user_lastname))',
'((gradebook_institution))',
@ -2017,12 +2016,12 @@ class DocumentManager
if (!empty($extraFields)) {
foreach ($extraFields as $extraField) {
$valueExtra = isset($extra_user_info_data[$extraField['variable']]) ? $extra_user_info_data[$extraField['variable']] : '';
$info_to_be_replaced_in_content_html[] = '(('.strtolower($extraField['variable']).'))';
$tags[] = '(('.strtolower($extraField['variable']).'))';
$info_to_replace_in_content_html[] = $valueExtra;
}
}
$info_list[] = $info_to_be_replaced_in_content_html;
$info_list[] = $tags;
$info_list[] = $info_to_replace_in_content_html;
return $info_list;

@ -384,7 +384,7 @@ class PDF
$this->pdf->WriteHTML($document_html.$page_break);
}
} elseif (in_array($extension, array('jpg', 'jpeg', 'png', 'gif'))) {
//Images
// Images
$image = Display::img($file);
$this->pdf->WriteHTML('<html><body>'.$image.'</body></html>'.$page_break);
}

Loading…
Cancel
Save