|
|
|
|
@ -29,7 +29,7 @@ if (api_get_plugin_setting('learning_calendar', 'enabled') === 'true') { |
|
|
|
|
$htmlHeadXtra[] = api_get_jqgrid_js(); |
|
|
|
|
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null; |
|
|
|
|
$userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0; |
|
|
|
|
$calendarId = isset($_GET['calendar_id']) ? (int) $_GET['calendar_id'] : 0; |
|
|
|
|
$calendarId = isset($_REQUEST['calendar_id']) ? (int) $_REQUEST['calendar_id'] : 0; |
|
|
|
|
|
|
|
|
|
// setting breadcrumbs |
|
|
|
|
$interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')]; |
|
|
|
|
@ -37,23 +37,16 @@ $interbreadcrumb[] = ['url' => '#', 'name' => $userGroupInfo['name']]; |
|
|
|
|
|
|
|
|
|
switch ($action) { |
|
|
|
|
case 'add_calendar': |
|
|
|
|
$calendars = $calendarPlugin->getCalendars(0, 1000, ''); |
|
|
|
|
if (empty($calendars)) { |
|
|
|
|
echo Display::return_message(get_lang('NoData'), 'warning'); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
$userInfo = api_get_user_info($userId); |
|
|
|
|
$calendars = array_column($calendars, 'title', 'id'); |
|
|
|
|
$calendars = array_map('strip_tags', $calendars); |
|
|
|
|
|
|
|
|
|
$form = new FormValidator( |
|
|
|
|
'add_calendar', |
|
|
|
|
'post', |
|
|
|
|
api_get_self().'?id='.$id.'&user_id='.$userId.'&action=add_calendar' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$userInfo = api_get_user_info($userId); |
|
|
|
|
$form->addHeader($userInfo['complete_name']); |
|
|
|
|
$form->addSelect('calendar_id', get_lang('Calendar'), $calendars, ['disable_js' => true]); |
|
|
|
|
$form->addButtonSave(get_lang('Save')); |
|
|
|
|
$calendarPlugin->getAddUserToCalendarForm($form); |
|
|
|
|
$form->addButtonSave(get_lang('Add')); |
|
|
|
|
$form->display(); |
|
|
|
|
|
|
|
|
|
if ($form->validate()) { |
|
|
|
|
@ -68,15 +61,6 @@ switch ($action) { |
|
|
|
|
exit; |
|
|
|
|
break; |
|
|
|
|
case 'edit_calendar': |
|
|
|
|
$calendars = $calendarPlugin->getCalendars(0, 1000, ''); |
|
|
|
|
if (empty($calendars)) { |
|
|
|
|
echo Display::return_message(get_lang('Nodata')); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$calendars = array_column($calendars, 'title', 'id'); |
|
|
|
|
$calendars = array_map('strip_tags', $calendars); |
|
|
|
|
|
|
|
|
|
$form = new FormValidator( |
|
|
|
|
'add_calendar', |
|
|
|
|
'post', |
|
|
|
|
@ -84,9 +68,9 @@ switch ($action) { |
|
|
|
|
); |
|
|
|
|
$userInfo = api_get_user_info($userId); |
|
|
|
|
$form->addHeader($userInfo['complete_name']); |
|
|
|
|
$form->addSelect('calendar_id', get_lang('Calendar'), $calendars, ['disable_js' => true]); |
|
|
|
|
$form->addButtonSave(get_lang('Update')); |
|
|
|
|
$calendarPlugin->getAddUserToCalendarForm($form); |
|
|
|
|
$form->setDefaults(['calendar_id' => $calendarId]); |
|
|
|
|
$form->addButtonSave(get_lang('Update')); |
|
|
|
|
$form->display(); |
|
|
|
|
|
|
|
|
|
if ($form->validate()) { |
|
|
|
|
@ -103,6 +87,30 @@ switch ($action) { |
|
|
|
|
case 'delete': |
|
|
|
|
$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); |
|
|
|
|
exit; |
|
|
|
|
break; |
|
|
|
|
case 'create_control_point': |
|
|
|
|
$value = isset($_GET['value']) ? (int) $_GET['value'] : 0; |
|
|
|
|
$calendarPlugin->addControlPoint($userId, $value); |
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message($calendarPlugin->get_lang('ControlPointAdded'), 'confirmation') |
|
|
|
|
); |
|
|
|
|
header('Location: '.api_get_self().'?id='.$id); |
|
|
|
|
exit; |
|
|
|
|
case 'add_multiple_users_to_calendar': |
|
|
|
|
$userList = isset($_REQUEST['user_list']) ? explode(',', $_REQUEST['user_list']) : 0; |
|
|
|
|
foreach ($userList as $userId) { |
|
|
|
|
$isAdded = $calendarPlugin->addUserToCalendar($calendarId, $userId); |
|
|
|
|
if (!$isAdded) { |
|
|
|
|
$isAdded = $calendarPlugin->updateUserToCalendar($calendarId, $userId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message(get_lang('Added'), 'confirmation') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
header('Location: '.api_get_self().'?id='.$id); |
|
|
|
|
exit; |
|
|
|
|
break; |
|
|
|
|
@ -194,18 +202,23 @@ $urlStats = api_get_path(WEB_CODE_PATH); |
|
|
|
|
|
|
|
|
|
//$addCalendar = '<a href="'.$urlStats.'mySpace/myStudents.php?student=\'+options.rowId+\'">'.Display::return_icon('agenda.png', get_lang('Agenda'), '', ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
|
|
|
|
|
$reportingIcon = Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_SMALL); |
|
|
|
|
$controlPoint = Display::return_icon('add.png', get_lang('ControlPoint'), '', ICON_SIZE_SMALL); |
|
|
|
|
|
|
|
|
|
//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 = ' |
|
|
|
|
function action_formatter(cellvalue, options, rowObject) { |
|
|
|
|
var value = rowObject[5]; |
|
|
|
|
return \''. |
|
|
|
|
' <a href="'.$urlStats.'mySpace/myStudents.php?student=\'+options.rowId+\'">'.Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_SMALL).'</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>\'; |
|
|
|
|
' <a href="'.$urlStats.'admin/usergroup_users.php?action=create_control_point&value=\'+value+\'&id='.$id.'&user_id=\'+options.rowId+\'">'.$controlPoint.'</a>'. |
|
|
|
|
' <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>\'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function extra_formatter(cellvalue, options, rowObject) { |
|
|
|
|
var calendarName = rowObject[1]; |
|
|
|
|
var calendarId = rowObject[3]; |
|
|
|
|
var calendarId = rowObject[7]; |
|
|
|
|
|
|
|
|
|
if (calendarName == "") { |
|
|
|
|
return \'<a href="'. |
|
|
|
|
@ -224,6 +237,15 @@ function extra_formatter(cellvalue, options, rowObject) { |
|
|
|
|
|
|
|
|
|
$deleteUrl = api_get_path(WEB_AJAX_PATH).'usergroup.ajax.php?a=delete_user_in_usergroup&group_id='.$id; |
|
|
|
|
|
|
|
|
|
$form = new FormValidator( |
|
|
|
|
'add_multiple_calendar', |
|
|
|
|
'post', |
|
|
|
|
api_get_self().'?id='.$id.'&action=add_multiple_users_to_calendar' |
|
|
|
|
); |
|
|
|
|
$calendarPlugin->getAddUserToCalendarForm($form); |
|
|
|
|
$form->addHidden('user_list', ''); |
|
|
|
|
$form->addButtonSave(get_lang('Add')); |
|
|
|
|
|
|
|
|
|
?> |
|
|
|
|
<script> |
|
|
|
|
$(function() { |
|
|
|
|
@ -248,9 +270,41 @@ $(function() { |
|
|
|
|
{ height:280, reloadAfterSubmit:false }, // add options |
|
|
|
|
{ reloadAfterSubmit:false, url: "<?php echo $deleteUrl; ?>" }, // del options
|
|
|
|
|
{ width:500 } // search options |
|
|
|
|
); |
|
|
|
|
) |
|
|
|
|
.navButtonAdd('#usergroups_pager',{ |
|
|
|
|
caption:"<?php echo addslashes($calendarPlugin->get_lang('UpdateCalendar')); ?>",
|
|
|
|
|
buttonicon:"ui-icon ui-icon-plus", |
|
|
|
|
onClickButton: function(a) { |
|
|
|
|
var userIdList = $("#usergroups").jqGrid('getGridParam', 'selarrrow'); |
|
|
|
|
if (userIdList.length) { |
|
|
|
|
$(".modal-body #add_multiple_calendar_user_list").val(userIdList); |
|
|
|
|
$('#myModal').modal(); |
|
|
|
|
} else { |
|
|
|
|
alert("<?php echo addslashes(get_lang('SelectStudents')); ?>");
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
position:"last" |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> |
|
|
|
|
<div class="modal-dialog" role="document"> |
|
|
|
|
<div class="modal-content"> |
|
|
|
|
<div class="modal-header"> |
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|
|
|
|
<span aria-hidden="true">×</span></button> |
|
|
|
|
<h4 class="modal-title" id="myModalLabel"> |
|
|
|
|
<?php echo $calendarPlugin->get_lang('AddMultipleUsersToCalendar'); ?> |
|
|
|
|
</h4> |
|
|
|
|
</div> |
|
|
|
|
<div class="modal-body"> |
|
|
|
|
<?php echo $form->display(); ?> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
$usergroup->showGroupTypeSetting = true; |
|
|
|
|
|