Remove $_configuration calls and use functions, format code.

1.10.x
Julio Montoya 10 years ago
parent bf9f7fd603
commit 74ca0d17bc
  1. 2
      main/admin/configure_homepage.php
  2. 14
      main/admin/course_add.php
  3. 12
      main/admin/course_request_rejected.php
  4. 1
      main/admin/dashboard_add_users_to_user.php
  5. 9
      main/exercice/exercise.class.php
  6. 3
      main/exercice/hotpotatoes.lib.php
  7. 4
      main/exercice/savescores.php
  8. 2
      main/inc/lib/access_url_edit_courses_to_url_functions.lib.php
  9. 2
      main/inc/lib/access_url_edit_sessions_to_url_functions.lib.php
  10. 2
      main/inc/lib/access_url_edit_users_to_url_functions.lib.php
  11. 2
      main/inc/lib/add_course.lib.inc.php
  12. 3
      main/inc/lib/add_courses_to_session_functions.lib.php
  13. 6
      main/inc/lib/add_many_session_to_category_functions.lib.php
  14. 9
      main/inc/lib/api.lib.php
  15. 8
      main/inc/lib/link.lib.php
  16. 11
      main/inc/lib/sessionmanager.lib.php
  17. 3
      main/inc/lib/template.lib.php
  18. 3
      main/newscorm/learnpath.class.php
  19. 1
      main/newscorm/resourcelinker.inc.php
  20. 5
      main/session/add_users_to_session.php
  21. 6
      main/session/session_add.php
  22. 2
      main/session/session_export.php
  23. 6
      main/user/add_users_to_session.php
  24. 13
      tests/main/inc/banner.inc.test.php

@ -70,8 +70,6 @@ $(function() {
});
</script>';
global $_configuration;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$tool_name = get_lang('ConfigureHomePage');

@ -14,19 +14,21 @@ $tool_name = get_lang('AddCourse');
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'course_list.php', 'name' => get_lang('CourseList'));
/* MAIN CODE */
global $_configuration;
// Get all possible teachers.
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT user_id,lastname,firstname FROM $table_user WHERE status=1".$order_clause;
$sql = "SELECT user_id,lastname,firstname
FROM $table_user
WHERE status=1".$order_clause;
// Filtering teachers when creating a course.
if (api_is_multiple_url_enabled()) {
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT u.user_id,lastname,firstname FROM $table_user as u
$sql = "SELECT u.user_id,lastname,firstname
FROM $table_user as u
INNER JOIN $access_url_rel_user_table url_rel_user
ON (u.user_id=url_rel_user.user_id) WHERE url_rel_user.access_url_id=".api_get_current_access_url_id()." AND status=1".$order_clause;
ON (u.user_id=url_rel_user.user_id)
WHERE url_rel_user.access_url_id=".api_get_current_access_url_id()." AND status=1".$order_clause;
}
$res = Database::query($sql);
@ -117,7 +119,7 @@ $form->addGroup($group,'', get_lang('Subscription'), '<br />');
$group = array();
$group[]= $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$group[]= $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$form->addGroup($group,'', get_lang('Unsubscription'), '<br />');
$form->addGroup($group, '', get_lang('Unsubscription'), '<br />');
$form->addElement('text','disk_quota',array(get_lang('CourseQuota'), null, get_lang('MB')));
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');

