Minor - fix format code

pull/3064/head
Julio 6 years ago
parent 65cd1562df
commit 737906aa85
  1. 13
      public/certificates/index.php
  2. 86
      public/main/announcements/announcements.php
  3. 7
      public/main/announcements/download.php

@ -1,9 +1,8 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Show specified user certificate. * Show specified user certificate.
*
* @package chamilo.certificate
*/ */
require_once '../main/inc/global.inc.php'; require_once '../main/inc/global.inc.php';
@ -18,8 +17,8 @@ switch ($action) {
case 'export': case 'export':
$hideExportLink = api_get_setting('hide_certificate_export_link'); $hideExportLink = api_get_setting('hide_certificate_export_link');
$hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students'); $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
if ($hideExportLink === 'true' || if ('true' === $hideExportLink ||
(api_is_student() && $hideExportLinkStudent === 'true') (api_is_student() && 'true' === $hideExportLinkStudent)
) { ) {
api_not_allowed(true); api_not_allowed(true);
} }
@ -42,7 +41,7 @@ switch ($action) {
$pdfParams['orientation'] = $orientation; $pdfParams['orientation'] = $orientation;
} }
$pageFormat = $pdfParams['orientation'] === 'landscape' ? 'A4-L' : 'A4'; $pageFormat = 'landscape' === $pdfParams['orientation'] ? 'A4-L' : 'A4';
$userInfo = api_get_user_info($certificate->user_id); $userInfo = api_get_user_info($certificate->user_id);
$pdfName = api_replace_dangerous_char( $pdfName = api_replace_dangerous_char(
get_lang('Certificate').' '.$userInfo['username'] get_lang('Certificate').' '.$userInfo['username']
@ -57,6 +56,7 @@ switch ($action) {
false false
); );
} }
break; break;
default: default:
// Special rules for anonymous users // Special rules for anonymous users
@ -67,6 +67,7 @@ switch ($action) {
'warning' 'warning'
); );
Display::display_reduced_footer(); Display::display_reduced_footer();
break; break;
} }
@ -77,10 +78,12 @@ switch ($action) {
'error' 'error'
); );
Display::display_reduced_footer(); Display::display_reduced_footer();
break; break;
} }
// Show certificate HTML // Show certificate HTML
$certificate->show(); $certificate->show();
break; break;
} }

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -9,9 +10,6 @@
* @abstract The task of the internship was to integrate the 'send messages to specific users' with the * @abstract The task of the internship was to integrate the 'send messages to specific users' with the
* Announcements tool and also add the resource linker here. The database also needed refactoring * Announcements tool and also add the resource linker here. The database also needed refactoring
* as there was no title field (the title was merged into the content field) * as there was no title field (the title was merged into the content field)
*
* @package chamilo.announcements
* multiple functions
*/ */
// use anonymous mode when accessing this course tool // use anonymous mode when accessing this course tool
@ -59,7 +57,7 @@ if (!empty($group_id)) {
'name' => get_lang('Group area').' '.$groupProperties['name'], 'name' => get_lang('Group area').' '.$groupProperties['name'],
]; ];
if ($allowToEdit === false) { if (false === $allowToEdit) {
// Check if user is tutor group // Check if user is tutor group
$isTutor = GroupManager::is_tutor_of_group(api_get_user_id(), $groupProperties, $courseId); $isTutor = GroupManager::is_tutor_of_group(api_get_user_id(), $groupProperties, $courseId);
if ($isTutor) { if ($isTutor) {
@ -67,7 +65,7 @@ if (!empty($group_id)) {
} }
// Last chance ... students can send announcements // Last chance ... students can send announcements
if ($groupProperties['announcements_state'] == GroupManager::TOOL_PRIVATE_BETWEEN_USERS) { if (GroupManager::TOOL_PRIVATE_BETWEEN_USERS == $groupProperties['announcements_state']) {
$allowStudentInGroupToSend = true; $allowStudentInGroupToSend = true;
} }
} }
@ -97,13 +95,13 @@ switch ($action) {
/* Move announcement up/down */ /* Move announcement up/down */
if (!empty($_GET['down'])) { if (!empty($_GET['down'])) {
$thisAnnouncementId = intval($_GET['down']); $thisAnnouncementId = (int) ($_GET['down']);
$sortDirection = "DESC"; $sortDirection = 'DESC';
} }
if (!empty($_GET['up'])) { if (!empty($_GET['up'])) {
$thisAnnouncementId = intval($_GET['up']); $thisAnnouncementId = (int) ($_GET['up']);
$sortDirection = "ASC"; $sortDirection = 'ASC';
} }
if (!empty($sortDirection)) { if (!empty($sortDirection)) {
@ -136,6 +134,7 @@ switch ($action) {
$sql = "UPDATE $tbl_announcement SET display_order = '$thisAnnouncementOrder' $sql = "UPDATE $tbl_announcement SET display_order = '$thisAnnouncementOrder'
WHERE c_id = $courseId AND id = $nextAnnouncementId"; WHERE c_id = $courseId AND id = $nextAnnouncementId";
Database::query($sql); Database::query($sql);
break; break;
} }
// STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
@ -148,6 +147,7 @@ switch ($action) {
header('Location: '.$homeUrl); header('Location: '.$homeUrl);
exit; exit;
} }
break; break;
case 'view': case 'view':
$interbreadcrumb[] = [ $interbreadcrumb[] = [
@ -159,6 +159,7 @@ switch ($action) {
if (empty($content)) { if (empty($content)) {
api_not_allowed(true); api_not_allowed(true);
} }
break; break;
case 'list': case 'list':
$htmlHeadXtra[] = api_get_jqgrid_js(); $htmlHeadXtra[] = api_get_jqgrid_js();
@ -281,7 +282,7 @@ switch ($action) {
if (empty($count)) { if (empty($count)) {
$html = ''; $html = '';
if (($allowToEdit || $allowStudentInGroupToSend) && if (($allowToEdit || $allowStudentInGroupToSend) &&
(empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') (empty($_GET['origin']) || 'learnpath' !== $_GET['origin'])
) { ) {
$html .= '<div id="no-data-view">'; $html .= '<div id="no-data-view">';
$html .= '<h3>'.get_lang('Announcements').'</h3>'; $html .= '<h3>'.get_lang('Announcements').'</h3>';
@ -289,7 +290,7 @@ switch ($action) {
$html .= '<div class="controls">'; $html .= '<div class="controls">';
$html .= Display::url( $html .= Display::url(
get_lang('Add an announcement'), get_lang('Add an announcement'),
api_get_self()."?".api_get_cidreq()."&action=add", api_get_self().'?'.api_get_cidreq().'&action=add',
['class' => 'btn btn-primary'] ['class' => 'btn btn-primary']
); );
$html .= '</div>'; $html .= '</div>';
@ -301,11 +302,12 @@ switch ($action) {
} else { } else {
$content .= Display::grid_html('announcements'); $content .= Display::grid_html('announcements');
} }
break; break;
case 'delete': case 'delete':
/* Delete announcement */ /* Delete announcement */
$id = (int) $_GET['id']; $id = (int) $_GET['id'];
if ($sessionId != 0 && api_is_allowed_to_session_edit(false, true) == false) { if (0 != $sessionId && false == api_is_allowed_to_session_edit(false, true)) {
api_not_allowed(); api_not_allowed();
} }
$delete = false; $delete = false;
@ -323,17 +325,19 @@ switch ($action) {
} }
header('Location: '.$homeUrl); header('Location: '.$homeUrl);
exit; exit;
break; break;
case 'delete_all': case 'delete_all':
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
$allow = api_get_configuration_value('disable_delete_all_announcements'); $allow = api_get_configuration_value('disable_delete_all_announcements');
if ($allow === false) { if (false === $allow) {
AnnouncementManager::delete_all_announcements($_course); AnnouncementManager::delete_all_announcements($_course);
Display::addFlash(Display::return_message(get_lang('Announcement has been deletedAll'))); Display::addFlash(Display::return_message(get_lang('Announcement has been deletedAll')));
} }
header('Location: '.$homeUrl); header('Location: '.$homeUrl);
exit; exit;
} }
break; break;
case 'delete_attachment': case 'delete_attachment':
$id = (int) $_GET['id_attach']; $id = (int) $_GET['id_attach'];
@ -344,12 +348,13 @@ switch ($action) {
header('Location: '.$homeUrl); header('Location: '.$homeUrl);
exit; exit;
break; break;
case 'showhide': case 'showhide':
if (!isset($_GET['isStudentView']) || $_GET['isStudentView'] != 'false') { if (!isset($_GET['isStudentView']) || 'false' != $_GET['isStudentView']) {
if (isset($_GET['id']) && $_GET['id']) { if (isset($_GET['id']) && $_GET['id']) {
if ($sessionId != 0 && if (0 != $sessionId &&
api_is_allowed_to_session_edit(false, true) == false false == api_is_allowed_to_session_edit(false, true)
) { ) {
api_not_allowed(); api_not_allowed();
} }
@ -371,16 +376,17 @@ switch ($action) {
} }
} }
} }
break; break;
case 'add': case 'add':
case 'modify': case 'modify':
if ($sessionId != 0 && if (0 != $sessionId &&
api_is_allowed_to_session_edit(false, true) == false false == api_is_allowed_to_session_edit(false, true)
) { ) {
api_not_allowed(true); api_not_allowed(true);
} }
if ($allowStudentInGroupToSend === false) { if (false === $allowStudentInGroupToSend) {
if (!$allowToEdit) { if (!$allowToEdit) {
api_not_allowed(true); api_not_allowed(true);
} }
@ -428,12 +434,12 @@ switch ($action) {
get_lang('Inactivity on %s'), get_lang('Inactivity on %s'),
api_get_setting('siteName') api_get_setting('siteName')
); );
} elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives'] === 'true') { } elseif (isset($_GET['remindallinactives']) && 'true' === $_GET['remindallinactives']) {
// we want to remind inactive users. The $_GET['since'] parameter // we want to remind inactive users. The $_GET['since'] parameter
// determines which users have to be warned (i.e the users who have been inactive for x days or more // determines which users have to be warned (i.e the users who have been inactive for x days or more
$since = 6; $since = 6;
if (isset($_GET['since'])) { if (isset($_GET['since'])) {
if ($_GET['since'] === 'never') { if ('never' === $_GET['since']) {
$since = 'never'; $since = 'never';
} else { } else {
$since = (int) $_GET['since']; $since = (int) $_GET['since'];
@ -466,7 +472,7 @@ switch ($action) {
); );
// when we want to remind the users who have never been active // when we want to remind the users who have never been active
// then we have a different subject and content for the announcement // then we have a different subject and content for the announcement
if ($_GET['since'] === 'never') { if ('never' === $_GET['since']) {
$title_to_modify = sprintf( $title_to_modify = sprintf(
get_lang('Inactivity on %s'), get_lang('Inactivity on %s'),
api_get_setting('siteName') api_get_setting('siteName')
@ -571,6 +577,7 @@ switch ($action) {
}); });
</script> </script>
"); ");
break; break;
} }
} }
@ -610,7 +617,7 @@ switch ($action) {
$config = api_get_configuration_value('announcement.hide_send_to_hrm_users'); $config = api_get_configuration_value('announcement.hide_send_to_hrm_users');
if ($config === false) { if (false === $config) {
$form->addCheckBox( $form->addCheckBox(
'send_to_hrm_users', 'send_to_hrm_users',
null, null,
@ -748,57 +755,58 @@ switch ($action) {
} }
} }
$content = $form->returnForm(); $content = $form->returnForm();
break; break;
} }
if (!empty($_GET['remind_inactive'])) { if (!empty($_GET['remind_inactive'])) {
$to[] = 'USER:'.intval($_GET['remind_inactive']); $to[] = 'USER:'.(int) ($_GET['remind_inactive']);
} }
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { if (empty($_GET['origin']) or 'learnpath' !== $_GET['origin']) {
// We are not in the learning path // We are not in the learning path
Display::display_header($nameTools, get_lang('Announcements')); Display::display_header($nameTools, get_lang('Announcements'));
} }
// Tool introduction // Tool introduction
if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') { if (empty($_GET['origin']) || 'learnpath' !== $_GET['origin']) {
Display::display_introduction_section(TOOL_ANNOUNCEMENT); Display::display_introduction_section(TOOL_ANNOUNCEMENT);
} }
// Actions // Actions
$show_actions = false; $show_actions = false;
$actionsLeft = ''; $actionsLeft = '';
if (($allowToEdit || $allowStudentInGroupToSend) && (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath')) { if (($allowToEdit || $allowStudentInGroupToSend) && (empty($_GET['origin']) || 'learnpath' !== $_GET['origin'])) {
if (in_array($action, ['add', 'modify', 'view'])) { if (in_array($action, ['add', 'modify', 'view'])) {
$actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."'>". $actionsLeft .= "<a href='".api_get_self().'?'.api_get_cidreq()."'>".
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM). Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).
"</a>"; '</a>';
} else { } else {
$actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."&action=add'>". $actionsLeft .= "<a href='".api_get_self().'?'.api_get_cidreq()."&action=add'>".
Display::return_icon('new_announce.png', get_lang('Add an announcement'), '', ICON_SIZE_MEDIUM). Display::return_icon('new_announce.png', get_lang('Add an announcement'), '', ICON_SIZE_MEDIUM).
"</a>"; '</a>';
} }
$show_actions = true; $show_actions = true;
} else { } else {
if (in_array($action, ['view'])) { if (in_array($action, ['view'])) {
$actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."'>". $actionsLeft .= "<a href='".api_get_self().'?'.api_get_cidreq()."'>".
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM)."</a>"; Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
} }
} }
if ($allowToEdit && api_get_group_id() == 0) { if ($allowToEdit && 0 == api_get_group_id()) {
$allow = api_get_configuration_value('disable_delete_all_announcements'); $allow = api_get_configuration_value('disable_delete_all_announcements');
if ($allow === false && api_is_allowed_to_edit()) { if (false === $allow && api_is_allowed_to_edit()) {
if (!isset($_GET['action']) || if (!isset($_GET['action']) ||
isset($_GET['action']) && $_GET['action'] == 'list' isset($_GET['action']) && 'list' == $_GET['action']
) { ) {
$actionsLeft .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("Please confirm your choice")."')) return false;\">". $actionsLeft .= '<a href="'.api_get_self().'?'.api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang('Please confirm your choice')."')) return false;\">".
Display::return_icon( Display::return_icon(
'delete_announce.png', 'delete_announce.png',
get_lang('Clear list of announcements'), get_lang('Clear list of announcements'),
'', '',
ICON_SIZE_MEDIUM ICON_SIZE_MEDIUM
)."</a>"; ).'</a>';
} }
} }
} }
@ -809,7 +817,7 @@ if ($show_actions) {
echo $content; echo $content;
if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') { if (empty($_GET['origin']) || 'learnpath' !== $_GET['origin']) {
//we are not in learnpath tool //we are not in learnpath tool
Display::display_footer(); Display::display_footer();
} }

@ -1,12 +1,11 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* This file is responsible for passing requested documents to the browser. * This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs, * Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL * but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism. * rewrite mechanism.
*
* @package chamilo.announcements
*/ */
session_cache_limiter('nocache'); session_cache_limiter('nocache');
@ -42,7 +41,7 @@ if (is_dir($full_file_name)) {
//remove last slash if present //remove last slash if present
//$doc_url = ($doc_url{strlen($doc_url)-1}=='/')?substr($doc_url,0,strlen($doc_url)-1):$doc_url; //$doc_url = ($doc_url{strlen($doc_url)-1}=='/')?substr($doc_url,0,strlen($doc_url)-1):$doc_url;
//mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (René) //mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (René)
while ($doc_url[$dul = strlen($doc_url) - 1] == '/') { while ('/' == $doc_url[$dul = strlen($doc_url) - 1]) {
$doc_url = substr($doc_url, 0, $dul); $doc_url = substr($doc_url, 0, $dul);
} }
//create the path //create the path
@ -72,7 +71,7 @@ if (Database::num_rows($result) > 0) {
) )
) { ) {
$result = DocumentManager::file_send_for_download($full_file_name, true, $title); $result = DocumentManager::file_send_for_download($full_file_name, true, $title);
if ($result === false) { if (false === $result) {
api_not_allowed(true); api_not_allowed(true);
} }
} }

Loading…
Cancel
Save