Fix upgrade process, remove chamilo.class.php

1.10.x
Julio Montoya 9 years ago
parent ce522a76ba
commit e377125c02
  1. 2
      index.php
  2. 3
      main/auth/shibboleth/lib/shibboleth_session.class.php
  3. 6
      main/inc/global.inc.php
  4. 28
      main/inc/lib/chamilo.class.php
  5. 45
      main/inc/lib/database.lib.php
  6. 2
      main/inc/lib/portfolio.class.php
  7. 20
      main/install/install.lib.php
  8. 84
      src/Chamilo/CoreBundle/Composer/ScriptHandler.php
  9. 8
      src/Chamilo/CoreBundle/DoctrineExtensions/DBAL/Types/UTCDateTimeType.php
  10. 8
      tests/main/inc/lib/main_api.lib.test.php

@ -103,8 +103,6 @@ if (!empty($_POST['submitAuth'])) {
Session::write('user_last_login_datetime',$user_last_login_datetime);
}
}
Database::free_result($result_last_login);
//Event::event_login();
}
// End login -- if ($_POST['submitAuth'])

@ -2,7 +2,6 @@
namespace Shibboleth;
use Chamilo;
use ChamiloSession as Session;
use Database;
@ -68,7 +67,7 @@ class ShibbolethSession
$this->logout();
Chamilo::session()->start();
Session::instance();
Session::write('_uid', $_uid);
global $_user;

@ -81,9 +81,6 @@ define('USERNAME_MAX_LENGTH', $defaultUserNameLength);
// Fix bug in IIS that doesn't fill the $_SERVER['REQUEST_URI'].
api_request_uri();
// This is for compatibility with MAC computers.
ini_set('auto_detect_line_endings', '1');
// Include the libraries that are necessary everywhere
require_once __DIR__.'/../../vendor/autoload.php';
@ -91,7 +88,6 @@ require_once __DIR__.'/../../vendor/autoload.php';
$libraryPath = api_get_path(LIBRARY_PATH);
// @todo convert this libs in classes
require_once $libraryPath.'database.constants.inc.php';
require_once $libraryPath.'text.lib.php';
require_once $libraryPath.'array.lib.php';
@ -191,7 +187,7 @@ $charset = 'UTF-8';
\Patchwork\Utf8\Bootup::initAll();
// Start session after the internationalization library has been initialized.
Chamilo::session()->start($alreadyInstalled);
ChamiloSession::instance()->start($alreadyInstalled);
// Remove quotes added by PHP - get_magic_quotes_gpc() is deprecated in PHP 5 see #2970

@ -1,28 +0,0 @@
<?php
/**
*
* @return ChamiloSession
*/
function session()
{
return Chamilo::session();
}
/**
* Description of chamilo
*
* @license see /license.txt
* @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
*/
class Chamilo
{
/**
*
* @return ChamiloSession
*/
static function session()
{
return ChamiloSession::instance();
}
}

