Minor - Format code, add docs

1.10.x
Julio Montoya 10 years ago
parent 43523019c3
commit aed1b3baf5
  1. 13
      main/inc/lib/TeacherTimeReport.php
  2. 6
      main/inc/lib/VideoChat.php
  3. 24
      main/inc/lib/plugin.class.php
  4. 28
      main/inc/lib/social.lib.php
  5. 4
      main/inc/lib/table_sort.class.php
  6. 4
      main/inc/lib/template.lib.php
  7. 23
      main/inc/lib/thematic.lib.php
  8. 19
      main/inc/lib/tracking.lib.php
  9. 74
      main/inc/lib/urlmanager.lib.php
  10. 27
      main/inc/lib/usermanager.lib.php
  11. 67
      main/inc/lib/userportal.lib.php

@ -9,7 +9,6 @@
*/ */
class TeacherTimeReport class TeacherTimeReport
{ {
/** /**
* The report data * The report data
* @var array * @var array
@ -18,9 +17,9 @@ class TeacherTimeReport
/** /**
* Callback for compare sessions names * Callback for compare sessions names
* @param array $dataA The datab A * @param array $dataA The data A
* @param array $dataB The data B * @param array $dataB The data B
* @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal * @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal
*/ */
public function compareSessions($dataA, $dataB) public function compareSessions($dataA, $dataB)
{ {
@ -31,7 +30,7 @@ class TeacherTimeReport
* Callback for compare courses names * Callback for compare courses names
* @param array $dataA The datab A * @param array $dataA The datab A
* @param array $dataB The data B * @param array $dataB The data B
* @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal * @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal
*/ */
public function compareCourses($dataA, $dataB) public function compareCourses($dataA, $dataB)
{ {
@ -42,7 +41,7 @@ class TeacherTimeReport
* Callback for compare coaches names * Callback for compare coaches names
* @param array $dataA The datab A * @param array $dataA The datab A
* @param array $dataB The data B * @param array $dataB The data B
* @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal * @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal
*/ */
public function compareCoaches($dataA, $dataB) public function compareCoaches($dataA, $dataB)
{ {
@ -63,6 +62,10 @@ class TeacherTimeReport
uasort($this->data, array($this, 'compareCoaches')); uasort($this->data, array($this, 'compareCoaches'));
} }
/**
* @param bool|false $withFilter
* @return array
*/
public function prepareDataToExport($withFilter = false) public function prepareDataToExport($withFilter = false)
{ {
$dataToExport = array(); $dataToExport = array();

@ -1,8 +1,9 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* VideoChat class * VideoChat class
* *
* This class provides methods for video chat management. * This class provides methods for video chat management.
* *
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
@ -43,6 +44,7 @@ class VideoChat
* @param string $name The video chat name * @param string $name The video chat name
* @param int $fromUser The sender user * @param int $fromUser The sender user
* @param int $toUser The receiver user * @param int $toUser The receiver user
*
* @return int The created video chat id. Otherwise return false * @return int The created video chat id. Otherwise return false
*/ */
public static function createRoom($name, $fromUser, $toUser) public static function createRoom($name, $fromUser, $toUser)
@ -61,6 +63,7 @@ class VideoChat
/** /**
* Check if the video chat exists by its room name * Check if the video chat exists by its room name
* @param string $name The video chat name * @param string $name The video chat name
*
* @return boolean * @return boolean
*/ */
public static function nameExists($name) public static function nameExists($name)
@ -84,6 +87,7 @@ class VideoChat
/** /**
* Get the video chat info by its room name * Get the video chat info by its room name
* @param string $name The video chat name * @param string $name The video chat name
*
* @return array The video chat info. Otherwise return false * @return array The video chat info. Otherwise return false
*/ */
public static function getChatRoomByName($name) public static function getChatRoomByName($name)

@ -70,13 +70,13 @@ class Plugin
public function get_info() public function get_info()
{ {
$result = array(); $result = array();
$result['title'] = $this->get_title(); $result['title'] = $this->get_title();
$result['comment'] = $this->get_comment(); $result['comment'] = $this->get_comment();
$result['version'] = $this->get_version(); $result['version'] = $this->get_version();
$result['author'] = $this->get_author(); $result['author'] = $this->get_author();
$result['plugin_class'] = get_class($this); $result['plugin_class'] = get_class($this);
$result['is_course_plugin'] = $this->isCoursePlugin; $result['is_course_plugin'] = $this->isCoursePlugin;
$result['is_mail_plugin'] = $this->isMailPlugin; $result['is_mail_plugin'] = $this->isMailPlugin;
if ($form = $this->get_settings_form()) { if ($form = $this->get_settings_form()) {
$result['settings_form'] = $form; $result['settings_form'] = $form;
@ -88,6 +88,7 @@ class Plugin
$result[$name] = $value; $result[$name] = $value;
} }
} }
return $result; return $result;
} }
@ -489,6 +490,7 @@ class Plugin
* Delete the fields added to the course settings page and the link to the * Delete the fields added to the course settings page and the link to the
* tool on the course's homepage * tool on the course's homepage
* @param int $courseId * @param int $courseId
*
* @return void * @return void
*/ */
public function uninstall_course_fields($courseId) public function uninstall_course_fields($courseId)
@ -598,9 +600,9 @@ class Plugin
public function addTab($tabName, $url) public function addTab($tabName, $url)
{ {
$sql = "SELECT * FROM settings_current $sql = "SELECT * FROM settings_current
WHERE WHERE
variable = 'show_tabs' AND variable = 'show_tabs' AND
subkey like 'custom_tab_%'"; subkey LIKE 'custom_tab_%'";
$result = Database::query($sql); $result = Database::query($sql);
$customTabsNum = Database::num_rows($result); $customTabsNum = Database::num_rows($result);
@ -714,8 +716,8 @@ class Plugin
/** /**
* This method shows or hides plugin's tab * This method shows or hides plugin's tab
* @param boolean Shows or hides the main menu plugin tab * @param boolean $showTab Shows or hides the main menu plugin tab
* @param string Plugin starter file path * @param string $filePath Plugin starter file path
*/ */
public function manageTab($showTab, $filePath = 'index.php') public function manageTab($showTab, $filePath = 'index.php')
{ {

@ -221,9 +221,9 @@ class SocialManager extends UserManager
return true; return true;
} else { } else {
// invitation already exist // invitation already exist
$sql_if_exist = 'SELECT COUNT(*) AS count, id FROM '.$tbl_message.' $sql = 'SELECT COUNT(*) AS count, id FROM '.$tbl_message.'
WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status = 7'; WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status = 7';
$res_if_exist = Database::query($sql_if_exist); $res_if_exist = Database::query($sql);
$row_if_exist = Database::fetch_array($res_if_exist, 'ASSOC'); $row_if_exist = Database::fetch_array($res_if_exist, 'ASSOC');
if ($row_if_exist['count'] == 1) { if ($row_if_exist['count'] == 1) {
$sql = 'UPDATE '.$tbl_message.' SET $sql = 'UPDATE '.$tbl_message.' SET
@ -296,6 +296,7 @@ class SocialManager extends UserManager
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$list_friend_invitation[$row['user_receiver_id']] = $row; $list_friend_invitation[$row['user_receiver_id']] = $row;
} }
return $list_friend_invitation; return $list_friend_invitation;
} }
@ -1134,14 +1135,8 @@ class SocialManager extends UserManager
'content' => $cleanMessageContent, 'content' => $cleanMessageContent,
'parent_id' => $messageId 'parent_id' => $messageId
); );
return Database::insert($tblMessage, $attributes);
/* Deprecated since 2014-10-29
$senderInfo = api_get_user_info($userId);
$notification = new Notification();
$notification->save_notification(Notification::NOTIFICATION_TYPE_WALL_MESSAGE, array($friendId), '', $messageContent, $senderInfo);
*/
return Database::insert($tblMessage, $attributes);
} }
/** /**
@ -1155,7 +1150,6 @@ class SocialManager extends UserManager
*/ */
public static function sendWallMessageAttachmentFile($userId, $fileAttach, $messageId, $fileComment = '') public static function sendWallMessageAttachmentFile($userId, $fileAttach, $messageId, $fileComment = '')
{ {
$flag = false;
$tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); $tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
// create directory // create directory
@ -1222,15 +1216,15 @@ class SocialManager extends UserManager
} }
$tblMessage = Database::get_main_table(TABLE_MESSAGE); $tblMessage = Database::get_main_table(TABLE_MESSAGE);
$tblMessageAttachement = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); $tblMessageAttachment = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
$userId = intval($userId); $userId = intval($userId);
$start = Database::escape_string($start); $start = Database::escape_string($start);
$limit = intval($limit); $limit = intval($limit);
$sql = "SELECT id, user_sender_id,user_receiver_id, send_date, content, parent_id, $sql = "SELECT id, user_sender_id,user_receiver_id, send_date, content, parent_id,
(SELECT ma.path FROM $tblMessageAttachement ma WHERE ma.message_id = tm.id ) as path, (SELECT ma.path FROM $tblMessageAttachment ma WHERE ma.message_id = tm.id ) as path,
(SELECT ma.filename FROM $tblMessageAttachement ma WHERE ma.message_id = tm.id ) as filename (SELECT ma.filename FROM $tblMessageAttachment ma WHERE ma.message_id = tm.id ) as filename
FROM $tblMessage tm FROM $tblMessage tm
WHERE user_receiver_id = $userId WHERE user_receiver_id = $userId
AND send_date > '$start' "; AND send_date > '$start' ";
@ -1518,6 +1512,7 @@ class SocialManager extends UserManager
$tblMessage = Database::get_main_table(TABLE_MESSAGE); $tblMessage = Database::get_main_table(TABLE_MESSAGE);
$statusMessage = MESSAGE_STATUS_WALL_DELETE; $statusMessage = MESSAGE_STATUS_WALL_DELETE;
$sql = "UPDATE $tblMessage SET msg_status = '$statusMessage' WHERE id = '{$id}' "; $sql = "UPDATE $tblMessage SET msg_status = '$statusMessage' WHERE id = '{$id}' ";
return Database::query($sql); return Database::query($sql);
} }
@ -1563,12 +1558,10 @@ class SocialManager extends UserManager
$template->assign('gamification_points', $gamificationPoints); $template->assign('gamification_points', $gamificationPoints);
} }
$chatEnabled = api_is_global_chat_enabled(); $chatEnabled = api_is_global_chat_enabled();
$templateName = $template->assign('chat_enabled', $chatEnabled); $template->assign('chat_enabled', $chatEnabled);
$templateName = $template->get_template('social/user_block.tpl'); $templateName = $template->get_template('social/user_block.tpl');
if (in_array($groupBlock, ['groups', 'group_edit', 'member_list'])) { if (in_array($groupBlock, ['groups', 'group_edit', 'member_list'])) {
$templateName = $template->get_template('social/group_block.tpl'); $templateName = $template->get_template('social/group_block.tpl');
} }
@ -1770,5 +1763,4 @@ class SocialManager extends UserManager
return $template->fetch($skillBlock); return $template->fetch($skillBlock);
} }
} }

