parent
e1be9c9864
commit
f0f62976b2
@ -0,0 +1,59 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Validate requirements for a open session |
||||
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> |
||||
* @package chamilo.plugin.advanced_subscription |
||||
*/ |
||||
require_once __DIR__ . '/../config.php'; |
||||
|
||||
$plugin = AdvancedSubscriptionPlugin::create(); |
||||
|
||||
if (!isset($_GET['session_id'], $_GET['user_id'], $_GET['profile_completed'])) { |
||||
die; |
||||
} |
||||
|
||||
$sessionInfo = api_get_session_info($_GET['session_id']); |
||||
|
||||
$tpl = new Template( |
||||
$plugin->get_lang('plugin_title'), |
||||
false, |
||||
false, |
||||
false, |
||||
false, |
||||
false |
||||
); |
||||
$tpl->assign('session', $sessionInfo); |
||||
|
||||
if (SessionManager::isUserSubscribedAsStudent( |
||||
$_GET['session_id'], |
||||
$_GET['user_id'] |
||||
)) { |
||||
$tpl->assign('is_subscribed', false); |
||||
$tpl->assign( |
||||
'errorMessages', |
||||
[sprintf( |
||||
$plugin->get_lang('YouAreAlreadySubscribedToSessionX'), |
||||
$sessionInfo['name'] |
||||
)] |
||||
); |
||||
} else { |
||||
if (!$plugin->isAllowedSubscribeToOpenSession($_GET)) { |
||||
$tpl->assign('is_subscribed', false); |
||||
$tpl->assign('errorMessages', $plugin->getErrorMessages()); |
||||
} else { |
||||
SessionManager::suscribe_users_to_session( |
||||
$_GET['session_id'], |
||||
[$_GET['user_id']], |
||||
SESSION_VISIBLE_READ_ONLY, |
||||
false |
||||
); |
||||
|
||||
$tpl->assign('is_subscribed', true); |
||||
} |
||||
} |
||||
|
||||
$content = $tpl->fetch('/advanced_subscription/views/open_session.tpl'); |
||||
|
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,54 @@ |
||||
<link href="{{ _p.web_plugin }}advanced_subscription/views/css/style.css" rel="stylesheet" type="text/css"> |
||||
|
||||
<script> |
||||
$(document).on('ready', function () { |
||||
$('#asp-close-window').on('click', function (e) { |
||||
e.preventDefault(); |
||||
|
||||
window.close(); |
||||
}); |
||||
|
||||
$('#asp-go-to').on('click', function (e) { |
||||
e.preventDefault(); |
||||
|
||||
window.close(); |
||||
window.opener.location.href = '{{ _p.web_main ~ 'session/index.php?session_id=' ~ session.id }}'; |
||||
}); |
||||
}); |
||||
</script> |
||||
|
||||
<h2 class="legal-terms-title legal-terms-popup"> |
||||
{{ "SubscriptionToOpenSession"|get_plugin_lang('AdvancedSubscriptionPlugin') }} |
||||
</h2> |
||||
|
||||
{% if not is_subscribed %} |
||||
<div class="alert alert-warning legal-terms-popup"> |
||||
<ul> |
||||
{% for errorMessage in errorMessages %} |
||||
<li>{{ errorMessage }}</li> |
||||
{% endfor %} |
||||
</ul> |
||||
</div> |
||||
|
||||
<div class="legal-terms-buttons legal-terms-popup"> |
||||
<a |
||||
class="btn btn-success btn-advanced-subscription btn-accept" |
||||
href="#" id="asp-close-window"> |
||||
<i class="fa fa-check"></i> |
||||
{{ "AcceptInfinitive"|get_plugin_lang('AdvancedSubscriptionPlugin') }} |
||||
</a> |
||||
</div> |
||||
{% else %} |
||||
<div class="alert alert-success legal-terms-popup"> |
||||
{{ 'SuccessSubscriptionToSessionX'|get_plugin_lang('AdvancedSubscriptionPlugin') }} |
||||
</div> |
||||
|
||||
<div class="text-right legal-terms-popup"> |
||||
<a |
||||
class="btn btn-success btn-advanced-subscription btn-accept" |
||||
href="#" id="asp-go-to"> |
||||
<i class="fa fa-external-link"></i> |
||||
{{ "GoToSessionX"|get_plugin_lang('AdvancedSubscriptionPlugin')|format(session.name) }} |
||||
</a> |
||||
</div> |
||||
{% endif %} |
Loading…
Reference in new issue