Minor - format code, use Session class

pull/2487/head
jmontoyaa 9 years ago
parent 33a2f013ca
commit d0a9275c14
  1. 1
      main/inc/lib/legal.lib.php
  2. 32
      main/inc/lib/link.lib.php
  3. 24
      main/inc/lib/lp_item.lib.php
  4. 20
      main/inc/lib/message.lib.php
  5. 2
      main/inc/lib/plugin.class.php
  6. 1
      main/inc/lib/rights.lib.php
  7. 8
      main/inc/lib/security.lib.php
  8. 20
      main/inc/lib/sortable_table.class.php
  9. 75
      main/inc/lib/system_announcements.lib.php
  10. 14
      main/inc/lib/thematic.lib.php
  11. 59
      main/inc/lib/urlmanager.lib.php
  12. 26
      main/inc/lib/userportal.lib.php

@ -126,7 +126,6 @@ class LegalManager
{ {
if (strpos($content, '{{sessions}}')) { if (strpos($content, '{{sessions}}')) {
$sessionListToString = ''; $sessionListToString = '';
$sessionList = SessionManager::get_sessions_by_user(api_get_user_id()); $sessionList = SessionManager::get_sessions_by_user(api_get_user_id());
if ($sessionList) { if ($sessionList) {
$sessionListToString = get_lang('SessionList').'<ul>'; $sessionListToString = get_lang('SessionList').'<ul>';

@ -558,7 +558,7 @@ class Link extends Model
'display_order' => $max_display_order, 'display_order' => $max_display_order,
'on_homepage' => $values['on_homepage'], 'on_homepage' => $values['on_homepage'],
'target' => $values['target'], 'target' => $values['target'],
'category_id' => $values['category_id'], 'category_id' => $values['category_id']
]; ];
Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id] ]); Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id] ]);
@ -887,7 +887,8 @@ class Link extends Model
$toolbar = ''; $toolbar = '';
$link_validator = ''; $link_validator = '';
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
$toolbar .= Display::toolbarButton('', $toolbar .= Display::toolbarButton(
'',
'#', '#',
'retweet', 'retweet',
'default btn-sm', 'default btn-sm',
@ -903,7 +904,6 @@ class Link extends Model
'class' => 'check-link' 'class' => 'check-link'
) )
); );
} }
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
@ -954,8 +954,8 @@ class Link extends Model
'title' => $title 'title' => $title
) )
); );
} }
if ($myrow['visibility'] == '0') { if ($myrow['visibility'] == '0') {
$url .= 'link.php?' . api_get_cidreq() .'&sec_token=' . $token .'&action=visible&id=' . $myrow['id'] .'&scope=link&category_id=' . $myrow['category_id']; $url .= 'link.php?' . api_get_cidreq() .'&sec_token=' . $token .'&action=visible&id=' . $myrow['id'] .'&scope=link&category_id=' . $myrow['category_id'];
$title = get_lang('MakeVisible'); $title = get_lang('MakeVisible');
@ -984,8 +984,6 @@ class Link extends Model
'title' => $title 'title' => $title
) )
); );
} else { } else {
$title = get_lang('EditionNotAvailableFromSession'); $title = get_lang('EditionNotAvailableFromSession');
$toolbar .= Display::toolbarButton( $toolbar .= Display::toolbarButton(
@ -998,7 +996,6 @@ class Link extends Model
) )
); );
} }
} }
$iconLink = Display::return_icon( $iconLink = Display::return_icon(
'url.png', 'url.png',
@ -1285,16 +1282,11 @@ class Link extends Model
$result $result
)) ))
) { ) {
Database:: query( $sql = "UPDATE $tbl_link SET
"UPDATE $tbl_link set title='" . Database:: escape_string( title = '" . Database:: escape_string($title) . "',
$title description = '" . Database:: escape_string($description) . "'
) . "', description='" . Database:: escape_string( WHERE c_id = $course_id AND id='" . Database:: escape_string($row['id']) . "'";
$description Database:: query($sql);
) . "'
WHERE c_id = $course_id AND id='" . Database:: escape_string(
$row['id']
) . "'"
);
$ipu = 'LinkUpdated'; $ipu = 'LinkUpdated';
$rv = 1; // 1 = upd $rv = 1; // 1 = upd
@ -1321,6 +1313,7 @@ class Link extends Model
$ipu = 'LinkAdded'; $ipu = 'LinkAdded';
$rv = 2; // 2 = new $rv = 2; // 2 = new
} }
api_item_property_update( api_item_property_update(
$_course, $_course,
TOOL_LINK, TOOL_LINK,
@ -1338,6 +1331,7 @@ class Link extends Model
$_user['user_id'] $_user['user_id']
); );
} }
return $rv; return $rv;
} }
@ -1421,7 +1415,6 @@ class Link extends Model
// i.e. allow some BBcode tags, e.g. [b]...[/b] // i.e. allow some BBcode tags, e.g. [b]...[/b]
} }
/** /**
* This function checks if the url is a vimeo link * This function checks if the url is a vimeo link
* @author Julio Montoya * @author Julio Montoya
@ -1430,6 +1423,7 @@ class Link extends Model
public static function isVimeoLink($url) public static function isVimeoLink($url)
{ {
$isLink = strrpos($url, "vimeo.com"); $isLink = strrpos($url, "vimeo.com");
return $isLink; return $isLink;
} }
@ -1622,8 +1616,8 @@ class Link extends Model
/** /**
* @param int $linkId * @param int $linkId
* @param $action * @param $action
* @param null $urlview
* @param null $token * @param null $token
*
* @return FormValidator * @return FormValidator
*/ */
public static function getLinkForm($linkId, $action, $token = null) public static function getLinkForm($linkId, $action, $token = null)

