Minor - format code

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent f7b24a3e1f
commit e5aa8199bf
  1. 116
      main/admin/ldap_users_list.php
  2. 26
      main/inc/lib/attendance.lib.php
  3. 45
      main/inc/lib/myspace.lib.php
  4. 5
      main/session/session_export.php

@ -4,9 +4,6 @@
* @author Mustapha Alouani
* @package chamilo.admin
*/
/**
* Init
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
require('../auth/ldap/authldap.php');
@ -38,26 +35,21 @@ $tool_name = get_lang('SearchLDAPUsers');
if (isset ($_GET['action']))
{
$check = Security::check_token('get');
if ($check)
{
switch ($_GET['action'])
{
case 'show_message' :
if ($check) {
switch ($_GET['action']) {
case 'show_message':
Display::addFlash(Display::return_message($_GET['message'], 'normal'));
Display::display_header($tool_name);
break;
case 'delete_user' :
if ($user_id != $_user['user_id'] && UserManager::delete_user($_GET['user_id']))
{
case 'delete_user':
if ($user_id != $_user['user_id'] && UserManager::delete_user($_GET['user_id'])) {
Display::addFlash(Display::return_message(get_lang('UserDeleted'), 'normal'));
}
else
{
} else {
Display::addFlash(Display::return_message(get_lang('CannotDeleteUser'), 'error'));
}
Display::display_header($tool_name);
break;
case 'lock' :
case 'lock':
$message = lock_unlock_user('lock', $_GET['user_id']);
Display::addFlash(Display::return_message($message, 'normal'));
Display::display_header($tool_name);
@ -81,16 +73,12 @@ if (isset ($_GET['action']))
header('Location: resume_session.php?id_session='.intval($_GET['id_session']));
} else {
Display::display_header($tool_name);
if (count($userid_match_login) > 0)
{
if (count($userid_match_login) > 0) {
$message = get_lang('LDAPUsersAddedOrUpdated').':<br />';
foreach ($userid_match_login as $user_id => $login)
{
foreach ($userid_match_login as $user_id => $login) {
$message .= '- '.$login.'<br />';
}
}
else
{
} else {
$message = get_lang('NoUserAdded');
}
Display::addFlash(Display::return_message($message, 'normal', false));
@ -101,64 +89,50 @@ if (isset ($_GET['action']))
Display::display_header($tool_name);
}
Security::clear_token();
}
else
{
} else {
Display::display_header($tool_name);
}
}
else
{
} else {
Display::display_header($tool_name);
}
if (isset ($_POST['action']))
{
if (isset($_POST['action'])) {
$check = Security::check_token('get');
if ($check)
{
switch ($_POST['action'])
{
case 'delete' :
if ($check) {
switch ($_POST['action']) {
case 'delete':
$number_of_selected_users = count($_POST['id']);
$number_of_deleted_users = 0;
foreach ($_POST['id'] as $index => $user_id)
{
if ($user_id != $_user['user_id'])
{
if (UserManager::delete_user($user_id))
{
foreach ($_POST['id'] as $index => $user_id) {
if ($user_id != $_user['user_id']) {
if (UserManager::delete_user($user_id)) {
$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');
}
else
{
} else {
echo Display::return_message(get_lang('SomeUsersNotDeleted'), 'error');
}
break;
case 'add_user' :
case 'add_user':
$number_of_selected_users = count($_POST['id']);
$number_of_added_users = 0;
$UserList = array();
foreach ($_POST['id'] as $index => $user_id)
{
if ($user_id != $_user['user_id'])
{
foreach ($_POST['id'] as $index => $user_id) {
if ($user_id != $_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']);
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'));
}
break;
@ -170,18 +144,16 @@ if (isset ($_POST['action']))
$form = new FormValidator('advanced_search', 'get');
$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_lastname', get_lang('LastName'), false);
}
else
{
} else {
$form->addText('keyword_lastname', get_lang('LastName'), 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']);
}
$type = array();
$type["all"] = get_lang('All');
@ -195,19 +167,22 @@ $form->addElement('submit', 'submit', get_lang('Ok'));
//$defaults['keyword_inactive'] = 1;
//$form->setDefaults($defaults);
$form->display();
$parameters['keyword_username'] = @$_GET['keyword_username'] ?: null;
$parameters['keyword_firstname'] = @$_GET['keyword_firstname'] ?: null;
$parameters['keyword_lastname'] = @$_GET['keyword_lastname'] ?: null;
$parameters['keyword_email'] = @$_GET['keyword_email'] ?: null;
if (isset($_GET['id_session']))
if (isset($_GET['id_session'])) {
$parameters['id_session'] = $_GET['id_session'];
}
// Create a sortable table with user-data
$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_header(0, '', false);
$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->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 Number of users to get
* @param int Column to sort on
* @param string Order (ASC,DESC)
* @see SortableTable#get_table_data($from)
* @return array
*/
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);
if (!empty($last_id)) {
$sql = "UPDATE $tbl_attendance SET id = iid WHERE iid = $last_id";
Database::query($sql);
@ -1002,10 +1002,24 @@ class Attendance
$user_id = intval($user_id);
$attendance_id = intval($attendance_id);
$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 = self::get_number_of_attendance_calendar($attendance_id, $groupId, true, $user_id);
$attendance_user_score = $this->get_user_score($user_id, $attendance_id, $groupId);
$total_done_attendance = self::get_number_of_attendance_calendar(
$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
//$total_done_attendance = $calendar_count;
@ -1053,7 +1067,6 @@ class Attendance
//$course_info = api_get_course_info($course_code);
$course_id = $course['real_id'];
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$attendances_by_course = $this->get_attendances_list($course_id);
foreach ($attendances_by_course as $attendance) {
@ -1513,7 +1526,6 @@ class Attendance
return $count;
}
/**
* Get count dates inside attendance calendar by attendance id
* @param int $attendance_id

@ -355,18 +355,18 @@ class MySpace
$parameters['view'] = 'admin';
$table->set_additional_parameters($parameters);
if ($is_western_name_order) {
$table -> set_header(0, get_lang('FirstName'), true);
$table -> set_header(1, get_lang('LastName'), true);
$table->set_header(0, get_lang('FirstName'), true);
$table->set_header(1, get_lang('LastName'), true);
} else {
$table -> set_header(0, get_lang('LastName'), true);
$table -> set_header(1, get_lang('FirstName'), true);
$table->set_header(0, get_lang('LastName'), true);
$table->set_header(1, get_lang('FirstName'), true);
}
$table -> set_header(2, get_lang('TimeSpentOnThePlatform'), false);
$table -> set_header(3, get_lang('LastConnexion'), false);
$table -> set_header(4, get_lang('NbStudents'), false);
$table -> set_header(5, get_lang('CountCours'), false);
$table -> set_header(6, get_lang('NumberOfSessions'), false);
$table -> set_header(7, get_lang('Sessions'), false);
$table->set_header(2, get_lang('TimeSpentOnThePlatform'), false);
$table->set_header(3, get_lang('LastConnexion'), false);
$table->set_header(4, get_lang('NbStudents'), false);
$table->set_header(5, get_lang('CountCours'), false);
$table->set_header(6, get_lang('NumberOfSessions'), false);
$table->set_header(7, get_lang('Sessions'), false);
if ($is_western_name_order) {
$csv_header[] = array(
@ -1052,7 +1052,12 @@ class MySpace
$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();
@ -1810,7 +1815,6 @@ class MySpace
$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);
} else {
$avg_time_spent_in_course = null;
$avg_progress_in_course = null;
@ -1868,6 +1872,7 @@ class MySpace
* @param int $numberItems
* @param int $column
* @param string $direction
* @return array
*/
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);
return $extra_data;
}
/**
* 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
@ -2116,7 +2122,7 @@ class MySpace
/**
* Validates imported data.
* @param list of users
* @param $users list of users
*/
function validate_data($users, $id_session = null)
{
@ -2356,7 +2362,8 @@ class MySpace
/**
* XML-parser: the handler at the end of element.
*/
function element_end($parser, $data) {
function element_end($parser, $data)
{
$data = api_utf8_decode($data);
global $user;
global $users;
@ -2377,7 +2384,8 @@ class MySpace
/**
* XML-parser: the handler for character data.
*/
function character_data($parser, $data) {
function character_data($parser, $data)
{
$data = trim(api_utf8_decode($data));
global $current_value;
$current_value = $data;
@ -2388,7 +2396,8 @@ class MySpace
* @param string $file Path to the XML-file
* @return array All userinformation read from the file
*/
function parse_xml_data($file) {
function parse_xml_data($file)
{
global $current_tag;
global $current_value;
global $user;
@ -2537,7 +2546,9 @@ class MySpace
$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('table', $table ? $table->return_table() : null);

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
* @package chamilo.admin
*/
$cidReset = true;
@ -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=';
$tool_name = get_lang('ExportSessionListXMLCSV');
$interbreadcrumb[] = array('url' => 'session_list.php', 'name' => get_lang('SessionList'));
set_time_limit(0);
if (isset($_POST['formSent'])) {
$formSent = $_POST['formSent'];
$file_type = isset($_POST['file_type']) ? $_POST['file_type'] : 'csv';

Loading…
Cancel
Save