From 51e86cd01d25b3db852fc5d36c2dcceeb3d305ff Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 3 Jun 2019 08:18:57 +0200 Subject: [PATCH] Minor - flint fixes --- main/inc/lib/statistics.lib.php | 94 +++++++++++++-------------- main/mySpace/lp_tracking.php | 4 +- main/session/add_users_to_session.php | 2 +- main/work/view.php | 4 +- 4 files changed, 51 insertions(+), 53 deletions(-) diff --git a/main/inc/lib/statistics.lib.php b/main/inc/lib/statistics.lib.php index 2cca455fa0..46b31284ea 100644 --- a/main/inc/lib/statistics.lib.php +++ b/main/inc/lib/statistics.lib.php @@ -1150,53 +1150,6 @@ class Statistics return $chartCode; } - /** - * @param string $startDate - * @param string $endDate - * - * @return array - */ - private static function getLoginsByDate($startDate, $endDate) - { - /** @var DateTime $startDate */ - $startDate = api_get_utc_datetime("$startDate 00:00:00"); - /** @var DateTime $endDate */ - $endDate = api_get_utc_datetime("$endDate 23:59:59"); - - if (empty($startDate) || empty($endDate)) { - return []; - } - - $tblUser = Database::get_main_table(TABLE_MAIN_USER); - $tblLogin = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); - $urlJoin = ''; - $urlWhere = ''; - - if (api_is_multiple_url_enabled()) { - $tblUrlUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - - $urlJoin = "INNER JOIN $tblUrlUser au ON u.id = au.user_id"; - $urlWhere = 'AND au.access_url_id = '.api_get_current_access_url_id(); - } - - $sql = "SELECT u.id, - u.firstname, - u.lastname, - u.username, - SUM(TIMESTAMPDIFF(SECOND, l.login_date, l.logout_date)) AS time_count - FROM $tblUser u - INNER JOIN $tblLogin l ON u.id = l.login_user_id - $urlJoin - WHERE l.login_date BETWEEN '$startDate' AND '$endDate' - $urlWhere - GROUP BY u.id"; - - $stmt = Database::query($sql); - $result = Database::store_result($stmt, 'ASSOC'); - - return $result; - } - /** * Display the Logins By Date report and allow export its result to XLS. */ @@ -1280,4 +1233,51 @@ class Statistics echo $content; } + + /** + * @param string $startDate + * @param string $endDate + * + * @return array + */ + private static function getLoginsByDate($startDate, $endDate) + { + /** @var DateTime $startDate */ + $startDate = api_get_utc_datetime("$startDate 00:00:00"); + /** @var DateTime $endDate */ + $endDate = api_get_utc_datetime("$endDate 23:59:59"); + + if (empty($startDate) || empty($endDate)) { + return []; + } + + $tblUser = Database::get_main_table(TABLE_MAIN_USER); + $tblLogin = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); + $urlJoin = ''; + $urlWhere = ''; + + if (api_is_multiple_url_enabled()) { + $tblUrlUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); + + $urlJoin = "INNER JOIN $tblUrlUser au ON u.id = au.user_id"; + $urlWhere = 'AND au.access_url_id = '.api_get_current_access_url_id(); + } + + $sql = "SELECT u.id, + u.firstname, + u.lastname, + u.username, + SUM(TIMESTAMPDIFF(SECOND, l.login_date, l.logout_date)) AS time_count + FROM $tblUser u + INNER JOIN $tblLogin l ON u.id = l.login_user_id + $urlJoin + WHERE l.login_date BETWEEN '$startDate' AND '$endDate' + $urlWhere + GROUP BY u.id"; + + $stmt = Database::query($sql); + $result = Database::store_result($stmt, 'ASSOC'); + + return $result; + } } diff --git a/main/mySpace/lp_tracking.php b/main/mySpace/lp_tracking.php index 3b321753e7..75265fd4fe 100755 --- a/main/mySpace/lp_tracking.php +++ b/main/mySpace/lp_tracking.php @@ -159,7 +159,7 @@ switch ($action) { } $table->setCellContents($row, 0, 'Q'.$choiceCounter); $table->setCellContents($row, 1, $option['student_response_formatted']); - $result = Display::return_icon('icon_check.png',null,[],ICON_SIZE_SMALL); + $result = Display::return_icon('icon_check.png', null, [], ICON_SIZE_SMALL); if ($option['result'] === 'wrong') { $result = Display::return_icon('icon_error.png', null, [], ICON_SIZE_SMALL); } @@ -224,7 +224,7 @@ switch ($action) { $content = $contentText.''.$tableToString; - $pdf = new PDF('A4', 'P', ['margin_footer' => 4, 'top' => 40, 'bottom' => 25 ]); + $pdf = new PDF('A4', 'P', ['margin_footer' => 4, 'top' => 40, 'bottom' => 25]); $table = new HTML_Table(['class' => 'table', 'style' => 'display: block; margin-bottom: 50px;']); $logo = ChamiloApi::getPlatformLogo( diff --git a/main/session/add_users_to_session.php b/main/session/add_users_to_session.php index f2dc1a2d3e..6c85cb328b 100644 --- a/main/session/add_users_to_session.php +++ b/main/session/add_users_to_session.php @@ -239,7 +239,7 @@ function search_users($needle, $type) $return .= Display::url( $person_name, 'javascript: void(0);', - ['onclick' => "add_user_to_session('".$user['id']."', '".addslashes($person_name)."');",] + ['onclick' => "add_user_to_session('".$user['id']."', '".addslashes($person_name)."');"] ).'
'; } else { $return .= '...
'; diff --git a/main/work/view.php b/main/work/view.php index ed45f9dfdb..4fa72dd2ff 100755 --- a/main/work/view.php +++ b/main/work/view.php @@ -64,9 +64,7 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i $work['active'] == 1 && $work['accepted'] == 1 ) || - (api_is_allowed_to_edit() || api_is_coach()) || - user_is_author($id) || - $isDrhOfCourse + (api_is_allowed_to_edit() || api_is_coach()) || user_is_author($id) || $isDrhOfCourse ) { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : null;