Minor - format code.

pull/2487/head
jmontoyaa 8 years ago
parent dc08aac0f4
commit 5cc6f0cb32
  1. 79
      main/gradebook/lib/be/category.class.php
  2. 150
      main/inc/lib/display.lib.php
  3. 143
      main/user/resume_session.php

@ -1347,8 +1347,16 @@ class Category implements GradebookItem
$crscats = self::load(null, null, $this->course_code, 0);
foreach ($crscats as $cat) {
if ($this->can_be_moved_to_cat($cat)) {
$targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
$targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
$targets[] = array(
$cat->get_id(),
$cat->get_name(),
$level + 1
);
$targets = $this->add_target_subcategories(
$targets,
$level + 1,
$cat->get_id()
);
}
}
}
@ -1357,7 +1365,11 @@ class Category implements GradebookItem
foreach ($indcats as $cat) {
if ($this->can_be_moved_to_cat($cat)) {
$targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
$targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
$targets = $this->add_target_subcategories(
$targets,
$level + 1,
$cat->get_id()
);
}
}
@ -1470,15 +1482,33 @@ class Category implements GradebookItem
$user = api_is_platform_admin() ? null : api_get_user_id();
$cats = self::get_root_categories_for_teacher($user);
foreach ($cats as $cat) {
$targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
$targets = self::add_subtree($targets, $level + 1, $cat->get_id(), null);
$targets[] = array(
$cat->get_id(),
$cat->get_name(),
$level + 1
);
$targets = self::add_subtree(
$targets,
$level + 1,
$cat->get_id(),
null
);
}
} else {
// student
$cats = self::get_root_categories_for_student(api_get_user_id());
foreach ($cats as $cat) {
$targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
$targets = self::add_subtree($targets, $level + 1, $cat->get_id(), 1);
$targets[] = array(
$cat->get_id(),
$cat->get_name(),
$level + 1
);
$targets = self::add_subtree(
$targets,
$level + 1,
$cat->get_id(),
1
);
}
}
@ -1733,15 +1763,42 @@ class Category implements GradebookItem
// root
if ($this->id == 0) {
return $this->get_root_categories_for_teacher(api_get_user_id(), $course_code, $session_id, false);
return $this->get_root_categories_for_teacher(
api_get_user_id(),
$course_code,
$session_id,
false
);
// inside a course
} elseif (!empty($this->course_code)) {
return self::load(null, null, $this->course_code, $this->id, null, $session_id, $order);
return self::load(
null,
null,
$this->course_code,
$this->id,
null,
$session_id,
$order
);
} elseif (!empty($course_code)) {
return self::load(null, null, $course_code, $this->id, null, $session_id, $order);
return self::load(
null,
null,
$course_code,
$this->id,
null,
$session_id,
$order
);
// course independent
} else {
return self::load(null, api_get_user_id(), 0, $this->id, null);
return self::load(
null,
api_get_user_id(),
0,
$this->id,
null
);
}
} elseif (api_is_platform_admin()) {
// platform admin

@ -56,8 +56,11 @@ class Display
* @param string Optional help file name
* @param string $page_header
*/
public static function display_header($tool_name = '', $help = null, $page_header = null)
{
public static function display_header(
$tool_name = '',
$help = null,
$page_header = null
) {
$origin = api_get_origin();
$showHeader = true;
if (isset($origin) && $origin == 'learnpath') {
@ -106,7 +109,12 @@ class Display
public static function display_reduced_header()
{
global $show_learnpath, $tool_name;
self::$global_template = new Template($tool_name, false, false, $show_learnpath);
self::$global_template = new Template(
$tool_name,
false,
false,
$show_learnpath
);
echo self::$global_template->show_header_template();
}
@ -117,7 +125,12 @@ class Display
{
global $tool_name, $show_learnpath;
$disable_js_and_css_files = true;
self::$global_template = new Template($tool_name, false, false, $show_learnpath);
self::$global_template = new Template(
$tool_name,
false,
false,
$show_learnpath
);
}
/**
@ -126,7 +139,12 @@ class Display
public static function set_header()
{
global $show_learnpath, $tool_name;
self::$global_template = new Template($tool_name, false, false, $show_learnpath);
self::$global_template = new Template(
$tool_name,
false,
false,
$show_learnpath
);
}
/**
@ -160,8 +178,10 @@ class Display
* return: $tool return a string array list with the "define" in main_api.lib
* @return html code for adding an introduction
*/
public static function display_introduction_section($tool, $editor_config = null)
{
public static function display_introduction_section(
$tool,
$editor_config = null
) {
echo self::return_introduction_section($tool, $editor_config);
}
@ -170,8 +190,10 @@ class Display
* @param array $editor_config
* @return null
*/
public static function return_introduction_section($tool, $editor_config = null)
{
public static function return_introduction_section(
$tool,
$editor_config = null
) {
$is_allowed_to_edit = api_is_allowed_to_edit();
$moduleId = $tool;
if (api_get_setting('enable_tool_introduction') == 'true' || $tool == TOOL_COURSE_HOMEPAGE) {
@ -442,8 +464,11 @@ class Display
*
* @return void
*/
public static function display_normal_message($message, $filter = true, $returnValue = false)
{
public static function display_normal_message(
$message,
$filter = true,
$returnValue = false
) {
$message = self::return_message($message, 'normal', $filter);
if ($returnValue) {
return $message;
@ -458,8 +483,11 @@ class Display
*
* @deprecated use Display::addFlash(Display::return_message($message, 'warning'));
*/
public static function display_warning_message($message, $filter = true, $returnValue = false)
{
public static function display_warning_message(
$message,
$filter = true,
$returnValue = false
) {
$message = self::return_message($message, 'warning', $filter);
if ($returnValue) {
return $message;
@ -474,8 +502,11 @@ class Display
* @deprecated use Display::addFlash(Display::return_message($message, 'confirm'));
* @return void
*/
public static function display_confirmation_message($message, $filter = true, $returnValue = false)
{
public static function display_confirmation_message(
$message,
$filter = true,
$returnValue = false
) {
$message = self::return_message($message, 'confirm', $filter);
if ($returnValue) {
return $message;
@ -493,8 +524,11 @@ class Display
*
* @return void
*/
public static function display_error_message($message, $filter = true, $returnValue = false)
{
public static function display_error_message(
$message,
$filter = true,
$returnValue = false
) {
$message = self::return_message($message, 'error', $filter);
if ($returnValue) {
return $message;
@ -508,8 +542,11 @@ class Display
* @param string $type
* @param bool $filter
*/
public static function return_message_and_translate($message, $type = 'normal', $filter = true)
{
public static function return_message_and_translate(
$message,
$type = 'normal',
$filter = true
) {
$message = get_lang($message);
echo self::return_message($message, $type, $filter);
}
@ -521,14 +558,21 @@ class Display
* @param bool $filter Whether to XSS-filter or not
* @return string Message wrapped into an HTML div
*/
public static function return_message($message, $type = 'normal', $filter = true)
{
public static function return_message(
$message,
$type = 'normal',
$filter = true
) {
if (empty($message)) {
return '';
}
if ($filter) {
$message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
$message = api_htmlentities(
$message,
ENT_QUOTES,
api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding()
);
}
$class = '';
@ -560,8 +604,11 @@ class Display
* @param string optional, class from stylesheet
* @return string encrypted mailto hyperlink
*/
public static function encrypted_mailto_link($email, $clickable_text = null, $style_class = '')
{
public static function encrypted_mailto_link(
$email,
$clickable_text = null,
$style_class = ''
) {
if (is_null($clickable_text)) {
$clickable_text = $email;
}
@ -602,8 +649,12 @@ class Display
* @param string optional, class from stylesheet
* @return string encrypted mailto hyperlink
*/
public static function icon_mailto_link($email, $icon_file = "mail.png", $icon_size = 22, $style_class = '')
{
public static function icon_mailto_link(
$email,
$icon_file = "mail.png",
$icon_size = 22,
$style_class = ''
) {
// "mailto:" already present?
if (substr($email, 0, 7) != 'mailto:') {
$email = 'mailto:'.$email;
@ -815,8 +866,12 @@ class Display
* @return string
* @author Julio Montoya 2010
*/
public static function img($image_path, $alt_text = '', $additional_attributes = null, $filterPath = true)
{
public static function img(
$image_path,
$alt_text = '',
$additional_attributes = null,
$filterPath = true
) {
if (empty($image_path)) {
// For some reason, the call to img() happened without a proper
// image. Log the error and return an empty string to avoid
@ -979,7 +1034,11 @@ class Display
} else {
$blank_item_text = Security::remove_XSS($blank_item_text);
}
$html .= self::tag('option', '-- '.$blank_item_text.' --', array('value' => '-1'));
$html .= self::tag(
'option',
'-- '.$blank_item_text.' --',
array('value' => '-1')
);
}
if ($values) {
foreach ($values as $key => $value) {
@ -1027,8 +1086,13 @@ class Display
*
* @return string
*/
public static function tabs($headers, $items, $id = 'tabs', $attributes = array(), $ul_attributes = array())
{
public static function tabs(
$headers,
$items,
$id = 'tabs',
$attributes = array(),
$ul_attributes = array()
) {
if (empty($headers) || count($headers) == 0) {
return '';
}
@ -1055,7 +1119,15 @@ class Display
$lis .= self::tag('li', $item, $ul_attributes);
$i++;
}
$ul = self::tag('ul', $lis, ['class' => 'nav nav-tabs tabs-margin', 'role'=> 'tablist', 'id' => 'ul_'.$id]);
$ul = self::tag(
'ul',
$lis,
[
'class' => 'nav nav-tabs tabs-margin',
'role' => 'tablist',
'id' => 'ul_'.$id
]
);
$i = 1;
$divs = '';
@ -1109,7 +1181,12 @@ class Display
$lis .= self::tag('li', $item, array('class' => $class));
$i++;
}
return self::tag('ul', $lis, array('class' => 'nav nav-tabs tabs-margin'));
return self::tag(
'ul',
$lis,
array('class' => 'nav nav-tabs tabs-margin')
);
}
/**
@ -1189,12 +1266,11 @@ class Display
// encoding problems - see #6159
//$column_names = array_map("utf8_encode", $column_names);
$obj->colNames = $column_names;
$obj->colModel = $column_model;
$obj->pager = '#'.$div_id.'_pager';
$obj->colNames = $column_names;
$obj->colModel = $column_model;
$obj->pager = '#'.$div_id.'_pager';
$obj->datatype = 'json';
$obj->viewrecords = 'true';
$all_value = 10000000;
// Default row quantity

@ -77,9 +77,13 @@ if ($allowTutors === 'true') {
if ($result) {
Display::addFlash(
Display::return_message(
get_lang('UserAdded').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']),
'confirm'
));
get_lang('UserAdded').' '.api_get_person_name(
$user_info['firstname'],
$user_info['lastname']
),
'confirm'
)
);
}
break;
case 'delete':
@ -120,70 +124,73 @@ if ($allowTutors === 'true') {
}
Display::display_header($tool_name);
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);
?>
<!-- General properties -->
<table class="data_table">
<tr>
<td><?php echo get_lang('GeneralCoach'); ?> :</td>
<td><?php echo api_get_person_name($session['firstname'], $session['lastname']).' ('.$session['username'].')' ?></td>
<td><?php echo get_lang('GeneralCoach'); ?> :</td>
<td><?php echo api_get_person_name($session['firstname'], $session['lastname']).' ('.$session['username'].')' ?></td>
</tr>
<?php if (!empty($session_category)) { ?>
<tr>
<td><?php echo get_lang('SessionCategory') ?></td>
<td><?php echo $session_category; ?></td>
<td><?php echo get_lang('SessionCategory') ?></td>
<td><?php echo $session_category; ?></td>
</tr>
<?php } ?>
<tr>
<td><?php echo get_lang('Date'); ?> :</td>
<td>
<?php
if ($session['access_start_date'] == '00-00-0000' && $session['access_end_date'] == '00-00-0000') {
echo get_lang('NoTimeLimits');
<td><?php echo get_lang('Date'); ?> :</td>
<td>
<?php
if ($session['access_start_date'] == '00-00-0000' && $session['access_end_date'] == '00-00-0000') {
echo get_lang('NoTimeLimits');
} else {
if ($session['access_start_date'] != '00-00-0000') {
//$session['date_start'] = Display::tag('i', get_lang('NoTimeLimits'));
$session['access_start_date'] = get_lang('From').' '.$session['access_start_date'];
} else {
$session['access_start_date'] = '';
}
else {
if ($session['access_start_date'] != '00-00-0000') {
//$session['date_start'] = Display::tag('i', get_lang('NoTimeLimits'));
$session['access_start_date'] = get_lang('From').' '.$session['access_start_date'];
} else {
$session['access_start_date'] = '';
}
if ($session['access_end_date'] == '00-00-0000') {
$session['access_end_date'] = '';
} else {
$session['access_end_date'] = get_lang('Until').' '.$session['access_end_date'];
}
echo $session['access_start_date'].' '.$session['access_end_date'];
if ($session['access_end_date'] == '00-00-0000') {
$session['access_end_date'] = '';
} else {
$session['access_end_date'] = get_lang('Until').' '.$session['access_end_date'];
}
?>
</td>
echo $session['access_start_date'].' '.$session['access_end_date'];
} ?>
</td>
</tr>
<!-- show nb_days_before and nb_days_after only if they are different from 0 -->
<tr>
<td>
<?php echo api_ucfirst(get_lang('SessionCoachStartDate')) ?> :
</td>
<td>
<?php echo intval($session['coach_access_start_date']) ?>
</td>
<td>
<?php echo api_ucfirst(get_lang('SessionCoachStartDate')) ?> :
</td>
<td>
<?php echo intval($session['coach_access_start_date']) ?>
</td>
</tr>
<tr>
<td>
<?php echo api_ucfirst(get_lang('SessionCoachEndDate')) ?> :
</td>
<td>
<?php echo intval($session['coach_session_access_end_date']) ?>
</td>
<td>
<?php echo api_ucfirst(get_lang('SessionCoachEndDate')) ?> :
</td>
<td>
<?php echo intval($session['coach_session_access_end_date']) ?>
</td>
</tr>
<tr>
<td>
<?php echo api_ucfirst(get_lang('SessionVisibility')) ?> :
</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')) ?>
</td>
<td>
<?php echo api_ucfirst(get_lang('SessionVisibility')) ?> :
</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')) ?>
</td>
</tr>
<?php
@ -216,14 +223,14 @@ if ($allowTutors === 'true') {
if ($session['nbr_courses'] == 0) {
echo '<tr>
<td colspan="4">'.get_lang('NoCoursesForThisSession').'</td>
</tr>';
</tr>';
} else {
// select the courses
$sql = "SELECT c.id, code,title,visual_code, nbr_users
FROM $tbl_course c,$tbl_session_rel_course sc
WHERE c.id = sc.c_id
AND session_id='$id_session'
ORDER BY title";
FROM $tbl_course c,$tbl_session_rel_course sc
WHERE c.id = sc.c_id
AND session_id='$id_session'
ORDER BY title";
$result = Database::query($sql);
$courses = Database::store_result($result);
foreach ($courses as $course) {
@ -243,21 +250,21 @@ if ($allowTutors === 'true') {
// Get coachs of the courses in session
$sql = "SELECT user.lastname,user.firstname,user.username
FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
WHERE
session_rcru.user_id = user.user_id AND
session_rcru.session_id = '".intval($id_session)."' AND
session_rcru.c_id ='".Database::escape_string($course['id'])."' AND
session_rcru.status=2";
FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
WHERE
session_rcru.user_id = user.user_id AND
session_rcru.session_id = '".intval($id_session)."' AND
session_rcru.c_id ='".Database::escape_string($course['id'])."' AND
session_rcru.status=2";
$rs = Database::query($sql);
$coachs = array();
if (Database::num_rows($rs) > 0) {
while ($info_coach = Database::fetch_array($rs)) {
$coachs[] = api_get_person_name(
$info_coach['firstname'],
$info_coach['lastname']
).' ('.$info_coach['username'].')';
$info_coach['firstname'],
$info_coach['lastname']
).' ('.$info_coach['username'].')';
}
} else {
$coach = get_lang('None');
@ -273,12 +280,12 @@ if ($allowTutors === 'true') {
//hide_course_breadcrumb the parameter has been added to hide the
// name of the course, that appeared in the default $interbreadcrumb
echo '
<tr>
<td>'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$id_session), '</td>
<td>'.$coach.'</td>
<td>'.$course['nbr_users'].'</td>
<tr>
<td>'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$id_session), '</td>
<td>'.$coach.'</td>
<td>'.$course['nbr_users'].'</td>
</tr>';
</tr>';
}
}
?>
@ -301,8 +308,8 @@ if ($allowTutors === 'true') {
if ($session['nbr_users'] == 0) {
echo '<tr>
<td colspan="2">'.get_lang('NoUsersForThisSession').'</td>
</tr>';
<td colspan="2">'.get_lang('NoUsersForThisSession').'</td>
</tr>';
} else {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
@ -366,4 +373,4 @@ if ($allowTutors === 'true') {
api_not_allowed();
}
// footer
Display :: display_footer();
Display::display_footer();

Loading…
Cancel
Save