|
@@ -4,7 +4,7 @@
|
|
|
/**
|
|
|
* @package chamilo.admin
|
|
|
*/
|
|
|
-$cidReset = true;
|
|
|
+
|
|
|
require_once __DIR__.'/../inc/global.inc.php';
|
|
|
|
|
|
$this_section = SECTION_PLATFORM_ADMIN;
|
|
@@ -17,10 +17,11 @@ if (empty($userGroupInfo)) {
|
|
|
api_not_allowed(true);
|
|
|
}
|
|
|
|
|
|
-$usergroup->protectScript($userGroupInfo);
|
|
|
+$usergroup->protectScript($userGroupInfo, true, true);
|
|
|
+$allowEdit = api_is_platform_admin() || isset($userGroupInfo['author_id']) && $userGroupInfo['author_id'] == api_get_user_id();
|
|
|
|
|
|
$calendarPlugin = null;
|
|
|
-if (api_get_plugin_setting('learning_calendar', 'enabled') === 'true') {
|
|
|
+if ($allowEdit && api_get_plugin_setting('learning_calendar', 'enabled') === 'true') {
|
|
|
$calendarPlugin = LearningCalendarPlugin::create();
|
|
|
}
|
|
|
|
|
@@ -30,10 +31,19 @@ $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
|
|
|
$userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0;
|
|
|
$calendarId = isset($_REQUEST['calendar_id']) ? (int) $_REQUEST['calendar_id'] : 0;
|
|
|
|
|
|
-// setting breadcrumbs
|
|
|
-$interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')];
|
|
|
+$courseInfo = api_get_course_info();
|
|
|
+if (empty($courseInfo)) {
|
|
|
+ $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')];
|
|
|
+} else {
|
|
|
+ $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'user/class.php?'.api_get_cidreq(), 'name' => get_lang('Classes')];
|
|
|
+
|
|
|
+}
|
|
|
$interbreadcrumb[] = ['url' => '#', 'name' => $userGroupInfo['name']];
|
|
|
|
|
|
+if (!empty($action)) {
|
|
|
+ $usergroup->protectScript($userGroupInfo);
|
|
|
+}
|
|
|
+
|
|
|
switch ($action) {
|
|
|
case 'add_calendar':
|
|
|
$form = new FormValidator(
|
|
@@ -194,7 +204,7 @@ $extraParams['autowidth'] = 'true';
|
|
|
$extraParams['height'] = 'auto';
|
|
|
$extraParams['sortname'] = 'name';
|
|
|
$extraParams['sortorder'] = 'desc';
|
|
|
-$extraParams['multiselect'] = true;
|
|
|
+$extraParams['multiselect'] = $allowEdit;
|
|
|
|
|
|
$deleteIcon = Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL);
|
|
|
$urlStats = api_get_path(WEB_CODE_PATH);
|
|
@@ -207,6 +217,11 @@ $link = '';
|
|
|
if ($calendarPlugin) {
|
|
|
$link = '<a href="'.$urlStats.'admin/usergroup_users.php?action=create_control_point&value=\'+value+\'&id='.$id.'&user_id=\'+options.rowId+\'">'.$controlPoint.'</a>';
|
|
|
}
|
|
|
+
|
|
|
+$deleteButton = '';
|
|
|
+if ($allowEdit) {
|
|
|
+ $deleteButton = '<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."\'".')) return false;" href="?id='.$id.'&action=delete&user_id=\'+options.rowId+\'">'.$deleteIcon.'</a>';
|
|
|
+}
|
|
|
//return \'<a href="session_edit.php?page=resume_session.php&id=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
|
|
|
// With this function we can add actions to the jgrid
|
|
|
$action_links = '
|
|
@@ -215,7 +230,7 @@ function action_formatter(cellvalue, options, rowObject) {
|
|
|
return \''.
|
|
|
' '.$link.
|
|
|
' <a href="'.$urlStats.'mySpace/myStudents.php?student=\'+options.rowId+\'">'.$reportingIcon.'</a>'.
|
|
|
- ' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."\'".')) return false;" href="?id='.$id.'&action=delete&user_id=\'+options.rowId+\'">'.$deleteIcon.'</a>\';
|
|
|
+ ' '.$deleteButton.' \';
|
|
|
}
|
|
|
|
|
|
function extra_formatter(cellvalue, options, rowObject) {
|
|
@@ -269,7 +284,7 @@ $(function() {
|
|
|
$("#usergroups").jqGrid(
|
|
|
"navGrid",
|
|
|
"#usergroups_pager",
|
|
|
- { edit: false, add: false, del: true, search: false},
|
|
|
+ { edit: false, add: false, del: <?php echo $allowEdit ? 'true' : 'false'; ?>, search: false},
|
|
|
{ height:280, reloadAfterSubmit:false }, // edit options
|
|
|
{ height:280, reloadAfterSubmit:false }, // add options
|
|
|
{ reloadAfterSubmit:false, url: "<?php echo $deleteUrl; ?>" }, // del options
|
|
@@ -316,7 +331,7 @@ $(function() {
|
|
|
|
|
|
$usergroup->showGroupTypeSetting = true;
|
|
|
// Action handling: Adding a note
|
|
|
-if ($action === 'delete' && is_numeric($_GET['id'])) {
|
|
|
+if ($allowEdit && $action === 'delete' && is_numeric($_GET['id'])) {
|
|
|
$res = $usergroup->delete_user_rel_group($_GET['user_id'], $_GET['id']);
|
|
|
Display::addFlash(Display::return_message(get_lang('Deleted'), 'confirmation'));
|
|
|
header('Location: '.api_get_self().'?id='.$id);
|