Adding configuration setting verification -refs #6222

1.9.x
unknown 12 years ago
parent 7c3455c07c
commit 092e4f63c8
  1. 188
      main/user/add_users_to_session.php
  2. 165
      main/user/resume_session.php
  3. 71
      main/user/session_list.php

@ -30,38 +30,39 @@ if (api_is_platform_admin()) {
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList')); $interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview')); $interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview'));
} }
// Database Table Definitions if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); // Database Table Definitions
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
// setting the name of the tool // setting the name of the tool
$tool_name = get_lang('SubscribeUsersToSession'); $tool_name = get_lang('SubscribeUsersToSession');
$add_type = 'unique'; $add_type = 'unique';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') { if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') {
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
$page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null; $page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null;
//checking for extra field with filter on //checking for extra field with filter on
$extra_field_list= UserManager::get_extra_fields(); $extra_field_list= UserManager::get_extra_fields();
$new_field_list = array(); $new_field_list = array();
if (is_array($extra_field_list)) { if (is_array($extra_field_list)) {
foreach ($extra_field_list as $extra_field) { foreach ($extra_field_list as $extra_field) {
//if is enabled to filter and is a "<select>" field type //if is enabled to filter and is a "<select>" field type
if ($extra_field[8]==1 && $extra_field[2]==4 ) { if ($extra_field[8]==1 && $extra_field[2]==4 ) {
$new_field_list[] = array('name'=> $extra_field[3], 'variable'=>$extra_field[1], 'data'=> $extra_field[9]); $new_field_list[] = array('name'=> $extra_field[3], 'variable'=>$extra_field[1], 'data'=> $extra_field[9]);
} }
} }
} }
function search_users($needle, $type) function search_users($needle, $type)
{ {
global $tbl_user,$tbl_session_rel_user,$id_session; global $tbl_user,$tbl_session_rel_user,$id_session;
$xajax_response = new XajaxResponse(); $xajax_response = new XajaxResponse();
$return = ''; $return = '';
@ -182,14 +183,14 @@ function search_users($needle, $type)
} }
} }
return $xajax_response; return $xajax_response;
} }
$xajax -> processRequests(); $xajax -> processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = ' $htmlHeadXtra[] = '
<script type="text/javascript"> <script type="text/javascript">
function add_user_to_session (code, content) { function add_user_to_session (code, content) {
document.getElementById("user_to_add").value = ""; document.getElementById("user_to_add").value = "";
document.getElementById("ajax_list_users_single").innerHTML = ""; document.getElementById("ajax_list_users_single").innerHTML = "";
@ -203,45 +204,45 @@ function add_user_to_session (code, content) {
destination.options[destination.length] = new Option(content,code); destination.options[destination.length] = new Option(content,code);
destination.selectedIndex = -1; destination.selectedIndex = -1;
sortOptions(destination.options); sortOptions(destination.options);
} }
function remove_item(origin) { function remove_item(origin) {
for(var i = 0 ; i<origin.options.length ; i++) { for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) { if(origin.options[i].selected) {
origin.options[i]=null; origin.options[i]=null;
i = i-1; i = i-1;
} }
} }
} }
function validate_filter() { function validate_filter() {
document.formulaire.add_type.value = \''.$add_type.'\'; document.formulaire.add_type.value = \''.$add_type.'\';
document.formulaire.form_sent.value=0; document.formulaire.form_sent.value=0;
document.formulaire.submit(); document.formulaire.submit();
} }
function checked_in_no_session(checked) { function checked_in_no_session(checked) {
$("#first_letter_user") $("#first_letter_user")
.find("option") .find("option")
.attr("selected", false); .attr("selected", false);
xajax_search_users(checked, "any_session"); xajax_search_users(checked, "any_session");
} }
function change_select(val) { function change_select(val) {
$("#user_with_any_session_id").attr("checked", false); $("#user_with_any_session_id").attr("checked", false);
xajax_search_users(val,"multiple"); xajax_search_users(val,"multiple");
} }
</script>'; </script>';
$form_sent = 0; $form_sent = 0;
$errorMsg = $firstLetterUser = $firstLetterSession=''; $errorMsg = $firstLetterUser = $firstLetterSession='';
$UserList = $SessionList = array(); $UserList = $SessionList = array();
$sessions = array(); $sessions = array();
$noPHP_SELF = true; $noPHP_SELF = true;
if (isset($_POST['form_sent']) && $_POST['form_sent']) { if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent']; $form_sent = $_POST['form_sent'];
$firstLetterUser = $_POST['firstLetterUser']; $firstLetterUser = $_POST['firstLetterUser'];
$firstLetterSession = $_POST['firstLetterSession']; $firstLetterSession = $_POST['firstLetterSession'];
@ -257,17 +258,17 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
header('Location: resume_session.php?id_session='.$id_session); header('Location: resume_session.php?id_session='.$id_session);
exit; exit;
} }
} }
$session_info = SessionManager::fetch($id_session); $session_info = SessionManager::fetch($id_session);
Display::display_header($tool_name); Display::display_header($tool_name);
$nosessionUsersList = $sessionUsersList = array(); $nosessionUsersList = $sessionUsersList = array();
$ajax_search = $add_type == 'unique' ? true : false; $ajax_search = $add_type == 'unique' ? true : false;
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
if ($ajax_search) { if ($ajax_search) {
$sql = "SELECT user_id, lastname, firstname, username, id_session $sql = "SELECT user_id, lastname, firstname, username, id_session
FROM $tbl_user u FROM $tbl_user u
INNER JOIN $tbl_session_rel_user INNER JOIN $tbl_session_rel_user
@ -295,7 +296,7 @@ if ($ajax_search) {
$sessionUsersList[$user['user_id']] = $user ; $sessionUsersList[$user['user_id']] = $user ;
} }
unset($users); //clean to free memory unset($users); //clean to free memory
} else { } else {
//Filter by Extra Fields //Filter by Extra Fields
$use_extra_fields = false; $use_extra_fields = false;
if (is_array($extra_field_list)) { if (is_array($extra_field_list)) {
@ -416,24 +417,24 @@ if ($ajax_search) {
unset($users[$uid]); unset($users[$uid]);
} }
unset($users); //clean to free memory unset($users); //clean to free memory
} }
if ($add_type == 'multiple') { if ($add_type == 'multiple') {
$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
} else { } else {
$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.Security::remove_XSS($_GET['add']).'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.Security::remove_XSS($_GET['add']).'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
} }
$link_add_group = '<a href="usergroups.php">'.Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>'; $link_add_group = '<a href="usergroups.php">'.Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>';
?> ?>
<div class="actions"> <div class="actions">
<?php echo $link_add_type_unique ?>&nbsp;|&nbsp;<?php echo $link_add_type_multiple ?>&nbsp;|&nbsp;<?php echo $link_add_group; ?> <?php echo $link_add_type_unique ?>&nbsp;|&nbsp;<?php echo $link_add_type_multiple ?>&nbsp;|&nbsp;<?php echo $link_add_group; ?>
</div> </div>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $id_session; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $id_session; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
<?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?> <?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?>
<?php <?php
if ($add_type == 'multiple') { if ($add_type == 'multiple') {
if (is_array($extra_field_list)) { if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list)>0 ) { if (is_array($new_field_list) && count($new_field_list)>0 ) {
echo '<h3>'.get_lang('FilterUsers').'</h3>'; echo '<h3>'.get_lang('FilterUsers').'</h3>';
@ -458,18 +459,18 @@ if ($add_type == 'multiple') {
echo '<br /><br />'; echo '<br /><br />';
} }
} }
} }
?> ?>
<input type="hidden" name="form_sent" value="1" /> <input type="hidden" name="form_sent" value="1" />
<input type="hidden" name="add_type" /> <input type="hidden" name="add_type" />
<?php <?php
if (!empty($errorMsg)) { if (!empty($errorMsg)) {
Display::display_normal_message($errorMsg); //main API Display::display_normal_message($errorMsg); //main API
} }
?> ?>
<div class="row"> <div class="row">
<div class="span5"> <div class="span5">
<div class="multiple_select_header"> <div class="multiple_select_header">
<b><?php echo get_lang('UserListInPlatform') ?> :</b> <b><?php echo get_lang('UserListInPlatform') ?> :</b>
@ -558,12 +559,12 @@ if (!empty($errorMsg)) {
?> ?>
</select> </select>
</div> </div>
</div> </div>
</form> </form>
<script> <script>
<!-- <!--
function moveItem(origin , destination) function moveItem(origin , destination)
{ {
for (var i = 0 ; i<origin.options.length ; i++) { for (var i = 0 ; i<origin.options.length ; i++) {
if (origin.options[i].selected) { if (origin.options[i].selected) {
@ -575,10 +576,10 @@ function moveItem(origin , destination)
destination.selectedIndex = -1; destination.selectedIndex = -1;
sortOptions(destination.options); sortOptions(destination.options);
} }
function sortOptions(options) function sortOptions(options)
{ {
newOptions = new Array(); newOptions = new Array();
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
@ -589,10 +590,10 @@ function sortOptions(options)
for (i = 0 ; i < newOptions.length ; i++) for (i = 0 ; i < newOptions.length ; i++)
options[i] = newOptions[i]; options[i] = newOptions[i];
} }
function mysort(a, b) function mysort(a, b)
{ {
if (a.text.toLowerCase() > b.text.toLowerCase()) { if (a.text.toLowerCase() > b.text.toLowerCase()) {
return 1; return 1;
} }
@ -600,19 +601,19 @@ function mysort(a, b)
return -1; return -1;
} }
return 0; return 0;
} }
function valide() function valide()
{ {
var options = document.getElementById('destination_users').options; var options = document.getElementById('destination_users').options;
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
options[i].selected = true; options[i].selected = true;
document.forms.formulaire.submit(); document.forms.formulaire.submit();
} }
function loadUsersInSelect(select) function loadUsersInSelect(select)
{ {
var xhr_object = null; var xhr_object = null;
@ -641,10 +642,10 @@ function loadUsersInSelect(select)
//alert(xhr_object.responseText); //alert(xhr_object.responseText);
} }
} }
} }
function makepost(select) function makepost(select)
{ {
var options = select.options; var options = select.options;
var ret = ""; var ret = "";
@ -653,9 +654,12 @@ function makepost(select)
return ret; return ret;
} }
--> -->
</script> </script>
<?php <?php
} else {
api_not_allowed();
}
/* FOOTER */ /* FOOTER */
Display::display_footer(); Display::display_footer();