@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\EntityManager;
use Chamilo\CoreBundle\DoctrineExtensions\DBAL\Types\UTCDateTimeType;
/**
* Class Database
@ -150,7 +151,10 @@ class Database
$sysPath."vendor/gedmo/doctrine-extensions/lib"
);
Type::overrideType('datetime', 'Chamilo\CoreBundle\DoctrineExtensions\DBAL\Types\UTCDateTimeType');
Type::overrideType(
Type::DATETIME,
'Chamilo\CoreBundle\DoctrineExtensions\DBAL\Types\UTCDateTimeType'
);
$listener = new \Gedmo\Timestampable\TimestampableListener();
$entityManager->getEventManager()->addEventSubscriber($listener);
@ -160,40 +164,10 @@ class Database
$listener = new \Gedmo\Sortable\SortableListener();
$entityManager->getEventManager()->addEventSubscriber($listener);
$connection = $entityManager->getConnection();
$this->setConnection($entityManager->getConnection());
$this->setConnection($connection);
$this->setManager($entityManager);
// A MySQL-specific implementation.
/*if (!isset($parameters['server'])) {
$parameters['server'] = @ini_get('mysql.default_host');
if (empty($parameters['server'])) {
$parameters['server'] = 'localhost:3306';
}
}
if (!isset($parameters['username'])) {
$parameters['username'] = @ini_get('mysql.default_user');
}
if (!isset($parameters['password'])) {
$parameters['password'] = @ini_get('mysql.default_password');
}
if (!isset($parameters['new_link'])) {
$parameters['new_link'] = false;
}
if (!isset($parameters['client_flags']) || empty($parameters['client_flags'])) {
$parameters['client_flags'] = 0;
}
$persistent = isset($parameters['persistent']) ? $parameters['persistent'] : null;
$server = isset($parameters['server']) ? $parameters['server'] : null;
$username = isset($parameters['username']) ? $parameters['username'] : null;
$password = isset($parameters['password']) ? $parameters['password'] : null;
$client_flag = isset($parameters['client_flags']) ? $parameters['client_flags'] : null;
$new_link = isset($parameters['new_link']) ? $parameters['new_link'] : null;
$client_flags = isset($parameters['client_flags']) ? $parameters['client_flags'] : null;
return $persistent
? mysql_pconnect($server, $username, $password, $client_flags)
: mysql_connect($server, $username, $password, $new_link, $client_flags);*/
}
/**
@ -224,7 +198,6 @@ class Database
return trim($string, "'");
}
/**
* Gets the array from a SQL result (as returned by Database::query)
*
@ -331,7 +304,7 @@ class Database
}
/**
* @param $query
* @param string $query
*
* @return Statement
*
@ -351,7 +324,7 @@ class Database
*/
public static function customOptionToDoctrineOption($option)
{
switch($option) {
switch ($option) {
case 'ASSOC':
return PDO::FETCH_ASSOC;
break;

@ -287,7 +287,7 @@ class PortfolioController
*/
function course_code()
{
return Chamilo::session()->course()->code();
return ChamiloSession::instance()->course()->code();
}
/**

@ -1944,6 +1944,11 @@ function migrate($chamiloVersion, EntityManager $manager)
}
}
/**
* @param EntityManager $em
*
* @throws \Doctrine\DBAL\DBALException
*/
function fixIds(EntityManager $em)
{
$connection = $em->getConnection();
@ -2174,7 +2179,6 @@ function fixIds(EntityManager $em)
}
}
$sql = "SELECT * FROM groups";
$result = $connection->executeQuery($sql);
$groups = $result->fetchAll();
@ -2377,7 +2381,6 @@ function fixIds(EntityManager $em)
}
}
}
}
/**
@ -2470,19 +2473,6 @@ function finishInstallation(
false //$isAdmin = false
);
/*
// Insert admin and Anonymous users.
$uniqueAdmin = sha1(uniqid(null, true));
$uniqueAnon = sha1(uniqid(null, true));
$sql = "INSERT INTO user (user_id, lastname, firstname, username, username_canonical, salt, password, auth_source, email, status, official_code, phone, creator_id, registration_date, expiration_date,active,openid,language) VALUES
(1, '$adminLastName','$adminFirstName','$loginForm','$loginForm', '$uniqueAdmin', '$encryptPassword','".PLATFORM_AUTH_SOURCE."','$emailForm',1,'ADMIN','$adminPhoneForm',1,NOW(),NULL,'1',NULL,'$languageForm'),
(2, 'Anonymous', 'Joe', 'anon', 'anon', '$uniqueAnon', '', 'platform', 'anonymous@localhost', 6, 'anonymous', NULL, 1, NOW(), NULL, 1,NULL,'$languageForm')";
//Database::query($sql);*/
// Insert user as admin
//$sql = "INSERT INTO admin VALUES(1, 1)";
//Database::query($sql);
// Set default language
$sql = "UPDATE language SET available=1 WHERE dokeos_folder = '$languageForm'";
Database::query($sql);

