Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent f7b24a3e1f
commit e5aa8199bf
  1. 106
      main/admin/ldap_users_list.php
  2. 26
      main/inc/lib/attendance.lib.php
  3. 25
      main/inc/lib/myspace.lib.php
  4. 3
      main/session/session_export.php

@ -4,9 +4,6 @@
* @author Mustapha Alouani * @author Mustapha Alouani
* @package chamilo.admin * @package chamilo.admin
*/ */
/**
* Init
*/
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
require('../auth/ldap/authldap.php'); require('../auth/ldap/authldap.php');
@ -38,21 +35,16 @@ $tool_name = get_lang('SearchLDAPUsers');
if (isset ($_GET['action'])) if (isset ($_GET['action']))
{ {
$check = Security::check_token('get'); $check = Security::check_token('get');
if ($check) if ($check) {
{ switch ($_GET['action']) {
switch ($_GET['action'])
{
case 'show_message': case 'show_message':
Display::addFlash(Display::return_message($_GET['message'], 'normal')); Display::addFlash(Display::return_message($_GET['message'], 'normal'));
Display::display_header($tool_name); Display::display_header($tool_name);
break; break;
case 'delete_user': case 'delete_user':
if ($user_id != $_user['user_id'] && UserManager::delete_user($_GET['user_id'])) if ($user_id != $_user['user_id'] && UserManager::delete_user($_GET['user_id'])) {
{
Display::addFlash(Display::return_message(get_lang('UserDeleted'), 'normal')); Display::addFlash(Display::return_message(get_lang('UserDeleted'), 'normal'));
} } else {
else
{
Display::addFlash(Display::return_message(get_lang('CannotDeleteUser'), 'error')); Display::addFlash(Display::return_message(get_lang('CannotDeleteUser'), 'error'));
} }
Display::display_header($tool_name); Display::display_header($tool_name);
@ -81,16 +73,12 @@ if (isset ($_GET['action']))
header('Location: resume_session.php?id_session='.intval($_GET['id_session'])); header('Location: resume_session.php?id_session='.intval($_GET['id_session']));
} else { } else {
Display::display_header($tool_name); Display::display_header($tool_name);
if (count($userid_match_login) > 0) if (count($userid_match_login) > 0) {
{
$message = get_lang('LDAPUsersAddedOrUpdated').':<br />'; $message = get_lang('LDAPUsersAddedOrUpdated').':<br />';
foreach ($userid_match_login as $user_id => $login) foreach ($userid_match_login as $user_id => $login) {
{
$message .= '- '.$login.'<br />'; $message .= '- '.$login.'<br />';
} }
} } else {
else
{
$message = get_lang('NoUserAdded'); $message = get_lang('NoUserAdded');
} }
Display::addFlash(Display::return_message($message, 'normal', false)); Display::addFlash(Display::return_message($message, 'normal', false));
@ -101,42 +89,30 @@ if (isset ($_GET['action']))
Display::display_header($tool_name); Display::display_header($tool_name);
} }
Security::clear_token(); Security::clear_token();
} } else {
else
{
Display::display_header($tool_name); Display::display_header($tool_name);
} }
} } else {
else
{
Display::display_header($tool_name); Display::display_header($tool_name);
} }
if (isset ($_POST['action']))
{ if (isset($_POST['action'])) {
$check = Security::check_token('get'); $check = Security::check_token('get');
if ($check) if ($check) {
{ switch ($_POST['action']) {
switch ($_POST['action'])
{
case 'delete': case 'delete':
$number_of_selected_users = count($_POST['id']); $number_of_selected_users = count($_POST['id']);
$number_of_deleted_users = 0; $number_of_deleted_users = 0;
foreach ($_POST['id'] as $index => $user_id) foreach ($_POST['id'] as $index => $user_id) {
{ if ($user_id != $_user['user_id']) {
if ($user_id != $_user['user_id']) if (UserManager::delete_user($user_id)) {
{
if (UserManager::delete_user($user_id))
{
$number_of_deleted_users++; $number_of_deleted_users++;
} }
} }
} }
if ($number_of_selected_users == $number_of_deleted_users) if ($number_of_selected_users == $number_of_deleted_users) {
{
echo Display::return_message(get_lang('SelectedUsersDeleted'), 'normal'); echo Display::return_message(get_lang('SelectedUsersDeleted'), 'normal');
} } else {
else
{
echo Display::return_message(get_lang('SomeUsersNotDeleted'), 'error'); echo Display::return_message(get_lang('SomeUsersNotDeleted'), 'error');
} }
break; break;
@ -144,21 +120,19 @@ if (isset ($_POST['action']))
$number_of_selected_users = count($_POST['id']); $number_of_selected_users = count($_POST['id']);
$number_of_added_users = 0; $number_of_added_users = 0;
$UserList = array(); $UserList = array();
foreach ($_POST['id'] as $index => $user_id) foreach ($_POST['id'] as $index => $user_id) {
{ if ($user_id != $_user['user_id']) {
if ($user_id != $_user['user_id'])
{
$UserList[] = ldap_add_user($user_id); $UserList[] = ldap_add_user($user_id);
} }
} }
if (isset($_GET['id_session']) && (trim($_GET['id_session']) != "")) if (isset($_GET['id_session']) && (trim($_GET['id_session']) != "")) {
addUserToSession($UserList, $_GET['id_session']); addUserToSession($UserList, $_GET['id_session']);
if (count($UserList) > 0)
{
echo Display::return_message(count($UserList)." ".get_lang('LDAPUsersAdded'));
} }
else if (count($UserList) > 0) {
{ echo Display::return_message(
count($UserList)." ".get_lang('LDAPUsersAdded')
);
} else {
echo Display::return_message(get_lang('NoUserAdded')); echo Display::return_message(get_lang('NoUserAdded'));
} }
break; break;
@ -170,18 +144,16 @@ if (isset ($_POST['action']))
$form = new FormValidator('advanced_search', 'get'); $form = new FormValidator('advanced_search', 'get');
$form->addText('keyword_username', get_lang('LoginName'), false); $form->addText('keyword_username', get_lang('LoginName'), false);
if (api_is_western_name_order()) if (api_is_western_name_order()) {
{
$form->addText('keyword_firstname', get_lang('FirstName'), false); $form->addText('keyword_firstname', get_lang('FirstName'), false);
$form->addText('keyword_lastname', get_lang('LastName'), false); $form->addText('keyword_lastname', get_lang('LastName'), false);
} } else {
else
{
$form->addText('keyword_lastname', get_lang('LastName'), false); $form->addText('keyword_lastname', get_lang('LastName'), false);
$form->addText('keyword_firstname', get_lang('FirstName'), false); $form->addText('keyword_firstname', get_lang('FirstName'), false);
} }
if (isset($_GET['id_session'])) if (isset($_GET['id_session'])) {
$form->addElement('hidden', 'id_session', $_GET['id_session']); $form->addElement('hidden', 'id_session', $_GET['id_session']);
}
$type = array(); $type = array();
$type["all"] = get_lang('All'); $type["all"] = get_lang('All');
@ -195,19 +167,22 @@ $form->addElement('submit', 'submit', get_lang('Ok'));
//$defaults['keyword_inactive'] = 1; //$defaults['keyword_inactive'] = 1;
//$form->setDefaults($defaults); //$form->setDefaults($defaults);
$form->display(); $form->display();
$parameters['keyword_username'] = @$_GET['keyword_username'] ?: null; $parameters['keyword_username'] = @$_GET['keyword_username'] ?: null;
$parameters['keyword_firstname'] = @$_GET['keyword_firstname'] ?: null; $parameters['keyword_firstname'] = @$_GET['keyword_firstname'] ?: null;
$parameters['keyword_lastname'] = @$_GET['keyword_lastname'] ?: null; $parameters['keyword_lastname'] = @$_GET['keyword_lastname'] ?: null;
$parameters['keyword_email'] = @$_GET['keyword_email'] ?: null; $parameters['keyword_email'] = @$_GET['keyword_email'] ?: null;
if (isset($_GET['id_session'])) if (isset($_GET['id_session'])) {
$parameters['id_session'] = $_GET['id_session']; $parameters['id_session'] = $_GET['id_session'];
}
// Create a sortable table with user-data // Create a sortable table with user-data
$parameters['sec_token'] = Security::get_token(); $parameters['sec_token'] = Security::get_token();
$table = new SortableTable('users', 'ldap_get_number_of_users', 'ldap_get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2); $table = new SortableTable(
'users',
'ldap_get_number_of_users',
'ldap_get_user_data',
(api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2
);
$table->set_additional_parameters($parameters); $table->set_additional_parameters($parameters);
$table->set_header(0, '', false); $table->set_header(0, '', false);
$table->set_header(1, get_lang('LoginName')); $table->set_header(1, get_lang('LoginName'));
@ -226,9 +201,4 @@ $table->set_column_filter(5, 'modify_filter');
$table->set_form_actions(array('add_user' => get_lang('AddLDAPUsers'))); $table->set_form_actions(array('add_user' => get_lang('AddLDAPUsers')));
$table->display(); $table->display();
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer(); Display::display_footer();

@ -91,12 +91,13 @@ class Attendance
} }
/** /**
* Get the attendaces to display on the current page (fill the sortable-table) * Get the attendances to display on the current page (fill the sortable-table)
* @param int offset of first user to recover * @param int offset of first user to recover
* @param int Number of users to get * @param int Number of users to get
* @param int Column to sort on * @param int Column to sort on
* @param string Order (ASC,DESC) * @param string Order (ASC,DESC)
* @see SortableTable#get_table_data($from) * @see SortableTable#get_table_data($from)
* @return array
*/ */
public static function get_attendance_data($from, $number_of_items, $column, $direction) public static function get_attendance_data($from, $number_of_items, $column, $direction)
{ {
@ -306,7 +307,6 @@ class Attendance
$last_id = Database::insert($tbl_attendance, $params); $last_id = Database::insert($tbl_attendance, $params);
if (!empty($last_id)) { if (!empty($last_id)) {
$sql = "UPDATE $tbl_attendance SET id = iid WHERE iid = $last_id"; $sql = "UPDATE $tbl_attendance SET id = iid WHERE iid = $last_id";
Database::query($sql); Database::query($sql);
@ -1002,10 +1002,24 @@ class Attendance
$user_id = intval($user_id); $user_id = intval($user_id);
$attendance_id = intval($attendance_id); $attendance_id = intval($attendance_id);
$results = array(); $results = array();
$calendar_count = self::get_number_of_attendance_calendar($attendance_id, $groupId, NULL, $user_id); $calendar_count = self::get_number_of_attendance_calendar(
$attendance_id,
$groupId,
null,
$user_id
);
// $total_done_attendance = $attendance_data['attendance_qualify_max']; // $total_done_attendance = $attendance_data['attendance_qualify_max'];
$total_done_attendance = self::get_number_of_attendance_calendar($attendance_id, $groupId, true, $user_id); $total_done_attendance = self::get_number_of_attendance_calendar(
$attendance_user_score = $this->get_user_score($user_id, $attendance_id, $groupId); $attendance_id,
$groupId,
true,
$user_id
);
$attendance_user_score = $this->get_user_score(
$user_id,
$attendance_id,
$groupId
);
//This is the main change of the BT#1381 //This is the main change of the BT#1381
//$total_done_attendance = $calendar_count; //$total_done_attendance = $calendar_count;
@ -1053,7 +1067,6 @@ class Attendance
//$course_info = api_get_course_info($course_code); //$course_info = api_get_course_info($course_code);
$course_id = $course['real_id']; $course_id = $course['real_id'];
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$attendances_by_course = $this->get_attendances_list($course_id); $attendances_by_course = $this->get_attendances_list($course_id);
foreach ($attendances_by_course as $attendance) { foreach ($attendances_by_course as $attendance) {
@ -1513,7 +1526,6 @@ class Attendance
return $count; return $count;
} }
/** /**
* Get count dates inside attendance calendar by attendance id * Get count dates inside attendance calendar by attendance id
* @param int $attendance_id * @param int $attendance_id

@ -1052,7 +1052,12 @@ class MySpace
$direction = 'ASC'; $direction = 'ASC';
} }
$course_data = self::get_course_data_tracking_overview($from, 1000, $orderby, $direction); $course_data = self::get_course_data_tracking_overview(
$from,
1000,
$orderby,
$direction
);
$csv_content = array(); $csv_content = array();
@ -1810,7 +1815,6 @@ class MySpace
$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2); $avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
} }
$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course); $avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
} else { } else {
$avg_time_spent_in_course = null; $avg_time_spent_in_course = null;
$avg_progress_in_course = null; $avg_progress_in_course = null;
@ -1868,6 +1872,7 @@ class MySpace
* @param int $numberItems * @param int $numberItems
* @param int $column * @param int $column
* @param string $direction * @param string $direction
* @return array
*/ */
public static function get_user_data_tracking_overview($from, $numberItems, $column, $direction) public static function get_user_data_tracking_overview($from, $numberItems, $column, $direction)
{ {
@ -1934,6 +1939,7 @@ class MySpace
$extra_data = UserManager::get_extra_user_data($user_id, true); $extra_data = UserManager::get_extra_user_data($user_id, true);
return $extra_data; return $extra_data;
} }
/** /**
* Checks if a username exist in the DB otherwise it create a "double" * Checks if a username exist in the DB otherwise it create a "double"
* i.e. if we look into for jmontoya but the user's name already exist we create the user jmontoya2 * i.e. if we look into for jmontoya but the user's name already exist we create the user jmontoya2
@ -2116,7 +2122,7 @@ class MySpace
/** /**
* Validates imported data. * Validates imported data.
* @param list of users * @param $users list of users
*/ */
function validate_data($users, $id_session = null) function validate_data($users, $id_session = null)
{ {
@ -2356,7 +2362,8 @@ class MySpace
/** /**
* XML-parser: the handler at the end of element. * XML-parser: the handler at the end of element.
*/ */
function element_end($parser, $data) { function element_end($parser, $data)
{
$data = api_utf8_decode($data); $data = api_utf8_decode($data);
global $user; global $user;
global $users; global $users;
@ -2377,7 +2384,8 @@ class MySpace
/** /**
* XML-parser: the handler for character data. * XML-parser: the handler for character data.
*/ */
function character_data($parser, $data) { function character_data($parser, $data)
{
$data = trim(api_utf8_decode($data)); $data = trim(api_utf8_decode($data));
global $current_value; global $current_value;
$current_value = $data; $current_value = $data;
@ -2388,7 +2396,8 @@ class MySpace
* @param string $file Path to the XML-file * @param string $file Path to the XML-file
* @return array All userinformation read from the file * @return array All userinformation read from the file
*/ */
function parse_xml_data($file) { function parse_xml_data($file)
{
global $current_tag; global $current_tag;
global $current_value; global $current_value;
global $user; global $user;
@ -2537,7 +2546,9 @@ class MySpace
$table->set_header(6, get_lang('TimeLoggedIn'), false); $table->set_header(6, get_lang('TimeLoggedIn'), false);
} }
$template = new Template(null, false, false, false, false, false, false); $template = new Template(
null, false, false, false, false, false, false
);
$template->assign('form', $form->returnForm()); $template->assign('form', $form->returnForm());
$template->assign('table', $table ? $table->return_table() : null); $template->assign('table', $table ? $table->return_table() : null);

@ -31,11 +31,8 @@ $archivePath = api_get_path(SYS_ARCHIVE_PATH);
$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive_path=&archive='; $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive_path=&archive=';
$tool_name = get_lang('ExportSessionListXMLCSV'); $tool_name = get_lang('ExportSessionListXMLCSV');
$interbreadcrumb[] = array('url' => 'session_list.php', 'name' => get_lang('SessionList')); $interbreadcrumb[] = array('url' => 'session_list.php', 'name' => get_lang('SessionList'));
set_time_limit(0); set_time_limit(0);
if (isset($_POST['formSent'])) { if (isset($_POST['formSent'])) {
$formSent = $_POST['formSent']; $formSent = $_POST['formSent'];
$file_type = isset($_POST['file_type']) ? $_POST['file_type'] : 'csv'; $file_type = isset($_POST['file_type']) ? $_POST['file_type'] : 'csv';

Loading…
Cancel
Save