|
|
|
@ -242,10 +242,10 @@ class SessionManager { |
|
|
|
|
|
|
|
|
|
$select = "SELECT * FROM (SELECT |
|
|
|
|
IF ( |
|
|
|
|
(s.date_start <= '$today' AND '$today' < s.date_end) OR |
|
|
|
|
(s.date_start = '0000-00-00' AND s.date_end = '0000-00-00' ) OR |
|
|
|
|
(s.date_start <= '$today' AND '0000-00-00' = s.date_end) OR |
|
|
|
|
('$today' < s.date_end AND '0000-00-00' = s.date_start) |
|
|
|
|
(s.date_start <= '$today' AND '$today' < s.date_end) OR |
|
|
|
|
(s.date_start = '0000-00-00' AND s.date_end = '0000-00-00' ) OR |
|
|
|
|
(s.date_start <= '$today' AND '0000-00-00' = s.date_end) OR |
|
|
|
|
('$today' < s.date_end AND '0000-00-00' = s.date_start) |
|
|
|
|
, 1, 0) |
|
|
|
|
as session_active, |
|
|
|
|
s.name, |
|
|
|
@ -256,12 +256,18 @@ class SessionManager { |
|
|
|
|
$coach_name, |
|
|
|
|
sc.name as category_name, |
|
|
|
|
s.visibility, |
|
|
|
|
u.user_id, s.id"; |
|
|
|
|
u.user_id, |
|
|
|
|
s.id"; |
|
|
|
|
|
|
|
|
|
$limit = null; |
|
|
|
|
if (!empty($options['limit'])) { |
|
|
|
|
$limit = " LIMIT ".$options['limit']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query = "$select FROM $tbl_session s |
|
|
|
|
LEFT JOIN $tbl_session_category sc ON s.session_category_id = sc.id |
|
|
|
|
INNER JOIN $tbl_user u ON s.id_coach = u.user_id ". |
|
|
|
|
$where; |
|
|
|
|
INNER JOIN $tbl_user u ON s.id_coach = u.user_id |
|
|
|
|
$where $limit"; |
|
|
|
|
|
|
|
|
|
global $_configuration; |
|
|
|
|
if ($_configuration['multiple_access_urls']) { |
|
|
|
@ -269,22 +275,26 @@ class SessionManager { |
|
|
|
|
$access_url_id = api_get_current_access_url_id(); |
|
|
|
|
if ($access_url_id != -1) { |
|
|
|
|
$where.= " AND ar.access_url_id = $access_url_id "; |
|
|
|
|
$query = "$select |
|
|
|
|
$query = " $select |
|
|
|
|
FROM $tbl_session s |
|
|
|
|
LEFT JOIN $tbl_session_category sc ON s.session_category_id = sc.id |
|
|
|
|
INNER JOIN $tbl_user u ON s.id_coach = u.user_id |
|
|
|
|
INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id |
|
|
|
|
$where "; |
|
|
|
|
$where $limit"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query .= ") AS session_table"; |
|
|
|
|
|
|
|
|
|
if (!empty($options['where'])) { |
|
|
|
|
$query .= ' WHERE '.$options['where']; |
|
|
|
|
$query .= ' WHERE '.$options['where']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query .= " ORDER BY ".$options['order']." LIMIT ".$options['limit']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($options['order'])) { |
|
|
|
|
$query .= " ORDER BY ".$options['order']; |
|
|
|
|
} |
|
|
|
|
//var_dump($query); |
|
|
|
|
|
|
|
|
|
$result = Database::query($query); |
|
|
|
|
$formatted_sessions = array(); |
|
|
|
|
if (Database::num_rows($result)) { |
|
|
|
|