Browse Source

Removing "log.class.php" using monolog in order to debug code

Julio Montoya 12 years ago
parent
commit
6a4477262c
34 changed files with 524 additions and 929 deletions
  1. 44 60
      main/inc/global.inc.php
  2. 3 3
      main/inc/lib/database.lib.php
  3. 0 222
      main/inc/lib/log.class.php
  4. 0 16
      main/inc/lib/mail.lib.inc.php
  5. 20 10
      main/inc/lib/main_api.lib.php
  6. 10 80
      main/install/db_main.sql
  7. 9 27
      main/install/i_database.class.php
  8. 11 23
      main/install/index.php
  9. 0 16
      main/install/install.class.php
  10. 2 7
      main/install/install.lib.php
  11. 13 8
      main/install/install_db.inc.php
  12. 8 8
      main/install/update-configuration.inc.php
  13. 0 2
      main/install/update-db-1.6.x-1.8.0.inc.php
  14. 2 3
      main/install/update-db-1.8.0-1.8.2.inc.php
  15. 1 3
      main/install/update-db-1.8.2-1.8.3.inc.php
  16. 1 3
      main/install/update-db-1.8.3-1.8.4.inc.php
  17. 2 4
      main/install/update-db-1.8.4-1.8.5.inc.php
  18. 15 15
      main/install/update-db-1.8.5-1.8.6.inc.php
  19. 17 18
      main/install/update-db-1.8.6-1.8.6.1.inc.php
  20. 26 28
      main/install/update-db-1.8.6.1-1.8.6.2.inc.php
  21. 38 39
      main/install/update-db-1.8.6.2-1.8.7.inc.php
  22. 65 67
      main/install/update-db-1.8.7-1.8.8.inc.php
  23. 143 145
      main/install/update-db-1.8.8-1.9.0.inc.php
  24. 4 6
      main/install/update-db-1.9.0-1.10.0.inc.php
  25. 42 43
      main/install/update-db-scorm-1.6.x-1.8.0.inc.php
  26. 11 14
      main/install/update-files-1.6.x-1.8.0.inc.php
  27. 0 2
      main/install/update-files-1.8.3-1.8.4.inc.php
  28. 30 36
      main/install/update-files-1.8.4-1.8.5.inc.php
  29. 4 7
      main/install/update-files-1.8.5-1.8.6.inc.php
  30. 0 2
      main/install/update-files-1.8.6-1.8.6.1.inc.php
  31. 3 6
      main/install/update-files-1.8.6.1-1.8.6.2.inc.php
  32. 0 2
      main/install/update-files-1.8.6.2-1.8.7.inc.php
  33. 0 2
      main/install/update-files-1.8.7-1.8.8.inc.php
  34. 0 2
      main/install/update-files-1.8.8-1.9.0.inc.php

+ 44 - 60
main/inc/global.inc.php

@@ -49,12 +49,13 @@ if (file_exists($main_configuration_file_path)) {
 }
 
 //Redirects to the main/install/ page
+/*
 if (!$already_installed) {
     $global_error_code = 2;
     // The system has not been installed yet.
     require $includePath.'/global_error_message.inc.php';
     die();
-}
+}*/
 
 // Ensure that _configuration is in the global scope before loading
 // main_api.lib.php. This is particularly helpful for unit tests
@@ -117,6 +118,7 @@ use Silex\Application;
 
 $app = new Application();
 $app['configuration_file'] = $main_configuration_file_path;
+$app['conf'] = $_configuration;
 
 //require_once __DIR__.'/../../resources/config/prod.php';
 require_once __DIR__.'/../../resources/config/dev.php';
@@ -187,58 +189,45 @@ $app['twig'] = $app->share($app->extend('twig', function($twig, $app) {
 }));
 
 //Setting Doctrine service provider (DBAL)