@ -26,10 +26,88 @@ class ScriptHandler
*/
public static function deleteOldFilesFrom19x()
{
$path = __DIR__.'/../../../../main/inc/lib/symfony/';
if (is_dir($path) && is_writable($path)) {
self::rmdirr($path);
$paths = [
__DIR__.'/../../../../main/conference/',
__DIR__.'/../../../../main/course_notice/',
__DIR__.'/../../../../main/metadata/',
__DIR__.'/../../../../main/reservation/',
__DIR__.'/../../../../main/inc/lib/symfony/',
__DIR__.'/../../../../main/inc/entity/',
//__DIR__.'/../../../../main/inc/lib/phpdocx/',
__DIR__.'/../../../../main/inc/lib/phpqrcode/',
__DIR__.'/../../../../main/inc/lib/fckeditor',
//__DIR__.'/../../../../main/inc/lib/htmlpurifier/',
__DIR__.'/../../../../main/inc/lib/mpdf/',
__DIR__.'/../../../../main/inc/lib/symfony/',
__DIR__.'/../../../../main/inc/lib/system/media/renderer',
__DIR__.'/../../../../main/inc/lib/system/io',
__DIR__.'/../../../../main/inc/lib/system/net',
__DIR__.'/../../../../main/inc/lib/system/text/',
__DIR__.'/../../../../main/inc/lib/tools/',
__DIR__.'/../../../../main/inc/lib/pchart/',
];
$files = [
__DIR__.'/../../../../main/admin/statistics/statistics.lib.php',
__DIR__.'/../../../../main/inc/lib/main_api.lib.php',
__DIR__.'/../../../../main/exercice/export/scorm/scorm_export.php',
__DIR__.'/../../../../main/exercice/export/qti/qti_export.php',
__DIR__.'/../../../../main/exercice/export/qti/qti_classes.php',
//__DIR__.'/../../../../main/inc/lib/nusoap/class.soapclient.php',
__DIR__.'/../../../../main/inc/lib/nusoap/nusoap.php',
__DIR__.'/../../../../main/admin/admin_page.class.php',
__DIR__.'/../../../../main/inc/lib/autoload.class.php',
__DIR__.'/../../../../main/inc/autoload.inc.php',
__DIR__.'/../../../../main/inc/lib/uri.class.php',
__DIR__.'/../../../../main/inc/lib/db.class.php',
__DIR__.'/../../../../main/install/i_database.class.php',
__DIR__.'/../../../../main/inc/lib/phpmailer/test/phpmailerTest.php',
__DIR__.'/../../../../main/inc/lib/xht.lib.php',
__DIR__.'/../../../../main/inc/lib/xmd.lib.php',
__DIR__.'/../../../../main/inc/lib/entity.class.php',
__DIR__.'/../../../../main/inc/lib/entity_repository.class.php',
__DIR__.'/../../../../main/install/install.class.php',
__DIR__.'/../../../../main/inc/lib/javascript.class.php',
__DIR__.'/../../../../main/inc/lib/course.class.php',
__DIR__.'/../../../../main/inc/lib/document.class.php',
__DIR__.'/../../../../main/inc/lib/item_property.class.php',
__DIR__.'/../../../../main/inc/lib/chamilo.class.php',
__DIR__.'/../../../../main/inc/lib/events.lib.inc.php',
__DIR__.'/../../../../main/inc/lib/ezpdf/class.ezpdf.php',
__DIR__.'/../../../../main/inc/lib/current_user.class.php',
__DIR__.'/../../../../main/inc/lib/current_course.class.php',
__DIR__.'/../../../../main/inc/lib/response.class.php',
__DIR__.'/../../../../main/inc/lib/result_set.class.php',
__DIR__.'/../../../../main/inc/lib/session_handler.class.php',
__DIR__.'/../../../../main/exercice/testcategory.class.php',
__DIR__.'/../../../../main/inc/lib/WCAG/WCAG_rendering.php',
__DIR__.'/../../../../main/inc/lib/zip.class.php',
__DIR__.'/../../../../main/inc/lib/student_publication.class.php',
__DIR__.'/../../../../main/inc/lib/ajax_controller.class.php',
__DIR__.'/../../../../main/inc/lib/system/closure_compiler.class.php',
__DIR__.'/../../../../main/inc/lib/system/code_utilities.class.php',
__DIR__.'/../../../../main/inc/lib/controller.class.php',
__DIR__.'/../../../../main/inc/lib/system/text/converter.class.php',
__DIR__.'/../../../../main/inc/lib/course_entity_repository.class.php',
__DIR__.'/../../../../main/inc/lib/course_entity.class.php',
__DIR__.'/../../../../main/inc/lib/cache.class.php',
__DIR__.'/../../../../main/inc/lib/system/web/request_server.class.php',
__DIR__.'/../../../../main/inc/lib/system/session.class.php',
__DIR__.'/../../../../main/inc/lib/page.class.php',
__DIR__.'/../../../../main/inc/lib/mail.lib.inc.php',
__DIR__.'/../../../../main/admin/system_management.php',
];
foreach ($paths as $path) {
if (is_dir($path) && is_writable($path)) {
self::rmdirr($path);
}
}
$fs = new Filesystem();
$fs->remove($files);
}
private static function rmdirr($dirname, $delete_only_content_in_folder = false, $strict = false)

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\DoctrineExtensions\DBAL\Types;
@ -8,12 +9,16 @@ use Doctrine\DBAL\Types\DateTimeType;
/**
* Save datetime values in UTC in the database
*
* @package Chamilo\CoreBundle\DoctrineExtensions\DBAL\Types
*/
class UTCDateTimeType extends DateTimeType
{
static private $utc = null;
/**
* {@inheritdoc}
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value === null) {
@ -29,6 +34,9 @@ class UTCDateTimeType extends DateTimeType
return $value->format($platform->getDateTimeFormatString());
}
/**
* {@inheritdoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {

@ -139,14 +139,6 @@ class TestMainApi extends UnitTestCase {
$this->assertTrue($res);
ob_end_clean();
}
function testApiSessionStart(){
if (!headers_sent()) {
$res = Chamilo::session()->start($already_sintalled=true);
}
$this->assertTrue(is_null($res));
}
// function testApiSessionRegister(){
// $$variable[session_register]=false;
// global $$variable;

Loading…
Cancel
Save