@ -14,11 +14,11 @@ class LpItem
public $c_id = 0; public $c_id = 0;
public $id = 0; public $id = 0;
public $lp_id = 0; public $lp_id = 0;
public $item_type = ""; public $item_type = '';
public $ref = ""; public $ref = '';
public $title = ""; public $title = '';
public $description = ""; public $description = '';
public $path = ""; public $path = '';
public $min_score = 0; public $min_score = 0;
public $max_score = 0; public $max_score = 0;
public $mastery_score = 0; public $mastery_score = 0;
@ -26,15 +26,15 @@ class LpItem
public $previous_item_id = 0; public $previous_item_id = 0;
public $next_item_id = 0; public $next_item_id = 0;
public $display_order = 0; public $display_order = 0;
public $prerequisite = ""; public $prerequisite = '';
public $parameters = ""; public $parameters = '';
public $launch_data = ""; public $launch_data = '';
public $max_time_allowed = ""; public $max_time_allowed = '';
public $terms = ""; public $terms = '';
public $search_did = 0; public $search_did = 0;
public $audio = ""; public $audio = '';
public function __construct($in_c_id=0, $in_id=0) public function __construct($in_c_id = 0, $in_id = 0)
{ {
if ($in_c_id > 0 && $in_id >0) { if ($in_c_id > 0 && $in_id >0) {
$item_view_table = Database::get_course_table(TABLE_LP_ITEM); $item_view_table = Database::get_course_table(TABLE_LP_ITEM);

@ -227,8 +227,7 @@ class MessageManager
$topic_id = 0, $topic_id = 0,
$sender_id = null, $sender_id = null,
$directMessage = false $directMessage = false
) ) {
{
$table_message = Database::get_main_table(TABLE_MESSAGE); $table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id); $group_id = intval($group_id);
$receiver_user_id = intval($receiver_user_id); $receiver_user_id = intval($receiver_user_id);
@ -435,8 +434,7 @@ class MessageManager
$sender_id = null, $sender_id = null,
$sendCopyToDrhUsers = false, $sendCopyToDrhUsers = false,
$directMessage = false $directMessage = false
) ) {
{
$result = MessageManager::send_message( $result = MessageManager::send_message(
$receiver_user_id, $receiver_user_id,
$subject, $subject,
@ -521,8 +519,9 @@ class MessageManager
public static function delete_message_by_user_receiver($user_receiver_id, $id) public static function delete_message_by_user_receiver($user_receiver_id, $id)
{ {
$table_message = Database::get_main_table(TABLE_MESSAGE); $table_message = Database::get_main_table(TABLE_MESSAGE);
if ($id != strval(intval($id))) if ($id != strval(intval($id))) {
return false; return false;
}
$user_receiver_id = intval($user_receiver_id); $user_receiver_id = intval($user_receiver_id);
$id = intval($id); $id = intval($id);
$sql = "SELECT * FROM $table_message $sql = "SELECT * FROM $table_message
@ -536,6 +535,7 @@ class MessageManager
$query = "UPDATE $table_message SET msg_status=3 $query = "UPDATE $table_message SET msg_status=3
WHERE user_receiver_id=" . $user_receiver_id . " AND id=" . $id; WHERE user_receiver_id=" . $user_receiver_id . " AND id=" . $id;
$result = Database::query($query); $result = Database::query($query);
return $result; return $result;
} else { } else {
return false; return false;
@ -594,8 +594,7 @@ class MessageManager
$receiver_user_id = 0, $receiver_user_id = 0,
$sender_user_id = 0, $sender_user_id = 0,
$group_id = 0 $group_id = 0
) ) {
{
$tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); $tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
// Try to add an extension to the file if it hasn't one // Try to add an extension to the file if it hasn't one
@ -745,6 +744,7 @@ class MessageManager
$query = "SELECT * FROM $table_message $query = "SELECT * FROM $table_message
WHERE user_receiver_id=" . intval($user_id) . " AND id='" . intval($message_id) . "'"; WHERE user_receiver_id=" . intval($user_id) . " AND id='" . intval($message_id) . "'";
$result = Database::query($query); $result = Database::query($query);
return $row = Database::fetch_array($result); return $row = Database::fetch_array($result);
} }
@ -755,8 +755,9 @@ class MessageManager
*/ */
public static function get_messages_by_group($group_id) public static function get_messages_by_group($group_id)
{ {
if ($group_id != strval(intval($group_id))) if ($group_id != strval(intval($group_id))) {
return false; return false;
}
$table_message = Database::get_main_table(TABLE_MESSAGE); $table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id); $group_id = intval($group_id);
@ -783,8 +784,9 @@ class MessageManager
*/ */
public static function get_messages_by_group_by_message($group_id, $message_id) public static function get_messages_by_group_by_message($group_id, $message_id)
{ {
if ($group_id != strval(intval($group_id))) if ($group_id != strval(intval($group_id))) {
return false; return false;
}
$table_message = Database::get_main_table(TABLE_MESSAGE); $table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id); $group_id = intval($group_id);
$sql = "SELECT * FROM $table_message $sql = "SELECT * FROM $table_message

@ -534,7 +534,7 @@ class Plugin
/** /**
* Install the course fields and tool link of this plugin in all courses * Install the course fields and tool link of this plugin in all courses
* @param boolean Whether we want to add a plugin link on the course homepage * @param boolean $add_tool_link Whether we want to add a plugin link on the course homepage
* *
* @return void * @return void
*/ */

@ -1,6 +1,7 @@
<?php <?php
/** /**
* @deprecated
* Class Rights * Class Rights
* @deprecated Don't use this class * @deprecated Don't use this class
*/ */

@ -44,7 +44,8 @@ class Security
* Checks if the absolute path (directory) given is really under the * Checks if the absolute path (directory) given is really under the
* checker path (directory) * checker path (directory)
* @param string Absolute path to be checked (with trailing slash) * @param string Absolute path to be checked (with trailing slash)
* @param string Checker path under which the path should be (absolute path, with trailing slash, get it from api_get_path(SYS_COURSE_PATH)) * @param string Checker path under which the path
* should be (absolute path, with trailing slash, get it from api_get_path(SYS_COURSE_PATH))
* @return bool True if the path is under the checker, false otherwise * @return bool True if the path is under the checker, false otherwise
*/ */
public static function check_abs_path($abs_path, $checker_path) public static function check_abs_path($abs_path, $checker_path)
@ -77,7 +78,8 @@ class Security
* Checks if the relative path (directory) given is really under the * Checks if the relative path (directory) given is really under the
* checker path (directory) * checker path (directory)
* @param string Relative path to be checked (relative to the current directory) (with trailing slash) * @param string Relative path to be checked (relative to the current directory) (with trailing slash)
* @param string Checker path under which the path should be (absolute path, with trailing slash, get it from api_get_path(SYS_COURSE_PATH)) * @param string Checker path under which the path
* should be (absolute path, with trailing slash, get it from api_get_path(SYS_COURSE_PATH))
* @return bool True if the path is under the checker, false otherwise * @return bool True if the path is under the checker, false otherwise
*/ */
public static function check_rel_path($rel_path, $checker_path) public static function check_rel_path($rel_path, $checker_path)
@ -156,7 +158,7 @@ class Security
*/ */
public static function check_ua() public static function check_ua()
{ {
if (isset($_SESSION['sec_ua']) and $_SESSION['sec_ua'] === $_SERVER['HTTP_USER_AGENT'].$_SESSION['sec_ua_seed']) { if (isset($_SESSION['sec_ua']) && $_SESSION['sec_ua'] === $_SERVER['HTTP_USER_AGENT'].$_SESSION['sec_ua_seed']) {
return true; return true;
} }

@ -1,6 +1,8 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/** /**
* This class allows you to display a sortable data-table. It is possible to * This class allows you to display a sortable data-table. It is possible to
* split the data in several pages. * split the data in several pages.
@ -131,13 +133,12 @@ class SortableTable extends HTML_Table
$this->additional_parameters = array(); $this->additional_parameters = array();
$this->param_prefix = $table_name.'_'; $this->param_prefix = $table_name.'_';
$this->page_nr = isset($_SESSION[$this->param_prefix.'page_nr']) ? intval($_SESSION[$this->param_prefix.'page_nr']) : 1; $this->page_nr = Session::read($this->param_prefix.'page_nr', 1);
$this->page_nr = isset($_GET[$this->param_prefix.'page_nr']) ? intval($_GET[$this->param_prefix.'page_nr']) : $this->page_nr; $this->page_nr = isset($_GET[$this->param_prefix.'page_nr']) ? intval($_GET[$this->param_prefix.'page_nr']) : $this->page_nr;
$this->column = isset($_SESSION[$this->param_prefix.'column']) ? intval($_SESSION[$this->param_prefix.'column']) : $default_column; $this->column = Session::read($this->param_prefix.'column', $default_column);
$this->column = isset($_GET[$this->param_prefix.'column']) ? intval($_GET[$this->param_prefix.'column']) : $this->column; $this->column = isset($_GET[$this->param_prefix.'column']) ? intval($_GET[$this->param_prefix.'column']) : $this->column;
// Default direction. // Default direction.
if (in_array(strtoupper($default_order_direction), array('ASC', 'DESC'))) { if (in_array(strtoupper($default_order_direction), array('ASC', 'DESC'))) {
$this->direction = $default_order_direction; $this->direction = $default_order_direction;
} }
@ -169,15 +170,16 @@ class SortableTable extends HTML_Table
} }
// Allow to change paginate in multiples tabs // Allow to change paginate in multiples tabs
unset($_SESSION[$this->param_prefix.'per_page']); Session::erase($this->param_prefix.'per_page');
$this->per_page = isset($_SESSION[$this->param_prefix.'per_page']) ? intval($_SESSION[$this->param_prefix.'per_page']) : $default_items_per_page; $this->per_page = Session::read($this->param_prefix.'per_page', $default_items_per_page);
$this->per_page = isset($_GET[$this->param_prefix.'per_page']) ? intval($_GET[$this->param_prefix.'per_page']) : $this->per_page; $this->per_page = isset($_GET[$this->param_prefix.'per_page']) ? intval($_GET[$this->param_prefix.'per_page']) : $this->per_page;
$_SESSION[$this->param_prefix.'per_page'] = $this->per_page; Session::write($this->param_prefix.'per_page', $this->per_page);
$_SESSION[$this->param_prefix.'direction'] = $this->direction; Session::write($this->param_prefix.'direction', $this->direction);
$_SESSION[$this->param_prefix.'page_nr'] = $this->page_nr; Session::write($this->param_prefix.'page_nr', $this->page_nr);
$_SESSION[$this->param_prefix.'column'] = $this->column; Session::write($this->param_prefix.'column', $this->column);
$this->pager = null; $this->pager = null;
$this->default_items_per_page = $default_items_per_page; $this->default_items_per_page = $default_items_per_page;
$this->total_number_of_items = -1; $this->total_number_of_items = -1;

@ -129,13 +129,13 @@ class SystemAnnouncementManager
( '$now' >= date_start AND '$now' <= date_end) "; ( '$now' >= date_start AND '$now' <= date_end) ";
switch ($visible) { switch ($visible) {
case self::VISIBLE_GUEST : case self::VISIBLE_GUEST:
$sql .= " AND visible_guest = 1 "; $sql .= " AND visible_guest = 1 ";
break; break;
case self::VISIBLE_STUDENT : case self::VISIBLE_STUDENT:
$sql .= " AND visible_student = 1 "; $sql .= " AND visible_student = 1 ";
break; break;
case self::VISIBLE_TEACHER : case self::VISIBLE_TEACHER:
$sql .= " AND visible_teacher = 1 "; $sql .= " AND visible_teacher = 1 ";
break; break;
} }
@ -240,13 +240,13 @@ class SystemAnnouncementManager
WHERE (lang="'.$user_selected_language.'" OR lang IS NULL) '; WHERE (lang="'.$user_selected_language.'" OR lang IS NULL) ';
if (isset($user_id)) { if (isset($user_id)) {
switch ($visibility) { switch ($visibility) {
case self::VISIBLE_GUEST : case self::VISIBLE_GUEST:
$sql .= " AND visible_guest = 1 "; $sql .= " AND visible_guest = 1 ";
break; break;
case self::VISIBLE_STUDENT : case self::VISIBLE_STUDENT:
$sql .= " AND visible_student = 1 "; $sql .= " AND visible_student = 1 ";
break; break;
case self::VISIBLE_TEACHER : case self::VISIBLE_TEACHER:
$sql .= " AND visible_teacher = 1 "; $sql .= " AND visible_teacher = 1 ";
break; break;
} }
@ -322,15 +322,15 @@ class SystemAnnouncementManager
$sendEmailTest = false $sendEmailTest = false
) { ) {
$original_content = $content; $original_content = $content;
$a_dateS = explode(' ',$date_start); $a_dateS = explode(' ', $date_start);
$a_arraySD = explode('-',$a_dateS[0]); $a_arraySD = explode('-', $a_dateS[0]);
$a_arraySH = explode(':',$a_dateS[1]); $a_arraySH = explode(':', $a_dateS[1]);
$date_start_to_compare = array_merge($a_arraySD,$a_arraySH); $date_start_to_compare = array_merge($a_arraySD, $a_arraySH);
$a_dateE = explode(' ',$date_end); $a_dateE = explode(' ', $date_end);
$a_arrayED = explode('-',$a_dateE[0]); $a_arrayED = explode('-', $a_dateE[0]);
$a_arrayEH = explode(':',$a_dateE[1]); $a_arrayEH = explode(':', $a_dateE[1]);
$date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); $date_end_to_compare = array_merge($a_arrayED, $a_arrayEH);
$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
@ -360,8 +360,6 @@ class SystemAnnouncementManager
//$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
$content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content);
$content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content);
$lang = is_null($lang) ? '' : $lang; $lang = is_null($lang) ? '' : $lang;
$current_access_url_id = 1; $current_access_url_id = 1;
@ -427,8 +425,8 @@ class SystemAnnouncementManager
/** /**
* Makes the announcement id visible only for groups in groups_array * Makes the announcement id visible only for groups in groups_array
* @param int announcement id * @param int $announcement_id
* @param array array of group id * @param array $group_array array of group id
**/ **/
public static function announcement_for_groups($announcement_id, $group_array) public static function announcement_for_groups($announcement_id, $group_array)
{ {
@ -437,9 +435,8 @@ class SystemAnnouncementManager
); );
//first delete all group associations for this announcement //first delete all group associations for this announcement
$res = Database::query( $res = Database::query(
"DELETE FROM $tbl_announcement_group WHERE announcement_id=".intval( "DELETE FROM $tbl_announcement_group
$announcement_id WHERE announcement_id=".intval($announcement_id)
)
); );
if ($res === false) { if ($res === false) {
@ -482,6 +479,7 @@ class SystemAnnouncementManager
ag.group_id = g.id"; ag.group_id = g.id";
$res = Database::query($sql); $res = Database::query($sql);
$groups = Database::fetch_array($res); $groups = Database::fetch_array($res);
return $groups; return $groups;
} }
@ -509,20 +507,21 @@ class SystemAnnouncementManager
) { ) {
$em = Database::getManager(); $em = Database::getManager();
$a_dateS = explode(' ',$date_start); $a_dateS = explode(' ', $date_start);
$a_arraySD = explode('-',$a_dateS[0]); $a_arraySD = explode('-', $a_dateS[0]);
$a_arraySH = explode(':',$a_dateS[1]); $a_arraySH = explode(':', $a_dateS[1]);
$date_start_to_compare = array_merge($a_arraySD,$a_arraySH); $date_start_to_compare = array_merge($a_arraySD, $a_arraySH);
$a_dateE = explode(' ',$date_end); $a_dateE = explode(' ', $date_end);
$a_arrayED = explode('-',$a_dateE[0]); $a_arrayED = explode('-', $a_dateE[0]);
$a_arrayEH = explode(':',$a_dateE[1]); $a_arrayEH = explode(':', $a_dateE[1]);
$date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); $date_end_to_compare = array_merge($a_arrayED, $a_arrayEH);
$lang = is_null($lang) ? '' : $lang; $lang = is_null($lang) ? '' : $lang;
if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
Display :: display_normal_message(get_lang('InvalidStartDate')); Display:: display_normal_message(get_lang('InvalidStartDate'));
return false; return false;
} }
@ -670,8 +669,14 @@ class SystemAnnouncementManager
* @param string Language (optional, considered for all languages if left empty) * @param string Language (optional, considered for all languages if left empty)
* @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. * @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error.
*/ */
public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) public static function send_system_announcement_by_email(
{ $title,
$content,
$teacher,
$student,
$language = null,
$sendEmailTest = false
) {
global $charset; global $charset;
$title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset); $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset);
@ -753,13 +758,13 @@ class SystemAnnouncementManager
('$now' >= date_start AND '$now' <= date_end) "; ('$now' >= date_start AND '$now' <= date_end) ";
switch ($visible) { switch ($visible) {
case self::VISIBLE_GUEST : case self::VISIBLE_GUEST:
$sql .= " AND visible_guest = 1 "; $sql .= " AND visible_guest = 1 ";
break; break;
case self::VISIBLE_STUDENT : case self::VISIBLE_STUDENT:
$sql .= " AND visible_student = 1 "; $sql .= " AND visible_student = 1 ";
break; break;
case self::VISIBLE_TEACHER : case self::VISIBLE_TEACHER:
$sql .= " AND visible_teacher = 1 "; $sql .= " AND visible_teacher = 1 ";
break; break;
} }

@ -408,6 +408,7 @@ class Thematic
); );
} }
} }
return $affected_rows; return $affected_rows;
} }
@ -654,6 +655,7 @@ class Thematic
$return .= '</div>'; $return .= '</div>';
$final_return[$thematic_id] = $return; $final_return[$thematic_id] = $return;
} }
return $final_return; return $final_return;
} }
@ -668,9 +670,7 @@ class Thematic
) { ) {
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); $tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$data = array(); $data = array();
$condition = ''; $condition = '';
if (isset($thematic_advance_id)) { if (isset($thematic_advance_id)) {
$thematic_advance_id = intval($thematic_advance_id); $thematic_advance_id = intval($thematic_advance_id);
@ -691,7 +691,7 @@ class Thematic
api_get_session_id() api_get_session_id()
); );
foreach ($list as $value) { foreach ($list as $value) {
$elements[$value['ref']]= $value; $elements[$value['ref']] = $value;
} }
} }
@ -1157,9 +1157,7 @@ class Thematic
); );
if ($item_info['session_id'] == $sessionId) { if ($item_info['session_id'] == $sessionId) {
$a_thematic_advance_ids[] = $thematic_advance['id']; $a_thematic_advance_ids[] = $thematic_advance['id'];
// update done thematic for previous advances ((done_advance = 1)) // update done thematic for previous advances ((done_advance = 1))
$upd = "UPDATE $tbl_thematic_advance SET $upd = "UPDATE $tbl_thematic_advance SET
done_advance = 1 done_advance = 1
@ -1321,7 +1319,10 @@ class Thematic
if (!empty($thematic_data)) { if (!empty($thematic_data)) {
foreach ($thematic_data as $thematic) { foreach ($thematic_data as $thematic) {
$thematic_id = $thematic['id']; $thematic_id = $thematic['id'];
$a_average_of_advances_by_thematic[$thematic_id] = $this->get_average_of_advances_by_thematic($thematic_id, $course_code); $a_average_of_advances_by_thematic[$thematic_id] = $this->get_average_of_advances_by_thematic(
$thematic_id,
$course_code
);
} }
} }
@ -1331,6 +1332,7 @@ class Thematic
$score = array_sum($a_average_of_advances_by_thematic); $score = array_sum($a_average_of_advances_by_thematic);
$total_average = round(($score * 100) / ($count_tematics * 100)); $total_average = round(($score * 100) / ($count_tematics * 100));
} }
return $total_average; return $total_average;
} }