@ -28,7 +28,6 @@ $delete_course_request = isset($_GET['delete_course_request']) ? intval($_GET['d
$request_info = isset($_GET['request_info']) ? intval($_GET['request_info']) : '';
$message = isset($_GET['message']) ? trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))) : '';
$is_error_message = !empty($_GET['is_error_message']);
$keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : '';
if ($course_validation_feature) {
@ -107,8 +106,9 @@ function get_number_of_requests() {
/**
* Get course data to display
*/
function get_request_data($from, $number_of_items, $column, $direction) {
global $keyword;
function get_request_data($from, $number_of_items, $column, $direction)
{
$keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : '';
$course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
$from = intval($from);
@ -128,7 +128,11 @@ function get_request_data($from, $number_of_items, $column, $direction) {
WHERE status = ".COURSE_REQUEST_REJECTED;
if ($keyword != '') {
$sql .= " AND (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')";
$sql .= " AND (
title LIKE '%".$keyword."%' OR
code LIKE '%".$keyword."%' OR
visual_code LIKE '%".$keyword."%'
)";
}
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";

@ -10,7 +10,6 @@ $cidReset = true;
require_once '../inc/global.inc.php';
global $_configuration;
$ajax_search = false;
// create an ajax object
$xajax = new xajax();

@ -94,7 +94,6 @@ class Exercise
*/
public function read($id)
{
global $_configuration;
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
$table_lp_item = Database::get_course_table(TABLE_LP_ITEM);
@ -146,7 +145,7 @@ class Exercise
$this->lpList = Database::store_result($result, 'ASSOC');
}
$this->force_edit_exercise_in_lp = isset($_configuration['force_edit_exercise_in_lp']) ? $_configuration['force_edit_exercise_in_lp'] : false;
$this->force_edit_exercise_in_lp = api_get_configuration_value('force_edit_exercise_in_lp');
if ($this->exercise_was_added_in_lp) {
$this->edit_exercise_in_lp = $this->force_edit_exercise_in_lp == true;
@ -1032,10 +1031,8 @@ class Exercise
*/
public function createForm($form, $type='full')
{
global $id;
if (empty($type)){
$type='full';
if (empty($type)) {
$type = 'full';
}
// form title

@ -98,13 +98,14 @@ function GetComment($path, $course_code = '')
*/
function SetComment($path, $comment)
{
global $dbTable;
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
$path = Database::escape_string($path);
$comment = Database::escape_string($comment);
$course_id = api_get_course_int_id();
$query = "UPDATE $dbTable SET comment='$comment'
WHERE $course_id AND path='$path'";
$result = Database::query($query);
return $result;
}

@ -38,7 +38,9 @@ $jscript2run = '';
*/
function save_scores($file, $score)
{
global $origin, $_user, $TABLETRACK_HOTPOTATOES;
global $origin;
$TABLETRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$_user = api_get_user_info();
// if tracking is disabled record nothing
$weighting = 100; // 100%
$date = api_get_utc_datetime();

@ -27,7 +27,7 @@ class Accessurleditcoursestourl
*/
function search_courses($needle, $id)
{
global $tbl_course;
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$xajax_response = new xajaxResponse();
$return = '';

@ -29,7 +29,7 @@ class Accessurleditsessionstourl
*/
function search_sessions($needle, $id)
{
global $tbl_session;
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$xajax_response = new xajaxResponse();
$return = '';

@ -28,7 +28,7 @@ class Accessurledituserstourl
*/
function search_users($needle, $id)
{
global $tbl_user;
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$xajax_response = new xajaxResponse();
$return = '';

@ -20,7 +20,6 @@ class AddCourse
*/
public static function define_course_keys($wanted_code, $prefix_for_all = '', $prefix_for_base_name = '', $prefix_for_path = '', $add_unique_prefix = false, $use_code_indepedent_keys = true)
{
global $prefixAntiNumber, $_configuration;
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$wanted_code = CourseManager::generate_course_code($wanted_code);
$keys_course_code = $wanted_code;
@ -425,7 +424,6 @@ class AddCourse
'example_material_course_creation'
) != 'false';
}
global $_configuration;
$course_id = intval($course_id);
if (empty($course_id)) {

@ -16,7 +16,8 @@ class AddCourseToSession
*/
public static function search_courses($needle, $type)
{
global $tbl_course, $tbl_session_rel_course, $id_session;
global $tbl_session_rel_course, $id_session;
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$course_title = null;
$xajax_response = new xajaxResponse();
$return = '';

@ -21,9 +21,9 @@ class AddManySessionToCategoryFunctions
* @assert () !== ''
* @assert ('abc','single') !== ''
*/
function search_courses($needle,$type) {
global $tbl_course, $tbl_session, $id_session;
function search_courses($needle,$type)
{
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$xajax_response = new xajaxResponse();
$return = '';
if(!empty($needle) && !empty($type)) {

@ -4937,9 +4937,9 @@ function api_get_version() {
* @return string
*/
function api_get_software_name() {
global $_configuration;
if (isset($_configuration['software_name']) && !empty($_configuration['software_name'])) {
return $_configuration['software_name'];
$name = api_get_configuration_value('software_name');
if (!empty($name)) {
return $name;
} else {
return 'Chamilo';
}
@ -6907,8 +6907,7 @@ function api_set_default_visibility($item_id, $tool_id, $group_id = 0, $courseIn
* @return string
*/
function api_get_security_key() {
global $_configuration;
return $_configuration['security_key'];
return api_get_configuration_value('security_key');
}
/**

@ -1270,14 +1270,17 @@ class Link extends Model
*/
public static function put_link($url, $cat, $title, $description, $on_homepage, $hidden)
{
$_course = api_get_course_info();
$_user = api_get_user_info();
$tbl_link = Database:: get_course_table(TABLE_LINK);
$course_id = api_get_course_int_id();
$urleq = "url='" . Database:: escape_string($url) . "'";
$cateq = "category_id=" . intval($cat);
$result = Database:: query(
"SELECT id FROM $tbl_link
$result = Database:: query("
SELECT id FROM $tbl_link
WHERE c_id = $course_id AND " . $urleq . ' AND ' . $cateq
);
@ -1321,7 +1324,6 @@ class Link extends Model
$ipu = 'LinkAdded';
$rv = 2; // 2 = new
}
global $_course, $_user;
api_item_property_update(
$_course,
TOOL_LINK,

@ -1154,8 +1154,6 @@ class SessionManager
$date_to = '',
$options
) {
global $_configuration;
//escaping variables
$sessionId = intval($sessionId);
$courseId = intval($courseId);
@ -5506,14 +5504,7 @@ class SessionManager
*/
public static function durationPerUserIsEnabled()
{
global $_configuration;
if (isset($_configuration['session_duration_feature']) &&
$_configuration['session_duration_feature']
) {
return true;
}
return false;
return api_get_configuration_value('session_duration_feature');
}
/**

@ -728,7 +728,8 @@ class Template
*/
private function set_header_parameters($sendHeaders)
{
global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $_configuration, $this_section;
global $httpHeadXtra, $interbreadcrumb, $language_file, $_configuration, $this_section;
$_course = api_get_course_info();
$help = $this->help;
$nameTools = $this->title;
$navigation = return_navigation_array();

@ -3100,7 +3100,6 @@ class learnpath
*/
public function get_html_toc($toc_list = null)
{
global $_configuration;
$is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
if ($this->debug > 0) {
@ -3111,7 +3110,7 @@ class learnpath
}
//$html = '<div id="scorm_title" class="scorm-heading">'.Security::remove_XSS($this->get_name()) . '</div>';
$html = '<div class="scorm-body">';
$hide_teacher_icons_lp = isset($_configuration['hide_teacher_icons_lp']) ? $_configuration['hide_teacher_icons_lp'] : true;
$hide_teacher_icons_lp = api_get_configuration_value('hide_teacher_icons_lp');
if ($is_allowed_to_edit && $hide_teacher_icons_lp == false) {
$gradebook = Security :: remove_XSS($_GET['gradebook']);

@ -61,7 +61,6 @@ function show_folder_up() {
* @param $folder
*/
function show_documents($folder) {
global $_course;
global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
// Documents are a special case: The teacher can add an invisible document (it will be viewable by the user)

@ -63,7 +63,10 @@ if (is_array($extra_field_list)) {
function search_users($needle, $type)
{
global $tbl_user, $tbl_session_rel_user, $id_session;
global $id_session;
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$xajax_response = new xajaxResponse();
$return = '';

@ -33,9 +33,9 @@ $interbreadcrumb[] = array(
);
function search_coachs($needle) {
global $tbl_user;
function search_coachs($needle)
{
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$xajax_response = new xajaxResponse();
$return = '';

@ -32,8 +32,6 @@ $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
$tool_name = get_lang('ExportSessionListXMLCSV');
global $_configuration;
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
set_time_limit(0);

@ -62,7 +62,11 @@ if($allowTutors == 'true') {
function search_users($needle, $type)
{
global $tbl_user,$tbl_session_rel_user,$id_session;
global $id_session;
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$xajax_response = new xajaxResponse();
$return = '';

@ -1,12 +1,15 @@
<?php
class TestBanner extends UnitTestCase{
class TestBanner extends UnitTestCase
{
public function TestBanner(){
public function TestBanner()
{
$this->UnitTestCase('Banners library - main/inc/banner.inc.test.php');
}
public function testGetTabs(){
global $_course, $_user;
public function testGetTabs()
{
ob_start();
require_once(api_get_path(SYS_CODE_PATH).'inc/banner.inc.php');
ob_end_clean();
@ -15,6 +18,4 @@ class TestBanner extends UnitTestCase{
$this->assertTrue($res);
//var_dump($res);
}
}
?>

Loading…
Cancel
Save