Minor - Improve code styles - refs BT#20363

pull/4502/head
Christian 3 years ago
parent 4254613dd6
commit 74dd8b0734
  1. 12
      main/inc/ajax/user_manager.ajax.php
  2. 51
      main/inc/lib/attendance.lib.php
  3. 9
      main/inc/lib/export.lib.inc.php
  4. 2
      main/install/configuration.dist.php

@ -20,12 +20,13 @@ switch ($action) {
case 'comment_attendance':
$selected = $_REQUEST['selected'];
$comment = $_REQUEST['comment'];
$attendanceId = $_REQUEST['attendance_id'];
$attendanceId = (int) $_REQUEST['attendance_id'];
if (!empty($selected)) {
list($prefix, $userId, $attendanceCalendarId) = explode('-', $selected);
$attendance = new Attendance();
$attendance->saveComment($userId,
$attendanceCalendarId,
$attendance->saveComment(
(int) $userId,
(int) $attendanceCalendarId,
$comment,
$attendanceId
);
@ -39,7 +40,10 @@ switch ($action) {
if (!empty($selected)) {
list($prefix, $userId, $attendanceCalendarId) = explode('-', $selected);
$attendance = new Attendance();
$comment = $attendance->getComment($userId, $attendanceCalendarId);
$comment = $attendance->getComment(
(int) $userId,
(int) $attendanceCalendarId
);
echo $comment;
}
break;

@ -1921,7 +1921,7 @@ class Attendance
// 86400 = 24 hours in seconds
// 604800 = 1 week in seconds
// 1296000 = 1 biweek in seconds
// 1296000 = 2 weeks in seconds
// 2419200 = 1 month in seconds
// 86400 x xdays = interval by x days (in seconds)
// Saves repeated dates
@ -2677,22 +2677,15 @@ class Attendance
}
/**
* It exports the attendance sheet to Xls format.
*
* @param $attendanceId
* @param $studentId
* @param $courseId
* @param $groupId
* @param $filterType
* @param $myCalendarId
* Exports the attendance sheet to Xls format.
*/
public function exportAttendanceSheetToXls(
$attendanceId,
$studentId,
$courseId,
$groupId,
$filterType,
$myCalendarId
int $attendanceId,
int $studentId,
string $courseCode,
int $groupId,
string $filterType,
int $myCalendarId
) {
$users = $this->get_users_rel_course($attendanceId, $groupId);
$calendar = $this->get_attendance_calendar(
@ -2703,11 +2696,11 @@ class Attendance
);
if (!empty($studentId)) {
$userId = (int) $studentId;
$userId = $studentId;
} else {
$userId = api_get_user_id();
}
$courseInfo = api_get_course_info($courseId);
$courseInfo = api_get_course_info($courseCode);
$userPresence = [];
$faults = [];
@ -2776,14 +2769,11 @@ class Attendance
/**
* Get the user comment in attendance sheet.
*
* @param $userId
* @param $attendanceCalendarId
*
* @return false|string
*/
public function getComment(
$userId,
$attendanceCalendarId
int $userId,
int $attendanceCalendarId
) {
$allowComment = api_get_configuration_value('attendance_allow_comments');
if (!$allowComment) {
@ -2824,20 +2814,15 @@ class Attendance
}
/**
* It saves the user comment from attendance sheet.
* Saves the user comment from attendance sheet.
*
* @param $userId
* @param $attendanceCalendarId
* @param $comment
* @param $attendanceId
*
* @return false or void when it is saved.
* @return false
*/
public function saveComment(
$userId,
$attendanceCalendarId,
$comment,
$attendanceId
int $userId,
int $attendanceCalendarId,
string $comment,
int $attendanceId
) {
$allowComment = api_get_configuration_value('attendance_allow_comments');
if (!$allowComment) {

@ -93,11 +93,12 @@ class Export
/**
* Export tabular data to XLS-file included comments.
*
* @param array $data The comment by cell should be added with the prefix [comment] to be added ($txtCellValue.'[comment]'.$txtComment)
* @param string $filename
* @param array $data The comment by cell should be added with the prefix [comment] to be added ($txtCellValue.'[comment]'.$txtComment)
*/
public static function arrayToXlsAndComments($data, $filename = 'export', $encoding = 'utf-8')
{
public static function arrayToXlsAndComments(
array $data,
string $filename = 'export'
) {
$filePath = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.xlsx';
$file = new \SplFileObject($filePath, 'w');

@ -2321,7 +2321,7 @@ INSERT INTO `extra_field` (`extra_field_type`, `field_type`, `variable`, `displa
// Create a document extra field with field label "can_be_downloaded" of type "Checkbox options".
// $_configuration['documents_hide_download_icon'] = false;
// It adds option to define duration for a calendar in attendance sheet.
// Option to define duration for a calendar in attendance sheet.
// Create an attendance calendar extra field with field label "duration" of type "text".
// $_configuration['attendance_calendar_set_duration'] = false;

Loading…
Cancel
Save