@ -80,22 +80,22 @@ class UrlManager
$tableGroup = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); $tableGroup = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
$sql = "DELETE FROM $tableCourse WHERE access_url_id = ".$id; $sql = "DELETE FROM $tableCourse WHERE access_url_id = ".$id;
$result = Database::query($sql); Database::query($sql);
/* /*
$sql = "DELETE FROM $tableCourseCategory WHERE access_url_id = ".$id; $sql = "DELETE FROM $tableCourseCategory WHERE access_url_id = ".$id;
$result = Database::query($sql); Database::query($sql);
*/ */
$sql = "DELETE FROM $tableSession WHERE access_url_id = ".$id; $sql = "DELETE FROM $tableSession WHERE access_url_id = ".$id;
$result = Database::query($sql); Database::query($sql);
$sql = "DELETE FROM $tableGroup WHERE access_url_id = ".$id; $sql = "DELETE FROM $tableGroup WHERE access_url_id = ".$id;
$result = Database::query($sql); Database::query($sql);
$sql = "DELETE FROM $tableUser WHERE access_url_id = ".$id; $sql = "DELETE FROM $tableUser WHERE access_url_id = ".$id;
$result = Database::query($sql); Database::query($sql);
$sql= "DELETE FROM $table WHERE id = ".$id; $sql= "DELETE FROM $table WHERE id = ".$id;
$result = Database::query($sql); Database::query($sql);
return $result; return true;
} }
/** /**
@ -281,8 +281,9 @@ class UrlManager
$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
@ -430,7 +431,8 @@ class UrlManager
{ {
$table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
$sql= "SELECT usergroup_id FROM $table $sql= "SELECT usergroup_id FROM $table
WHERE access_url_id = ".intval($urlId)." AND WHERE
access_url_id = ".intval($urlId)." AND
usergroup_id = ".intval($userGroupId); usergroup_id = ".intval($userGroupId);
$result = Database::query($sql); $result = Database::query($sql);
$num = Database::num_rows($result); $num = Database::num_rows($result);
@ -472,13 +474,15 @@ class UrlManager
$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);
$result_array = array(); $result_array = array();
if (is_array($user_list) && is_array($url_list)){ if (is_array($user_list) && is_array($url_list)) {
foreach ($url_list as $url_id) { foreach ($url_list as $url_id) {
foreach ($user_list as $user_id) { foreach ($user_list as $user_id) {
$count = UrlManager::relation_url_user_exist($user_id,$url_id); $count = UrlManager::relation_url_user_exist($user_id,$url_id);
if ($count==0) { if ($count == 0) {
$sql = "INSERT INTO $table_url_rel_user $sql = "INSERT INTO $table_url_rel_user
SET user_id = ".intval($user_id).", access_url_id = ".intval($url_id); SET
user_id = ".intval($user_id).",
access_url_id = ".intval($url_id);
$result = Database::query($sql); $result = Database::query($sql);
if ($result) { if ($result) {
$result_array[$url_id][$user_id] = 1; $result_array[$url_id][$user_id] = 1;
@ -643,14 +647,15 @@ class UrlManager
return Database::insert_id(); return Database::insert_id();
} }
return 0; return 0;
} }
/** /**
* Add a group of sessions into a group of URLs * Add a group of sessions into a group of URLs
* @author Julio Montoya * @author Julio Montoya
* @param array of session ids * @param array $session_list of session ids
* @param array of url_ids * @param array $url_list of url_ids
* @return array * @return array
* */ * */
public static function add_sessions_to_urls($session_list, $url_list) public static function add_sessions_to_urls($session_list, $url_list)
@ -873,8 +878,8 @@ class UrlManager
/** /**
* Updates the access_url_rel_user table with a given user list * Updates the access_url_rel_user table with a given user list
* @author Julio Montoya * @author Julio Montoya
* @param array user list * @param array $user_list
* @param int access_url_id * @param int $access_url_id
* */ * */
public static function update_urls_rel_user($user_list, $access_url_id) public static function update_urls_rel_user($user_list, $access_url_id)
{ {
@ -954,8 +959,8 @@ class UrlManager
/** /**
* Updates the access_url_rel_course table with a given user list * Updates the access_url_rel_course table with a given user list
* @author Julio Montoya * @author Julio Montoya
* @param array user list * @param array $userGroupList user list
* @param int access_url_id * @param int $urlId
* */ * */
public static function update_urls_rel_usergroup($userGroupList, $urlId) public static function update_urls_rel_usergroup($userGroupList, $urlId)
{ {
@ -987,8 +992,8 @@ class UrlManager
/** /**
* Updates the access_url_rel_course_category table with a given list * Updates the access_url_rel_course_category table with a given list
* @author Julio Montoya * @author Julio Montoya
* @param array course category list * @param array $list course category list
* @param int access_url_id * @param int $urlId access_url_id
**/ **/
public static function updateUrlRelCourseCategory($list, $urlId) public static function updateUrlRelCourseCategory($list, $urlId)
{ {
@ -1031,15 +1036,13 @@ class UrlManager
} }
} }
/** /**
* Updates the access_url_rel_session table with a given user list * Updates the access_url_rel_session table with a given user list
* @author Julio Montoya * @author Julio Montoya
* @param array user list * @param array $session_list
* @param int access_url_id * @param int $access_url_id
* */ * */
public static function update_urls_rel_session($session_list,$access_url_id) public static function update_urls_rel_session($session_list, $access_url_id)
{ {
$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);
@ -1072,6 +1075,7 @@ class UrlManager
/** /**
* @param int $user_id * @param int $user_id
*
* @return array * @return array
*/ */
public static function get_access_url_from_user($user_id) public static function get_access_url_from_user($user_id)
@ -1083,6 +1087,7 @@ class UrlManager
WHERE user_id = ".intval($user_id); WHERE user_id = ".intval($user_id);
$result = Database::query($sql); $result = Database::query($sql);
$url_list = Database::store_result($result,'ASSOC'); $url_list = Database::store_result($result,'ASSOC');
return $url_list; return $url_list;
} }
@ -1130,6 +1135,7 @@ class UrlManager
$sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'"; $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
$result = Database::query($sql); $result = Database::query($sql);
$access_url_id = Database::result($result, 0, 0); $access_url_id = Database::result($result, 0, 0);
return $access_url_id; return $access_url_id;
} }
@ -1167,6 +1173,7 @@ class UrlManager
} }
} }
$response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return)); $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
return $response; return $response;
} }
} }