-$app->register(new Silex\Provider\DoctrineServiceProvider(), array(
-    'db.options' => array(
-        'driver'    => 'pdo_mysql',
-        'dbname'    => $_configuration['main_database'],
-        'user'      => $_configuration['db_user'],
-        'password'  => $_configuration['db_password'],
-        'host'      => $_configuration['db_host'],
-    )
-));
-
-//Setting Doctrine ORM
-$app->register(new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider, array(
-    "orm.proxies_dir" => $app['db.orm.proxies_dir'],
-    "orm.em.options" => array(
-        "mappings" => array(
-            array(
-                "type" => "annotation",
-                "namespace" => "Entity",
-                "path" => api_get_path(INCLUDE_PATH).'Entity',
-            )
+if (isset($_configuration['main_database'])) {
+
+    $app->register(new Silex\Provider\DoctrineServiceProvider(), array(
+        'db.options' => array(
+            'driver'    => 'pdo_mysql',
+            'dbname'    => $_configuration['main_database'],
+            'user'      => $_configuration['db_user'],
+            'password'  => $_configuration['db_password'],
+            'host'      => $_configuration['db_host'],
+        )
+    ));
+
+
+    //Setting Doctrine ORM
+    $app->register(new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider, array(
+        "orm.proxies_dir" => $app['db.orm.proxies_dir'],
+        "orm.em.options" => array(
+            "mappings" => array(
+                array(
+                    "type" => "annotation",
+                    "namespace" => "Entity",
+                    "path" => api_get_path(INCLUDE_PATH).'Entity',
+                )
+            ),
         ),
-    ),
-));
-
-//Setting Doctrine2 extensions
+    ));
 
-$timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
-$app['db.event_manager']->addEventSubscriber($timestampableListener);
 
-$sluggableListener = new \Gedmo\Sluggable\SluggableListener();
-$app['db.event_manager']->addEventSubscriber($sluggableListener);
+    //Setting Doctrine2 extensions
 
-$sortableListener = new \Gedmo\Sortable\SortableListener();
-$app['db.event_manager']->addEventSubscriber($sortableListener);
+    $timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
+    $app['db.event_manager']->addEventSubscriber($timestampableListener);
 
+    $sluggableListener = new \Gedmo\Sluggable\SluggableListener();
+    $app['db.event_manager']->addEventSubscriber($sluggableListener);
 
-//Testing with another silex service provider
-/*
-// Register Doctrine ORM
-$app->register(new Nutwerk\Provider\DoctrineORMServiceProvider(), array(
-    'db.orm.proxies_dir'           => $app['db.orm.proxies_dir'],
-    'db.orm.proxies_namespace'     => 'DoctrineProxy',
-    'db.orm.cache'                 =>
-        !$app['debug'] && extension_loaded('apc') ? new ApcCache() : new ArrayCache(),
-    'db.orm.auto_generate_proxies' => true,
-    'db.orm.entities'              => array(array(
-        'type'      => 'annotation',       // entity definition
-        'path'      => api_get_path(INCLUDE_PATH).'Entity',
-        'namespace' => 'Entity', // your classes namespace
-    )),
-));*/
-
+    $sortableListener = new \Gedmo\Sortable\SortableListener();
+    $app['db.event_manager']->addEventSubscriber($sortableListener);
+}
 
 //Creating Chamilo service provider
 use Silex\ServiceProviderInterface;
@@ -257,7 +246,7 @@ class ChamiloServiceProvider implements ServiceProviderInterface {
 //Registering Chamilo service provider
 $app->register(new ChamiloServiceProvider(), array());
 
-//Controllers
+//Controllers as services
 $app->register(new Silex\Provider\ServiceControllerServiceProvider());
 
 $app['pages.controller'] = $app->share(function() use ($app) {
@@ -265,11 +254,12 @@ $app['pages.controller'] = $app->share(function() use ($app) {
 });
 
 //Manage error messages
-/*
+
 $app->error(function (\Exception $e, $code) use ($app) {
     if ($app['debug']) {
         //return;
     }
+
     if (isset($code)) {
         switch ($code) {
              case 404:
@@ -289,13 +279,12 @@ $app->error(function (\Exception $e, $code) use ($app) {
     $response = $app['template']->render_layout('error.tpl');
     return new Response($response);
 });
- *
- */
 
 /*
 use Symfony\Component\HttpKernel\Debug\ErrorHandler;
 ErrorHandler::register();
  */
+use Symfony\Component\HttpFoundation\RedirectResponse;
 
 //Filters
 $app->before(function() use ($app) {
@@ -305,7 +294,7 @@ $app->before(function() use ($app) {
     }
 
     if (!file_exists($app['configuration_file'])) {
-        $app->abort(500, "Chamilo has not been installed"); //error 2
+        return new RedirectResponse(api_get_path(WEB_CODE_PATH).'install');
     }
     //$app['request']->getSession()->start();
 });
@@ -349,11 +338,6 @@ require_once $lib_path.'online.inc.php';
 
 /*  DATABASE CONNECTION  */
 
-// @todo: this shouldn't be done here. It should be stored correctly during installation.
-if (empty($_configuration['statistics_database']) && $already_installed) {
-    $_configuration['statistics_database'] = $_configuration['main_database'];
-}
-
 global $database_connection;
 // Connect to the server database and select the main chamilo database.
 if (!($conn_return = @Database::connect(
@@ -363,11 +347,11 @@ if (!($conn_return = @Database::connect(
         'password'      => $_configuration['db_password'],
         'persistent'    => $_configuration['db_persistent_connection'] // When $_configuration['db_persistent_connection'] is set, it is expected to be a boolean type.
     )))) {
-    $app->abort(500, "Database is unavailable"); //error 3
+    //$app->abort(500, "Database is unavailable"); //error 3
 }
 
 if (!$_configuration['db_host']) {
-    $app->abort(500, "Database is unavailable"); //error 3
+    //$app->abort(500, "Database is unavailable"); //error 3
 }
 
 
@@ -393,7 +377,7 @@ if (!empty($_configuration['multiple_access_urls'])) {
 Database::query("set session sql_mode='';");
 
 if (!Database::select_db($_configuration['main_database'], $database_connection)) {
-    $app->abort(500, "Database is unavailable"); //error 3
+    //$app->abort(500, "Database is unavailable"); //error 3
 }
 
 /*   Initialization of the default encodings */

+ 3 - 3
main/inc/lib/database.lib.php

@@ -1003,11 +1003,11 @@ class Database {
      */
     private static function format_table_name($database, $table) {
         global $_configuration;
-        if ($_configuration['single_database']) {
+        /*if ($_configuration['single_database']) {
             $table_name =  '`'.$database.'`.`'.$table.'`';
-        } else {
+        } else {*/
             $table_name =  '`'.$database.$_configuration['db_glue'].$table.'`';
-        }
+        //}
         return $table_name;
     }
 

+ 0 - 222
main/inc/lib/log.class.php

@@ -1,222 +0,0 @@
-<?php
-
-use Monolog\Logger;
-
-/**
- * Since static constructors do not exist in php the line below serves as a 
- * substitute.
- * 
- * Log is used by install which do not use autoload at the moment. If it becomes
- * the case then the line below may/should be moved to the main autoloading 
- * function.
- */
-Log::register_autoload();
-
-/**
- * Provides access to the main log - i.e. stderr - and allows to register events.
- * It is a facade to the monolog library:
- * 
- * Log::error('message');
- * Log::warning('message');
- * ...
- * 
- * 
- * Note:
- * This class uses a static approach which has the benefit of being simpler but do
- * no allow as much freedom as using an object approche. Another approach could be
- * 
- * Chamilo::log()->error('message');
- * Chamilo::log()->warning('message');
- * 
- * To somewhat alleviate this issue the user can register a different logger if hew
- * wants.
- *
- * @license see /license.txt
- * @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
- */
-class Log
-{
-
-    public static function register_autoload()
-    {
-        static $has_run = false;
-        if ($has_run) {
-            return true;
-        }
-
-        $directory = api_get_path(SYS_PATH) . 'vendor';
-        if (!class_exists('Doctrine\Common\ClassLoader', false)) {
-            require_once $directory . '/doctrine/common/lib/Doctrine/Common/ClassLoader.php';
-        }
-
-        $loader = new Doctrine\Common\ClassLoader('Monolog', $directory);
-        $loader->register();
-
-        $has_run = true;
-    }
-
-    /**
-     *
-     * @return \Monolog\Logger 
-     */
-    public static function default_logger()
-    {
-        $name = 'chamilo';
-        $result = new Logger($name);
-        $handler = new Monolog\Handler\StreamHandler('php://stderr');
-        $handler->setFormatter(new Monolog\Formatter\LineFormatter('[%datetime%] [%level_name%] [%channel%] %message%' . PHP_EOL, 'Y-m-d H:i:s')); //%context% %extra%
-        $result->pushHandler($handler);
-        return $result;
-    }
-
-    private static $logger = null;
-
-    /**
-     *
-     * @return \Monolog\Logger 
-     */
-    public static function logger()
-    {
-        if (empty(self::$logger)) {
-            self::$logger = self::default_logger();
-        }
-        return self::$logger;
-    }
-
-    public static function set_logger($value)
-    {
-        self::$logger = $value;
-    }
-
-    /**
-     * Returns the 
-     * @param type $index
-     * @return type 
-     */
-    public static function frame($index)
-    {
-        $result = debug_backtrace();
-        return isset($result[$index]) ? $result[$index] : array();
-    }
-
-    public static function write($level, $message, $context = array())
-    {
-        /*
-         * Note that the same could be done with a monolog processor.
-         */
-        if (!isset($context['file'])) {
-            $trace = debug_backtrace();
-            $trace = $trace[1];
-            $context['file'] = $trace['file'];
-            $context['line'] = $trace['line'];
-        }
-        $file = $context['file'];
-        $root = realpath(api_get_path(SYS_PATH));
-        $file = str_replace($root, '', $file);
-        $file = trim($file, DIRECTORY_SEPARATOR);
-        $line = $context['line'];
-        $line = str_pad($line, 4, ' ', STR_PAD_LEFT);
-        $message = "[$file:$line] " . $message;
-
-        self::logger()->addRecord($level, $message, $context);
-    }
-
-    /**
-     * Adds a log record at the DEBUG level.
-     *
-     * This method allows to have an easy ZF compatibility.
-     *
-     * @param string $message The log message
-     * @param array $context The log context
-     * @return Boolean Whether the record has been processed
-     */
-    public static function debug($message, array $context = array())
-    {
-        return self::write(Logger::DEBUG, $message, $context);
-    }
-
-    /**
-     * Adds a log record at the INFO level.
-     *
-     * This method allows to have an easy ZF compatibility.
-     *
-     * @param string $message The log message
-     * @param array $context The log context
-     * @return Boolean Whether the record has been processed
-     */
-    public static function info($message, array $context = array())
-    {
-        return self::write(Logger::INFO, self::message($message), $context);
-    }
-
-    /**
-     * Adds a log record at the INFO level.
-     *
-     * This method allows to have an easy ZF compatibility.
-     *
-     * @param string $message The log message
-     * @param array $context The log context
-     * @return Boolean Whether the record has been processed
-     */
-    public static function notice($message, array $context = array())
-    {
-        return self::write(Logger::INFO, $message, $context);
-    }
-
-    /**
-     * Adds a log record at the WARNING level.
-     *
-     * This method allows to have an easy ZF compatibility.
-     *
-     * @param string $message The log message
-     * @param array $context The log context
-     * @return Boolean Whether the record has been processed
-     */
-    public static function warning($message, array $context = array())
-    {
-        return self::write(Logger::WARNING, $message, $context);
-    }
-
-    /**
-     * Adds a log record at the ERROR level.
-     *
-     * This method allows to have an easy ZF compatibility.
-     *
-     * @param string $message The log message
-     * @param array $context The log context
-     * @return Boolean Whether the record has been processed
-     */
-    public static function error($message, array $context = array())
-    {
-        return self::write(Logger::ERROR, $message, $context);
-    }
-
-    /**
-     * Adds a log record at the CRITICAL level.
-     *
-     * This method allows to have an easy ZF compatibility.
-     *
-     * @param string $message The log message
-     * @param array $context The log context
-     * @return Boolean Whether the record has been processed
-     */
-    public static function crit($message, array $context = array())
-    {
-        return self::write(Logger::CRITICAL, $message, $context);
-    }
-
-    /**
-     * Adds a log record at the ALERT level.
-     *
-     * This method allows to have an easy ZF compatibility.
-     *
-     * @param string $message The log message
-     * @param array $context The log context
-     * @return Boolean Whether the record has been processed
-     */
-    public static function alert($message, array $context = array())
-    {
-        return self::write(Logger::ALERT, $message, $context);
-    }
-
-}

+ 0 - 16
main/inc/lib/mail.lib.inc.php

@@ -1,16 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
- *
- * @package chamilo.library
- */
-/**
- * Code
- */
-require_once api_get_path(LIBRARY_PATH).'phpmailer/class.phpmailer.php';
-
-
-// A regular expression for testing against valid email addresses.
-// It should actually be revised for using the complete RFC3696 description:
-// http://tools.ietf.org/html/rfc3696#section-3
-//$regexp_rfc3696 = "^[0-9a-z_\.+-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,3})$"; // Deprecated, 13-OCT-2010.

+ 20 - 10
main/inc/lib/main_api.lib.php

@@ -505,10 +505,10 @@ function api_get_path($path_type, $path = null) {
     // Always load root_web modifications for multiple url features
     global $_configuration;
     //default $_configuration['root_web'] configuration
-    $root_web = $_configuration['root_web'];
+    $root_web = isset($_configuration['root_web']) ? $_configuration['root_web'] : null;
 
     // Configuration data for already installed system.
-    $root_sys = $_configuration['root_sys'];
+    $root_sys = isset($_configuration['root_sys']) ? $_configuration['root_sys'] : realpath(dirname(__FILE__).'/../../../');
     $load_new_config = false;
 
     // To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php
@@ -520,20 +520,27 @@ function api_get_path($path_type, $path = null) {
             $load_new_config = true;
         }
     }
-
     if (!$is_this_function_initialized) {
         global $_configuration;
 
-        $root_rel       = $_configuration['url_append'];
-        $code_folder    = $_configuration['code_append'];
-        $course_folder  = $_configuration['course_folder'];
+        $root_rel       = isset($_configuration['url_append']) ? $_configuration['url_append'] : null;
+        //$code_folder    = $_configuration['code_append'];
+        $code_folder    = 'main/';
+        $course_folder  = isset($_configuration['course_folder']) ? $_configuration['course_folder'] : null;
 
         // Support for the installation process.
         // Developers might use the function api_get_path() directly or indirectly (this is difficult to be traced), at the moment when
         // configuration has not been created yet. This is why this function should be upgraded to return correct results in this case.
 
-        if (defined('SYSTEM_INSTALLATION') && SYSTEM_INSTALLATION) {
-            if (($pos = strpos(($requested_page_rel = api_get_self()), 'main/install')) !== false) {
+        //if (defined('SYSTEM_INSTALLATION') && SYSTEM_INSTALLATION) {
+        if (empty($root_web)) {
+            $pos = strpos(($requested_page_rel = api_get_self()), 'index.php');
+            $pos_install = strpos(($requested_page_rel = api_get_self()), 'main/install');
+
+            if ($pos_install) {
+                $pos = $pos_install;
+            }
+            //if (() !== false) {
                 $root_rel = substr($requested_page_rel, 0, $pos);
                 // See http://www.mediawiki.org/wiki/Manual:$wgServer
                 $server_protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
@@ -552,15 +559,18 @@ function api_get_path($path_type, $path = null) {
                 $root_sys = str_replace('\\', '/', realpath(dirname(__FILE__).'/../../../')).'/';
                 $code_folder = 'main/';
                 $course_folder = 'courses/';
-            }
+            //}
             // Here we give up, so we don't touch anything.
         }
 
         // Dealing with trailing slashes.
         $root_web       = api_add_trailing_slash($root_web);
+
         $root_sys       = api_add_trailing_slash($root_sys);
+
         $root_rel       = api_add_trailing_slash($root_rel);
         $code_folder    = api_add_trailing_slash($code_folder);
+
         $course_folder  = api_add_trailing_slash($course_folder);
 
         // Web server base and system server base.
@@ -578,6 +588,7 @@ function api_get_path($path_type, $path = null) {
         $paths[REL_COURSE_PATH]         = $root_rel.$course_folder;
         $paths[REL_CODE_PATH]           = $root_rel.$code_folder;
         $paths[WEB_CODE_PATH]           = $root_web.$code_folder;
+
         $paths[SYS_CODE_PATH]           = $root_sys.$code_folder;
 
         // Now we can switch into api_get_path() "terminology".
@@ -6618,7 +6629,6 @@ function api_mail_html($recipient_name, $recipient_email, $subject, $body, $send
         $reply_to_mail = $extra_headers['reply_to']['mail'];
         $reply_to_name = $extra_headers['reply_to']['name'];
     }
-    //var_dump(array($reply_to_mail => $reply_to_name));
     try {
         $message = \Swift_Message::newInstance()
             ->setSubject($subject)

+ 10 - 80
main/install/db_main.sql

@@ -13,11 +13,6 @@
 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
 
-
---
--- Table structure for table user
---
-
 DROP TABLE IF EXISTS user;
 CREATE TABLE IF NOT EXISTS user (
   user_id int unsigned NOT NULL auto_increment,
@@ -52,9 +47,6 @@ CREATE TABLE IF NOT EXISTS user (
 );
 ALTER TABLE user ADD INDEX (status);
 
---
--- Dumping data for table user
---
 
 /*!40000 ALTER TABLE user DISABLE KEYS */;
 LOCK TABLES user WRITE;
@@ -165,11 +157,11 @@ CREATE TABLE IF NOT EXISTS course (
 );
 ALTER TABLE course ADD INDEX idx_course_category_code (category_code);
 ALTER TABLE course ADD INDEX idx_course_directory (directory(10));
+
 --
 -- Dumping data for table course
 --
 
-
 /*!40000 ALTER TABLE course DISABLE KEYS */;
 LOCK TABLES course WRITE;
 UNLOCK TABLES;
@@ -489,8 +481,6 @@ CREATE TABLE IF NOT EXISTS session (
 ALTER TABLE session ADD INDEX idx_id_coach (id_coach);
 ALTER TABLE session ADD INDEX idx_id_session_admin_id (session_admin_id);
 
--- --------------------------------------------------------
-
 --
 -- Table structure for table session_rel_course
 --
@@ -505,7 +495,7 @@ CREATE TABLE IF NOT EXISTS session_rel_course (
 
 ALTER TABLE session_rel_course ADD INDEX idx_session_rel_course_course_id (course_id);
 
--- --------------------------------------------------------
+
 
 --
 -- Table structure for table session_rel_course_rel_user
@@ -525,7 +515,7 @@ CREATE TABLE IF NOT EXISTS session_rel_course_rel_user (
 ALTER TABLE session_rel_course_rel_user ADD INDEX idx_session_rel_course_rel_user_id_user (id_user);
 ALTER TABLE session_rel_course_rel_user ADD INDEX idx_session_rel_course_rel_user_course_id (course_id);
 
--- --------------------------------------------------------
+
 
 --
 -- Table structure for table session_rel_user
@@ -1315,11 +1305,6 @@ CREATE TABLE IF NOT EXISTS shared_survey (
   UNIQUE KEY id (survey_id)
 );
 
--- --------------------------------------------------------
-
---
--- Table structure for shared_survey_question
---
 
 DROP TABLE IF EXISTS shared_survey_question;
 CREATE TABLE IF NOT EXISTS shared_survey_question (
@@ -1335,11 +1320,6 @@ CREATE TABLE IF NOT EXISTS shared_survey_question (
   PRIMARY KEY  (question_id)
 );
 
--- --------------------------------------------------------
-
---
--- Table structure for shared_survey_question_option
---
 
 DROP TABLE IF EXISTS shared_survey_question_option;
 CREATE TABLE IF NOT EXISTS shared_survey_question_option (
@@ -1352,12 +1332,6 @@ CREATE TABLE IF NOT EXISTS shared_survey_question_option (
 );
 
 
--- --------------------------------------------------------
-
---
--- Table structure for templates (User's FCKEditor templates)
---
-
 DROP TABLE IF EXISTS templates;
 CREATE TABLE IF NOT EXISTS templates (
   id int NOT NULL auto_increment,
@@ -1370,16 +1344,6 @@ CREATE TABLE IF NOT EXISTS templates (
   PRIMARY KEY  (id)
 );
 
-
-
---
-
--- --------------------------------------------------------
-
---
--- Table structure of openid_association (keep info on openid servers)
---
-
 DROP TABLE IF EXISTS openid_association;
 CREATE TABLE IF NOT EXISTS openid_association (
   id int NOT NULL auto_increment,
@@ -1392,11 +1356,8 @@ CREATE TABLE IF NOT EXISTS openid_association (
   created bigint NOT NULL,
   PRIMARY KEY  (id)
 );
---
--- --------------------------------------------------------
---
--- Tables for gradebook
---
+
+
 DROP TABLE IF EXISTS gradebook_category;
 CREATE TABLE IF NOT EXISTS gradebook_category (
     id int NOT NULL auto_increment,
@@ -1570,12 +1531,6 @@ CREATE TABLE IF NOT EXISTS gradebook_linkeval_log (
     PRIMARY KEY  (id)
 );
 
---
--- --------------------------------------------------------
---
--- Tables for the access URL feature
---
-
 DROP TABLE IF EXISTS access_url;
 CREATE TABLE IF NOT EXISTS access_url(
     id	int	unsigned NOT NULL auto_increment,
@@ -2409,18 +2364,6 @@ INSERT INTO system_template (title, comment, image, content) VALUES
             </body>
 ');
 
-
---
--- --------------------------------------------------------
---
--- Tables for reservation
---
-
-
---
--- Table structure for table reservation category
---
-
 DROP TABLE IF EXISTS reservation_category;
 CREATE TABLE IF NOT EXISTS reservation_category (
    id  int unsigned NOT NULL auto_increment,
@@ -2429,10 +2372,6 @@ CREATE TABLE IF NOT EXISTS reservation_category (
   PRIMARY KEY  ( id )
 );
 
---
--- Table structure for table reservation category_rights
---
-
 DROP TABLE IF EXISTS reservation_category_rights;
 CREATE TABLE IF NOT EXISTS reservation_category_rights  (
     id  int unsigned NOT NULL auto_increment,
@@ -2442,9 +2381,6 @@ CREATE TABLE IF NOT EXISTS reservation_category_rights  (
     PRIMARY KEY  ( id )
 );
 
---
--- Table structure for table  item reservation
---
 DROP TABLE IF EXISTS reservation_item;
 CREATE TABLE IF NOT EXISTS  reservation_item  (
    id  int unsigned NOT NULL auto_increment,
@@ -2458,7 +2394,7 @@ CREATE TABLE IF NOT EXISTS  reservation_item  (
   PRIMARY KEY  ( id )
 );
 
--- --------------------------------------------------------
+
 
 --
 -- Table structure for table reservation item_rights
@@ -2475,7 +2411,7 @@ CREATE TABLE IF NOT EXISTS  reservation_item_rights  (
   PRIMARY KEY  ( item_id , class_id )
 );
 
--- --------------------------------------------------------
+
 
 --
 -- Table structure for main reservation table
@@ -2500,8 +2436,6 @@ CREATE TABLE IF NOT EXISTS  reservation_main  (
   PRIMARY KEY  ( id )
 );
 
--- --------------------------------------------------------
-
 --
 -- Table structure for reservation subscription table
 --
@@ -2517,8 +2451,6 @@ CREATE TABLE IF NOT EXISTS  reservation_subscription  (
   PRIMARY KEY  ( dummy )
 );
 
--- ---------------------------------------------------------
-
 --
 -- Table structure for table user_rel_user
 --
@@ -2566,15 +2498,15 @@ CREATE TABLE IF NOT EXISTS user_api_key (
 );
 ALTER TABLE user_api_key ADD INDEX idx_user_api_keys_user (user_id);
 
---
 -- Table structure for table message
---
+-- status: 0 read, 1 unread, 3 deleted, 5 pending invitation, 6 accepted invitation, 7 invitation denied
+
 DROP TABLE IF EXISTS message;
 CREATE TABLE IF NOT EXISTS message(
     id bigint unsigned not null auto_increment,
     user_sender_id int unsigned not null,
     user_receiver_id int unsigned not null,
-    msg_status tinyint unsigned not null default 0, -- 0 read, 1 unread, 3 deleted, 5 pending invitation, 6 accepted invitation, 7 invitation denied
+    msg_status tinyint unsigned not null default 0,
     send_date datetime not null default '0000-00-00 00:00:00',
     title varchar(255) not null,
     content text not null,
@@ -2632,8 +2564,6 @@ ALTER TABLE gradebook_certificate ADD INDEX idx_gradebook_certificate_category_i
 ALTER TABLE gradebook_certificate ADD INDEX idx_gradebook_certificate_user_id(user_id);
 ALTER TABLE gradebook_certificate ADD INDEX idx_gradebook_certificate_category_id_user_id(cat_id,user_id);
 
-
-
 --
 -- Tables structure for search tool
 --

+ 9 - 27
main/install/i_database.class.php

@@ -1,8 +1,8 @@
 <?php
 
 /**
- * Install database. Provides access to the Database class and allows to add 
- * hooks for logging, testing, etc during installation. 
+ * Install database. Provides access to the Database class and allows to add
+ * hooks for logging, testing, etc during installation.
  *
  * @license see /license.txt
  * @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
@@ -24,19 +24,21 @@ class iDatabase extends Database
 
     static function select_db($database_name, $connection = null)
     {
+        global $app;
         if (self::is_logging()) {
-            Log::notice(__FUNCTION__ . ' ' . $database_name, Log::frame(1));
+            $app['monolog']->addInfo(__FUNCTION__ . ' ' . $database_name);
         }
         return parent::select_db($database_name, $connection);
     }
 
     static function query($query, $connection = null, $file = null, $line = null)
     {
+        global $app;
+
         if (self::is_logging()) {
-            $query = str_replace("\n", '', $query);
-            Log::notice(__FUNCTION__ . ' ' . $query, Log::frame(1));
+            //$query = str_replace("\n", '', $query);
+            //$app['monolog']->addInfo(__FUNCTION__ . ' ' . $query);
         }
-
         $result = parent::query($query, $connection, $file, $line);
 
         if (empty($result)) {
@@ -45,29 +47,9 @@ class iDatabase extends Database
             $file = $caller['file'];
             $line = $caller['line'];
             $message = " sql: $query \n file: $file \n line:$line";
-            Log::error($message);
+            $app['monolog']->addError($message);
         }
         return $result;
     }
-
-    /**
-     * Returns true if the table exists in the database, false otherwise.
-     * @param string $database
-     * @param string table
-     * @return boolean 
-     */
-    static
-
-    function table_exists($database, $table)
-    {
-        $tables = mysql_list_tables($db);
-        while (list ($temp) = mysql_fetch_array($tables)) {
-            if (strtolower($temp) == strtolower($table)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
 }
 

+ 11 - 23
main/install/index.php

@@ -25,23 +25,9 @@ define('FORM_FIELD_DISPLAY_LENGTH',             40);
 define('DATABASE_FORM_FIELD_DISPLAY_LENGTH',    25);
 define('MAX_FORM_FIELD_LENGTH',                 80);
 
-/*		PHP VERSION CHECK */
-
-// Including necessary libraries.
-require_once '../inc/lib/main_api.lib.php';
-
-api_check_php_version('../inc/');
-
-/*		INITIALIZATION SECTION */
-
-ob_implicit_flush(true);
-session_start();
-
-//Composer autoloader
-require_once __DIR__.'../../../vendor/autoload.php';
+require_once '../inc/global.inc.php';
 
 require_once 'install.lib.php';
-require_once 'install.class.php';
 require_once 'i_database.class.php';
 
 // This value is use in database::query in order to prompt errors in the error log (course databases)
@@ -126,13 +112,13 @@ if (!empty($_POST['old_version'])) {
 
 require_once __DIR__.'/version.php';
 
+
 // A protection measure for already installed systems.
 
 if (is_already_installed_system()) {
 	// The system has already been installed, so block re-installation.
-	$global_error_code = 6;
-	require '../inc/global_error_message.inc.php';
-	die();
+    header("Location: ".api_get_path(WEB_PATH));
+    exit;
 }
 
 /*		STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */
@@ -740,12 +726,13 @@ if (@$_POST['step2']) {
           <div id="pleasewait" class="warning-message">'.get_lang('PleaseWaitThisCouldTakeAWhile').'</div>
           </div>';
 
-
     // Push the web server to send these strings before we start the real
     // installation process
     flush();
     ob_flush();
 
+    $app['monolog']->addInfo("installType: $installType");
+
 	if ($installType == 'update') {
 
 		require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
@@ -762,8 +749,7 @@ if (@$_POST['step2']) {
 		if (empty($my_old_version)) { $my_old_version = '1.8.6.2'; } //we guess
 
 		$_configuration['main_database'] = $dbNameForm;
-		//$urlAppendPath = get_config_param('urlAppend');
-        Log::notice('Starting migration process from old version: '.$my_old_version.' ('.time().')');
+        $app['monolog']->addInfo('Starting migration process from old version: '.$my_old_version.' ('.time().')');
 
         if (isset($userPasswordCrypted)) {
             if ($userPasswordCrypted == '1') {
@@ -780,7 +766,7 @@ if (@$_POST['step2']) {
             $singleDbForm   	= isset($_configuration['single_database']) ? $_configuration['single_database'] : false;
         }
 
-        Log::notice("singledbForm: '$singleDbForm'");
+        $app['monolog']->addInfo("singledbForm: '$singleDbForm'");
 
 		Database::query("SET storage_engine = MYISAM;");
 
@@ -791,6 +777,8 @@ if (@$_POST['step2']) {
 			Database::query("SET NAMES 'utf8';");
 		}
 
+        $app['monolog']->addInfo("my_old_version $my_old_version");
+
 		switch ($my_old_version) {
 			case '1.6':
 			case '1.6.0':
@@ -892,4 +880,4 @@ if (@$_POST['step2']) {
 </div><!-- wrapper end-->
 <footer></footer>
 </body>
-</html>
+</html>

+ 0 - 16
main/install/install.class.php

@@ -1,16 +0,0 @@
-<?php
-
-/**
- * Description of install
- *
- * @license see /license.txt
- * @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
- */
-class Install
-{
-    static function message($message)
-    {
-        echo '<div>' . $message . '</div>';
-    }
-
-}

+ 2 - 7
main/install/install.lib.php

@@ -717,11 +717,11 @@ function parse_sql_queries($sql_text) {
 
         //UTF8 fix see #5678
         if (strpos(strtolower($this_sql_query), 'create table') === false) {
-            Database::query($this_sql_query);
+            iDatabase::query($this_sql_query);
         } else {
             //$this_sql_query .= substr($this_sql_query, strlen($this_sql_query), strlen($this_sql_query)-1);
             $this_sql_query .= ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ';
-            Database::query($this_sql_query);
+            iDatabase::query($this_sql_query);
         }
     }
 }
@@ -2134,9 +2134,6 @@ function compare_setting_values($current_value, $wanted_value) {
 }
 
 
-
-
-
 /* Executed only before create_course_tables() */
 function drop_course_tables() {
     $list = CourseManager::get_course_tables();
@@ -2146,8 +2143,6 @@ function drop_course_tables() {
     }
 }
 
-
-
 /**
  * Creates all the necessary tables for a new course
  */

+ 13 - 8
main/install/install_db.inc.php

@@ -66,21 +66,21 @@ if (empty($mysqlUserDb) || $mysqlUserDb == 'mysql' || $mysqlUserDb == $dbPrefixF
 if (!defined('CLI_INSTALLATION')) {
 
 	$result = Database::query("SHOW VARIABLES LIKE 'datadir'") or die(Database::error());
-	
+
 	$mysqlRepositorySys = Database::fetch_array($result);
 	$mysqlRepositorySys = $mysqlRepositorySys['Value'];
-	
+
 	$create_database = true;
-    
+
 	if (database_exists($mysqlMainDb)) {
         $create_database = false;
-    }	
+    }
 	//Create database
 	if ($create_database) {
         $charset_clause = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci';
-		$sql = "CREATE DATABASE IF NOT EXISTS `$mysqlMainDb` $charset_clause";   
+		$sql = "CREATE DATABASE IF NOT EXISTS `$mysqlMainDb` $charset_clause";
 		Database::query($sql) or die(Database::error());
-	}	
+	}
 }
 
 $mysqlStatsDb = $mysqlMainDb;
@@ -95,7 +95,7 @@ if (!defined('CLI_INSTALLATION')) {
 	}
 }
 
-Database::select_db($mysqlMainDb) or die(Database::error());
+iDatabase::select_db($mysqlMainDb) or die(Database::error());
 
 $installation_settings = array();
 $installation_settings['{ORGANISATIONNAME}']                = $institutionForm;
@@ -116,18 +116,23 @@ $installation_settings['{HASHFUNCTIONMODE}']                = $encryptPassForm;
 
 load_main_database($installation_settings);
 
-
+$app['monolog']->addInfo("drop_course_tables");
 drop_course_tables();
 
+$app['monolog']->addInfo("create_course_tables");
 create_course_tables();
 
+$app['monolog']->addInfo("loading db_stats.sql");
 load_database_script('db_stats.sql');
 
 $track_countries_table = "track_c_countries";
+
+$app['monolog']->addInfo("fill_track_countries_table");
 fill_track_countries_table($track_countries_table);
 
 load_database_script('db_user.sql');
 
+$app['monolog']->addInfo("locking_settings");
 locking_settings();
 
 update_dir_and_files_permissions();

+ 8 - 8
main/install/update-configuration.inc.php

@@ -2,20 +2,20 @@
 
 /* For licensing terms, see /license.txt */
 /**
- * 
+ *
  * Chamilo LMS
- * 
- * Only updates the  main/inc/conf/configuration.php  file with the new version use only from 1.8.8.1 to 1.8.8.2 (with no DB changes) 
+ *
+ * Only updates the  main/inc/conf/configuration.php  file with the new version use only from 1.8.8.1 to 1.8.8.2 (with no DB changes)
  * @package chamilo.install
  */
 if (defined('SYSTEM_INSTALLATION')) {
 
-    Log::notice("Starting " . basename(__FILE__));
+    $app['monolog']->addInfo("Starting " . basename(__FILE__));
 
     // Edit the configuration file
     $file   = file(api_get_path(CONFIGURATION_PATH) . 'configuration.php');
     $fh     = fopen(api_get_path(CONFIGURATION_PATH) . 'configuration.php', 'w');
-    
+
     $found_version_old      = false;
     $found_stable_old       = false;
     $found_version          = false;
@@ -47,7 +47,7 @@ if (defined('SYSTEM_INSTALLATION')) {
             $line = '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n";
         } elseif (stripos($line, '$userPasswordCrypted') !== false) {
             //$line = '$userPasswordCrypted = \'' . ($userPasswordCrypted) . '\';' . "\r\n";
-            $line = '$_configuration[\'password_encryption\'] = \'' .$userPasswordCrypted.'\';' . "\r\n";            
+            $line = '$_configuration[\'password_encryption\'] = \'' .$userPasswordCrypted.'\';' . "\r\n";
         } elseif (stripos($line, '?>') !== false) {
             $ignore = true;
         }
@@ -55,7 +55,7 @@ if (defined('SYSTEM_INSTALLATION')) {
             fwrite($fh, $line);
         }
     }
-    
+
     if (!$found_version) {
         fwrite($fh, '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n");
     }
@@ -67,7 +67,7 @@ if (defined('SYSTEM_INSTALLATION')) {
     }
     if (!$found_software_url) {
         fwrite($fh, '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n");
-    }    
+    }
     fwrite($fh, '?>');
     fclose($fh);
 } else {

+ 0 - 2
main/install/update-db-1.6.x-1.8.0.inc.php

@@ -18,8 +18,6 @@
  * @todo use database library
  */
 
-Log::notice('Entering file');
-
 // Check if we come from index.php or update_courses.php - otherwise display error msg
 if (defined('SYSTEM_INSTALLATION')) {
 

+ 2 - 3
main/install/update-db-1.8.0-1.8.2.inc.php

@@ -17,7 +17,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
 
 // Check if we come from index.php or update_courses.php - otherwise display error msg
 if (defined('SYSTEM_INSTALLATION')) {
@@ -185,8 +184,8 @@ if (defined('SYSTEM_INSTALLATION')) {
                      */
                     if (!$singleDbForm) { // otherwise just use the main one
                         Database::select_db($row_course['db_name']);
-                    }                
-                    Log::notice('Course db ' . $row_course['db_name']);
+                    }
+                    $app['monolog']->addInfo('Course db ' . $row_course['db_name']);
 
                     foreach ($c_q_list as $query) {
                         if ($singleDbForm) {

+ 1 - 3
main/install/update-db-1.8.2-1.8.3.inc.php

@@ -16,7 +16,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
 
 // Check if we come from index.php or update_courses.php - otherwise display error msg
 if (defined('SYSTEM_INSTALLATION')) {
@@ -184,8 +183,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 					if (!$singleDbForm) { //otherwise just use the main one
 						Database::select_db($row_course['db_name']);
 					}
-                    Log::notice('Course db ' . $row_course['db_name']);
-
+                    
 					foreach ($c_q_list as $query) {
 						if ($singleDbForm) { //otherwise just use the main one
 							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query);

+ 1 - 3
main/install/update-db-1.8.3-1.8.4.inc.php

@@ -16,7 +16,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
 
 // Check if we come from index.php or update_courses.php - otherwise display error msg
 if (defined('SYSTEM_INSTALLATION')) {
@@ -184,8 +183,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 					if (!$singleDbForm) { //otherwise just use the main one
 						Database::select_db($row_course['db_name']);
 					}
-                    Log::notice('Course db ' . $row_course['db_name']);
-
+                    
 					foreach ($c_q_list as $query) {
 						if ($singleDbForm) {
 							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query);

+ 2 - 4
main/install/update-db-1.8.4-1.8.5.inc.php

@@ -16,8 +16,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
-
 $old_file_version = '1.8.4';
 $new_file_version = '1.8.5';
 
@@ -30,7 +28,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 								'.get_lang('PleasGoBackToStep1').'.
 							    <p><button type="submit" class="back" name="step1" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
 							    </td></tr></table></form></body></html>';
-		exit ();
+		exit();
 	}
 
 	$_configuration['db_glue'] = get_config_param('dbGlu');
@@ -191,7 +189,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 					if (!$singleDbForm) { //otherwise just use the main one
 						Database::select_db($row_course['db_name']);
 					}
-                    Log::notice('Course db ' . $row_course['db_name']);
+                    $app['monolog']->addInfo('Course db ' . $row_course['db_name']);
 
 					foreach ($c_q_list as $query) {
 						if ($singleDbForm) {

+ 15 - 15
main/install/update-db-1.8.5-1.8.6.inc.php

@@ -17,7 +17,7 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
+$app['monolog']->addInfo('Entering file');
 
 $old_file_version = '1.8.5';
 $new_file_version = '1.8.6';
@@ -84,18 +84,18 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbNameForm) > 40) {
-                Log::error('Database name ' . $dbNameForm . ' is too long, skipping');
+                $app['monolog']->addError('Database name ' . $dbNameForm . ' is too long, skipping');
             } elseif (!in_array($dbNameForm, $dblist)) {
-                Log::error('Database ' . $dbNameForm . ' was not found, skipping');
+                $app['monolog']->addError('Database ' . $dbNameForm . ' was not found, skipping');
             } else {
                 iDatabase::select_db($dbNameForm);
                 foreach ($m_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("iDatabase::query($dbNameForm,$query)");
+                        $app['monolog']->addInfo("iDatabase::query($dbNameForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($log) {
-                            Log::notice("In $dbNameForm, executed: $query");
+                            $app['monolog']->addInfo("In $dbNameForm, executed: $query");
                         }
                     }
                 }
@@ -103,7 +103,7 @@ if (defined('SYSTEM_INSTALLATION')) {
         }
 
         require_once '../inc/lib/image.lib.php'; //this library has been created
-        // in 1.8.8, which makes this inclusion retroactively necessary in 
+        // in 1.8.8, which makes this inclusion retroactively necessary in
         // updates from 1.8.5
         // Filling the access_url_rel_user table with access_url_id by default = 1
         $query = "SELECT user_id FROM $dbNameForm.user";
@@ -1023,18 +1023,18 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbStatsForm) > 40) {
-                Log::error('Database name ' . $dbStatsForm . ' is too long, skipping');
+                $app['monolog']->addError('Database name ' . $dbStatsForm . ' is too long, skipping');
             } elseif (!in_array($dbStatsForm, $dblist)) {
-                Log::error('Database ' . $dbStatsForm . ' was not found, skipping');
+                $app['monolog']->addError('Database ' . $dbStatsForm . ' was not found, skipping');
             } else {
                 iDatabase::select_db($dbStatsForm);
                 foreach ($s_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("iDatabase::query($dbStatsForm,$query)");
+                        $app['monolog']->addInfo("iDatabase::query($dbStatsForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($log) {
-                            Log::notice("In $dbStatsForm, executed: $query");
+                            $app['monolog']->addInfo("In $dbStatsForm, executed: $query");
                         }
                     }
                 }
@@ -1049,9 +1049,9 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbUserForm) > 40) {
-                Log::error('Database name ' . $dbUserForm . ' is too long, skipping');
+                $app['monolog']->addError('Database name ' . $dbUserForm . ' is too long, skipping');
             } elseif (!in_array($dbUserForm, $dblist)) {
-                Log::error('Database ' . $dbUserForm . ' was not found, skipping');
+                $app['monolog']->addError('Database ' . $dbUserForm . ' was not found, skipping');
             } else {
                 iDatabase::select_db($dbUserForm);
                 foreach ($u_q_list as $query) {
@@ -1105,7 +1105,7 @@ if (defined('SYSTEM_INSTALLATION')) {
                     if (!$singleDbForm) { //otherwise just use the main one
                         iDatabase::select_db($row_course['db_name']);
                     }
-                    Log::notice('Course db ' . $row_course['db_name']);
+                    $app['monolog']->addInfo('Course db ' . $row_course['db_name']);
 
                     foreach ($c_q_list as $query) {
                         if ($singleDbForm) { //otherwise just use the main one
@@ -1113,11 +1113,11 @@ if (defined('SYSTEM_INSTALLATION')) {
                         }
 
                         if ($only_test) {
-                            Log::notice("iDatabase::query(" . $row_course['db_name'] . ",$query)");
+                            $app['monolog']->addInfo("iDatabase::query(" . $row_course['db_name'] . ",$query)");
                         } else {
                             $res = iDatabase::query($query);
                             if ($log) {
-                                Log::notice("In " . $row_course['db_name'] . ", executed: $query");
+                                $app['monolog']->addInfo("In " . $row_course['db_name'] . ", executed: $query");
                             }
                         }
                     }

+ 17 - 18
main/install/update-db-1.8.6-1.8.6.1.inc.php

@@ -16,7 +16,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
 
 $old_file_version = '1.8.6';
 $new_file_version = '1.8.6.1';
@@ -83,18 +82,18 @@ if (defined('SYSTEM_INSTALLATION')) {
 			 * without a database name
 			 */
 			if (strlen($dbNameForm) > 40) {
-				 Log::error('Database name '.$dbNameForm.' is too long, skipping');
+				 $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
 			} elseif (!in_array($dbNameForm,$dblist)) {
-				 Log::error('Database '.$dbNameForm.' was not found, skipping');
+				 $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
 			} else {
 				iDatabase::select_db($dbNameForm);
 				foreach($m_q_list as $query) {
 					if ($only_test){
-						 Log::notice("iDatabase::query($dbNameForm,$query)");
+						 $app['monolog']->addInfo("iDatabase::query($dbNameForm,$query)");
 					} else {
 						$res = iDatabase::query($query);
 						if ($log) {
-							 Log::notice("In $dbNameForm, executed: $query");
+							 $app['monolog']->addInfo("In $dbNameForm, executed: $query");
 						}
 					}
 				}
@@ -112,18 +111,18 @@ if (defined('SYSTEM_INSTALLATION')) {
 			 * without a database name
 			 */
 			if (strlen($dbStatsForm) > 40) {
-				 Log::error('Database name '.$dbStatsForm.' is too long, skipping');
+				 $app['monolog']->addError('Database name '.$dbStatsForm.' is too long, skipping');
 			} elseif (!in_array($dbStatsForm,$dblist)) {
-				 Log::error('Database '.$dbStatsForm.' was not found, skipping');
+				 $app['monolog']->addError('Database '.$dbStatsForm.' was not found, skipping');
 			} else {
 				iDatabase::select_db($dbStatsForm);
 				foreach ($s_q_list as $query) {
 					if ($only_test) {
-						 Log::notice("iDatabase::query($dbStatsForm,$query)");
+						 $app['monolog']->addInfo("iDatabase::query($dbStatsForm,$query)");
 					} else {
 						$res = iDatabase::query($query);
 						if ($log) {
-							 Log::notice("In $dbStatsForm, executed: $query");
+							 $app['monolog']->addInfo("In $dbStatsForm, executed: $query");
 						}
 					}
 				}
@@ -138,15 +137,15 @@ if (defined('SYSTEM_INSTALLATION')) {
 			 * without a database name
 			 */
 			if (strlen($dbUserForm) > 40) {
-				 Log::error('Database name '.$dbUserForm.' is too long, skipping');
+				 $app['monolog']->addError('Database name '.$dbUserForm.' is too long, skipping');
 			} elseif (!in_array($dbUserForm, $dblist)) {
-				 Log::error('Database '.$dbUserForm.' was not found, skipping');
+				 $app['monolog']->addError('Database '.$dbUserForm.' was not found, skipping');
 			} else {
 				iDatabase::select_db($dbUserForm);
 				foreach ($u_q_list as $query) {
 					if ($only_test) {
-						 Log::notice("iDatabase::query($dbUserForm,$query)");
-						 Log::notice("In $dbUserForm, executed: $query");
+						 $app['monolog']->addInfo("iDatabase::query($dbUserForm,$query)");
+						 $app['monolog']->addInfo("In $dbUserForm, executed: $query");
 					} else {
 						$res = iDatabase::query($query);
 					}
@@ -167,9 +166,9 @@ if (defined('SYSTEM_INSTALLATION')) {
 	if (count($c_q_list) > 0) {
 		// Get the courses list
 		if (strlen($dbNameForm) > 40) {
-			 Log::error('Database name '.$dbNameForm.' is too long, skipping');
+			 $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
 		} elseif (!in_array($dbNameForm, $dblist)) {
-			 Log::error('Database '.$dbNameForm.' was not found, skipping');
+			 $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
 		} else {
 			iDatabase::select_db($dbNameForm);
 			$res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
@@ -192,7 +191,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 					if (!$singleDbForm) { //otherwise just use the main one
 						iDatabase::select_db($row_course['db_name']);
 					}
-                    Log::notice('Course db ' . $row_course['db_name']);
+                    $app['monolog']->addInfo('Course db ' . $row_course['db_name']);
 
 					foreach ($c_q_list as $query) {
 						if ($singleDbForm) {
@@ -200,11 +199,11 @@ if (defined('SYSTEM_INSTALLATION')) {
 						}
 
 						if ($only_test) {
-							 Log::notice("iDatabase::query(".$row_course['db_name'].",$query)");
+							 $app['monolog']->addInfo("iDatabase::query(".$row_course['db_name'].",$query)");
 						} else {
 							$res = iDatabase::query($query);
 							if ($log) {
-								 Log::notice("In ".$row_course['db_name'].", executed: $query");
+								 $app['monolog']->addInfo("In ".$row_course['db_name'].", executed: $query");
 							}
 						}
 					}

+ 26 - 28
main/install/update-db-1.8.6.1-1.8.6.2.inc.php

@@ -16,8 +16,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
-
 $old_file_version = '1.8.6.1';
 $new_file_version = '1.8.6.2';
 
@@ -83,18 +81,18 @@ if (defined('SYSTEM_INSTALLATION')) {
 			 * without a database name
 			 */
 			if (strlen($dbNameForm) > 40) {
-				 Log::error('Database name '.$dbNameForm.' is too long, skipping');
+				 $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
 			} elseif (!in_array($dbNameForm,$dblist)) {
-				 Log::error('Database '.$dbNameForm.' was not found, skipping');
+				 $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
 			} else {
 				iDatabase::select_db($dbNameForm);
 				foreach ($m_q_list as $query) {
 					if ($only_test) {
-						 Log::notice("iDatabase::query($dbNameForm,$query)");
+						 $app['monolog']->addInfo("iDatabase::query($dbNameForm,$query)");
 					} else {
 						$res = iDatabase::query($query);
 						if ($log) {
-							 Log::notice("In $dbNameForm, executed: $query");
+							 $app['monolog']->addInfo("In $dbNameForm, executed: $query");
 						}
 					}
 				}
@@ -113,7 +111,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 				$res = iDatabase::query($sql);
 
 				if ($res === false) {
-				     Log::error('Could not query session course coaches table: '.iDatabase::error());
+				     $app['monolog']->addError('Could not query session course coaches table: '.iDatabase::error());
 				} else {
 					// For each coach found, add him as a course coach in the
 					// session_rel_course_rel_user table
@@ -135,7 +133,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 						$rs_coachs = iDatabase::query($sql_ins);
 
 						if ($rs_coachs === false) {
-							 Log::error('Could not move course coach to new table: '.iDatabase::error());
+							 $app['monolog']->addError('Could not move course coach to new table: '.iDatabase::error());
 						}
 
 					}
@@ -147,7 +145,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 				$rs_chk_id1 = iDatabase::query($sql);
 
 				if ($rs_chk_id1 === false) {
-				     Log::error('Could not query settings_current ids table: '.iDatabase::error());
+				     $app['monolog']->addError('Could not query settings_current ids table: '.iDatabase::error());
 				} else {
 					$i = 1;
 					while ($row_id1 = iDatabase::fetch_array($rs_chk_id1)) {
@@ -164,7 +162,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 				$rs_chk_id2 = iDatabase::query($sql);
 
 				if ($rs_chk_id2 === false) {
-				     Log::error('Could not query settings_current ids table: '.iDatabase::error());
+				     $app['monolog']->addError('Could not query settings_current ids table: '.iDatabase::error());
 				} else {
 					$i = 1;
 					while ($row_id2 = iDatabase::fetch_array($rs_chk_id2)) {
@@ -188,18 +186,18 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbNameForm) > 40) {
-                 Log::error('Database name '.$dbNameForm.' is too long, skipping');
+                 $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
             } elseif (!in_array($dbNameForm,$dblist)) {
-                 Log::error('Database '.$dbNameForm.' was not found, skipping');
+                 $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
             } else {
                 iDatabase::select_db($dbNameForm);
                 foreach ($m_q_list as $query) {
                     if ($only_test) {
-                         Log::notice("iDatabase::query($dbNameForm,$query)");
+                         $app['monolog']->addInfo("iDatabase::query($dbNameForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($log) {
-                             Log::notice("In $dbNameForm, executed: $query");
+                             $app['monolog']->addInfo("In $dbNameForm, executed: $query");
                         }
                     }
                 }
@@ -216,18 +214,18 @@ if (defined('SYSTEM_INSTALLATION')) {
 			 * without a database name
 			 */
 			if (strlen($dbStatsForm) > 40) {
-				 Log::error('Database name '.$dbStatsForm.' is too long, skipping');
+				 $app['monolog']->addError('Database name '.$dbStatsForm.' is too long, skipping');
 			} elseif (!in_array($dbStatsForm, $dblist)) {
-				 Log::error('Database '.$dbStatsForm.' was not found, skipping');
+				 $app['monolog']->addError('Database '.$dbStatsForm.' was not found, skipping');
 			} else {
 				iDatabase::select_db($dbStatsForm);
 				foreach ($s_q_list as $query) {
 					if ($only_test) {
-						 Log::notice("iDatabase::query($dbStatsForm,$query)");
+						 $app['monolog']->addInfo("iDatabase::query($dbStatsForm,$query)");
 					} else {
 						$res = iDatabase::query($query);
 						if ($log) {
-							 Log::notice("In $dbStatsForm, executed: $query");
+							 $app['monolog']->addInfo("In $dbStatsForm, executed: $query");
 						}
 					}
 				}
@@ -242,15 +240,15 @@ if (defined('SYSTEM_INSTALLATION')) {
 			 * without a database name
 			 */
 			if (strlen($dbUserForm) > 40) {
-				 Log::error('Database name '.$dbUserForm.' is too long, skipping');
+				 $app['monolog']->addError('Database name '.$dbUserForm.' is too long, skipping');
 			} elseif (!in_array($dbUserForm,$dblist)) {
-				 Log::error('Database '.$dbUserForm.' was not found, skipping');
+				 $app['monolog']->addError('Database '.$dbUserForm.' was not found, skipping');
 			} else {
 				iDatabase::select_db($dbUserForm);
 				foreach ($u_q_list as $query) {
 					if ($only_test){
-						 Log::notice("iDatabase::query($dbUserForm,$query)");
-						 Log::notice("In $dbUserForm, executed: $query");
+						 $app['monolog']->addInfo("iDatabase::query($dbUserForm,$query)");
+						 $app['monolog']->addInfo("In $dbUserForm, executed: $query");
 					} else {
 						$res = iDatabase::query($query);
 					}
@@ -271,9 +269,9 @@ if (defined('SYSTEM_INSTALLATION')) {
 	if (count($c_q_list) > 0) {
 		// Get the courses list
 		if (strlen($dbNameForm) > 40) {
-			 Log::error('Database name '.$dbNameForm.' is too long, skipping');
+			 $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
 		} elseif (!in_array($dbNameForm, $dblist)) {
-			 Log::error('Database '.$dbNameForm.' was not found, skipping');
+			 $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
 		} else {
 			iDatabase::select_db($dbNameForm);
 			$res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
@@ -296,7 +294,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 					if (!$singleDbForm) { //otherwise just use the main one
 						iDatabase::select_db($row_course['db_name']);
 					}
-                    Log::notice('Course db ' . $row_course['db_name']);
+                    $app['monolog']->addInfo('Course db ' . $row_course['db_name']);
 
 					foreach ($c_q_list as $query) {
 						if ($singleDbForm) {
@@ -304,11 +302,11 @@ if (defined('SYSTEM_INSTALLATION')) {
 						}
 
 						if ($only_test) {
-							 Log::error("iDatabase::query(".$row_course['db_name'].",$query)");
+							 $app['monolog']->addError("iDatabase::query(".$row_course['db_name'].",$query)");
 						} else {
 							$res = iDatabase::query($query);
 							if ($log) {
-								 Log::error("In ".$row_course['db_name'].", executed: $query");
+								 $app['monolog']->addError("In ".$row_course['db_name'].", executed: $query");
 							}
 						}
 					}
@@ -326,7 +324,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 					$rs_sel = iDatabase::query($sql_sel);
 
 					if ($rs_sel === false) {
-				    	 Log::error('Could not query course_description ids table: '.iDatabase::error());
+				    	 $app['monolog']->addError('Could not query course_description ids table: '.iDatabase::error());
 					} else {
 						if (iDatabase::num_rows($rs_sel) > 0) {
 							while ($row_ids = iDatabase::fetch_array($rs_sel)) {

+ 38 - 39
main/install/update-db-1.8.6.2-1.8.7.inc.php

@@ -17,7 +17,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
 
 $old_file_version = '1.8.6.2';
 $new_file_version = '1.8.7';
@@ -84,21 +83,21 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbNameForm) > 40) {
-                Log::error('Database name ' . $dbNameForm . ' is too long, skipping');
+                $app['monolog']->addError('Database name ' . $dbNameForm . ' is too long, skipping');
             } elseif (!in_array($dbNameForm, $dblist)) {
-                Log::error('Database ' . $dbNameForm . ' was not found, skipping');
+                $app['monolog']->addError('Database ' . $dbNameForm . ' was not found, skipping');
             } else {
                 iDatabase::select_db($dbNameForm);
                 foreach ($m_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("Database::query($dbNameForm,$query)");
+                        $app['monolog']->addInfo("Database::query($dbNameForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($log) {
-                            Log::notice("In $dbNameForm, executed: $query");
+                            $app['monolog']->addInfo("In $dbNameForm, executed: $query");
                         }
                         if ($res === false) {
-                            Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                            $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                         }
                     }
                 }
@@ -107,13 +106,13 @@ if (defined('SYSTEM_INSTALLATION')) {
                     $query = "ALTER TABLE `" . $table . "` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;";
                     $res = iDatabase::query($query);
                     if ($res === false) {
-                        Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                        $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                     }
                 }
                 $query = "ALTER DATABASE `" . $dbNameForm . "` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;";
                 $res = Database::query($query);
                 if ($res === false) {
-                    Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                    $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                 }
             }
         }
@@ -222,18 +221,18 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbNameForm) > 40) {
-                Log::error('Database name ' . $dbNameForm . ' is too long, skipping');
+                $app['monolog']->addError('Database name ' . $dbNameForm . ' is too long, skipping');
             } elseif (!in_array($dbNameForm, $dblist)) {
-                Log::error('Database ' . $dbNameForm . ' was not found, skipping');
+                $app['monolog']->addError('Database ' . $dbNameForm . ' was not found, skipping');
             } else {
                 iDatabase::select_db($dbNameForm);
                 foreach ($m_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("Database::query($dbNameForm,$query)");
+                        $app['monolog']->addInfo("Database::query($dbNameForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($log) {
-                            Log::notice("In $dbNameForm, executed: $query");
+                            $app['monolog']->addInfo("In $dbNameForm, executed: $query");
                         }
                     }
                 }
@@ -249,22 +248,22 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbStatsForm) > 40) {
-                Log::error('Database name ' . $dbStatsForm . ' is too long, skipping');
+                $app['monolog']->addError('Database name ' . $dbStatsForm . ' is too long, skipping');
             } elseif (!in_array($dbStatsForm, $dblist)) {
-                Log::error('Database ' . $dbStatsForm . ' was not found, skipping');
+                $app['monolog']->addError('Database ' . $dbStatsForm . ' was not found, skipping');
             } else {
                 iDatabase::select_db($dbStatsForm);
 
                 foreach ($s_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("Database::query($dbStatsForm,$query)");
+                        $app['monolog']->addInfo("Database::query($dbStatsForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($log) {
-                            Log::notice("In $dbStatsForm, executed: $query");
+                            $app['monolog']->addInfo("In $dbStatsForm, executed: $query");
                         }
                         if ($res === false) {
-                            Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                            $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                         }
                     }
                 }
@@ -273,13 +272,13 @@ if (defined('SYSTEM_INSTALLATION')) {
                     $query = "ALTER TABLE `" . $table . "` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;";
                     $res = iDatabase::query($query);
                     if ($res === false) {
-                        Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                        $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                     }
                 }
                 $query = "ALTER DATABASE `" . $dbStatsForm . "` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;";
                 $res = iDatabase::query($query);
                 if ($res === false) {
-                    Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                    $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                 }
 
 
@@ -298,7 +297,7 @@ if (defined('SYSTEM_INSTALLATION')) {
                         $question_id = $row['question_id'];
                         $answer = $row['answer'];
                         $exe_id = $row['exe_id'];
-                        
+
                         if(empty($answer)){
                             continue;
                         }
@@ -339,19 +338,19 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbUserForm) > 40) {
-                Log::error('Database name ' . $dbUserForm . ' is too long, skipping');
+                $app['monolog']->addError('Database name ' . $dbUserForm . ' is too long, skipping');
             } elseif (!in_array($dbUserForm, $dblist)) {
-                Log::error('Database ' . $dbUserForm . ' was not found, skipping');
+                $app['monolog']->addError('Database ' . $dbUserForm . ' was not found, skipping');
             } else {
                 iDatabase::select_db($dbUserForm);
                 foreach ($u_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("Database::query($dbUserForm,$query)");
-                        Log::notice("In $dbUserForm, executed: $query");
+                        $app['monolog']->addInfo("Database::query($dbUserForm,$query)");
+                        $app['monolog']->addInfo("In $dbUserForm, executed: $query");
                     } else {
                         $res = iDatabase::query($query);
                         if ($res === false) {
-                            Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                            $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                         }
                     }
                 }
@@ -360,13 +359,13 @@ if (defined('SYSTEM_INSTALLATION')) {
                     $query = "ALTER TABLE `" . $table . "` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;";
                     $res = iDatabase::query($query);
                     if ($res === false) {
-                        Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                        $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                     }
                 }
                 $query = "ALTER DATABASE `" . $dbUserForm . "` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;";
                 $res = iDatabase::query($query);
                 if ($res === false) {
-                    Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                    $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                 }
             }
         }
@@ -383,9 +382,9 @@ if (defined('SYSTEM_INSTALLATION')) {
     if (count($c_q_list) > 0) {
         // Get the courses list
         if (strlen($dbNameForm) > 40) {
-            Log::error('Database name ' . $dbNameForm . ' is too long, skipping');
+            $app['monolog']->addError('Database name ' . $dbNameForm . ' is too long, skipping');
         } elseif (!in_array($dbNameForm, $dblist)) {
-            Log::error('Database ' . $dbNameForm . ' was not found, skipping');
+            $app['monolog']->addError('Database ' . $dbNameForm . ' was not found, skipping');
         } else {
             iDatabase::select_db($dbNameForm);
             $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
@@ -417,14 +416,14 @@ if (defined('SYSTEM_INSTALLATION')) {
                         }
 
                         if ($only_test) {
-                            Log::notice("Database::query(" . $row_course['db_name'] . ",$query)");
+                            $app['monolog']->addInfo("Database::query(" . $row_course['db_name'] . ",$query)");
                         } else {
                             $res = iDatabase::query($query);
                             if ($log) {
-                                Log::notice("In " . $row_course['db_name'] . ", executed: $query");
+                                $app['monolog']->addInfo("In " . $row_course['db_name'] . ", executed: $query");
                             }
                             if ($res === false) {
-                                Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                                $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                             }
                         }
                     }
@@ -435,13 +434,13 @@ if (defined('SYSTEM_INSTALLATION')) {
                             $query = "ALTER TABLE `" . $table . "` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;";
                             $res = iDatabase::query($query);
                             if ($res === false) {
-                                Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                                $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                             }
                         }
                         $query = "ALTER DATABASE `" . $row_course['db_name'] . "` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;";
                         $res = iDatabase::query($query);
                         if ($res === false) {
-                            Log::error('Error in ' . $query . ': ' . iDatabase::error());
+                            $app['monolog']->addError('Error in ' . $query . ': ' . iDatabase::error());
                         }
                     }
                     $t_student_publication = $row_course['db_name'] . ".student_publication";
@@ -457,7 +456,7 @@ if (defined('SYSTEM_INSTALLATION')) {
                     $rs_insert_user = iDatabase::query($sql_insert_user);
 
                     if ($rs_insert_user === false) {
-                        Log::error('Could not query insert_user_id table: ' . iDatabase::error());
+                        $app['monolog']->addError('Could not query insert_user_id table: ' . iDatabase::error());
                     } else {
                         if (iDatabase::num_rows($rs_insert_user) > 0) {
                             while ($row_ids = iDatabase::fetch_array($rs_insert_user)) {
@@ -517,9 +516,9 @@ if (defined('SYSTEM_INSTALLATION')) {
     if (count($c_q_list) > 0) {
         // Get the courses list
         if (strlen($dbNameForm) > 40) {
-            Log::error('Database name ' . $dbNameForm . ' is too long, skipping');
+            $app['monolog']->addError('Database name ' . $dbNameForm . ' is too long, skipping');
         } elseif (!in_array($dbNameForm, $dblist)) {
-            Log::error('Database ' . $dbNameForm . ' was not found, skipping');
+            $app['monolog']->addError('Database ' . $dbNameForm . ' was not found, skipping');
         } else {
             iDatabase::select_db($dbNameForm);
             $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
@@ -550,11 +549,11 @@ if (defined('SYSTEM_INSTALLATION')) {
                             $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query);
                         }
                         if ($only_test) {
-                            Log::notice("Database::query(" . $row['db_name'] . ",$query)");
+                            $app['monolog']->addInfo("Database::query(" . $row['db_name'] . ",$query)");
                         } else {
                             $res = iDatabase::query($query);
                             if ($log) {
-                                Log::notice("In " . $row['db_name'] . ", executed: $query");
+                                $app['monolog']->addInfo("In " . $row['db_name'] . ", executed: $query");
                             }
                         }
                     }

+ 65 - 67
main/install/update-db-1.8.7-1.8.8.inc.php

@@ -16,8 +16,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
-
 $old_file_version = '1.8.7';
 $new_file_version = '1.8.8';
 
@@ -83,21 +81,21 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbNameForm) > 40) {
-                Log::error('Database name '.$dbNameForm.' is too long, skipping');
+                $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
             } elseif (!in_array($dbNameForm, $dblist)) {
-                Log::error('Database '.$dbNameForm.' was not found, skipping');
+                $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
             } else {
                 iDatabase::select_db($dbNameForm);
                 foreach ($m_q_list as $query){
                     if ($only_test) {
-                        Log::notice("iDatabase::query($dbNameForm,$query)");
+                        $app['monolog']->addInfo("iDatabase::query($dbNameForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($log) {
-                             Log::notice("In $dbNameForm, executed: $query");
+                             $app['monolog']->addInfo("In $dbNameForm, executed: $query");
                         }
                         if ($res === false) {
-                        	 Log::error('Error in '.$query.': '.iDatabase::error());
+                        	 $app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                         }
                     }
                 }
@@ -140,22 +138,22 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbStatsForm) > 40) {
-                 Log::error('Database name '.$dbStatsForm.' is too long, skipping');
+                 $app['monolog']->addError('Database name '.$dbStatsForm.' is too long, skipping');
             } elseif (!in_array($dbStatsForm, $dblist)){
-                 Log::error('Database '.$dbStatsForm.' was not found, skipping');
+                 $app['monolog']->addError('Database '.$dbStatsForm.' was not found, skipping');
             } else {
                 iDatabase::select_db($dbStatsForm);
 
                 foreach ($s_q_list as $query) {
                     if ($only_test) {
-                         Log::notice("iDatabase::query($dbStatsForm,$query)");
+                         $app['monolog']->addInfo("iDatabase::query($dbStatsForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($log) {
-                             Log::notice("In $dbStatsForm, executed: $query");
+                             $app['monolog']->addInfo("In $dbStatsForm, executed: $query");
                         }
                         if ($res === false) {
-                             Log::error('Error in '.$query.': '.iDatabase::error());
+                             $app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                         }
                     }
                 }
@@ -173,19 +171,19 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbUserForm) > 40) {
-                 Log::error('Database name '.$dbUserForm.' is too long, skipping');
+                 $app['monolog']->addError('Database name '.$dbUserForm.' is too long, skipping');
             } elseif (!in_array($dbUserForm,$dblist)) {
-                 Log::error('Database '.$dbUserForm.' was not found, skipping');
+                 $app['monolog']->addError('Database '.$dbUserForm.' was not found, skipping');
             } else {
                 iDatabase::select_db($dbUserForm);
                 foreach ($u_q_list as $query) {
                     if ($only_test) {
-                         Log::notice("iDatabase::query($dbUserForm,$query)");
-                         Log::notice("In $dbUserForm, executed: $query");
+                         $app['monolog']->addInfo("iDatabase::query($dbUserForm,$query)");
+                         $app['monolog']->addInfo("In $dbUserForm, executed: $query");
                     } else {
                         $res = iDatabase::query($query);
                         if ($res === false) {
-                             Log::error('Error in '.$query.': '.iDatabase::error());
+                             $app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                         }
                     }
                 }
@@ -204,9 +202,9 @@ if (defined('SYSTEM_INSTALLATION')) {
     if (count($c_q_list) > 0) {
         // Get the courses list
         if (strlen($dbNameForm) > 40) {
-             Log::error('Database name '.$dbNameForm.' is too long, skipping');
+             $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
         } elseif(!in_array($dbNameForm, $dblist)) {
-             Log::error('Database '.$dbNameForm.' was not found, skipping');
+             $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
         } else {
             iDatabase::select_db($dbNameForm);
             $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
@@ -229,7 +227,7 @@ if (defined('SYSTEM_INSTALLATION')) {
                     if (!$singleDbForm) { // otherwise just use the main one
                         iDatabase::select_db($row_course['db_name']);
                     }
-                    Log::notice('Course db ' . $row_course['db_name']);
+                    $app['monolog']->addInfo('Course db ' . $row_course['db_name']);
 
                     foreach ($c_q_list as $query) {
                         if ($singleDbForm) {
@@ -237,121 +235,121 @@ if (defined('SYSTEM_INSTALLATION')) {
                         }
 
                         if ($only_test) {
-                             Log::notice("iDatabase::query(".$row_course['db_name'].",$query)");
+                             $app['monolog']->addInfo("iDatabase::query(".$row_course['db_name'].",$query)");
                         } else {
                             $res = iDatabase::query($query);
                             if ($log) {
-                                 Log::notice("In ".$row_course['db_name'].", executed: $query");
+                                 $app['monolog']->addInfo("In ".$row_course['db_name'].", executed: $query");
                             }
                             if ($res === false) {
-                                 Log::error('Error in '.$query.': '.iDatabase::error());
+                                 $app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                             }
                         }
-                    }            
-                    
+                    }
+
                     $table_lp_item_view = $row_course['db_name'].".lp_item_view";
                     $table_lp_view = $row_course['db_name'].".lp_view";
-                    $table_lp_item = $row_course['db_name'].".lp_item";                                     
+                    $table_lp_item = $row_course['db_name'].".lp_item";
 
                     if ($singleDbForm) {
                         $table_lp_item_view = "$prefix{$row_course['db_name']}_lp_item_view";
                         $table_lp_view = "$prefix{$row_course['db_name']}_lp_view";
-                        $table_lp_item = "$prefix{$row_course['db_name']}_lp_item";                                              
-                    }                    
-                    
+                        $table_lp_item = "$prefix{$row_course['db_name']}_lp_item";
+                    }
+
                     // Filling the track_e_exercices.orig_lp_item_view_id field  in order to have better traceability in exercises included in a LP see #3188
-                                     
-                    $query = "SELECT DISTINCT path as exercise_id, lp_item_id, lp_view_id, user_id, v.lp_id 
+
+                    $query = "SELECT DISTINCT path as exercise_id, lp_item_id, lp_view_id, user_id, v.lp_id
                               FROM $table_lp_item_view iv INNER JOIN  $table_lp_view v  ON v.id = iv.lp_view_id INNER JOIN $table_lp_item i ON  i.id = lp_item_id
                               WHERE item_type = 'quiz'";
                     $result = iDatabase::query($query);
-                    
+
                     if (iDatabase::num_rows($result) > 0) {
-                        while ($row = iDatabase::fetch_array($result,'ASSOC')) {                            
-                            $sql = "SELECT exe_id FROM $dbStatsForm.track_e_exercices 
-                                    WHERE exe_user_id = {$row['user_id']} AND 
-                                    exe_cours_id = '{$row_course['code']}' AND 
+                        while ($row = iDatabase::fetch_array($result,'ASSOC')) {
+                            $sql = "SELECT exe_id FROM $dbStatsForm.track_e_exercices
+                                    WHERE exe_user_id = {$row['user_id']} AND
+                                    exe_cours_id = '{$row_course['code']}' AND
                                     exe_exo_id = {$row['exercise_id']}  AND
-                                    orig_lp_id = {$row['lp_id']}  AND 
+                                    orig_lp_id = {$row['lp_id']}  AND
                                     orig_lp_item_id = {$row['lp_item_id']} ";
                             $sub_result = iDatabase::query($sql);
                             $exe_list = array();
                             while ($sub_row = iDatabase::fetch_array($sub_result,'ASSOC')) {
-                                $exe_list[] = $sub_row['exe_id'];             
+                                $exe_list[] = $sub_row['exe_id'];
                             }
-                            
+
                             $sql = "SELECT iv.id, iv.view_count
                                       FROM $table_lp_item_view iv INNER JOIN  $table_lp_view v  ON v.id = iv.lp_view_id INNER JOIN $table_lp_item i ON  i.id = lp_item_id
                                       WHERE item_type = 'quiz' AND user_id =  {$row['user_id']} AND path = {$row['exercise_id']} ";
                             $sub_result = iDatabase::query($sql);
                             $lp_item_view_id_list = array();
                             while ($sub_row = iDatabase::fetch_array($sub_result,'ASSOC')) {
-                                $lp_item_view_id_list[] = $sub_row['id'];             
-                            } 
+                                $lp_item_view_id_list[] = $sub_row['id'];
+                            }
                             $i = 0;
-                            foreach($exe_list as $exe_id) {       
-                                $lp_item_view_id = $lp_item_view_id_list[$i];                         
-                                $update = "UPDATE $dbNameForm.track_e_exercices SET orig_lp_item_view_id  = '$lp_item_view_id' WHERE exe_id = $exe_id ";                                
-                                iDatabase::query($update);                                
+                            foreach($exe_list as $exe_id) {
+                                $lp_item_view_id = $lp_item_view_id_list[$i];
+                                $update = "UPDATE $dbNameForm.track_e_exercices SET orig_lp_item_view_id  = '$lp_item_view_id' WHERE exe_id = $exe_id ";
+                                iDatabase::query($update);
                                 $i++;
-                            }                            
-                        }            
+                            }
+                        }
                     }
                 }
             }
-            
+
             //Adding notifications options
-    
+
             $sql = "INSERT INTO $dbNameForm.user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_invitation',   'MailNotifyInvitation',1,1,'1') ";
             $result = iDatabase::query($sql);
             $id = iDatabase::insert_id();
-                        
+
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) ";
             $result = iDatabase::query($sql);
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) ";
             $result = iDatabase::query($sql);
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) ";
-            $result = iDatabase::query($sql);         
-                
-            
+            $result = iDatabase::query($sql);
+
+
             $sql = "INSERT INTO $dbNameForm.user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_message',		 'MailNotifyMessage',1,1,'1')";
             $result = iDatabase::query($sql);
             $id = iDatabase::insert_id();
-            
+
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) ";
             $result = iDatabase::query($sql);
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) ";
             $result = iDatabase::query($sql);
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) ";
             $result = iDatabase::query($sql);
-            
-                        
+
+
             $sql = "INSERT INTO $dbNameForm.user_field (field_type, field_variable, field_display_text, field_visible, field_changeable, field_default_value) values (4, 'mail_notify_group_message','MailNotifyGroupMessage',1,1,'1') ";
             $result = iDatabase::query($sql);
             $id = iDatabase::insert_id();
-            
+
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) ";
             $result = iDatabase::query($sql);
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) ";
             $result = iDatabase::query($sql);
             $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) ";
             $result = iDatabase::query($sql);
-                     
+
             //Fixing table access_url_rel_course if the platform have courses that were created in Dok€os 1.8.5
-              
+
             if (!isset($_configuration['multiple_access_urls']) || $_configuration['multiple_access_urls'] == false) {
                 $sql = "SELECT code FROM $dbNameForm.course";
                 $result = iDatabase::query($sql);
                 while ($row = iDatabase::fetch_array($result)) {
                     //Adding course to default URL just in case
-                    $sql = "INSERT INTO $dbNameForm.access_url_rel_course SET course_code = '".iDatabase::escape_string($row['code'])."', access_url_id = '1' ";  
+                    $sql = "INSERT INTO $dbNameForm.access_url_rel_course SET course_code = '".iDatabase::escape_string($row['code'])."', access_url_id = '1' ";
                     iDatabase::query($sql);
-                }                
+                }
             }
         }
     }
-    
-    
+
+
 
 
 
@@ -362,9 +360,9 @@ if (defined('SYSTEM_INSTALLATION')) {
     if (count($c_q_list) > 0) {
         // Get the courses list
         if (strlen($dbNameForm) > 40) {
-             Log::error('Database name '.$dbNameForm.' is too long, skipping');
+             $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
         } elseif (!in_array($dbNameForm, $dblist)) {
-             Log::error('Database '.$dbNameForm.' was not found, skipping');
+             $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
         } else {
             iDatabase::select_db($dbNameForm);
             $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
@@ -391,11 +389,11 @@ if (defined('SYSTEM_INSTALLATION')) {
                             $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query);
                         }
                         if ($only_test) {
-                             Log::notice("iDatabase::query(".$row['db_name'].",$query)");
+                             $app['monolog']->addInfo("iDatabase::query(".$row['db_name'].",$query)");
                         } else {
                             $res = iDatabase::query($query);
                             if ($log) {
-                                 Log::notice("In ".$row['db_name'].", executed: $query");
+                                 $app['monolog']->addInfo("In ".$row['db_name'].", executed: $query");
                             }
                         }
                     }

+ 143 - 145
main/install/update-db-1.8.8-1.9.0.inc.php

@@ -16,7 +16,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
 
 $old_file_version = '1.8.8';
 $new_file_version = '1.9.0';
@@ -34,7 +33,7 @@ if (defined('SYSTEM_INSTALLATION')) {
     }
 
     $_configuration['db_glue'] = get_config_param('dbGlu');
-    
+
     if ($singleDbForm) {
         $_configuration['table_prefix'] 	= get_config_param('courseTablePrefix');
         $_configuration['main_database'] 	= get_config_param('mainDbName');
@@ -57,25 +56,25 @@ if (defined('SYSTEM_INSTALLATION')) {
     // that we want to change the main databases as well...
     $only_test = false;
     if (defined('SYSTEM_INSTALLATION')) {
-        
+
         if ($singleDbForm) {
             $dbStatsForm = $dbNameForm;
             $dbScormForm = $dbNameForm;
             $dbUserForm  = $dbNameForm;
-        }        
+        }
         /**
          * Update the databases "pre" migration
          */
         include '../lang/english/create_course.inc.php';
-        
+
         if ($languageForm != 'english') {
             // languageForm has been escaped in index.php
             include '../lang/'.$languageForm.'/create_course.inc.php';
         }
-        
+
         // Get the main queries list (m_q_list)
         $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'main');
-        
+
         if (count($m_q_list) > 0) {
             // Now use the $m_q_list
             /**
@@ -83,41 +82,41 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbNameForm) > 40) {
-                Log::error('Database name '.$dbNameForm.' is too long, skipping');
+                $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
             } elseif (!in_array($dbNameForm, $dblist)) {
-                Log::error('Database '.$dbNameForm.' was not found, skipping');
+                $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
             } else {
                 iDatabase::select_db($dbNameForm);
                 foreach ($m_q_list as $query){
                     if ($only_test) {
-                        Log::notice("iDatabase::query($dbNameForm,$query)");
+                        $app['monolog']->addInfo("iDatabase::query($dbNameForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($res === false) {
-                        	Log::error('Error in '.$query.': '.iDatabase::error());
+                        	$app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                         }
                     }
                 }
             }
         }
-        
+
         if (INSTALL_TYPE_UPDATE == 'update') {
-            
+
             //Migrate classes to the new classes (usergroups)
-            
+
             $sql = "SELECT selected_value FROM $dbNameForm.settings_current WHERE variable='use_session_mode' ";
             $result = iDatabase::query($sql);
             $result = Database::fetch_array($result);
-            $session_mode  = $result['selected_value'];            
-                        
+            $session_mode  = $result['selected_value'];
+
             if ($session_mode == 'true') {
-                
-                $sql = "UPDATE $dbNameForm.settings_current SET selected_value = 'true' WHERE variable='use_session_mode' ";                
+
+                $sql = "UPDATE $dbNameForm.settings_current SET selected_value = 'true' WHERE variable='use_session_mode' ";
                 $result = iDatabase::query($sql);
-                
+
                 $sql = "SELECT * FROM $dbNameForm.class";
                 $result = iDatabase::query($sql);
-                $count = 0;                    	
+                $count = 0;
                 $new_table = "$dbNameForm.usergroup";
                 $classes_added = 0;
                 $mapping_classes = array();
@@ -133,22 +132,22 @@ if (defined('SYSTEM_INSTALLATION')) {
                         }
                     }
                 }
-                
+
                 $sql = "SELECT * FROM $dbNameForm.class_user";
                 $result = iDatabase::query($sql);
                 $new_table = "$dbNameForm.usergroup_rel_user";
                 if (Database::num_rows($result)) {
-                    while ($row = iDatabase::fetch_array($result, 'ASSOC')) {   
+                    while ($row = iDatabase::fetch_array($result, 'ASSOC')) {
                         $values = array('usergroup_id' => $mapping_classes[$row['class_id']],
                                         'user_id' => $row['user_id']);
                         iDatabase::insert($new_table, $values);
                     }
                 }
-                
+
                 $sql = "SELECT * FROM $dbNameForm.course_rel_class";
                 $result = iDatabase::query($sql);
                 $new_table = "$dbNameForm.usergroup_rel_course";
-                
+
                 if (Database::num_rows($result)) {
                     while ($row = iDatabase::fetch_array($result, 'ASSOC')) {
                         $course_code = $row['course_code'];
@@ -162,11 +161,11 @@ if (defined('SYSTEM_INSTALLATION')) {
                         iDatabase::insert($new_table, $values);
                     }
                 }
-                
-                Log::notice("#classes added $classes_added");                
+
+                $app['monolog']->addInfo("#classes added $classes_added");
             }
         }
-        
+
 
         // Get the stats queries list (s_q_list)
         $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'stats');
@@ -177,28 +176,28 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbStatsForm) > 40) {
-                Log::error('Database name '.$dbStatsForm.' is too long, skipping');
+                $app['monolog']->addError('Database name '.$dbStatsForm.' is too long, skipping');
             } elseif (!in_array($dbStatsForm, $dblist)){
-                Log::error('Database '.$dbStatsForm.' was not found, skipping');
+                $app['monolog']->addError('Database '.$dbStatsForm.' was not found, skipping');
             } else {
                 iDatabase::select_db($dbStatsForm);
 
                 foreach ($s_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("iDatabase::query($dbStatsForm,$query)");
+                        $app['monolog']->addInfo("iDatabase::query($dbStatsForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($res === false) {
-                            Log::error('Error in '.$query.': '.iDatabase::error());
+                            $app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                         }
                     }
                 }
             }
         }
-        
+
         //Moving Stats DB to the main DB
-        
-        $stats_table = array(        
+
+        $stats_table = array(
 			"track_c_browsers",
 			"track_c_countries",
 			"track_c_os",
@@ -223,7 +222,7 @@ if (defined('SYSTEM_INSTALLATION')) {
         	"track_stored_values",
         	"track_stored_values_stack",
         );
-        
+
         if ($dbNameForm != $dbStatsForm) {
         	iDatabase::select_db($dbStatsForm);
 	        foreach ($stats_table as $stat_table) {
@@ -232,10 +231,10 @@ if (defined('SYSTEM_INSTALLATION')) {
 	        }
 	        iDatabase::select_db($dbNameForm);
         }
-        
+
         // Get the user queries list (u_q_list)
         $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user');
-        
+
         if (count($u_q_list) > 0) {
             // Now use the $u_q_list
             /**
@@ -243,33 +242,33 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbUserForm) > 40) {
-                Log::error('Database name '.$dbUserForm.' is too long, skipping');
+                $app['monolog']->addError('Database name '.$dbUserForm.' is too long, skipping');
             } elseif (!in_array($dbUserForm,$dblist)) {
-                Log::error('Database '.$dbUserForm.' was not found, skipping');
+                $app['monolog']->addError('Database '.$dbUserForm.' was not found, skipping');
             } else {
                 iDatabase::select_db($dbUserForm);
                 foreach ($u_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("iDatabase::query($dbUserForm,$query)");
-                        Log::notice("In $dbUserForm, executed: $query");
+                        $app['monolog']->addInfo("iDatabase::query($dbUserForm,$query)");
+                        $app['monolog']->addInfo("In $dbUserForm, executed: $query");
                     } else {
                         $res = iDatabase::query($query);
                         if ($res === false) {
-                            Log::error('Error in '.$query.': '.iDatabase::error());
+                            $app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                         }
                     }
                 }
             }
         }
-        
+
         //Moving user database to the main database
         $users_tables = array(
         			"personal_agenda",
         			"personal_agenda_repeat",
         			"personal_agenda_repeat_not",
-        			"user_course_category"        			        
+        			"user_course_category"
         );
-        
+
         if ($dbNameForm != $dbUserForm) {
         	iDatabase::select_db($dbUserForm);
         	foreach ($users_tables as $table) {
@@ -278,53 +277,53 @@ if (defined('SYSTEM_INSTALLATION')) {
         	}
         	iDatabase::select_db($dbNameForm);
         }
-    }    
-    
+    }
+
     //Adding admin user in the access_url_rel_user  table
     $sql = "SELECT user_id FROM admin WHERE user_id = 1";
     $result = iDatabase::query($sql);
     $has_user_id = Database::num_rows($result) > 0;
-    
+
     $sql = "SELECT * FROM access_url_rel_user WHERE user_id = 1 AND access_url_id = 1";
     $result = iDatabase::query($sql);
     $has_entry = Database::num_rows($result) > 0;
-        
+
     if ($has_user_id && !$has_entry) {
         $sql = "INSERT INTO access_url_rel_user VALUES(1, 1)";
         iDatabase::query($sql);
     }
-    
+
     //Adds the c_XXX courses tables see #3910
     global $_configuration;
-    
-    drop_course_tables();    
+
+    drop_course_tables();
     create_course_tables();
-    
+
     $prefix = '';
     if ($singleDbForm) {
         $prefix =  get_config_param('table_prefix');
     }
-    
-    Log::notice("Database prefix: '$prefix'");
+
+    $app['monolog']->addInfo("Database prefix: '$prefix'");
 
     // Get the courses databases queries list (c_q_list)
     $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course');
-    Log::notice('Starting migration: '.$old_file_version.' - '.$new_file_version);
+    $app['monolog']->addInfo('Starting migration: '.$old_file_version.' - '.$new_file_version);
 
     if (count($c_q_list) > 0) {
         // Get the courses list
         if (strlen($dbNameForm) > 40) {
-            Log::error('Database name '.$dbNameForm.' is too long, skipping');
+            $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
         } elseif(!in_array($dbNameForm, $dblist)) {
-            Log::error('Database '.$dbNameForm.' was not found, skipping');
+            $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
         } else {
             iDatabase::select_db($dbNameForm);
             $res = iDatabase::query("SELECT id, code, db_name, directory, course_language, id as real_id FROM course WHERE target_course_code IS NULL ORDER BY code");
 
             if ($res === false) { die('Error while querying the courses list in update_db-1.8.8-1.9.0.inc.php'); }
-			
+
             $errors = array();
-              
+
             if (iDatabase::num_rows($res) > 0) {
                 $i = 0;
                 $list = array();
@@ -332,82 +331,82 @@ if (defined('SYSTEM_INSTALLATION')) {
                     $list[] = $row;
                     $i++;
                 }
-                
+
                 foreach ($list as $row_course) {
                     if (!$singleDbForm) { // otherwise just use the main one
                         iDatabase::select_db($row_course['db_name']);
                     }
-                    Log::notice('Course db ' . $row_course['db_name']);
-                    
+                    $app['monolog']->addInfo('Course db ' . $row_course['db_name']);
+
                     // Now use the $c_q_list
                     foreach ($c_q_list as $query) {
                         if ($singleDbForm) {
                             $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query);
                         }
                         if ($only_test) {
-                            Log::notice("iDatabase::query(".$row_course['db_name'].",$query)");
+                            $app['monolog']->addInfo("iDatabase::query(".$row_course['db_name'].",$query)");
                         } else {
                             $res = iDatabase::query($query);
                             if ($res === false) {
-                                Log::error('Error in '.$query.': '.iDatabase::error());
+                                $app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                             }
                         }
-                    }                    
-                    
+                    }
+
                     $work_table = $row_course['db_name'].".student_publication";
                     $item_table = $row_course['db_name'].".item_property";
-                    
+
                     if ($singleDbForm) {
                         $work_table = "$prefix{$row_course['db_name']}_student_publication";
                         $item_table = $row_course['db_name'].".item_property";
                     }
-                    
+
                     if (!$singleDbForm) {
                         // otherwise just use the main one
                         iDatabase::select_db($row_course['db_name']);
                     } else {
                         iDatabase::select_db($dbNameForm);
-                    }                    	
-                 
-                    
+                    }
+
+
                     /* Start work fix */
-                    
+
                     /* Fixes the work subfolder and work with no parent issues */
-                    
+
                     //1. Searching for works with no parents
                     $sql 	= "SELECT * FROM $work_table WHERE parent_id = 0 AND filetype ='file'";
                     $result = Database::query($sql);
-                    
+
                     $work_list = array();
-                    
+
                     if (Database::num_rows($result)) {
                         while ($row = Database::fetch_array($result, 'ASSOC')) {
                             $work_list[] = $row;
                         }
                     }
-                    
+
                     $today = api_get_utc_datetime();
-                    $user_id = 1;                    
+                    $user_id = 1;
                     require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
-                    
+
                     $sys_course_path 	= api_get_path(SYS_COURSE_PATH);
                     $course_dir 		= $sys_course_path . $row_course['directory'];
-                    $base_work_dir 		= $course_dir . '/work';                   
-                    
+                    $base_work_dir 		= $course_dir . '/work';
+
                     //2. Looping if there are works with no parents
-                    if (!empty($work_list)) {                        
+                    if (!empty($work_list)) {
                         $work_dir_created = array();
-                        
-                        foreach ($work_list as $work) {                            
+
+                        foreach ($work_list as $work) {
                             $session_id = intval($work['session_id']);
                             $group_id   = intval($work['post_group_id']);
                             $work_key   = $session_id.$group_id;
-                            
+
                             //Only create the folder once
                             if (!isset($work_dir_created[$work_key])) {
-                                
+
                                 $dir_name = "default_tasks_".$group_id."_".$session_id;
-                                
+
                                 //2.1 Creating a new work folder
                                 $sql = "INSERT INTO $work_table SET
                                                 url         		= 'work/".$dir_name."',
@@ -418,60 +417,60 @@ if (defined('SYSTEM_INSTALLATION')) {
                                                 accepted			= '1',
                                                 filetype            = 'folder',
                                                 post_group_id       = '$group_id',
-                                                sent_date           = '".$today."',                                            
+                                                sent_date           = '".$today."',
                                                 parent_id           = '0',
-                                                qualificator_id     = '',                                            
-                                                user_id 			= '".$user_id."'";                                
+                                                qualificator_id     = '',
+                                                user_id 			= '".$user_id."'";
                                 iDatabase::query($sql);
 
                                 $id = Database::insert_id();
                                 //2.2 Adding the folder in item property
                                 if ($id) {
-                                    //api_item_property_update($row_course, 'work', $id, 'DirectoryCreated', $user_id, $group_id, null, 0, 0 , $session_id);                                    
+                                    //api_item_property_update($row_course, 'work', $id, 'DirectoryCreated', $user_id, $group_id, null, 0, 0 , $session_id);
                                     $sql = "INSERT INTO $item_table (tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id, to_group_id, visibility, id_session)
                                             VALUES ('work','$id','$today', '$user_id', '$today', 'DirectoryCreated','$user_id', '$group_id', '1', '$session_id')";
-                                    
+
                                     iDatabase::query($sql);
-                                    $work_dir_created[$work_key] = $id;                                    
+                                    $work_dir_created[$work_key] = $id;
                                     create_unexisting_work_directory($base_work_dir, $dir_name);
                                     $final_dir = $base_work_dir.'/'.$dir_name;
                                 }
                             } else {
                                 $final_dir = $base_work_dir.'/'.$dir_name;
                             }
-                            
+
                             //2.3 Updating the url
                             if (!empty($work_dir_created[$work_key])) {
-                                $parent_id = $work_dir_created[$work_key];                                
+                                $parent_id = $work_dir_created[$work_key];
                                 $new_url = "work/".$dir_name.'/'.basename($work['url']);
-                                $new_url = Database::escape_string($new_url);$sql = "UPDATE $work_table SET url = '$new_url', parent_id = $parent_id, contains_file = '1' WHERE id = {$work['id']}";                                                               
-                                iDatabase::query($sql);     
-                                if (is_dir($final_dir)) {                                    
+                                $new_url = Database::escape_string($new_url);$sql = "UPDATE $work_table SET url = '$new_url', parent_id = $parent_id, contains_file = '1' WHERE id = {$work['id']}";
+                                iDatabase::query($sql);
+                                if (is_dir($final_dir)) {
                                     rename($course_dir.'/'.$work['url'], $course_dir.'/'.$new_url);
                                 }
-                            }                                                        
+                            }
                         }
                     }
-                    
+
                     //3.0 Moving subfolders to the root
-                    $sql 	= "SELECT * FROM $work_table WHERE parent_id <> 0 AND filetype ='folder'";             
+                    $sql 	= "SELECT * FROM $work_table WHERE parent_id <> 0 AND filetype ='folder'";
                     $result = Database::query($sql);
                     $work_list = array();
-                    
+
                     if (Database::num_rows($result)) {
                         while ($row = Database::fetch_array($result, 'ASSOC')) {
                             $work_list[] = $row;
                         }
-                        if (!empty($work_list)) {                            
-                            foreach ($work_list as $work_folder) {                                
-                                $folder_id = $work_folder['id'];                                
-                                check_work($folder_id, $work_folder['url'], $work_table, $base_work_dir);                                
+                        if (!empty($work_list)) {
+                            foreach ($work_list as $work_folder) {
+                                $folder_id = $work_folder['id'];
+                                check_work($folder_id, $work_folder['url'], $work_table, $base_work_dir);
                             }
                         }
-                    }         
-                    
+                    }
+
                     /*  End of work fix  */
-                 
+
                     //Course tables to be migrated
                     $table_list = array(
                     					'announcement',
@@ -560,40 +559,39 @@ if (defined('SYSTEM_INSTALLATION')) {
                                         'wiki',
                                         'wiki_conf',
                                         'wiki_discuss',
-                                        'wiki_mailcue'                   
+                                        'wiki_mailcue'
                     );
-                    
-                    Log::notice('<<<------- Loading DB course '.$row_course['db_name'].' -------->>');
-                    //Install::message('<<<------- Loading DB course '.$row_course['db_name'].' -------->>');
-                    
+
+                    $app['monolog']->addInfo('<<<------- Loading DB course '.$row_course['db_name'].' -------->>');
+
                     $count = $old_count = 0;
                     foreach ($table_list as $table) {
                         $just_table_name = $table;
                     	$old_table = $row_course['db_name'].".".$table;
-                        
+
                     	if ($singleDbForm) {
                     		$old_table = "$prefix{$row_course['db_name']}_".$table;
                             $just_table_name = "$prefix{$row_course['db_name']}_".$table;
                     	}
-                        
-                    	$course_id = $row_course['id'];                        
+
+                    	$course_id = $row_course['id'];
                     	$new_table = DB_COURSE_PREFIX.$table;
-                        
+
                         //Use the old database (if this is the case)
-                        
+
                         if (!$singleDbForm) {
                     		// otherwise just use the main one
                     		iDatabase::select_db($row_course['db_name']);
                     	} else {
                     		iDatabase::select_db($dbNameForm);
                     	}
-                    	
-                    	//Count of rows                    	
+
+                    	//Count of rows
                         $sql 	= "SHOW TABLES LIKE '$just_table_name'";
                         $result = iDatabase::query($sql);
-                        
+
                         if (Database::num_rows($result)) {
-                        
+
                             $sql 	= "SELECT count(*) FROM $old_table";
                             $result = iDatabase::query($sql);
 
@@ -602,41 +600,41 @@ if (defined('SYSTEM_INSTALLATION')) {
                                 $row 		= iDatabase::fetch_row($result);
                                 $old_count = $row[0];
                             } else {
-                                Log::error("Count(*) in table $old_table failed");
-                            }                       
-                        
-                            Log::notice("# rows in $old_table: $old_count");
+                                $app['monolog']->addError("Count(*) in table $old_table failed");
+                            }
+
+                            $app['monolog']->addInfo("# rows in $old_table: $old_count");
 
                             $sql = "SELECT * FROM $old_table";
                             $result = iDatabase::query($sql);
 
                             $count = 0;
-                            
+
                             /* Loads the main database */
                             iDatabase::select_db($dbNameForm);
-                            
+
                             while($row = iDatabase::fetch_array($result, 'ASSOC')) {
-                                $row['c_id'] = $course_id;                                
+                                $row['c_id'] = $course_id;
                                 $id = iDatabase::insert($new_table, $row);
                                 if (is_numeric($id)) {
                                     $count++;
                                 } else {
-                                    $errors[$old_table][] = $row;                    			
+                                    $errors[$old_table][] = $row;
                                 }
-                            }                    	
-                            Log::notice("#rows inserted in $new_table: $count");
+                            }
+                            $app['monolog']->addInfo("#rows inserted in $new_table: $count");
 
                             if ($old_count != $count) {
-                                Log::error("ERROR count of new and old table doesn't match: $old_count - $new_table");
-                                Log::error("Check the results: ");
-                                Log::error(print_r($errors, 1));
+                                $app['monolog']->addError("ERROR count of new and old table doesn't match: $old_count - $new_table");
+                                $app['monolog']->addError("Check the results: ");
+                                $app['monolog']->addError(print_r($errors, 1));
                                 error_log(print_r($errors, 1));
                             }
                         } else {
-                            Log::error("Seems that the table $old_table doesn't exists ");
+                            $app['monolog']->addError("Seems that the table $old_table doesn't exists ");
                         }
                     }
-                    Log::notice('<<<------- end  -------->>');
+                    $app['monolog']->addInfo('<<<------- end  -------->>');
                 }
             }
         }
@@ -648,7 +646,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 function check_work($folder_id, $work_url, $work_table, $base_work_dir) {
     $uniq_id = uniqid();
     //Looking for subfolders
-    $sql 	= "SELECT * FROM $work_table WHERE parent_id = $folder_id AND filetype ='folder'";             
+    $sql 	= "SELECT * FROM $work_table WHERE parent_id = $folder_id AND filetype ='folder'";
     $result = Database::query($sql);
 
     if (Database::num_rows($result)) {
@@ -658,7 +656,7 @@ function check_work($folder_id, $work_url, $work_table, $base_work_dir) {
     }
 
     //Moving the subfolder in the root
-    $new_url = '/'.basename($work_url).'_mv_'.$uniq_id;              
+    $new_url = '/'.basename($work_url).'_mv_'.$uniq_id;
     $new_url = Database::escape_string($new_url);
     $sql = "UPDATE $work_table SET url = '$new_url', parent_id = 0 WHERE id = $folder_id";
     iDatabase::query($sql);
@@ -666,15 +664,15 @@ function check_work($folder_id, $work_url, $work_table, $base_work_dir) {
     if (is_dir($base_work_dir.$work_url)) {
         rename($base_work_dir.$work_url, $base_work_dir.$new_url);
 
-        //Rename all files inside the folder                        
-        $sql 	= "SELECT * FROM $work_table WHERE parent_id = $folder_id AND filetype ='file'";             
+        //Rename all files inside the folder
+        $sql 	= "SELECT * FROM $work_table WHERE parent_id = $folder_id AND filetype ='file'";
         $result = Database::query($sql);
 
         if (Database::num_rows($result)) {
-            while ($row = Database::fetch_array($result, 'ASSOC')) {                                
-                $new_url = "work".$new_url.'/'.basename($row['url']);     
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
+                $new_url = "work".$new_url.'/'.basename($row['url']);
                 $new_url = Database::escape_string($new_url);
-                $sql = "UPDATE $work_table SET url = '$new_url', parent_id = $folder_id, contains_file = '1' WHERE id = {$row['id']}";                                
+                $sql = "UPDATE $work_table SET url = '$new_url', parent_id = $folder_id, contains_file = '1' WHERE id = {$row['id']}";
                 iDatabase::query($sql);
             }
         }

+ 4 - 6
main/install/update-db-1.9.0-1.10.0.inc.php

@@ -16,8 +16,6 @@
  * - reorganise code into functions
  * @todo use database library
  */
-Log::notice('Entering file');
-
 $old_file_version = '1.9.0';
 $new_file_version = '1.10.0';
 
@@ -83,18 +81,18 @@ if (defined('SYSTEM_INSTALLATION')) {
              * without a database name
              */
             if (strlen($dbNameForm) > 40) {
-                Log::error('Database name '.$dbNameForm.' is too long, skipping');
+                $app['monolog']->addError('Database name '.$dbNameForm.' is too long, skipping');
             } elseif (!in_array($dbNameForm, $dblist)) {
-                Log::error('Database '.$dbNameForm.' was not found, skipping');
+                $app['monolog']->addError('Database '.$dbNameForm.' was not found, skipping');
             } else {
                 iDatabase::select_db($dbNameForm);
                 foreach ($m_q_list as $query) {
                     if ($only_test) {
-                        Log::notice("iDatabase::query($dbNameForm,$query)");
+                        $app['monolog']->addInfo("iDatabase::query($dbNameForm,$query)");
                     } else {
                         $res = iDatabase::query($query);
                         if ($res === false) {
-                            Log::error('Error in '.$query.': '.iDatabase::error());
+                            $app['monolog']->addError('Error in '.$query.': '.iDatabase::error());
                         }
                     }
                 }

+ 42 - 43
main/install/update-db-scorm-1.6.x-1.8.0.inc.php

@@ -12,7 +12,6 @@
 /**
  * Include mandatory libraries
  */
-Log::notice('Entering file');
 
 require_once api_get_path(LIBRARY_PATH).'document.lib.php';
 require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; //check_name_exists()
@@ -81,7 +80,7 @@ while ($row = Database::fetch_array($res)) {
     $courses_dir_list[$row['code']] = $row['directory'];
 }
 
-if ($loglevel > 0) { Log::notice("Tables created/deleted for all courses"); }
+if ($loglevel > 0) { $app['monolog']->addInfo("Tables created/deleted for all courses"); }
 
 /**
  * The migration needs to take all data from the original learnpath tables and add them to the new
@@ -91,12 +90,12 @@ if ($loglevel > 0) { Log::notice("Tables created/deleted for all courses"); }
 // Test only one course
 foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
     if (strlen($courses_id_list[$course_code]) > 40) {
-        Log::error('Database '.$courses_id_list[$course_code].' is too long, skipping');
+        $app['monolog']->addError('Database '.$courses_id_list[$course_code].' is too long, skipping');
         continue;
     }
 
     $incoherences = 0;
-    if ($loglevel > 0) { Log::notice("Now starting migration of learnpath tables from $db database..."); }
+    if ($loglevel > 0) { $app['monolog']->addInfo("Now starting migration of learnpath tables from $db database..."); }
     $lp_doc = $db.TABLE_DOCUMENT;
     $lp_main = $db.TABLE_LEARNPATH_MAIN;
     $lp_ids = array();
@@ -119,13 +118,13 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
     $sql_test = "SELECT * FROM $my_new_lp";
     $res_test = Database::query($sql_test);
     $sql_lp = "SELECT * FROM $lp_main";
-    if ($loglevel > 1) { Log::notice("$sql_lp"); }
+    if ($loglevel > 1) { $app['monolog']->addInfo("$sql_lp"); }
     $res_lp = Database::query($sql_lp);
     if (!$res_lp or !$res_test) {
         if ($loglevel > 1) {
-            Log::error("+++Problem querying DB $lp_main+++ skipping (".Database::error().")");
+            $app['monolog']->addError("+++Problem querying DB $lp_main+++ skipping (".Database::error().")");
             if (!$res_test) {
-                Log::error("This might be due to no existing table in the destination course");
+                $app['monolog']->addError("This might be due to no existing table in the destination course");
             }
         }
         continue;
@@ -280,13 +279,13 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
                 case 'c':
                     // chapter-type prereq
                     $prereq_id = $lp_chap_items[$row['prereq_id']];
-                    if (empty($prereq_id) && $loglevel > 1) { Log::error("Could not find prereq chapter ".$row['prereq_id']); }
+                    if (empty($prereq_id) && $loglevel > 1) { $app['monolog']->addError("Could not find prereq chapter ".$row['prereq_id']); }
                     break;
                 case 'i':
                 default:
                     // item type prereq
                     $prereq_id = $lp_items[$parent_lps[$row['chapter_id']]][$row['prereq_id']];
-                    if (empty($prereq_id) && $loglevel > 1) { Log::error("Could not find prereq item ".$row['prereq_id']); }
+                    if (empty($prereq_id) && $loglevel > 1) { $app['monolog']->addError("Could not find prereq item ".$row['prereq_id']); }
                     break;
             }
         }
@@ -513,7 +512,7 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
             $sql_tool_upd = "UPDATE $tbl_tool " .
                     "SET link='newscorm/lp_controller.php?action=view&lp_id=$new_lp_id' " .
                     "WHERE id = ".$row_tool['id'];
-            Log::notice('New LP - Migration - Updating tool table: '.$sql_tool_upd);
+            $app['monolog']->addInfo('New LP - Migration - Updating tool table: '.$sql_tool_upd);
             // Make sure there is a way of retrieving which links were updated (to revert)
             fwrite($fh,$sql_tool_upd." AND link ='$link'");
             fwrite($fh_revert, "UPDATE $tbl_tool SET link='$link' WHERE id=".$row_tool['id']." AND link ='newscorm/lp_controller.php?action=view&lp_id=$new_lp_id';\n");
@@ -534,7 +533,7 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
             if (!empty($matches[3]) && (strtolower(substr($matches[3], -15)) == 'imsmanifest.xml') && !is_file(realpath(urldecode($matches[3])))) {
                 //echo "Removing link $link from tools<br />";
                 $sql_tool_upd = "DELETE FROM $tbl_tool WHERE id = ".$row_tool['id'];
-                Log::notice('New LP - Migration - Updating tool table (dead link): '.$sql_tool_upd);
+                $app['monolog']->addInfo('New LP - Migration - Updating tool table (dead link): '.$sql_tool_upd);
                 // Make sure there is a way of retrieving which links were updated (to revert)
                 fwrite($fh, $sql_tool_upd." AND link ='$link'");
                 fwrite($fh_revert, "INSERT INTO $tbl_tool (link) VALUES ('$link');\n");
@@ -579,7 +578,7 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
         }
     }
 
-    if ($loglevel > 0) { Log::notice("Done!".$msg); }
+    if ($loglevel > 0) { $app['monolog']->addInfo("Done!".$msg); }
     //flush();
     //ob_flush();
 }
@@ -602,7 +601,7 @@ fwrite($fh_res, "-- Recording resulting course homepages links changes for SCORM
  * The migration needs to take all data from the scorm.scorm_main and scorm.scorm_sco_data tables
  * and add them to the new lp, lp_view, lp_item and lp_item_view tables.
  */
-if ($loglevel > 0) { Log::notice("Now starting migration of scorm tables from global SCORM database"); }
+if ($loglevel > 0) { $app['monolog']->addInfo("Now starting migration of scorm tables from global SCORM database"); }
 
 $scorm_main = $dbScormForm.'.'.TABLE_SCORM_MAIN;
 $scorm_item = $dbScormForm.'.'.TABLE_SCORM_SCO_DATA;
@@ -619,7 +618,7 @@ $scorm_lp_paths = array();
 Database::select_db($dbNameForm);
 $course_main = TABLE_MAIN_COURSE;
 $sql_crs = "SELECT * FROM $course_main WHERE target_course_code IS NULL";
-if ($loglevel > 0) { Log::notice("$sql_crs"); }
+if ($loglevel > 0) { $app['monolog']->addInfo("$sql_crs"); }
 $res_crs = Database::query($sql_crs);
 $num = Database::num_rows($res_crs);
 
@@ -629,7 +628,7 @@ $course_code_swap = '';
 $scormdocuments_lps = array();
 while ($course_row = Database::fetch_array($res_crs)) {
 
-    if ($loglevel > 0) { Log::notice("Now dealing with course ".$course_row['code']."..."); }
+    if ($loglevel > 0) { $app['monolog']->addInfo("Now dealing with course ".$course_row['code']."..."); }
     // Check the validity of this new course
     $my_course_code = $course_row['code'];
 
@@ -637,21 +636,21 @@ while ($course_row = Database::fetch_array($res_crs)) {
     //$scormdocuments_lps = array();
     $db_name = $courses_id_full_table_prefix_list[$my_course_code];
     if (strlen($courses_id_list[$course_code]) > 40) {
-        Log::notice('Database '.$courses_id_list[$course_code].' is too long, skipping');
+        $app['monolog']->addInfo('Database '.$courses_id_list[$course_code].' is too long, skipping');
         continue;
     }
 
     //echo "Now processing database $db_name<br />";
     $tblscodoc = $db_name.TABLE_SCORMDOC;
     $sql_scodoc = "SELECT path FROM $tblscodoc WHERE path IS NOT NULL AND path != ''";
-    if ($loglevel > 1) { Log::notice("$sql_scodoc"); }
+    if ($loglevel > 1) { $app['monolog']->addInfo("$sql_scodoc"); }
     $res_scodoc = Database::query($sql_scodoc);
     while ($row_scodoc = Database::fetch_array($res_scodoc)) {
 
         // Check if there's more than one slash in total
         if (strpos($row_scodoc['path'], '/', 1) === false) {
             $tmp_path = $row_scodoc['path'];
-            if ($loglevel > 1) { Log::notice("++Now opening $tmp_path"); }
+            if ($loglevel > 1) { $app['monolog']->addInfo("++Now opening $tmp_path"); }
 
             // Add a prefixing slash if there is none
             if (substr($tmp_path, 0, 1) != '/') {
@@ -672,17 +671,17 @@ while ($course_row = Database::fetch_array($res_crs)) {
                 // Avoid if contentTitle is not the name of an existing directory
             } elseif (!is_file($courses_dir."/imsmanifest.xml")) {
                 // If the imsmanifest file was not found there
-                if ($loglevel > 2) { Log::error("  !!imsmanifest.xml  not found at scormdocument's $courses_dir/imsmanifest.xml, skipping"); }
+                if ($loglevel > 2) { $app['monolog']->addError("  !!imsmanifest.xml  not found at scormdocument's $courses_dir/imsmanifest.xml, skipping"); }
                 // Try subdirectories on one level depth
-                if ($loglevel > 2) { Log::notice("  Trying subdirectories..."); }
+                if ($loglevel > 2) { $app['monolog']->addInfo("  Trying subdirectories..."); }
                 $dh = opendir($courses_dir);
                 while ($entry = readdir($dh)) {
                     if (substr($entry, 0, 1) != '.') {
                         if (is_dir($courses_dir."/".$entry)) {
                             if (is_file($courses_dir."/".$entry."/imsmanifest.xml")) {
-                                if ($loglevel > 2) { Log::notice(".  .. and found $courses_dir/$entry/imsmanifest.xml!"); }
+                                if ($loglevel > 2) { $app['monolog']->addInfo(".  .. and found $courses_dir/$entry/imsmanifest.xml!"); }
                                 if (!in_array($tmp_path."/".$entry."/imsmanifest.xml",$scormdocuments_lps)) {
-                                    if ($loglevel > 2){ Log::notice("  Recording.<br />"); }
+                                    if ($loglevel > 2){ $app['monolog']->addInfo("  Recording.<br />"); }
                                     $scormdocuments_lps[] = $tmp_path."/".$entry;
                                 }
                             }
@@ -690,7 +689,7 @@ while ($course_row = Database::fetch_array($res_crs)) {
                     }
                 }
             } else {
-                if ($loglevel > 2) { Log::notice("  Found scormdocument $tmp_path in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm, treating it."); }
+                if ($loglevel > 2) { $app['monolog']->addInfo("  Found scormdocument $tmp_path in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm, treating it."); }
                 $scormdocuments_lps[] = $tmp_path;
             }
         }
@@ -736,9 +735,9 @@ while ($course_row = Database::fetch_array($res_crs)) {
                             //echo "Checking if manifest exists in ".$courses_dir.$entry."/imsmanifest.xml<br />";
                             if (is_file($courses_dir.$entry."/imsmanifest.xml")) {
                                 //echo "found $courses_dir/$entry/imsmanifest.xml!<br />";
-                                if ($loglevel > 2) { Log::notice(".  .. and found $courses_dir/$entry/imsmanifest.xml!"); }
+                                if ($loglevel > 2) { $app['monolog']->addInfo(".  .. and found $courses_dir/$entry/imsmanifest.xml!"); }
                                 if (!in_array($entry."/imsmanifest.xml", $scormdocuments_lps)) {
-                                    if ($loglevel > 2) { Log::notice("  Recording.<br />"); }
+                                    if ($loglevel > 2) { $app['monolog']->addInfo("  Recording.<br />"); }
                                     //echo "Recording $entry<br />";
                                     $scormdocuments_lps[] = $entry;
                                 }
@@ -756,7 +755,7 @@ while ($course_row = Database::fetch_array($res_crs)) {
     $scorms[$my_course_code] = array();
 
     $sql_paths = "SELECT * FROM $scorm_main WHERE dokeosCourse = '".$my_course_code."'";
-    if ($loglevel > 0) { Log::notice("$sql_paths"); }
+    if ($loglevel > 0) { $app['monolog']->addInfo("$sql_paths"); }
     $res_paths = Database::query($sql_paths);
     $num = Database::num_rows($res_paths);
     while ($scorm_row = Database::fetch_array($res_paths)) {
@@ -769,16 +768,16 @@ while ($course_row = Database::fetch_array($res_crs)) {
         if ($my_path == '/') {
             $my_path = '';
         }
-        if ($loglevel > 1) { Log::notice("++++Now opening $my_path"); }
+        if ($loglevel > 1) { $app['monolog']->addInfo("++++Now opening $my_path"); }
         if (!is_dir($courses_dir = $sys_course_path.''.$courses_dir_list[$my_course_code].'/scorm'.$my_path)) {
-            if ($loglevel > 1) { Log::notice("Path $my_content_id: $my_path doesn't exist in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm, skipping"); }
+            if ($loglevel > 1) { $app['monolog']->addInfo("Path $my_content_id: $my_path doesn't exist in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm, skipping"); }
             continue;
             // Avoid if contentTitle is not the name of an existing directory
         } elseif (!is_file($sys_course_path.$courses_dir_list[$my_course_code].'/scorm'.$my_path."/imsmanifest.xml")) {
-            if ($loglevel > 1) { Log::notice("!!imsmanifest.xml not found at ".$sys_course_path.$courses_dir_list[$my_course_code].'/scorm'.$my_path."/imsmanifest.xml, skipping"); }
+            if ($loglevel > 1) { $app['monolog']->addInfo("!!imsmanifest.xml not found at ".$sys_course_path.$courses_dir_list[$my_course_code].'/scorm'.$my_path."/imsmanifest.xml, skipping"); }
             continue;
         } else {
-            if ($loglevel > 1) { Log::notice("Found $my_path in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm".$mypath."/imsmanifest.xml, keeping it."); }
+            if ($loglevel > 1) { $app['monolog']->addInfo("Found $my_path in ".$sys_course_path.$courses_dir_list[$my_course_code]."/scorm".$mypath."/imsmanifest.xml, keeping it."); }
             $scorms[$my_course_code][$my_path] = $my_content_id;
         }
     }
@@ -787,7 +786,7 @@ while ($course_row = Database::fetch_array($res_crs)) {
     foreach ($scormdocuments_lps as $path) {
         if (!in_array($path,array_keys($scorms[$my_course_code]))) {
             // Add it (-1 means no ID)
-            if ($loglevel > 1) { Log::notice("** Scormdocument path $path wasn't recorded yet. Added."); }
+            if ($loglevel > 1) { $app['monolog']->addInfo("** Scormdocument path $path wasn't recorded yet. Added."); }
             $scorms[$my_course_code][$path] = -1;
         }
     }
@@ -801,7 +800,7 @@ $my_count = 0;
 foreach ($scorms as $mycourse => $my_paths) {
     $my_count += count($my_paths);
 }
-if ($loglevel > 0) { Log::notice("---- Scorms array now contains ".$mycount." paths to migrate. Starting migration..."); }
+if ($loglevel > 0) { $app['monolog']->addInfo("---- Scorms array now contains ".$mycount." paths to migrate. Starting migration..."); }
 
 /**
  * Looping through the SCO_MAIN table for SCORM learnpath attached to courses
@@ -813,9 +812,9 @@ foreach ($scorms as $my_course_code => $paths_list) {
   $course_lp_done = array();
   $db_name = $courses_id_full_table_prefix_list[$my_course_code];
   foreach ($paths_list as $my_path => $old_id) {
-    if ($loglevel > 1) { Log::notice("Migrating lp $my_path from course $my_course_code..."); }
+    if ($loglevel > 1) { $app['monolog']->addInfo("Migrating lp $my_path from course $my_course_code..."); }
     $i_count ++;
-    //Log::notice('New LP - Migration script - Content '.$i_count.' on '.$num.' (course '.$scorm['dokeosCourse'].')');
+    //$app['monolog']->addInfo('New LP - Migration script - Content '.$i_count.' on '.$num.' (course '.$scorm['dokeosCourse'].')');
     // Check whether there is no embedded learnpaths into other learnpaths (one root-level and another embedded)
     $embedded = false;
     foreach ($course_lp_done as $tmp_lp) {
@@ -826,7 +825,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
             // Let it be
         } else {
             // This lp is embedded inside another lp who's imsmanifest exists, so prevent from parsing
-            if ($loglevel > 1) { Log::notice("LP $my_path is embedded into $tmp_lp, ignoring..."); }
+            if ($loglevel > 1) { $app['monolog']->addInfo("LP $my_path is embedded into $tmp_lp, ignoring..."); }
             $embedded = true;
             continue;
         }
@@ -840,7 +839,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
     $my_path = $my_path;
     $my_name = basename($my_path);
 
-    if ($loglevel > 1) { Log::notice("Try importing LP $my_path from imsmanifest first as it is more reliable"); }
+    if ($loglevel > 1) { $app['monolog']->addInfo("Try importing LP $my_path from imsmanifest first as it is more reliable"); }
 
     // Setup the ims path (path to the imsmanifest.xml file)
     //echo "Looking for course with code ".$lp_course_code[$my_content_id]." (using $my_content_id)<br />\n";
@@ -855,7 +854,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
         $oScorm = new scorm();
         // Check whether imsmanifest.xml exists at this location. If not, ignore the imsmanifest.
         // That should have been done before already, now.
-        if ($loglevel > 1) { Log::notice("Found imsmanifest ($ims), importing..."); }
+        if ($loglevel > 1) { $app['monolog']->addInfo("Found imsmanifest ($ims), importing..."); }
         if (!empty($sco_middle_path)) { $oScorm->subdir = $sco_middle_path; } //this sets the subdir for the scorm package inside the scorm dir
         // Parse manifest file
         $manifest = $oScorm->parse_manifest($ims);
@@ -864,7 +863,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
         //TODO: Add code to update the path in that new lp created, as it probably uses / where
         // $sco_path_temp should be used...
         $lp_ids[$my_content_id] = $oScorm->lp_id; // Contains the old LP ID => the new LP ID
-        if ($loglevel > 1) { Log::notice(" @@@ Created scorm lp ".$oScorm->lp_id." from imsmanifest [".$ims."] in course $my_course_code"); }
+        if ($loglevel > 1) { $app['monolog']->addInfo(" @@@ Created scorm lp ".$oScorm->lp_id." from imsmanifest [".$ims."] in course $my_course_code"); }
         $lp_course[$my_content_id] = $courses_id_list[$my_course_code]; // Contains the old learnpath ID => the course DB name
         $lp_course_code[$my_content_id] = $my_course_code;
         $max_dsp_lp++;
@@ -945,7 +944,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
 
     } else {
         //echo "Could not find $ims... Proceeding from database...(line ".__LINE__.")<br />";
-        if ($loglevel > 1) { Log::notice("This is a normal SCORM path"); }
+        if ($loglevel > 1) { $app['monolog']->addInfo("This is a normal SCORM path"); }
         $scorm_lp_paths[$my_content_id]['path'] = $my_path;
         //$scorm_lp_paths[$my_content_id]['ims'] = '';
         $table_name = $db_name.$new_lp;
@@ -972,7 +971,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
                 "'Unknown'," .
                 "'scorm_api.php'" .
                 ")";
-        if ($loglevel > 1) { Log::notice("$sql_ins"); }
+        if ($loglevel > 1) { $app['monolog']->addInfo("$sql_ins"); }
         $sql_res = Database::query($sql_ins);
         $in_id = Database::insert_id();
         if (!$in_id) die('Could not insert scorm lp: '.$sql_ins);
@@ -994,7 +993,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
         // Check whether imsmanifest.xml exists at this location. If not, ignore the imsmanifest.
         // That should have been done before already, now.
         if (!is_file($scorm_lp_paths[$my_content_id]['ims'])) {
-            if ($loglevel > 1) { Log::notice("!!! imsmanifest file not found at ".$scorm_lp_paths[$my_content_id]['ims'].' for old lp '.$my_content_id.' and new '.$lp_ids[$my_content_id]); }
+            if ($loglevel > 1) { $app['monolog']->addInfo("!!! imsmanifest file not found at ".$scorm_lp_paths[$my_content_id]['ims'].' for old lp '.$my_content_id.' and new '.$lp_ids[$my_content_id]); }
             $manifest = false;
         } else {
             //echo "Parsing ".$scorm_lp_paths[$my_content_id]['ims']."<br />\n";
@@ -1009,7 +1008,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
                         "SET name = '$my_lp_title', " .
                         "default_encoding = '".strtoupper($oScorm->manifest_encoding)."' " .
                         "WHERE id = ".$lp_ids[$my_content_id];
-                if ($loglevel > 1) { Log::notice("Updating title and encoding: ".$my_sql); }
+                if ($loglevel > 1) { $app['monolog']->addInfo("Updating title and encoding: ".$my_sql); }
                 $my_res = Database::query($my_sql);
             }
         }
@@ -1280,5 +1279,5 @@ foreach ($scorms as $my_course_code => $paths_list) {
 fclose($fh);
 fclose($fh_revert);
 fclose($fh_res);
-if ($loglevel > 0) { Log::notice("All done!"); }
+if ($loglevel > 0) { $app['monolog']->addInfo("All done!"); }
 //echo "</body></html>";

+ 11 - 14
main/install/update-files-1.6.x-1.8.0.inc.php

@@ -18,11 +18,9 @@
  *
  * @package chamilo.install
  */
-Log::notice('Entering file');
 
 function insert_db($db_name, $folder_name, $text)
 {
-
     // TODO: The (global?) variable $_course has not been declared/initialized.
     $_course['dbName'] = $db_name;
 
@@ -37,7 +35,7 @@ if (defined('SYSTEM_INSTALLATION')) {
     Database::select_db($dbNameForm);
     $db_name = $dbNameForm;
     $sql = "SELECT * FROM course";
-    Log::notice('Getting courses for files updates: ' . $sql);
+    $app['monolog']->addInfo('Getting courses for files updates: ' . $sql);
     $result = Database::query($sql);
 
     while ($courses_directories = Database::fetch_array($result)) {
@@ -47,13 +45,13 @@ if (defined('SYSTEM_INSTALLATION')) {
         $origCRS = $updatePath . 'courses/' . $courses_directories["directory"];
 
         if (!is_dir($origCRS)) {
-            Log::error('Directory ' . $origCRS . ' does not exist. Skipping.');
+            $app['monolog']->addError('Directory ' . $origCRS . ' does not exist. Skipping.');
             continue;
         }
         // Move everything to the new hierarchy (from old path to new path)
-        Log::notice('Renaming ' . $origCRS . ' to ' . $sys_course_path . $courses_directories["directory"]);
+        $app['monolog']->addInfo('Renaming ' . $origCRS . ' to ' . $sys_course_path . $courses_directories["directory"]);
         rename($origCRS, $sys_course_path . $courses_directories["directory"]);
-        Log::notice('Creating dirs in ' . $currentCourseRepositorySys);
+        $app['monolog']->addInfo('Creating dirs in ' . $currentCourseRepositorySys);
 
         // FOLDER DOCUMENT
         // document > audio
@@ -116,11 +114,11 @@ if (defined('SYSTEM_INSTALLATION')) {
         unlink($currentCourseRepositorySys . 'index.php');
         $fp = @ fopen($currentCourseRepositorySys . 'index.php', 'w');
         if ($fp) {
-            Log::error('Writing redirection file in ' . $currentCourseRepositorySys . 'index.php');
+            $app['monolog']->addError('Writing redirection file in ' . $currentCourseRepositorySys . 'index.php');
             fwrite($fp, $content);
             fclose($fp);
         } else {
-            Log::error('Could not open file ' . $currentCourseRepositorySys . 'index.php');
+            $app['monolog']->addError('Could not open file ' . $currentCourseRepositorySys . 'index.php');
         }
     }
 
@@ -135,17 +133,16 @@ if (defined('SYSTEM_INSTALLATION')) {
     copy($updatePath . 'claroline/inc/conf/mail.conf.php', $pathForm . 'main/inc/conf/mail.conf.php');
     copy($updatePath . 'claroline/inc/conf/profile.conf.inc.php', $pathForm . 'main/inc/conf/profile.conf.php');
 
-    Log::notice('Renaming ' . $updatePath . 'claroline/upload/users to ' . $pathForm . 'main/upload/users');
+    $app['monolog']->addInfo('Renaming ' . $updatePath . 'claroline/upload/users to ' . $pathForm . 'main/upload/users');
     rename($updatePath . 'claroline/upload/users', $pathForm . 'main/upload/users');
-    Log::notice('Renaming ' . $updatePath . 'claroline/upload/audio to ' . $pathForm . 'main/upload/audio');
+    $app['monolog']->addInfo('Renaming ' . $updatePath . 'claroline/upload/audio to ' . $pathForm . 'main/upload/audio');
     rename($updatePath . 'claroline/upload/audio', $pathForm . 'main/upload/audio');
-    Log::notice('Renaming ' . $updatePath . 'claroline/upload/images to ' . $pathForm . 'main/upload/images');
+    $app['monolog']->addInfo('Renaming ' . $updatePath . 'claroline/upload/images to ' . $pathForm . 'main/upload/images');
     rename($updatePath . 'claroline/upload/images', $pathForm . 'main/upload/images');
-    Log::notice('Renaming ' . $updatePath . 'claroline/upload/linked_files to ' . $pathForm . 'main/upload/linked_files');
+    $app['monolog']->addInfo('Renaming ' . $updatePath . 'claroline/upload/linked_files to ' . $pathForm . 'main/upload/linked_files');
     rename($updatePath . 'claroline/upload/linked_files', $pathForm . 'main/upload/linked_files');
-    Log::notice('Renaming ' . $updatePath . 'claroline/upload/video to ' . $pathForm . 'main/upload/video');
+    $app['monolog']->addInfo('Renaming ' . $updatePath . 'claroline/upload/video to ' . $pathForm . 'main/upload/video');
     rename($updatePath . 'claroline/upload/video', $pathForm . 'main/upload/video');
 } else {
-
     echo 'You are not allowed here !' . __FILE__;
 }

+ 0 - 2
main/install/update-files-1.8.3-1.8.4.inc.php

@@ -17,8 +17,6 @@
  * @package chamilo.install
  */
 
-Log::notice('Entering file');
-
 if (defined('SYSTEM_INSTALLATION')) {
 
 	// Edit the configuration file

+ 30 - 36
main/install/update-files-1.8.4-1.8.5.inc.php

@@ -16,43 +16,37 @@
  * version be available until the end of the installation.
  * @package chamilo.install
  */
-
-Log::notice('Entering file');
-
 if (defined('SYSTEM_INSTALLATION')) {
 
-	// Edit the configuration file
-	$file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
-	$fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
-	$found_version = false;
-	$found_stable = false;
-	foreach ($file as $line) {
-		$ignore = false;
-		if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
-			$found_version = true;
-			$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
-		} elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
-			$found_stable = true;
-			$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
-		} elseif (stripos($line, '?>') !== false) {
-			// Ignore the line
-			$ignore = true;
-		}
-		if (!$ignore) {
-			fwrite($fh, $line);
-		}
-	}
-	if (!$found_version) {
-		fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
-	}
-	if (!$found_stable) {
-		fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n");
-	}
-	fwrite($fh, '?>');
-	fclose($fh);
-
+    // Edit the configuration file
+    $file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
+    $fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
+    $found_version = false;
+    $found_stable = false;
+    foreach ($file as $line) {
+        $ignore = false;
+        if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
+            $found_version = true;
+            $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
+        } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
+            $found_stable = true;
+            $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
+        } elseif (stripos($line, '?>') !== false) {
+            // Ignore the line
+            $ignore = true;
+        }
+        if (!$ignore) {
+            fwrite($fh, $line);
+        }
+    }
+    if (!$found_version) {
+        fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
+    }
+    if (!$found_stable) {
+        fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n");
+    }
+    fwrite($fh, '?>');
+    fclose($fh);
 } else {
-
-	echo 'You are not allowed here !' . __FILE__;
-
+    echo 'You are not allowed here !'.__FILE__;
 }

+ 4 - 7
main/install/update-files-1.8.5-1.8.6.inc.php

@@ -18,8 +18,6 @@
  * @package chamilo.install
  */
 
-Log::notice('Entering file');
-
 if (defined('SYSTEM_INSTALLATION')) {
 
     // Edit the configuration file
@@ -64,7 +62,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 
     $db_name = $dbNameForm;
     $sql = "SELECT * FROM $db_name.course";
-    Log::notice('Getting courses for files updates: ' . $sql);
+    $app['monolog']->addInfo('Getting courses for files updates: ' . $sql);
     $result = iDatabase::query($sql);
 
     while ($courses_directories = iDatabase::fetch_array($result)) {
@@ -75,13 +73,13 @@ if (defined('SYSTEM_INSTALLATION')) {
         $origCRS = $updatePath . 'courses/' . $courses_directories['directory'];
 
         if (!is_dir($origCRS)) {
-            Log::error('Directory ' . $origCRS . ' does not exist. Skipping.');
+            $app['monolog']->addError('Directory ' . $origCRS . ' does not exist. Skipping.');
             continue;
         }
         // Move everything to the new hierarchy (from old path to new path)
-        Log::notice('Renaming ' . $origCRS . ' to ' . $sys_course_path . $courses_directories['directory']);
+        $app['monolog']->addInfo('Renaming ' . $origCRS . ' to ' . $sys_course_path . $courses_directories['directory']);
         rename($origCRS, $sys_course_path . $courses_directories['directory']);
-        Log::notice('Creating dirs in ' . $currentCourseRepositorySys);
+        $app['monolog']->addInfo('Creating dirs in ' . $currentCourseRepositorySys);
 
         // DOCUMENT FOLDER
         // document > shared_folder
@@ -116,6 +114,5 @@ if (defined('SYSTEM_INSTALLATION')) {
         }
     }
 } else {
-
     echo 'You are not allowed here !' . __FILE__;
 }

+ 0 - 2
main/install/update-files-1.8.6-1.8.6.1.inc.php

@@ -17,8 +17,6 @@
  * @package chamilo.install
  */
 
-Log::notice('Entering file');
-
 if (defined('SYSTEM_INSTALLATION')) {
 
 	// Edit the configuration file

+ 3 - 6
main/install/update-files-1.8.6.1-1.8.6.2.inc.php

@@ -12,8 +12,6 @@
  * @package chamilo.install
  */
 
-Log::notice('Entering file');
-
 if (defined('SYSTEM_INSTALLATION')) {
 
     // Edit the configuration file
@@ -59,7 +57,7 @@ if (defined('SYSTEM_INSTALLATION')) {
 
     $db_name = $dbNameForm;
     $sql = "SELECT * FROM $db_name.course";
-    Log::notice('Getting courses for files updates: ' . $sql);
+    $app['monolog']->addInfo('Getting courses for files updates: ' . $sql);
     $result = iDatabase::query($sql);
 
     if (iDatabase::num_rows($result) > 0) {
@@ -71,7 +69,7 @@ if (defined('SYSTEM_INSTALLATION')) {
                 $success = mkdir($path, $perm, true);
                 if(!$success){
                     $course_directory = $courses_directories['directory'];
-                    Log::error("Failed to create dir path: $path, course directory: $course_directory, sys course path: $sys_course_path, perm: , perm: $perm");
+                    $app['monolog']->addError("Failed to create dir path: $path, course directory: $course_directory, sys course path: $sys_course_path, perm: , perm: $perm");
                 }
             }
 
@@ -81,7 +79,7 @@ if (defined('SYSTEM_INSTALLATION')) {
                 $success = mkdir($path, $perm, true);
                 if(!$success){
                     $course_directory = $courses_directories['directory'];
-                    Log::error("Failed to create dir path: $path, course directory: $course_directory, sys course path: $sys_course_path, perm: $perm");
+                    $app['monolog']->addError("Failed to create dir path: $path, course directory: $course_directory, sys course path: $sys_course_path, perm: $perm");
                 }
             }
         }
@@ -93,6 +91,5 @@ if (defined('SYSTEM_INSTALLATION')) {
         mkdir($pathForm . 'home/default_platform_document/template_thumb', $perm);
     }
 } else {
-
     echo 'You are not allowed here !' . __FILE__;
 }

+ 0 - 2
main/install/update-files-1.8.6.2-1.8.7.inc.php

@@ -11,8 +11,6 @@
  * @package chamilo.install
  */
 
-Log::notice('Entering file');
-
 if (defined('SYSTEM_INSTALLATION')) {
 
 	// Edit the configuration file

+ 0 - 2
main/install/update-files-1.8.7-1.8.8.inc.php

@@ -11,8 +11,6 @@
  * @package chamilo.install
  */
 
-Log::notice('Entering file');
-
 if (defined('SYSTEM_INSTALLATION')) {
 
 	// Edit the configuration file

+ 0 - 2
main/install/update-files-1.8.8-1.9.0.inc.php

@@ -11,8 +11,6 @@
  * current configuration file.
  * @package chamilo.install
  */
-Log::notice('Entering file');
-
 if (defined('SYSTEM_INSTALLATION')) {
 
     $conf_dir = api_get_path(CONFIGURATION_PATH);