@ -18,43 +18,45 @@ $id_session = (int)$_GET['id_session'];
SessionManager::protect_teacher_session_edit($id_session); SessionManager::protect_teacher_session_edit($id_session);
$tool_name = get_lang('SessionOverview'); $tool_name = get_lang('SessionOverview');
// Database Table Definitions if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); // Database Table Definitions
$tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility $sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility
FROM '.$tbl_session.' LEFT JOIN '.$tbl_user.' ON id_coach = user_id FROM '.$tbl_session.' LEFT JOIN '.$tbl_user.' ON id_coach = user_id
WHERE '.$tbl_session.'.id='.$id_session; WHERE '.$tbl_session.'.id='.$id_session;
$rs = Database::query($sql); $rs = Database::query($sql);
$session = Database::store_result($rs); $session = Database::store_result($rs);
$session = $session[0]; $session = $session[0];
$sql = 'SELECT name FROM '.$tbl_session_category.' WHERE id = "'.intval($session['session_category_id']).'"'; $sql = 'SELECT name FROM '.$tbl_session_category.' WHERE id = "'.intval($session['session_category_id']).'"';
$rs = Database::query($sql); $rs = Database::query($sql);
$session_category = ''; $session_category = '';
if (Database::num_rows($rs)>0) { if (Database::num_rows($rs)>0) {
$rows_session_category = Database::store_result($rs); $rows_session_category = Database::store_result($rs);
$rows_session_category = $rows_session_category[0]; $rows_session_category = $rows_session_category[0];
$session_category = $rows_session_category['name']; $session_category = $rows_session_category['name'];
} }
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : null;
$url_id = api_get_current_access_url_id(); $url_id = api_get_current_access_url_id();
switch ($action) { switch ($action) {
case 'add_user_to_url': case 'add_user_to_url':
$user_id = $_REQUEST['user_id']; $user_id = $_REQUEST['user_id'];
$result = UrlManager::add_user_to_url($user_id, $url_id); $result = UrlManager::add_user_to_url($user_id, $url_id);
@ -99,36 +101,36 @@ switch ($action) {
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session'"); Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session'");
} }
break; break;
} }
Display::display_header($tool_name); Display::display_header($tool_name);
if (!empty($_GET['warn'])) { if (!empty($_GET['warn'])) {
Display::display_warning_message(urldecode($_GET['warn'])); Display::display_warning_message(urldecode($_GET['warn']));
} }
if (!empty($message)) { if (!empty($message)) {
echo $message; echo $message;
} }
echo Display::page_header(Display::return_icon('session.png', get_lang('Session')).' '.$session['name']); echo Display::page_header(Display::return_icon('session.png', get_lang('Session')).' '.$session['name']);
echo Display::page_subheader(get_lang('GeneralProperties').$url); echo Display::page_subheader(get_lang('GeneralProperties').$url);
?> ?>
<!-- General properties --> <!-- General properties -->
<table class="data_table"> <table class="data_table">
<tr> <tr>
<td><?php echo get_lang('GeneralCoach'); ?> :</td> <td><?php echo get_lang('GeneralCoach'); ?> :</td>
<td><?php echo api_get_person_name($session['firstname'], $session['lastname']).' ('.$session['username'].')' ?></td> <td><?php echo api_get_person_name($session['firstname'], $session['lastname']).' ('.$session['username'].')' ?></td>
</tr> </tr>
<?php if(!empty($session_category)) { ?> <?php if(!empty($session_category)) { ?>
<tr> <tr>
<td><?php echo get_lang('SessionCategory') ?></td> <td><?php echo get_lang('SessionCategory') ?></td>
<td><?php echo $session_category; ?></td> <td><?php echo $session_category; ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
<tr> <tr>
<td><?php echo get_lang('Date'); ?> :</td> <td><?php echo get_lang('Date'); ?> :</td>
<td> <td>
<?php <?php
@ -151,38 +153,38 @@ echo Display::page_subheader(get_lang('GeneralProperties').$url);
} }
?> ?>
</td> </td>
</tr> </tr>
<!-- show nb_days_before and nb_days_after only if they are different from 0 --> <!-- show nb_days_before and nb_days_after only if they are different from 0 -->
<tr> <tr>
<td> <td>
<?php echo api_ucfirst(get_lang('DaysBefore')) ?> : <?php echo api_ucfirst(get_lang('DaysBefore')) ?> :
</td> </td>
<td> <td>
<?php echo intval($session['nb_days_access_before_beginning']) ?> <?php echo intval($session['nb_days_access_before_beginning']) ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<?php echo api_ucfirst(get_lang('DaysAfter')) ?> : <?php echo api_ucfirst(get_lang('DaysAfter')) ?> :
</td> </td>
<td> <td>
<?php echo intval($session['nb_days_access_after_end']) ?> <?php echo intval($session['nb_days_access_after_end']) ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<?php echo api_ucfirst(get_lang('SessionVisibility')) ?> : <?php echo api_ucfirst(get_lang('SessionVisibility')) ?> :
</td> </td>
<td> <td>
<?php if ($session['visibility']==1) echo get_lang('ReadOnly'); elseif($session['visibility']==2) echo get_lang('Visible');elseif($session['visibility']==3) echo api_ucfirst(get_lang('Invisible')) ?> <?php if ($session['visibility']==1) echo get_lang('ReadOnly'); elseif($session['visibility']==2) echo get_lang('Visible');elseif($session['visibility']==3) echo api_ucfirst(get_lang('Invisible')) ?>
</td> </td>
</tr> </tr>
<?php <?php
$multiple_url_is_on = api_get_multiple_access_url(); $multiple_url_is_on = api_get_multiple_access_url();
if ($multiple_url_is_on) { if ($multiple_url_is_on) {
echo '<tr><td>'; echo '<tr><td>';
echo 'URL'; echo 'URL';
echo '</td>'; echo '</td>';
@ -192,30 +194,30 @@ if ($multiple_url_is_on) {
echo $url_data['url'].'<br />'; echo $url_data['url'].'<br />';
} }
echo '</td></tr>'; echo '</td></tr>';
} }
?> ?>
</table> </table>
<br /> <br />
<?php <?php
echo Display::page_subheader(get_lang('CourseList').$url); echo Display::page_subheader(get_lang('CourseList').$url);
?> ?>
<!--List of courses --> <!--List of courses -->
<table class="data_table"> <table class="data_table">
<tr> <tr>
<th width="35%"><?php echo get_lang('CourseTitle'); ?></th> <th width="35%"><?php echo get_lang('CourseTitle'); ?></th>
<th width="30%"><?php echo get_lang('CourseCoach'); ?></th> <th width="30%"><?php echo get_lang('CourseCoach'); ?></th>
<th width="20%"><?php echo get_lang('UsersNumber'); ?></th> <th width="20%"><?php echo get_lang('UsersNumber'); ?></th>
</tr> </tr>
<?php <?php
if ($session['nbr_courses'] == 0){ if ($session['nbr_courses'] == 0){
echo '<tr> echo '<tr>
<td colspan="4">'.get_lang('NoCoursesForThisSession').'</td> <td colspan="4">'.get_lang('NoCoursesForThisSession').'</td>
</tr>'; </tr>';
} else { } else {
// select the courses // select the courses
$sql = "SELECT code,title,visual_code, nbr_users $sql = "SELECT code,title,visual_code, nbr_users
FROM $tbl_course,$tbl_session_rel_course FROM $tbl_course,$tbl_session_rel_course
@ -265,20 +267,20 @@ if ($session['nbr_courses'] == 0){
</tr>'; </tr>';
} }
} }
?> ?>
</table> </table>
<br /> <br />
<?php <?php
echo Display::page_subheader(get_lang('UserList').$url); echo Display::page_subheader(get_lang('UserList').$url);
?> ?>
<!--List of users --> <!--List of users -->
<table class="data_table"> <table class="data_table">
<tr> <tr>
<th> <th>
<?php echo get_lang('User'); ?> <?php echo get_lang('User'); ?>
@ -287,13 +289,13 @@ echo Display::page_subheader(get_lang('UserList').$url);
<?php echo get_lang('Actions'); ?> <?php echo get_lang('Actions'); ?>
</th> </th>
</tr> </tr>
<?php <?php
if ($session['nbr_users']==0) { if ($session['nbr_users']==0) {
echo '<tr> echo '<tr>
<td colspan="2">'.get_lang('NoUsersForThisSession').'</td> <td colspan="2">'.get_lang('NoUsersForThisSession').'</td>
</tr>'; </tr>';
} else { } else {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname'; $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
if ($multiple_url_is_on) { if ($multiple_url_is_on) {
@ -342,9 +344,12 @@ if ($session['nbr_users']==0) {
</td> </td>
</tr>'; </tr>';
} }
} }
?> ?>
</table> </table>
<?php <?php
} else {
api_not_allowed();
}
// footer // footer
Display :: display_footer(); Display :: display_footer();