@ -5,9 +5,7 @@
* *
* @package chamilo.library * @package chamilo.library
*/ */
/**
* Code
*/
define('SORT_DATE', 3); define('SORT_DATE', 3);
define('SORT_IMAGE', 4); define('SORT_IMAGE', 4);

@ -886,9 +886,7 @@ class Template
$menu = return_menu(); $menu = return_menu();
$this->assign('menu', $menu); $this->assign('menu', $menu);
//Setting notifications // Setting notifications
$count_unread_message = 0; $count_unread_message = 0;
if (api_get_setting('allow_message_tool') == 'true') { if (api_get_setting('allow_message_tool') == 'true') {
// get count unread message and total invitations // get count unread message and total invitations

@ -260,12 +260,10 @@ class Thematic
} }
$data = array(); $data = array();
$condition = '';
if (isset($thematic_id)) { if (isset($thematic_id)) {
$thematic_id = intval($thematic_id); $thematic_id = intval($thematic_id);
$condition = " WHERE id = $thematic_id AND active = 1 "; $condition = " WHERE id = $thematic_id AND active = 1 ";
} else { } else {
$condition_session = '';
if (empty($session_id)) { if (empty($session_id)) {
$condition_session = api_get_session_condition(0); $condition_session = api_get_session_condition(0);
} else { } else {
@ -356,7 +354,6 @@ class Thematic
"ThematicUpdated", "ThematicUpdated",
$user_id $user_id
); );
} }
return $last_id; return $last_id;
@ -420,7 +417,12 @@ class Thematic
{ {
$thematic = self::get_thematic_list($thematic_id, api_get_course_id(), 0); $thematic = self::get_thematic_list($thematic_id, api_get_course_id(), 0);
$thematic_copy = new Thematic(); $thematic_copy = new Thematic();
$thematic_copy->set_thematic_attributes('', $thematic['title'].' - '.get_lang('Copy'), $thematic['content'], api_get_session_id()); $thematic_copy->set_thematic_attributes(
'',
$thematic['title'].' - '.get_lang('Copy'),
$thematic['content'],
api_get_session_id()
);
$new_thematic_id = $thematic_copy->thematic_save(); $new_thematic_id = $thematic_copy->thematic_save();
if (!empty($new_thematic_id)) { if (!empty($new_thematic_id)) {
@ -504,7 +506,11 @@ class Thematic
ORDER BY col$column $direction ORDER BY col$column $direction
LIMIT $from,$number_of_items "; LIMIT $from,$number_of_items ";
$list = api_get_item_property_by_tool('thematic_advance', api_get_course_id(), api_get_session_id()); $list = api_get_item_property_by_tool(
'thematic_advance',
api_get_course_id(),
api_get_session_id()
);
$elements = array(); $elements = array();
foreach ($list as $value) { foreach ($list as $value) {
@ -706,7 +712,6 @@ class Thematic
$data[$row['thematic_id']][$row['id']] = $row; $data[$row['thematic_id']][$row['id']] = $row;
} }
} }
} }
} }
} }
@ -831,7 +836,7 @@ class Thematic
{ {
// definition database table // definition database table
$tbl_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN); $tbl_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC); $tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -1029,8 +1034,8 @@ class Thematic
/** /**
* delete a thematic plan description * delete a thematic plan description
* @param int Thematic id * @param int $thematic_id Thematic id
* @param int Description type * @param int $description_type Description type
* @return int Affected rows * @return int Affected rows
*/ */
public function thematic_plan_destroy($thematic_id, $description_type) public function thematic_plan_destroy($thematic_id, $description_type)

