Add "lp_subscription_settings" settings see BT#10882

By default "add users to lp" and "add users to lp category" are "on":
You can edit the default settings changing this variable:

$_configuration['lp_subscription_settings'] = [
    'options' => [
        'allow_add_users_to_lp' => true,
        'allow_add_users_to_lp_category' => true,
    ]
];
pull/2487/head
jmontoyaa 8 years ago
parent e811ea4109
commit b2d96d9cb0
  1. 8
      main/install/configuration.dist.php
  2. 20
      main/lp/learnpath.class.php
  3. 10
      main/lp/lp_edit.php
  4. 12
      main/lp/lp_list.php
  5. 4
      main/lp/lp_subscribe_users.php
  6. 5
      main/lp/lp_subscribe_users_to_category.php
  7. 285
      main/template/default/learnpath/list.tpl

@ -616,3 +616,11 @@ $_configuration['gradebook_badge_sidebar'] = [
// Hide base course announcements when entering a group.
//$_configuration['hide_base_course_announcements_in_group'] = false;
// Allow or block user subcriptions to a lp/lp category
/*$_configuration['lp_subscription_settings'] = [
'options' => [
'allow_add_users_to_lp' => true,
'allow_add_users_to_lp_category' => true,
]
];*/

@ -12097,5 +12097,25 @@ EOD;
return array_reverse($return);
}
/**
* Reads and process "lp_subscription_settings" setting
* @return array
*/
public static function getSubscriptionSettings()
{
$subscriptionSettings = api_get_configuration_value('lp_subscription_settings');
if (empty($subscriptionSettings)) {
// By default allow both settings
$subscriptionSettings = [
'allow_add_users_to_lp' => true,
'allow_add_users_to_lp_category' => true,
];
} else {
$subscriptionSettings = $subscriptionSettings['options'];
}
return $subscriptionSettings;
}
}

