diff --git a/main/auth/courses.php b/main/auth/courses.php index 82db4b619a..e3fd01edff 100755 --- a/main/auth/courses.php +++ b/main/auth/courses.php @@ -211,9 +211,21 @@ switch ($action) { break; case 'subscribe_to_session': $userId = api_get_user_id(); + $confirmed = isset($_GET['confirm']); + $sessionId = intval($_GET['session_id']); if (empty($userId)) { - header('Location: ' . api_get_path(WEB_PATH)); + api_not_allowed(); + exit; + } + + if (!$confirmed) { + $template = new Template(null, false, false, false, false, false); + $template->assign('session_id', $sessionId); + + $layout = $template->get_template('auth/confirm_session_subscription.tpl'); + + echo $template->fetch($layout); exit; } @@ -223,7 +235,7 @@ switch ($action) { $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); $sequences = $repository->getRequirements( - $_GET['session_id'], + $sessionId, SequenceResource::SESSION_TYPE ); diff --git a/main/auth/courses_controller.php b/main/auth/courses_controller.php index ae75ebead3..8bd6930b6c 100755 --- a/main/auth/courses_controller.php +++ b/main/auth/courses_controller.php @@ -534,23 +534,32 @@ class CoursesController $url .= 'auth/courses.php?'; $url .= http_build_query([ 'action' => 'subscribe_to_session', - 'session_id' => intval($sessionId) + 'session_id' => intval($sessionId), + 'modal_size' => 'md' ]); + + $result = Display::toolbarButton( + get_lang('Subscribe'), + $url, + 'check-circle', + 'primary', + ['class' => 'btn-lg btn-block ajax'] + ); } else { $url .= 'inc/email_editor.php?'; $url .= http_build_query([ 'action' => 'subscribe_me_to_session', 'session' => Security::remove_XSS($sessionName) ]); - } - $result = Display::toolbarButton( - get_lang('Subscribe'), - $url, - 'check-circle', - 'primary', - ['class' => 'btn-lg btn-block'] - ); + $result = Display::toolbarButton( + get_lang('Subscribe'), + $url, + 'check-circle', + 'primary', + ['class' => 'btn-lg btn-block'] + ); + } $hook = HookResubscribe::create(); if (!empty($hook)) { diff --git a/main/template/default/auth/confirm_session_subscription.tpl b/main/template/default/auth/confirm_session_subscription.tpl new file mode 100644 index 0000000000..e0c773c7e2 --- /dev/null +++ b/main/template/default/auth/confirm_session_subscription.tpl @@ -0,0 +1,9 @@ +

{{ 'AreYouSureToSubscribe'|get_lang }}

+
+
+ {{ 'Yes'|get_lang }} +
+
+ +
+
diff --git a/main/template/default/layout/head.tpl b/main/template/default/layout/head.tpl index 9618b04b12..39537ad5cb 100755 --- a/main/template/default/layout/head.tpl +++ b/main/template/default/layout/head.tpl @@ -349,7 +349,7 @@ $(function() { }); // Global popup - $('a.ajax').on('click', function(e) { + $('body').on('click', 'a.ajax', function(e) { e.preventDefault(); var contentUrl = this.href,