@ -7001,16 +7001,16 @@ class TrackingUserLogCSV
$title[1] = get_lang('ExercicesDetails'); $title[1] = get_lang('ExercicesDetails');
$line = ''; $line = '';
$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
WHERE te.c_id = $courseId WHERE te.c_id = $courseId
AND te.exe_user_id = $userId AND te.exe_user_id = $userId
AND te.exe_exo_id = ce.id AND te.exe_exo_id = ce.id
ORDER BY ce.title ASC, te.exe_date ASC"; ORDER BY ce.title ASC, te.exe_date ASC";
$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
FROM $TABLETRACK_HOTPOTATOES AS te FROM $TABLETRACK_HOTPOTATOES AS te
WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
ORDER BY te.c_id ASC, te.exe_date ASC"; ORDER BY te.c_id ASC, te.exe_date ASC";
$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
@ -7062,7 +7062,8 @@ class TrackingUserLogCSV
*/ */
public function display_student_publications_tracking_info($view, $user_id, $course_id) public function display_student_publications_tracking_info($view, $user_id, $course_id)
{ {
global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK, $dateTimeFormatLong, $_course; global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
$_course = api_get_course_info();
$user_id = intval($user_id); $user_id = intval($user_id);
$course_id = intval($course_id); $course_id = intval($course_id);

@ -23,8 +23,8 @@ class UrlManager
public static function add($url, $description, $active) public static function add($url, $description, $active)
{ {
$tms = time(); $tms = time();
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "INSERT INTO $table_access_url $sql = "INSERT INTO $table
SET url = '".Database::escape_string($url)."', SET url = '".Database::escape_string($url)."',
description = '".Database::escape_string($description)."', description = '".Database::escape_string($description)."',
active = '".intval($active)."', active = '".intval($active)."',
@ -46,9 +46,9 @@ class UrlManager
public static function update($url_id, $url, $description, $active) public static function update($url_id, $url, $description, $active)
{ {
$url_id = intval($url_id); $url_id = intval($url_id);
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$tms = time(); $tms = time();
$sql = "UPDATE $table_access_url $sql = "UPDATE $table
SET url = '".Database::escape_string($url)."', SET url = '".Database::escape_string($url)."',
description = '".Database::escape_string($description)."', description = '".Database::escape_string($description)."',
active = '".intval($active)."', active = '".intval($active)."',
@ -56,6 +56,7 @@ class UrlManager
tms = FROM_UNIXTIME(".$tms.") tms = FROM_UNIXTIME(".$tms.")
WHERE id = '$url_id'"; WHERE id = '$url_id'";
$result = Database::query($sql); $result = Database::query($sql);
return $result; return $result;
} }
@ -68,9 +69,10 @@ class UrlManager
public static function delete($id) public static function delete($id)
{ {
$id = intval($id); $id = intval($id);
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql= "DELETE FROM $table_access_url WHERE id = ".$id; $sql= "DELETE FROM $table WHERE id = ".$id;
$result = Database::query($sql); $result = Database::query($sql);
return $result; return $result;
} }
@ -80,10 +82,11 @@ class UrlManager
*/ */
public static function url_exist($url) public static function url_exist($url)
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."' "; $sql = "SELECT id FROM $table WHERE url = '".Database::escape_string($url)."' ";
$res = Database::query($sql); $res = Database::query($sql);
$num = Database::num_rows($res); $num = Database::num_rows($res);
return $num; return $num;
} }
@ -94,10 +97,11 @@ class UrlManager
public static function url_id_exist($url) public static function url_id_exist($url)
{ {
if (empty($url)) { return false; } if (empty($url)) { return false; }
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id FROM $table_access_url WHERE id = ".intval($url).""; $sql = "SELECT id FROM $table WHERE id = ".intval($url)."";
$res = Database::query($sql); $res = Database::query($sql);
$num = Database::num_rows($res); $num = Database::num_rows($res);
return $num; return $num;
} }
@ -113,6 +117,7 @@ class UrlManager
$res = Database::query($sql); $res = Database::query($sql);
$url = Database::fetch_array($res,'ASSOC'); $url = Database::fetch_array($res,'ASSOC');
$result = $url['count_result']; $result = $url['count_result'];
return $result; return $result;
} }
@ -123,8 +128,8 @@ class UrlManager
* */ * */
public static function get_url_data() public static function get_url_data()
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id, url, description, active FROM $table_access_url ORDER BY id"; $sql = "SELECT id, url, description, active FROM $table ORDER BY id";
$res = Database::query($sql); $res = Database::query($sql);
$urls = array (); $urls = array ();
while ($url = Database::fetch_array($res)) { while ($url = Database::fetch_array($res)) {
@ -142,8 +147,8 @@ class UrlManager
* */ * */
public static function get_url_data_from_id($url_id) public static function get_url_data_from_id($url_id)
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id, url, description, active FROM $table_access_url WHERE id = ".intval($url_id); $sql = "SELECT id, url, description, active FROM $table WHERE id = ".intval($url_id);
$res = Database::query($sql); $res = Database::query($sql);
$row = Database::fetch_array($res); $row = Database::fetch_array($res);
return $row; return $row;
@ -158,7 +163,7 @@ class UrlManager
**/ **/
public static function get_url_rel_user_data($access_url_id = null, $order_by = null) public static function get_url_rel_user_data($access_url_id = null, $order_by = null)
{ {
$where = ''; $where = '';
$table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER); $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
if (!empty($access_url_id)) { if (!empty($access_url_id)) {
@ -171,10 +176,10 @@ class UrlManager
$order_clause = $order_by; $order_clause = $order_by;
} }
$sql = "SELECT u.user_id, lastname, firstname, username, official_code, access_url_id $sql = "SELECT u.user_id, lastname, firstname, username, official_code, access_url_id
FROM $tbl_user u FROM $tbl_user u
INNER JOIN $table_url_rel_user INNER JOIN $table_url_rel_user
ON $table_url_rel_user.user_id = u.user_id ON $table_url_rel_user.user_id = u.user_id
$where $order_clause"; $where $order_clause";
$result = Database::query($sql); $result = Database::query($sql);
$users = Database::store_result($result); $users = Database::store_result($result);
@ -239,13 +244,13 @@ class UrlManager
public static function get_url_rel_session_data($access_url_id = null) public static function get_url_rel_session_data($access_url_id = null)
{ {
$where =''; $where ='';
$table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
if (!empty($access_url_id)) if (!empty($access_url_id))
$where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id); $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
$sql="SELECT id, name, access_url_id $sql = "SELECT id, name, access_url_id
FROM $tbl_session u FROM $tbl_session u
INNER JOIN $table_url_rel_session INNER JOIN $table_url_rel_session
ON $table_url_rel_session.session_id = id ON $table_url_rel_session.session_id = id
@ -306,11 +311,11 @@ class UrlManager
$where .= " AND (parent_id IS NULL) "; $where .= " AND (parent_id IS NULL) ";
$sql = "SELECT id, name, access_url_id $sql = "SELECT id, name, access_url_id
FROM $table u FROM $table u
INNER JOIN $table_url_rel INNER JOIN $table_url_rel
ON $table_url_rel.course_category_id = u.id ON $table_url_rel.course_category_id = u.id
$where $where
ORDER BY name"; ORDER BY name";
$result = Database::query($sql); $result = Database::query($sql);
$courses = Database::store_result($result, 'ASSOC'); $courses = Database::store_result($result, 'ASSOC');
@ -332,11 +337,10 @@ class UrlManager
if ($status == 'unlock') { if ($status == 'unlock') {
$status_db = '1'; $status_db = '1';
} }
if (($status_db == '1' OR $status_db == '0') AND is_numeric($url_id)) { if (($status_db == '1' || $status_db == '0') && is_numeric($url_id)) {
$sql = "UPDATE $url_table SET active='".intval( $sql = "UPDATE $url_table SET active='".intval($status_db)."'
$status_db WHERE id='".intval($url_id)."'";
)."' WHERE id='".intval($url_id)."'"; Database::query($sql);
$result = Database::query($sql);
} }
} }
@ -349,9 +353,9 @@ class UrlManager
* */ * */
public static function relation_url_user_exist($user_id, $url_id) public static function relation_url_user_exist($user_id, $url_id)
{ {
$table_url_rel_user= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql= "SELECT user_id FROM $table_url_rel_user $sql= "SELECT user_id FROM $table
WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." "; WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." ";
$result = Database::query($sql); $result = Database::query($sql);
$num = Database::num_rows($result); $num = Database::num_rows($result);

@ -362,13 +362,23 @@ class UserManager
} }
if (!empty($email) && $send_mail) { if (!empty($email) && $send_mail) {
$recipient_name = api_get_person_name($firstName, $lastName, null, PERSON_NAME_EMAIL_ADDRESS); $recipient_name = api_get_person_name(
$firstName,
$lastName,
null,
PERSON_NAME_EMAIL_ADDRESS
);
$tplSubject = new Template(null, false, false, false, false, false); $tplSubject = new Template(null, false, false, false, false, false);
$layoutSubject = $tplSubject->get_template( $layoutSubject = $tplSubject->get_template(
'mail/subject_registration_platform.tpl' 'mail/subject_registration_platform.tpl'
); );
$emailSubject = $tplSubject->fetch($layoutSubject); $emailSubject = $tplSubject->fetch($layoutSubject);
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); $sender_name = api_get_person_name(
api_get_setting('administratorName'),
api_get_setting('administratorSurname'),
null,
PERSON_NAME_EMAIL_ADDRESS
);
$email_admin = api_get_setting('emailAdministrator'); $email_admin = api_get_setting('emailAdministrator');
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
@ -667,6 +677,7 @@ class UserManager
$deleted = self::delete_user($id); $deleted = self::delete_user($id);
$result = $deleted || $result; $result = $deleted || $result;
} }
return $result; return $result;
} }
@ -955,6 +966,7 @@ class UserManager
if ($r !== false) { if ($r !== false) {
Event::addEvent($ev, LOG_USER_ID, $user_id); Event::addEvent($ev, LOG_USER_ID, $user_id);
} }
return $r; return $r;
} }
@ -1437,7 +1449,6 @@ class UserManager
$userPath = api_get_path(REL_UPLOAD_PATH).$userPath; $userPath = api_get_path(REL_UPLOAD_PATH).$userPath;
break; break;
case 'last': // Only the last part starting with users/ case 'last': // Only the last part starting with users/
$userPath = $userPath;
break; break;
} }
@ -1702,6 +1713,7 @@ class UserManager
* *
* @param int $user_id User id * @param int $user_id User id
* @param $force Optional parameter to force building after a removal request * @param $force Optional parameter to force building after a removal request
*
* @return A string containing the XHTML code to dipslay the production list, or FALSE * @return A string containing the XHTML code to dipslay the production list, or FALSE
*/ */
public static function build_production_list($user_id, $force = false, $showdelete = false) public static function build_production_list($user_id, $force = false, $showdelete = false)
@ -1773,8 +1785,8 @@ class UserManager
/** /**
* Remove a user production. * Remove a user production.
* *
* @param $user_id User id * @param int $user_id User id
* @param $production The production to remove * @param string $production The production to remove
*/ */
public static function remove_user_production($user_id, $production) public static function remove_user_production($user_id, $production)
{ {
@ -1963,6 +1975,7 @@ class UserManager
$files[] = $path.$extra_files; $files[] = $path.$extra_files;
} }
} }
return $files; // can be an empty array return $files; // can be an empty array
} }
@ -2114,6 +2127,7 @@ class UserManager
} }
} }
} }
return $extra_data; return $extra_data;
} }
@ -2141,7 +2155,8 @@ class UserManager
$t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); $t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$user_id = intval($user_id); $user_id = intval($user_id);
$sql = "SELECT f.id as id, f.variable as fvar, f.field_type as type FROM $t_uf f $sql = "SELECT f.id as id, f.variable as fvar, f.field_type as type
FROM $t_uf f
WHERE f.variable = '$field_variable' "; WHERE f.variable = '$field_variable' ";
if (!$all_visibility) { if (!$all_visibility) {

@ -45,10 +45,13 @@ class IndexManager
$exercise_list = array(); $exercise_list = array();
if (!empty($personal_course_list)) { if (!empty($personal_course_list)) {
foreach($personal_course_list as $course_item) { foreach($personal_course_list as $course_item) {
$course_code = $course_item['c']; $course_code = $course_item['c'];
$session_id = $course_item['id_session']; $session_id = $course_item['id_session'];
$exercises = ExerciseLib::get_exercises_to_be_taken($course_code, $session_id); $exercises = ExerciseLib::get_exercises_to_be_taken(
$course_code,
$session_id
);
foreach($exercises as $exercise_item) { foreach($exercises as $exercise_item) {
$exercise_item['course_code'] = $course_code; $exercise_item['course_code'] = $course_code;
@ -68,7 +71,8 @@ class IndexManager
} }
} }
function return_announcements($show_slide = true) { function return_announcements($show_slide = true)
{
//// Display System announcements //// Display System announcements
$hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected'); $hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected');
if ($hideAnnouncements == 'true' && empty($userId)) { if ($hideAnnouncements == 'true' && empty($userId)) {
@ -80,17 +84,30 @@ class IndexManager
if (!api_is_anonymous() && $this->user_id) { if (!api_is_anonymous() && $this->user_id) {
$visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT; $visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT;
if ($show_slide) { if ($show_slide) {
$announcements = SystemAnnouncementManager :: display_announcements_slider($visibility, $announcement); $announcements = SystemAnnouncementManager:: display_announcements_slider(
$visibility,
$announcement
);
} else { } else {
$announcements = SystemAnnouncementManager :: display_all_announcements($visibility, $announcement); $announcements = SystemAnnouncementManager:: display_all_announcements(
$visibility,
$announcement
);
} }
} else { } else {
if ($show_slide) { if ($show_slide) {
$announcements = SystemAnnouncementManager :: display_announcements_slider(SystemAnnouncementManager::VISIBLE_GUEST, $announcement); $announcements = SystemAnnouncementManager:: display_announcements_slider(
SystemAnnouncementManager::VISIBLE_GUEST,
$announcement
);
} else { } else {
$announcements = SystemAnnouncementManager :: display_all_announcements(SystemAnnouncementManager::VISIBLE_GUEST, $announcement); $announcements = SystemAnnouncementManager:: display_all_announcements(
SystemAnnouncementManager::VISIBLE_GUEST,
$announcement
);
} }
} }
return $announcements; return $announcements;
} }
@ -98,7 +115,8 @@ class IndexManager
* Alias for the online_logout() function * Alias for the online_logout() function
* @param bool $redirect Whether to ask online_logout to redirect to index.php or not * @param bool $redirect Whether to ask online_logout to redirect to index.php or not
*/ */
function logout($redirect = true) { function logout($redirect = true)
{
online_logout($this->user_id, true); online_logout($this->user_id, true);
} }
@ -108,7 +126,8 @@ class IndexManager
* @param string $category * @param string $category
* @return boolean * @return boolean
*/ */
function category_has_open_courses($category) { function category_has_open_courses($category)
{
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$category = Database::escape_string($category); $category = Database::escape_string($category);
@ -125,6 +144,7 @@ class IndexManager
} }
} }
} }
return false; return false;
} }
@ -136,7 +156,8 @@ class IndexManager
* @version 1.0.1 * @version 1.0.1
* @todo does $_plugins need to be global? * @todo does $_plugins need to be global?
*/ */
function display_anonymous_right_menu() { function display_anonymous_right_menu()
{
global $loginFailed, $_user; global $loginFailed, $_user;
$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview'); $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');
$current_user_id = api_get_user_id(); $current_user_id = api_get_user_id();
@ -207,7 +228,6 @@ class IndexManager
public function return_home_page() public function return_home_page()
{ {
$userId = api_get_user_id(); $userId = api_get_user_id();
global $_configuration;
// Including the page for the news // Including the page for the news
$html = ''; $html = '';
@ -257,7 +277,8 @@ class IndexManager
return $html; return $html;
} }
function return_notice() { function return_notice()
{
$sys_path = api_get_path(SYS_PATH); $sys_path = api_get_path(SYS_PATH);
$user_selected_language = api_get_interface_language(); $user_selected_language = api_get_interface_language();
@ -276,7 +297,8 @@ class IndexManager
return $html; return $html;
} }
function return_help() { function return_help()
{
$user_selected_language = api_get_interface_language(); $user_selected_language = api_get_interface_language();
$sys_path = api_get_path(SYS_PATH); $sys_path = api_get_path(SYS_PATH);
$platformLanguage = api_get_setting('platformLanguage'); $platformLanguage = api_get_setting('platformLanguage');
@ -299,8 +321,8 @@ class IndexManager
return $html; return $html;
} }
function return_skills_links() { function return_skills_links()
$html = ''; {
$content = ''; $content = '';
$content .= '<ul class="nav nav-pills nav-stacked">'; $content .= '<ul class="nav nav-pills nav-stacked">';
/** /**
@ -350,7 +372,15 @@ class IndexManager
} }
} }
$content .= '</ul>'; $content .= '</ul>';
$html = self::show_right_block(get_lang("Skills"), $content, 'skill_block',null, 'skills', 'skillsCollapse'); $html = self::show_right_block(
get_lang("Skills"),
$content,
'skill_block',
null,
'skills',
'skillsCollapse'
);
return $html; return $html;
} }
@ -394,7 +424,6 @@ class IndexManager
ORDER BY title, UPPER(visual_code)"; ORDER BY title, UPPER(visual_code)";
// Showing only the courses of the current access_url_id. // Showing only the courses of the current access_url_id.
global $_configuration;
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
$url_access_id = api_get_current_access_url_id(); $url_access_id = api_get_current_access_url_id();
if ($url_access_id != -1) { if ($url_access_id != -1) {
@ -692,7 +721,7 @@ class IndexManager
$html .= '<div id="'.$idCollpase.'" class="panel-collapse collapse in" role="tabpanel">' . PHP_EOL; $html .= '<div id="'.$idCollpase.'" class="panel-collapse collapse in" role="tabpanel">' . PHP_EOL;
$html .= '<div class="panel-body">'.$content.'</div>' . PHP_EOL; $html .= '<div class="panel-body">'.$content.'</div>' . PHP_EOL;
$html .= '</div></div></div>' . PHP_EOL; $html .= '</div></div></div>' . PHP_EOL;
} else { } else {
if (!empty($id)) { if (!empty($id)) {
$params['id'] = $id; $params['id'] = $id;

Loading…
Cancel
Save