@ -195,7 +195,15 @@ if (api_is_platform_admin()) {
$defaults['use_max_score'] = $_SESSION['oLP']->use_max_score;
}
$form->addElement('checkbox', 'subscribe_users', null, get_lang('SubscribeUsersToLp'));
$subscriptionSettings = learnpath::getSubscriptionSettings();
if ($subscriptionSettings['allow_add_users_to_lp']) {
$form->addElement(
'checkbox',
'subscribe_users',
null,
get_lang('SubscribeUsersToLp')
);
}
// accumulate_scorm_time
$form->addElement(

@ -52,6 +52,8 @@ if (api_get_setting('search_enabled') === 'true') {
}
$current_session = api_get_session_id();
$subscriptionSettings = learnpath::getSubscriptionSettings();
/* Introduction section (editable by course admins) */
$introductionSection = Display::return_introduction_section(
TOOL_LEARNPATH,
@ -668,15 +670,16 @@ foreach ($categories as $item) {
);
// Subscribe users
$subscribeUsers = null;
if ($details['subscribe_users'] == 1) {
$subscribeUsers = '';
if ($details['subscribe_users'] == 1 &&
$subscriptionSettings['allow_add_users_to_lp']
) {
$subscribeUsers = Display::url(
Display::return_icon(
'user.png',
get_lang('SubscribeUsersToLp')
),
api_get_path(WEB_CODE_PATH)
."lp/lp_subscribe_users.php?lp_id=$id&".api_get_cidreq()
api_get_path(WEB_CODE_PATH)."lp/lp_subscribe_users.php?lp_id=$id&".api_get_cidreq()
);
}
@ -877,6 +880,7 @@ foreach ($categories as $item) {
}
$template = new Template($nameTools);
$template->assign('subscription_settings', $subscriptionSettings);
$template->assign('is_allowed_to_edit', $is_allowed_to_edit);
$template->assign('is_invitee', api_is_invitee());
$template->assign('actions', $actions);

@ -23,6 +23,10 @@ if (empty($lpId)) {
api_not_allowed(true);
}
$subscriptionSettings = learnpath::getSubscriptionSettings();
if ($subscriptionSettings['allow_add_users_to_lp'] == false) {
api_not_allowed(true);
}
$oLP = new learnpath(api_get_course_id(), $lpId, api_get_user_id());

@ -20,6 +20,11 @@ if (empty($categoryId)) {
api_not_allowed(true);
}
$subscriptionSettings = learnpath::getSubscriptionSettings();
if ($subscriptionSettings['allow_add_users_to_lp_category'] == false) {
api_not_allowed(true);
}
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();

@ -18,12 +18,11 @@
{% if filtered_category and filtered_category != lp_data.category.id %}
{% set show_category = false %}
{% endif %}
{% if show_category %}
{% if configuration == 0 %}
<!--- old view -->
<!--- old view -->
{% if categories|length > 1 and lp_data.category.id %}
{% if is_allowed_to_edit %}
<h3 class="page-header">
{{ lp_data.category.getName() }}
@ -34,9 +33,11 @@
<img src="{{ "edit.png"|icon }}" alt="{{ "Edit"|get_lang }}">
</a>
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=add_users_to_category&id=' ~ lp_data.category.getId() }}" title="{{ "AddUser"|get_lang }}">
<img src="{{ "user.png"|icon }}" alt="{{ "AddUser"|get_lang }}">
{% if subscription_settings.allow_add_users_to_lp_category %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=add_users_to_category&id=' ~ lp_data.category.getId() }}" title="{{ "AddUsers"|get_lang }}">
<img src="{{ "user.png"|icon }}" alt="{{ "AddUsers"|get_lang }}">
</a>
{% endif %}
{% if loop.index0 == 1 %}
<a href="#">
@ -82,7 +83,6 @@
<img src="{{ 'lp_publish.png'|icon }}" alt="{{ 'Hide'|get_lang }}">
</a>
{% endif %}
{% if not _c.session_id %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=delete_lp_category&id=' ~ lp_data.category.getId() }}" title="{{ "Delete"|get_lang }}">
<img src="{{ "delete.png"|icon }}" alt="{{ "Delete"|get_lang }}">
@ -93,7 +93,6 @@
{% elseif lp_data.lp_list is not empty %}
<h3 class="page-header">{{ lp_data.category.getName() }}</h3>
{% endif %}
{% endif %}
{% if lp_data.lp_list %}
@ -117,56 +116,55 @@
</tr>
</thead>
<tbody>
{% for row in lp_data.lp_list %}
<tr>
{% for row in lp_data.lp_list %}
<tr>
<td>
{{ row.learnpath_icon }}
<a href="{{ row.url_start }}">
{{ row.title }}
{{ row.session_image }}
{{ row.extra }}
</a>
</td>
{% if is_allowed_to_edit %}
<td>
{{ row.learnpath_icon }}
<a href="{{ row.url_start }}">
{{ row.title }}
{{ row.session_image }}
{{ row.extra }}
</a>
{% if row.start_time %}
<span class="small">{{ row.start_time }}</span>
{% endif %}
</td>
{% if is_allowed_to_edit %}
<td>
{% if row.start_time %}
<span class="small">{{ row.start_time }}</span>
{% endif %}
</td>
<td>
<span class="small">{{ row.end_time }}</span>
</td>
<td>
<span class="small">{{ row.end_time }}</span>
</td>
<td>
{{ row.dsp_progress }}
</td>
{% else %}
{% if not is_invitee %}
<td>
{{ row.dsp_progress }}
</td>
{% else %}
{% if not is_invitee %}
<td>
{{ row.dsp_progress }}
</td>
{% endif %}
{% endif %}
<td>
{{ row.action_build }}
{{ row.action_edit }}
{{ row.action_visible }}
{{ row.action_tracking }}
{{ row.action_publish }}
{{ row.action_subscribe_users }}
{{ row.action_serious_game }}
{{ row.action_reinit }}
{{ row.action_default_view }}
{{ row.action_debug }}
{{ row.action_export }}
{{ row.action_copy }}
{{ row.action_auto_launch }}
{{ row.action_pdf }}
{{ row.action_delete }}
{{ row.action_order }}
</td>
</tr>
{% endfor %}
{% endif %}
<td>
{{ row.action_build }}
{{ row.action_edit }}
{{ row.action_visible }}
{{ row.action_tracking }}
{{ row.action_publish }}
{{ row.action_subscribe_users }}
{{ row.action_serious_game }}
{{ row.action_reinit }}
{{ row.action_default_view }}
{{ row.action_debug }}
{{ row.action_export }}
{{ row.action_copy }}
{{ row.action_auto_launch }}
{{ row.action_pdf }}
{{ row.action_delete }}
{{ row.action_order }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
@ -196,63 +194,62 @@
</tr>
</thead>
<tbody>
{% for row in lp_data.lp_list %}
<tr>
{% for row in lp_data.lp_list %}
<tr>
<td>
{{ row.learnpath_icon }}
<a href="{{ row.url_start }}">
{{ row.title }}
{{ row.session_image }}
{{ row.extra }}
</a>
</td>
{% if is_allowed_to_edit %}
<td>
{{ row.learnpath_icon }}
<a href="{{ row.url_start }}">
{{ row.title }}
{{ row.session_image }}
{{ row.extra }}
</a>
{% if row.start_time %}
<span class="small">{{ row.start_time }}</span>
{% endif %}
</td>
{% if is_allowed_to_edit %}
<td>
{% if row.start_time %}
<span class="small">{{ row.start_time }}</span>
{% endif %}
</td>
<td>
<span class="small">{{ row.end_time }}</span>
</td>
<td>
<span class="small">{{ row.end_time }}</span>
</td>
<td>
{{ row.dsp_progress }}
</td>
{% else %}
{% if not is_invitee %}
<td>
{{ row.dsp_progress }}
</td>
{% else %}
{% if not is_invitee %}
<td>
{{ row.dsp_progress }}
</td>
{% endif %}
{% endif %}
{% endif %}
<td>
{{ row.action_build }}
{{ row.action_edit }}
{{ row.action_visible }}
{{ row.action_tracking }}
{{ row.action_publish }}
{{ row.action_subscribe_users }}
{{ row.action_serious_game }}
{{ row.action_reinit }}
{{ row.action_default_view }}
{{ row.action_debug }}
{{ row.action_export }}
{{ row.action_copy }}
{{ row.action_auto_launch }}
{{ row.action_pdf }}
{{ row.action_delete }}
{{ row.action_order }}
</td>
</tr>
{% endfor %}
<td>
{{ row.action_build }}
{{ row.action_edit }}
{{ row.action_visible }}
{{ row.action_tracking }}
{{ row.action_publish }}
{{ row.action_subscribe_users }}
{{ row.action_serious_game }}
{{ row.action_reinit }}
{{ row.action_default_view }}
{{ row.action_debug }}
{{ row.action_export }}
{{ row.action_copy }}
{{ row.action_auto_launch }}
{{ row.action_pdf }}
{{ row.action_delete }}
{{ row.action_order }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endif %}
{% if categories|length > 1 and lp_data.category.id %}
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-{{ lp_data.category.getId() }}">
<h4 class="panel-title">
@ -263,66 +260,68 @@
{% if is_allowed_to_edit %}
<div class="tools-actions pull-right">
{% if lp_data.category.getId() > 0 %}
{% if not _c.session_id %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=add_lp_category&id=' ~ lp_data.category.getId() }}" title="{{ "Edit"|get_lang }}">
<img src="{{ "edit.png"|icon }}" alt="{{ "Edit"|get_lang }}">
</a>
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=add_users_to_category&id=' ~ lp_data.category.getId() }}" title="{{ "AddUser"|get_lang }}">
<img src="{{ "user.png"|icon }}" alt="{{ "AddUser"|get_lang }}">
</a>
{% if not _c.session_id %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=add_lp_category&id=' ~ lp_data.category.getId() }}" title="{{ "Edit"|get_lang }}">
<img src="{{ "edit.png"|icon }}" alt="{{ "Edit"|get_lang }}">
</a>
{% if loop.index0 == 1 %}
<a href="#">
<img src="{{ "up_na.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
{% else %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=move_up_category&id=' ~ lp_data.category.getId() }}" title="{{ "Move"|get_lang }}">
<img src="{{ "up.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
{% endif %}
{% if (data|length - 1) == loop.index0 %}
<a href="#">
<img src="{{ "down_na.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
{% else %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=move_down_category&id=' ~ lp_data.category.getId() }}" title="{{ "Move"|get_lang }}">
<img src="{{ "down.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
{% endif %}
{% if subscription_settings.allow_add_users_to_lp_category %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=add_users_to_category&id=' ~ lp_data.category.getId() }}" title="{{ "AddUsers"|get_lang }}">
<img src="{{ "user.png"|icon }}" alt="{{ "AddUsers"|get_lang }}">
</a>
{% endif %}
{% if lp_data.category_visibility == 0 %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_visibility', 'id':lp_data.category.id, 'new_status':1}|url_encode }}"
title="{{ 'Show'|get_lang }}">
<img src="{{ 'invisible.png'|icon }}" alt="{{ 'Show'|get_lang }}">
{% if loop.index0 == 1 %}
<a href="#">
<img src="{{ "up_na.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
{% else %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_visibility', 'id':lp_data.category.id, 'new_status':0}|url_encode }}"
title="{{ 'Hide'|get_lang }}">
<img src="{{ 'visible.png'|icon }}" alt="{{ 'Hide'|get_lang }}">
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=move_up_category&id=' ~ lp_data.category.getId() }}" title="{{ "Move"|get_lang }}">
<img src="{{ "up.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
{% endif %}
{% if lp_data.category_is_published == 0 %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_publish', 'id':lp_data.category.id, 'new_status':1}|url_encode }}"
title="{{ 'LearnpathPublish'|get_lang }}">
<img src="{{ 'lp_publish_na.png'|icon }}" alt="{{ 'LearnpathPublish'|get_lang }}">
{% if (data|length - 1) == loop.index0 %}
<a href="#">
<img src="{{ "down_na.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
{% else %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_publish', 'id':lp_data.category.id, 'new_status':0}|url_encode }}"
title="{{ 'LearnpathDoNotPublish'|get_lang }}">
<img src="{{ 'lp_publish.png'|icon }}" alt="{{ 'Hide'|get_lang }}">
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=move_down_category&id=' ~ lp_data.category.getId() }}" title="{{ "Move"|get_lang }}">
<img src="{{ "down.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
{% endif %}
{% endif %}
{% if not _c.session_id %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=delete_lp_category&id=' ~ lp_data.category.getId() }}" title="{{ "Delete"|get_lang }}">
<img src="{{ "delete.png"|icon }}" alt="{{ "Delete"|get_lang }}">
</a>
{% endif %}
{% if lp_data.category_visibility == 0 %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_visibility', 'id':lp_data.category.id, 'new_status':1}|url_encode }}"
title="{{ 'Show'|get_lang }}">
<img src="{{ 'invisible.png'|icon }}" alt="{{ 'Show'|get_lang }}">
</a>
{% else %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_visibility', 'id':lp_data.category.id, 'new_status':0}|url_encode }}"
title="{{ 'Hide'|get_lang }}">
<img src="{{ 'visible.png'|icon }}" alt="{{ 'Hide'|get_lang }}">
</a>
{% endif %}
{% if lp_data.category_is_published == 0 %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_publish', 'id':lp_data.category.id, 'new_status':1}|url_encode }}"
title="{{ 'LearnpathPublish'|get_lang }}">
<img src="{{ 'lp_publish_na.png'|icon }}" alt="{{ 'LearnpathPublish'|get_lang }}">
</a>
{% else %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_publish', 'id':lp_data.category.id, 'new_status':0}|url_encode }}"
title="{{ 'LearnpathDoNotPublish'|get_lang }}">
<img src="{{ 'lp_publish.png'|icon }}" alt="{{ 'Hide'|get_lang }}">
</a>
{% endif %}
{% if not _c.session_id %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=delete_lp_category&id=' ~ lp_data.category.getId() }}" title="{{ "Delete"|get_lang }}">
<img src="{{ "delete.png"|icon }}" alt="{{ "Delete"|get_lang }}">
</a>
{% endif %}
{% endif %}
</div>
{% endif %}
</div>
@ -406,11 +405,11 @@
</div>
</div>
</div>
{% endif %}
<!-- end view block accordeon -->
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</div>
{% if is_allowed_to_edit and not lp_is_shown %}

Loading…
Cancel
Save