Minor - format code,

pull/2487/head
jmontoyaa 9 years ago
parent b3cd32a437
commit dff22364b7
  1. 24
      main/admin/access_url_edit_course_category_to_url.php
  2. 33
      main/auth/courses_controller.php
  3. 6
      main/auth/profile.php
  4. 7
      main/dropbox/dropbox_functions.inc.php
  5. 22
      main/gradebook/lib/be/abstractlink.class.php
  6. 9
      main/gradebook/lib/be/result.class.php
  7. 62
      main/inc/ajax/course_home.ajax.php
  8. 3
      main/inc/lib/display.lib.php
  9. 43
      main/inc/lib/message.lib.php
  10. 32
      main/inc/lib/notebook.lib.php

@ -1,16 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
* @author Julio Montoya <gugli100@gmail.com>
*/
* @package chamilo.admin
* @author Julio Montoya <gugli100@gmail.com>
*/
// resetting the course id
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$xajax = new xajax();
$xajax->registerFunction(array('searchCourseCategoryAjax', 'UrlManager', 'searchCourseCategoryAjax'));
$xajax->registerFunction(
array('searchCourseCategoryAjax', 'UrlManager', 'searchCourseCategoryAjax')
);
// Setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
@ -221,10 +223,11 @@ foreach($userGroupList as $item) {
<td colspan="3" align="center">
<br />
<?php
if(isset($_GET['add']))
echo '<button class="save" onclick="valide()" >'.get_lang('Add').'</button>';
else
echo '<button class="save" onclick="valide()" >'.get_lang('Edit').'</button>';
if (isset($_GET['add'])) {
echo '<button class="save" onclick="valide()" >'.get_lang('Add').'</button>';
} else {
echo '<button class="save" onclick="valide()" >'.get_lang('Edit').'</button>';
}
?>
</td>
</tr>
@ -273,10 +276,8 @@ function valide(){
document.forms.formulaire.submit();
}
function loadUsersInSelect(select){
function loadUsersInSelect(select) {
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
@ -291,7 +292,6 @@ function loadUsersInSelect(select){
nosessionClasses = makepost(document.getElementById('origin_classes'));
sessionClasses = makepost(document.getElementById('destination_classes'));
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses);
xhr_object.onreadystatechange = function() {
if(xhr_object.readyState == 4) {
document.getElementById('content_source').innerHTML = result = xhr_object.responseText;

@ -31,8 +31,8 @@ class CoursesController
/**
* It's used for listing courses,
* render to courses_list view
* @param string action
* @param string confirmation message(optional)
* @param string $action
* @param string $message confirmation message(optional)
* @param string $action
*/
public function courses_list($action, $message = '')
@ -57,11 +57,11 @@ class CoursesController
/**
* It's used for listing categories,
* render to categories_list view
* @param string $action
* @param string $message confirmation message(optional)
* @param string $error error message(optional)
* @param string $action
* @param string $message confirmation message(optional)
* @param string $error error message(optional)
*/
public function categories_list($action, $message='', $error='')
public function categories_list($action, $message = '', $error = '')
{
$data = array();
$data['user_course_categories'] = $this->model->get_user_course_categories();
@ -139,16 +139,13 @@ class CoursesController
$data['message'] = $message;
$data['content'] = $content;
$data['error'] = $error;
$data['catalogShowCoursesSessions'] = 0;
$showCoursesSessions = intval('catalog_show_courses_sessions');
if ($showCoursesSessions > 0) {
$data['catalogShowCoursesSessions'] = $showCoursesSessions;
}
// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('courses_categories');
@ -173,7 +170,6 @@ class CoursesController
) {
$data = array();
$limit = !empty($limit) ? $limit : CourseCategory::getLimitArray();
$browse_course_categories = $this->model->browse_course_categories();
$data['countCoursesInCategory'] = $this->model->count_courses_in_category('ALL', $search_term);
$data['browse_courses_in_category'] = $this->model->search_courses($search_term, $limit, $justVisible);
@ -422,9 +418,7 @@ class CoursesController
$subCategory1Name = $subCategory1['name'];
$subCategory1Code = $subCategory1['code'];
$subCategory1Courses = $subCategory1['count_courses'];
$html .= '<li>';
if ($code == $subCategory1Code) {
$html .= "<strong>$subCategory1Name ($subCategory1Courses)</strong>";
} else {
@ -512,6 +506,8 @@ class CoursesController
* @param boolean $checkRequirements Optional.
* Whether the session has requirement. Default is false
* @param bool $includeText Optional. Whether show the text in button
* @param bool $btnBing
*
* @return string The button HTML
*/
public function getRegisteredInSessionButton(
@ -521,9 +517,9 @@ class CoursesController
$includeText = false,
$btnBing = false
) {
if($btnBing){
if ($btnBing) {
$btnBing = 'btn-lg';
}else{
} else {
$btnBing = 'btn-sm';
}
if ($checkRequirements) {
@ -551,7 +547,6 @@ class CoursesController
}
$catalogSessionAutoSubscriptionAllowed = false;
if (api_get_setting('catalog_allow_session_auto_subscription') === 'true') {
$catalogSessionAutoSubscriptionAllowed = true;
}
@ -631,7 +626,12 @@ class CoursesController
*/
public function getSessionIcon($sessionName)
{
return Display::return_icon('window_list.png', $sessionName, null,ICON_SIZE_MEDIUM);
return Display::return_icon(
'window_list.png',
$sessionName,
null,
ICON_SIZE_MEDIUM
);
}
/**
@ -645,7 +645,6 @@ class CoursesController
$date = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
$hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
$limit = isset($limit) ? $limit : CourseCategory::getLimitArray();
$countSessions = $this->model->countSessions($date);
$sessions = $this->model->browseSessions($date, $limit);

@ -369,7 +369,8 @@ $form->setDefaults($user_data);
*
* @return boolean if auth_source is platform
*/
function is_platform_authentication() {
function is_platform_authentication()
{
$tab_user_info = api_get_user_info();
return $tab_user_info['auth_source'] == PLATFORM_AUTH_SOURCE;
}
@ -422,7 +423,8 @@ function upload_user_production($user_id)
* @return bool true o false
* @uses Gets user ID from global variable
*/
function check_user_email($email) {
function check_user_email($email)
{
$user_id = api_get_user_id();
if ($user_id != strval(intval($user_id)) || empty($email)) {
return false;

@ -504,7 +504,12 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
$form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'origin', $origin);
$form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
$form->addElement(
'file',
'file',
get_lang('UploadFile'),
array('onChange' => 'javascript: checkfile(this.value);')
);
$allowOverwrite = api_get_setting('dropbox_allow_overwrite');
if ($allowOverwrite == 'true') {

@ -246,16 +246,22 @@ abstract class AbstractLink implements GradebookItem
$paramcount ++;
}
if (isset($type)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
if ($paramcount != 0) {
$sql .= ' AND';
} else {
$sql .= ' WHERE';
}
$sql .= ' type = '.intval($type);
$paramcount ++;
$paramcount++;
}
if (isset($ref_id)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
if ($paramcount != 0) {
$sql .= ' AND';
} else {
$sql .= ' WHERE';
}
$sql .= ' ref_id = '.intval($ref_id);
$paramcount ++;
$paramcount++;
}
if (isset($user_id)) {
if ($paramcount != 0) {
@ -464,7 +470,7 @@ abstract class AbstractLink implements GradebookItem
$targets = array();
$level = 0;
$crscats = Category::load(null,null,$this->get_course_code(),0);
$crscats = Category::load(null, null, $this->get_course_code(), 0);
foreach ($crscats as $cat) {
$targets[] = array($cat->get_id(), $cat->get_name(), $level+1);
$targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
@ -479,7 +485,7 @@ abstract class AbstractLink implements GradebookItem
*/
private function add_target_subcategories($targets, $level, $catid)
{
$subcats = Category::load(null,null,null,$catid);
$subcats = Category::load(null, null, null, $catid);
foreach ($subcats as $cat) {
$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
$targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());

@ -158,12 +158,13 @@ class Result
$paramcount ++;
}
if (!empty($user_id)) {
if ($paramcount != 0)
if ($paramcount != 0) {
$sql .= ' AND';
else
} else {
$sql .= ' WHERE';
$sql .= ' gr.user_id = ' . intval($user_id);
$paramcount ++;
}
$sql .= ' gr.user_id = '.intval($user_id);
$paramcount++;
}
if (!empty($evaluation_id)) {
if ($paramcount != 0) {

@ -20,7 +20,14 @@ switch ($action) {
$tool_image = $tool_info['image'];
if (api_get_setting('homepage_view') != 'activity_big') {
$tool_image = Display::return_icon($tool_image, null, null, null, null, true);
$tool_image = Display::return_icon(
$tool_image,
null,
null,
null,
null,
true
);
$na_image = str_replace('.gif', '_na.gif', $tool_image);
} else {
// Display::return_icon() also checks in the app/Resources/public/css/themes/{theme}/icons folder
@ -46,7 +53,6 @@ switch ($action) {
$requested_message = ($tool_visibility == 0 ) ? 'is_active' : 'is_inactive';
$requested_view = ($tool_visibility == 0 ) ? 'visible.png' : 'invisible.png';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
$requested_view = ($tool_visibility == 0 ) ? 'visible.png' : 'invisible.png';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
@ -122,8 +128,9 @@ switch ($action) {
$new_session_list = UserManager::get_personal_session_course_list(api_get_user_id());
$my_session_list = array();
foreach ($new_session_list as $item) {
if (!empty($item['id_session']))
if (!empty($item['id_session'])) {
$my_session_list[] = $item['id_session'];
}
}
if (!in_array($session_id, $my_session_list)) {
break;
@ -207,7 +214,7 @@ switch ($action) {
$i =0;
$response = new stdClass();
foreach ($temp as $key=>$row) {
foreach ($temp as $key => $row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
@ -217,13 +224,11 @@ switch ($action) {
}
}
}
$total_pages = 0;
if ($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
$response->total = $total_pages;
if ($page > $total_pages) {
$response->page= $total_pages;
} else {
@ -235,19 +240,17 @@ switch ($action) {
case 'session_courses_lp_by_week':
require_once __DIR__.'/../global.inc.php';
$now = time();
$page = intval($_REQUEST['page']); //page
$page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); // quantity of rows
$sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'course';
$sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'course';
$sidx = str_replace(array('week desc,', ' '), '', $sidx);
$sord = $_REQUEST['sord']; //asc or desc
$sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
}
$session_id = intval($_REQUEST['session_id']);
$course_id = intval($_REQUEST['course_id']);
$session_id = intval($_REQUEST['session_id']);
$course_id = intval($_REQUEST['course_id']);
//Filter users that does not belong to the session
if (!api_is_platform_admin()) {
@ -263,7 +266,7 @@ switch ($action) {
}
}
$start = $limit*$page - $limit;
$start = $limit * $page - $limit;
$course_list = SessionManager::get_course_list_by_session_id($session_id);
$count = 0;
@ -354,7 +357,7 @@ switch ($action) {
$response = new stdClass();
$i =0;
foreach($temp as $key=>$row) {
foreach ($temp as $key => $row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
@ -364,11 +367,9 @@ switch ($action) {
}
}
}
$total_pages = 0;
if ($count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
if ($page > $total_pages) {
@ -397,10 +398,11 @@ switch ($action) {
//Filter users that does not belong to the session
if (!api_is_platform_admin()) {
$new_session_list = UserManager::get_personal_session_course_list(api_get_user_id());
$my_session_list = array();
foreach($new_session_list as $item) {
if (!empty($item['id_session']))
$my_session_list = array();
foreach ($new_session_list as $item) {
if (!empty($item['id_session'])) {
$my_session_list[] = $item['id_session'];
}
}
if (!in_array($session_id, $my_session_list)) {
break;
@ -418,7 +420,11 @@ switch ($action) {
}
}
$list = new LearnpathList(api_get_user_id(),$item['code'],$session_id);
$list = new LearnpathList(
api_get_user_id(),
$item['code'],
$session_id
);
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$item['title'] = Display::url(
@ -478,7 +484,6 @@ switch ($action) {
}
$temp = msort($temp, $sidx, $sord);
$response = new stdClass();
$i =0;
foreach ($temp as $key => $row) {
@ -491,17 +496,14 @@ switch ($action) {
}
}
}
$total_pages = 0;
if ($count > 0 && $limit > 0) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
$response->total = $total_pages;
$response->page = $page;
if ($page > $total_pages) {
$response->page = $total_pages;
} else {
$response->page = $page;
}
$response->records = $count;

@ -677,10 +677,11 @@ class Display
$result = '';
for ($i = $min; $i <= $max; $i ++) {
$result .= '<option value="'.$i.'"';
if (is_int($selected_num))
if (is_int($selected_num)) {
if ($selected_num == $i) {
$result .= ' selected="selected"';
}
}
$result .= '>'.$i.'</option>';
}
return $result;

@ -55,10 +55,10 @@ class MessageManager
}
$table = Database::get_main_table(TABLE_MESSAGE);
$sql = "SELECT COUNT(id) as count
FROM $table
WHERE
user_receiver_id=" . api_get_user_id() . " AND
msg_status = " . MESSAGE_STATUS_UNREAD;
FROM $table
WHERE
user_receiver_id=" . api_get_user_id() . " AND
msg_status = " . MESSAGE_STATUS_UNREAD;
$result = Database::query($sql);
$row = Database::fetch_assoc($result);
@ -680,8 +680,9 @@ class MessageManager
*/
public static function update_message($user_id, $message_id)
{
if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id)))
if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) {
return false;
}
$table_message = Database::get_main_table(TABLE_MESSAGE);
$sql = "UPDATE $table_message SET msg_status = '0'
@ -721,8 +722,9 @@ class MessageManager
*/
public static function get_message_by_user($user_id, $message_id)
{
if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id)))
if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) {
return false;
}
$table_message = Database::get_main_table(TABLE_MESSAGE);
$query = "SELECT * FROM $table_message
WHERE user_receiver_id=" . intval($user_id) . " AND id='" . intval($message_id) . "'";
@ -733,7 +735,7 @@ class MessageManager
/**
* get messages by group id
* @param int group id
* @param int $group_id group id
* @return array
*/
public static function get_messages_by_group($group_id)
@ -879,12 +881,12 @@ class MessageManager
$direction = 'DESC';
} else {
$column = intval($column);
if (!in_array($direction, array('ASC', 'DESC')))
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
}
$table_message = Database::get_main_table(TABLE_MESSAGE);
$request = api_is_xml_http_request();
$keyword = Session::read('message_sent_search_keyword');
$keywordCondition = '';
if (!empty($keyword)) {
@ -1039,7 +1041,6 @@ class MessageManager
$message_content .= '<tr>';
if (api_get_setting('allow_social_tool') == 'true') {
$message_content .= '<div class="row">';
if ($source == 'outbox') {
$message_content .= '<div class="col-md-12">';
$message_content .= '<ul class="list-message">';
@ -1067,8 +1068,7 @@ class MessageManager
}
}
$message_content .= '
$message_content .= '
<hr style="color:#ddd" />
<table width="100%">
<tr>
@ -1853,7 +1853,14 @@ class MessageManager
*/
public static function getSearchForm($url)
{
$form = new FormValidator('search', 'post', $url, null, [], FormValidator::LAYOUT_INLINE);
$form = new FormValidator(
'search',
'post',
$url,
null,
[],
FormValidator::LAYOUT_INLINE
);
$form->addElement('text', 'keyword');
$form->addButtonSearch(get_lang('Search'));
@ -1867,7 +1874,15 @@ class MessageManager
*/
public static function sendNotificationByRegisteredUser(User $user)
{
$tplMailBody = new Template(null, false, false, false, false, false, false);
$tplMailBody = new Template(
null,
false,
false,
false,
false,
false,
false
);
$tplMailBody->assign('user', $user);
$tplMailBody->assign('is_western_name_order', api_is_western_name_order());
$tplMailBody->assign('manageUrl', api_get_path(WEB_CODE_PATH) . 'admin/user_edit.php?user_id=' . $user->getId());

@ -24,7 +24,7 @@ class NotebookManager
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
* @version januari 2009, dokeos 1.8.6
*/
static function javascript_notebook()
public static function javascript_notebook()
{
return "<script>
function confirmation (name)
@ -49,11 +49,12 @@ class NotebookManager
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
* @version januari 2009, dokeos 1.8.6
*/
static function save_note($values, $userId = 0, $courseId = 0, $sessionId = 0)
public static function save_note($values, $userId = 0, $courseId = 0, $sessionId = 0)
{
if (!is_array($values) or empty($values['note_title'])) {
if (!is_array($values) || empty($values['note_title'])) {
return false;
}
// Database table definition
$table = Database::get_course_table(TABLE_NOTEBOOK);
$userId = $userId ?: api_get_user_id();
@ -97,11 +98,12 @@ class NotebookManager
* @param int $notebook_id
* @return array|mixed
*/
static function get_note_information($notebook_id)
public static function get_note_information($notebook_id)
{
if (empty($notebook_id)) {
return array();
}
// Database table definition
$t_notebook = Database::get_course_table(TABLE_NOTEBOOK);
$course_id = api_get_course_int_id();
@ -182,6 +184,7 @@ class NotebookManager
if (empty($notebook_id) || $notebook_id != strval(intval($notebook_id))) {
return false;
}
// Database table definition
$t_notebook = Database::get_course_table(TABLE_NOTEBOOK);
@ -197,6 +200,7 @@ class NotebookManager
if ($affected_rows != 1) {
return false;
}
//update item_property (delete)
api_item_property_update(
api_get_course_info(),
@ -228,15 +232,21 @@ class NotebookManager
// action links
echo '<div class="actions">';
if (!api_is_anonymous()) {
if (api_get_session_id() == 0)
echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' .
Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
elseif (api_is_allowed_to_session_edit(false, true)) {
if (api_get_session_id() == 0) {
echo '<a href="index.php?'.api_get_cidreq().'&action=addnote">'.
Display::return_icon(
'new_note.png',
get_lang('NoteAddNew'),
'',
'32'
).'</a>';
} elseif (api_is_allowed_to_session_edit(false, true)) {
echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' .
Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
}
} else {
echo '<a href="javascript:void(0)">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
echo '<a href="javascript:void(0)">' .
Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
}
echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=creation_date&direction=' . $link_sort_direction . '">' .
@ -247,7 +257,9 @@ class NotebookManager
Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>';
echo '</div>';
if (!isset($_SESSION['notebook_view']) || !in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))) {
if (!isset($_SESSION['notebook_view']) ||
!in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))
) {
$_SESSION['notebook_view'] = 'creation_date';
}

Loading…
Cancel
Save