|
|
|
@ -18,7 +18,6 @@ |
|
|
|
|
/** |
|
|
|
|
* INIT SECTION |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
// Language files that should be included. |
|
|
|
|
|
|
|
|
|
use \ChamiloSession as Session; |
|
|
|
@ -85,6 +84,7 @@ use Symfony\Component\HttpFoundation\Response; |
|
|
|
|
|
|
|
|
|
class UserPortalController |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
function indexAction(Application $app) |
|
|
|
|
{ |
|
|
|
|
// Check if a user is enrolled only in one course for going directly to the course after the login. |
|
|
|
@ -202,15 +202,14 @@ class UserPortalController |
|
|
|
|
return new Response($response, 200, array()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function check_last_login() { |
|
|
|
|
function check_last_login() |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled. |
|
|
|
|
* @todo Check if this code is used. I think this code is never executed because after clicking the submit button |
|
|
|
|
* the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending |
|
|
|
|
* on api_get_setting('page_after_login'). |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
if (!empty($_POST['submitAuth'])) { |
|
|
|
|
// The user has been already authenticated, we are now to find the last login of the user. |
|
|
|
|
if (!empty($this->user_id)) { |
|
|
|
@ -242,7 +241,8 @@ class UserPortalController |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function set_login_form() { |
|
|
|
|
function set_login_form() |
|
|
|
|
{ |
|
|
|
|
global $loginFailed; |
|
|
|
|
|
|
|
|
|
$login_form = ''; |
|
|
|
@ -274,7 +274,8 @@ class UserPortalController |
|
|
|
|
/** |
|
|
|
|
* Alias for the online_logout() function |
|
|
|
|
*/ |
|
|
|
|
function logout() { |
|
|
|
|
function logout() |
|
|
|
|
{ |
|
|
|
|
online_logout($this->user_id, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -284,7 +285,8 @@ class UserPortalController |
|
|
|
|
* @param string $category |
|
|
|
|
* @return boolean |
|
|
|
|
*/ |
|
|
|
|
function category_has_open_courses($category) { |
|
|
|
|
function category_has_open_courses($category) |
|
|
|
|
{ |
|
|
|
|
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; |
|
|
|
|
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
|
|
|
$category = Database::escape_string($category); |
|
|
|
@ -310,7 +312,8 @@ class UserPortalController |
|
|
|
|
* |
|
|
|
|
* @version 1.0.1 |
|
|
|
|
*/ |
|
|
|
|
function handle_login_failed() { |
|
|
|
|
function handle_login_failed() |
|
|
|
|
{ |
|
|
|
|
$message = get_lang('InvalidId'); |
|
|
|
|
|
|
|
|
|
if (!isset($_GET['error'])) { |
|
|
|
@ -350,7 +353,8 @@ class UserPortalController |
|
|
|
|
* @param int $user_id: the id of the user |
|
|
|
|
* @return array an array containing all the information of the courses of the given user |
|
|
|
|
*/ |
|
|
|
|
function get_courses_of_user($user_id) { |
|
|
|
|
function get_courses_of_user($user_id) |
|
|
|
|
{ |
|
|
|
|
$table_course = Database::get_main_table(TABLE_MAIN_COURSE); |
|
|
|
|
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
|
|
|
// Secondly we select the courses that are in a category (user_course_cat <> 0) and sort these according to the sort of the category |
|
|
|
@ -368,12 +372,23 @@ class UserPortalController |
|
|
|
|
$courses = array(); |
|
|
|
|
while ($row = Database::fetch_array($result)) { |
|
|
|
|
// We only need the database name of the course. |
|
|
|
|
$courses[$row['k']] = array('db' => $row['db'], 'code' => $row['k'], 'visual_code' => $row['vc'], 'title' => $row['i'], 'directory' => $row['dir'], 'status' => $row['status'], 'tutor' => $row['t'], 'subscribe' => $row['subscr'], 'unsubscribe' => $row['unsubscr'], 'sort' => $row['sort'], 'user_course_category' => $row['user_course_cat']); |
|
|
|
|
$courses[$row['k']] = array( |
|
|
|
|
'db' => $row['db'], |
|
|
|
|
'code' => $row['k'], |
|
|
|
|
'visual_code' => $row['vc'], |
|
|
|
|
'title' => $row['i'], |
|
|
|
|
'directory' => $row['dir'], |
|
|
|
|
'status' => $row['status'], |
|
|
|
|
'tutor' => $row['t'], |
|
|
|
|
'subscribe' => $row['subscr'], |
|
|
|
|
'unsubscribe' => $row['unsubscr'], |
|
|
|
|
'sort' => $row['sort'], |
|
|
|
|
'user_course_category' => $row['user_course_cat'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
return $courses; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$app->get('/', 'UserPortalController::indexAction'); |
|
|
|
|
$app->run(); |
|
|
|
|
//$app['http_cache']->run(); |