@ -21,36 +21,34 @@ $htmlHeadXtra[] = api_get_jqgrid_js();
$action = $_REQUEST['action']; $action = $_REQUEST['action'];
$idChecked = $_REQUEST['idChecked']; $idChecked = $_REQUEST['idChecked'];
if (api_is_platform_admin()) {
$interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'));
}
$tool_name = get_lang('SessionList'); $tool_name = get_lang('SessionList');
Display::display_header($tool_name); Display::display_header($tool_name);
$error_message = ''; // Avoid conflict with the global variable $error_msg (array type) in add_course.conf.php. if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
$error_message = ''; // Avoid conflict with the global variable $error_msg (array type) in add_course.conf.php.
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
$error_message = Security::remove_XSS($_GET['message']); $error_message = Security::remove_XSS($_GET['message']);
} }
if (!empty($error_message)) { if (!empty($error_message)) {
Display::display_normal_message($error_message, false); Display::display_normal_message($error_message, false);
} }
//jqgrid will use this URL to do the selects //jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&from_course_session=1'; $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&from_course_session=1';
if (isset($_REQUEST['keyword'])) { if (isset($_REQUEST['keyword'])) {
//Begin with see the searchOper param //Begin with see the searchOper param
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&from_course_session=1&_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=name&searchString='.Security::remove_XSS($_REQUEST['keyword']).'&searchOper=bw'; $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&from_course_session=1&_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=name&searchString='.Security::remove_XSS($_REQUEST['keyword']).'&searchOper=bw';
} }
//The order is important you need to check the the $column variable in the model.ajax.php file //The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('NumberOfUsers'), get_lang('SessionCategoryName'), $columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('NumberOfUsers'), get_lang('SessionCategoryName'),
get_lang('StartDate'), get_lang('EndDate'), get_lang('Coach'), get_lang('Status'), get_lang('Visibility'), get_lang('Actions')); get_lang('StartDate'), get_lang('EndDate'), get_lang('Coach'), get_lang('Status'), get_lang('Visibility'), get_lang('Actions'));
//$activeurl = '?sidx=session_active'; //$activeurl = '?sidx=session_active';
//Column config //Column config
$column_model = array( $column_model = array(
array('name'=>'name', 'index'=>'name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), array('name'=>'name', 'index'=>'name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
array('name'=>'nbr_courses', 'index'=>'nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'), array('name'=>'nbr_courses', 'index'=>'nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
array('name'=>'nbr_users', 'index'=>'nbr_users', 'width'=>'30', 'align'=>'left', 'search' => 'true'), array('name'=>'nbr_users', 'index'=>'nbr_users', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
@ -67,22 +65,22 @@ $column_model = array(
'editoptions' => array('value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))), 'editoptions' => array('value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))),
array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'), array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false') array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false')
); );
//Autowidth //Autowidth
$extra_params['autowidth'] = 'true'; $extra_params['autowidth'] = 'true';
//height auto //height auto
$extra_params['height'] = 'auto'; $extra_params['height'] = 'auto';
//$extra_params['excel'] = 'excel'; //$extra_params['excel'] = 'excel';
//$extra_params['rowList'] = array(10, 20 ,30); //$extra_params['rowList'] = array(10, 20 ,30);
//With this function we can add actions to the jgrid (edit, delete, etc) //With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) { $action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'&nbsp;<a href="add_users_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('user_subscribe_session.png',get_lang('SubscribeUsersToSession'),'',ICON_SIZE_SMALL).'</a>'. return \'&nbsp;<a href="add_users_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('user_subscribe_session.png',get_lang('SubscribeUsersToSession'),'',ICON_SIZE_SMALL).'</a>'.
'\'; '\';
}'; }';
?> ?>
<script> <script>
function setSearchSelect(columnName) { function setSearchSelect(columnName) {
$("#sessions").jqGrid('setColProp', columnName, $("#sessions").jqGrid('setColProp', columnName,
@ -96,10 +94,10 @@ $action_links = 'function action_formatter(cellvalue, options, rowObject) {
} }
} }
}); });
} }
$(function() { $(function() {
<?php <?php
echo Display::grid_js('sessions', $url,$columns,$column_model,$extra_params, array(), $action_links,true); echo Display::grid_js('sessions', $url,$columns,$column_model,$extra_params, array(), $action_links,true);
?> ?>
@ -141,15 +139,18 @@ $(function() {
jQuery("#sessions").jqGrid('filterToolbar',options); jQuery("#sessions").jqGrid('filterToolbar',options);
var sgrid = $("#sessions")[0]; var sgrid = $("#sessions")[0];
sgrid.triggerToolbar(); sgrid.triggerToolbar();
}); });
</script> </script>
<?php if (api_is_platform_admin()) {?> <?php if (api_is_platform_admin()) {?>
<div class="actions"> <div class="actions">
<?php <?php
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('new_session.png',get_lang('AddSession'),'',ICON_SIZE_MEDIUM).'</a>'; echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('new_session.png',get_lang('AddSession'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/add_many_session_to_category.php">'.Display::return_icon('session_to_category.png',get_lang('AddSessionsInCategories'),'',ICON_SIZE_MEDIUM).'</a>'; echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/add_many_session_to_category.php">'.Display::return_icon('session_to_category.png',get_lang('AddSessionsInCategories'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_list.php">'.Display::return_icon('folder.png',get_lang('ListSessionCategory'),'',ICON_SIZE_MEDIUM).'</a>'; echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_list.php">'.Display::return_icon('folder.png',get_lang('ListSessionCategory'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>'; echo '</div>';
}
} else {
api_not_allowed();
} }
echo Display::grid_html('sessions'); echo Display::grid_html('sessions');
Display::display_footer(); Display::display_footer();

Loading…
Cancel
Save