@ -49,7 +49,7 @@ class IndexManager
/** /**
* @param bool $setLoginForm * @param bool $setLoginForm
*/ */
function set_login_form($setLoginForm = true) public function set_login_form($setLoginForm = true)
{ {
global $loginFailed; global $loginFailed;
$this->tpl->setLoginForm($setLoginForm); $this->tpl->setLoginForm($setLoginForm);
@ -58,7 +58,7 @@ class IndexManager
/** /**
* @param array $personal_course_list * @param array $personal_course_list
*/ */
function return_exercise_block($personal_course_list) public function return_exercise_block($personal_course_list)
{ {
$exercise_list = array(); $exercise_list = array();
if (!empty($personal_course_list)) { if (!empty($personal_course_list)) {
@ -286,7 +286,7 @@ class IndexManager
return $html; return $html;
} }
function return_notice() public function return_notice()
{ {
$user_selected_language = api_get_interface_language(); $user_selected_language = api_get_interface_language();
@ -312,7 +312,7 @@ class IndexManager
return $html; return $html;
} }
function return_help() public function return_help()
{ {
$user_selected_language = api_get_interface_language(); $user_selected_language = api_get_interface_language();
$platformLanguage = api_get_setting('platformLanguage'); $platformLanguage = api_get_setting('platformLanguage');
@ -342,7 +342,10 @@ class IndexManager
return $html; return $html;
} }
function return_skills_links() /**
* @return null|string
*/
public function return_skills_links()
{ {
$content = ''; $content = '';
$content .= '<ul class="nav nav-pills nav-stacked">'; $content .= '<ul class="nav nav-pills nav-stacked">';
@ -411,7 +414,7 @@ class IndexManager
* *
* @version 1.0.1 * @version 1.0.1
*/ */
function handle_login_failed() public function handle_login_failed()
{ {
return $this->tpl->handleLoginFailed(); return $this->tpl->handleLoginFailed();
} }
@ -424,7 +427,7 @@ class IndexManager
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University - refactoring and code cleaning * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University - refactoring and code cleaning
* @author Julio Montoya <gugli100@gmail.com>, Beeznest template modifs * @author Julio Montoya <gugli100@gmail.com>, Beeznest template modifs
*/ */
function return_courses_in_categories() public function return_courses_in_categories()
{ {
$result = ''; $result = '';
$stok = Security::get_token(); $stok = Security::get_token();
@ -489,7 +492,8 @@ class IndexManager
LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id
LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses) LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses)
WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")." WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")."
GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count
ORDER BY t1.tree_pos, t1.name";
// Showing only the category of courses of the current access_url_id // Showing only the category of courses of the current access_url_id
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
@ -805,7 +809,7 @@ class IndexManager
public function return_classes_block() public function return_classes_block()
{ {
$html = ''; $html = '';
if (api_get_setting('show_groups_to_users') == 'true') { if (api_get_setting('show_groups_to_users') === 'true') {
$usergroup = new UserGroup(); $usergroup = new UserGroup();
$usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id()); $usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id());
$classes = ''; $classes = '';
@ -955,6 +959,9 @@ class IndexManager
return $html; return $html;
} }
/**
* @return null|string
*/
public function return_navigation_links() public function return_navigation_links()
{ {
$html = ''; $html = '';
@ -1068,6 +1075,7 @@ class IndexManager
'courseCollapse' 'courseCollapse'
); );
} }
return $html; return $html;
} }

Loading…
Cancel
Save