diff --git a/app/Migrations/Schema/V110/Version20150522222222.php b/app/Migrations/Schema/V110/Version20150522222222.php index 6c213004db..4383d13b37 100644 --- a/app/Migrations/Schema/V110/Version20150522222222.php +++ b/app/Migrations/Schema/V110/Version20150522222222.php @@ -17,9 +17,41 @@ class Version20150522222222 extends AbstractMigrationChamilo */ public function up(Schema $schema) { - $this->addSql('ALTER TABLE user ADD COLUMN last_login datetime DEFAULT NULL'); + // The first ALTER queries here requires a check because the field might already exist + $connection = $this->connection; + $fieldExists = false; + $sql = "SELECT * + FROM user + LIMIT 1"; + $result = $connection->executeQuery($sql); + $dataList = $result->fetchAll(); + if (!empty($dataList)) { + foreach ($dataList as $data) { + if (isset($data['last_login'])) { + $fieldExists = true; + } + } + } + if (!$fieldExists) { + $this->addSql('ALTER TABLE user ADD COLUMN last_login datetime DEFAULT NULL'); + } // calendar events comments - $this->addSql("ALTER TABLE c_calendar_event ADD COLUMN comment TEXT"); + $fieldExists = false; + $sql = "SELECT * + FROM c_calendar_event + LIMIT 1"; + $result = $connection->executeQuery($sql); + $dataList = $result->fetchAll(); + if (!empty($dataList)) { + foreach ($dataList as $data) { + if (isset($data['comment'])) { + $fieldExists = true; + } + } + } + if (!$fieldExists) { + $this->addSql("ALTER TABLE c_calendar_event ADD COLUMN comment TEXT"); + } // Move some settings from configuration.php to the database // Current settings categories are: diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index bffa10622e..3932eac53c 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -4297,8 +4297,6 @@ function api_get_language_id($language) **/ function api_get_language_from_type($lang_type) { - $_user = api_get_user_info(); - $_course = api_get_course_info(); $return = false; switch ($lang_type) { @@ -4308,6 +4306,7 @@ function api_get_language_from_type($lang_type) $return = $temp_lang; break; case 'user_profil_lang': + $_user = api_get_user_info(); if (isset($_user['language']) && !empty($_user['language'])) $return = $_user['language']; break; @@ -4316,6 +4315,21 @@ function api_get_language_from_type($lang_type) $return = $_SESSION['user_language_choice']; break; case 'course_lang': + global $_course; + $cidReq = null; + if (empty($_course)) { + // Code modified because the local.inc.php file it's declarated after this work + // causing the function api_get_course_info() returns a null value + $cidReq = isset($_GET["cidReq"]) ? Database::escape_string($_GET["cidReq"]) : null; + $cDir = (!empty($_GET['cDir']) ? $_GET['cDir'] : null); + if (empty($cidReq) && !empty($cDir)) { + $c = CourseManager::get_course_id_from_path($cDir); + if ($c) { + $cidReq = $c; + } + } + } + $_course = api_get_course_info($cidReq); if (isset($_course['language']) && !empty($_course['language'])) $return = $_course['language']; break; diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 5ee9eee836..0706c9946f 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -2464,7 +2464,7 @@ class CourseManager if ($access_url_id != -1) { $tbl_url_course = Database:: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $join_access_url = "LEFT JOIN $tbl_url_course url_rel_course - ON url_rel_course.c_id = tcfv.c_id "; + ON url_rel_course.c_id = tcfv.item_id "; $where_access_url = " AND access_url_id = $access_url_id "; } } diff --git a/main/install/install.lib.php b/main/install/install.lib.php index 562bf2752c..9072c129be 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -1101,11 +1101,6 @@ function display_license_agreement() - - -