get($id); if (empty($userGroupInfo)) { api_not_allowed(true); } $usergroup->protectScript($userGroupInfo); $calendarPlugin = null; if (api_get_plugin_setting('learning_calendar', 'enabled') === 'true') { $calendarPlugin = LearningCalendarPlugin::create(); } // Add the JS needed to use the jqgrid $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($_REQUEST['calendar_id']) ? (int) $_REQUEST['calendar_id'] : 0; // setting breadcrumbs $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')]; $interbreadcrumb[] = ['url' => '#', 'name' => $userGroupInfo['name']]; switch ($action) { case 'add_calendar': $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']); $calendarPlugin->getAddUserToCalendarForm($form); $form->addButtonSave(get_lang('Add')); $form->display(); if ($form->validate()) { $calendarId = $form->getSubmitValue('calendar_id'); if (!empty($calendarId)) { $calendarPlugin->addUserToCalendar($calendarId, $userId); Display::addFlash(Display::return_message(get_lang('Added'), 'confirmation')); header('Location: '.api_get_self().'?id='.$id); exit; } } exit; break; case 'edit_calendar': $form = new FormValidator( 'add_calendar', 'post', api_get_self().'?id='.$id.'&user_id='.$userId.'&action=edit_calendar&calendar_id='.$calendarId ); $userInfo = api_get_user_info($userId); $form->addHeader($userInfo['complete_name']); $calendarPlugin->getAddUserToCalendarForm($form); $form->setDefaults(['calendar_id' => $calendarId]); $form->addButtonSave(get_lang('Update')); $form->display(); if ($form->validate()) { $calendarId = $form->getSubmitValue('calendar_id'); if (!empty($calendarId)) { $calendarPlugin->updateUserToCalendar($calendarId, $userId); Display::addFlash(Display::return_message(get_lang('Added'), 'confirmation')); header('Location: '.api_get_self().'?id='.$id); exit; } } exit; break; 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; } Display::display_header(); // jqgrid will use this URL to do the selects $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_usergroups_users&id='.$id; // The order is important you need to check the the $column variable in the model.ajax.php file $columns = [ get_lang('Name'), get_lang('Actions'), ]; // Column config $column_model = [ ['name' => 'name', 'index' => 'name', 'width' => '35', 'align' => 'left', 'sortable' => 'false'], [ 'name' => 'actions', 'index' => 'actions', 'width' => '20', 'align' => 'center', 'sortable' => 'false', 'formatter' => 'action_formatter', ], ]; if (api_get_plugin_setting('learning_calendar', 'enabled') === 'true') { $columns = [ get_lang('Name'), get_lang('Calendar'), get_lang('ClassroomActivity'), get_lang('TimeSpentByStudentsInCourses'), $calendarPlugin->get_lang('NumberDaysAccumulatedInCalendar'), $calendarPlugin->get_lang('DifferenceOfDaysAndCalendar'), get_lang('Actions'), ]; // Column config $column_model = [ ['name' => 'name', 'index' => 'name', 'width' => '35', 'align' => 'left', 'sortable' => 'false'], [ 'name' => 'calendar', 'index' => 'calendar', 'width' => '35', 'align' => 'left', 'sortable' => 'false', 'formatter' => 'extra_formatter', ], [ 'name' => 'gradebook_items', 'index' => 'gradebook_items', 'width' => '35', 'align' => 'left', 'sortable' => 'false', ], ['name' => 'time_spent', 'index' => 'time_spent', 'width' => '35', 'align' => 'left', 'sortable' => 'false'], [ 'name' => 'lp_day_completed', 'index' => 'lp_day_completed', 'width' => '35', 'align' => 'left', 'sortable' => 'false', ], ['name' => 'days_diff', 'index' => 'days_diff', 'width' => '35', 'align' => 'left', 'sortable' => 'false'], [ 'name' => 'actions', 'index' => 'actions', 'width' => '20', 'align' => 'center', 'sortable' => 'false', 'formatter' => 'action_formatter', ], ]; } // Autowidth $extraParams['autowidth'] = 'true'; // height auto $extraParams['height'] = 'auto'; $extraParams['sortname'] = 'name'; $extraParams['sortorder'] = 'desc'; $extraParams['multiselect'] = true; $deleteIcon = Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL); $urlStats = api_get_path(WEB_CODE_PATH); //$addCalendar = ''.Display::return_icon('agenda.png', get_lang('Agenda'), '', ICON_SIZE_SMALL).''; $reportingIcon = Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_SMALL); $controlPoint = Display::return_icon('add.png', get_lang('ControlPoint'), '', ICON_SIZE_SMALL); //return \''.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).''. // With this function we can add actions to the jgrid $action_links = ' function action_formatter(cellvalue, options, rowObject) { var value = rowObject[5]; return \''. ' '.$controlPoint.''. ' '.$reportingIcon.''. ' '.$deleteIcon.'\'; } function extra_formatter(cellvalue, options, rowObject) { var calendarName = rowObject[1]; var calendarId = rowObject[7]; if (calendarName == "") { return \''.get_lang('Add').'\'; } else { return \' \'+calendarName+\' '.get_lang('Edit').'\'; } return calendarName; return \''. ' '.Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_SMALL).''. ' '.$deleteIcon.'\'; }'; $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')); ?> showGroupTypeSetting = true; // Action handling: Adding a note if ($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); exit; } else { $usergroup->displayToolBarUserGroupUsers(); } Display::display_footer();