Updating vendors

1.10.x
Julio Montoya 12 years ago
parent 9b27f561a9
commit 5f7d19f3e7
  1. 1
      vendor/alchemy/binary-driver/.gitignore
  2. 1
      vendor/alchemy/ghostscript/.gitignore
  3. 6
      vendor/alchemy/zippy/.gitignore
  4. 0
      vendor/alchemy/zippy/tests/Alchemy/Zippy/Tests/Resource/input/path/to/a/.gitignore
  5. 2
      vendor/autoload.php
  6. 6
      vendor/braincrafted/bootstrap-bundle/Bc/Bundle/BootstrapBundle/.gitignore
  7. 4
      vendor/braincrafted/bootstrap-bundle/Bc/Bundle/BootstrapBundle/README.md
  8. 4
      vendor/bt51/gaufrette-serviceprovider/.gitignore
  9. 7
      vendor/chamilo/chash/.gitignore
  10. 140
      vendor/chamilo/chash/README.md
  11. 19
      vendor/chamilo/chash/chash.php
  12. 5
      vendor/chamilo/chash/composer.json
  13. 569
      vendor/chamilo/chash/composer.lock
  14. 4
      vendor/chamilo/chash/createPhar.php
  15. 122
      vendor/chamilo/chash/src/Chash/Command/Database/ImportCommand.php
  16. 85
      vendor/chamilo/chash/src/Chash/Command/Files/CleanDeletedDocumentsCommand.php
  17. 179
      vendor/chamilo/chash/src/Chash/Command/Files/ConvertVideosCommand.php
  18. 12
      vendor/chamilo/chash/src/Chash/Command/Installation/CommonCommand.php
  19. 8
      vendor/chamilo/chash/src/Chash/Command/Installation/InstallCommand.php
  20. 49
      vendor/chamilo/chash/src/Chash/Command/Installation/UpgradeCommand.php
  21. 8
      vendor/chamilo/chash/src/Chash/Command/Installation/WipeCommand.php
  22. 230
      vendor/chamilo/chash/src/Chash/Command/Translation/TermsPackageCommand.php
  23. 20
      vendor/chamilo/chash/src/Chash/Helpers/ConfigurationHelper.php
  24. 7
      vendor/chamilo/chash/src/Chash/Resources/Database/1.8.8/migrate-db-1.8.7-1.8.8-pre.sql
  25. 57
      vendor/chamilo/chash/src/Chash/Resources/Database/1.8.8/update-db-1.8.7-1.8.8.inc.php
  26. 71
      vendor/chamilo/chash/src/Chash/Resources/Database/1.9.0/migrate-db-1.8.8-1.9.0-pre.sql
  27. 84
      vendor/chamilo/chash/src/Chash/Resources/Database/1.9.0/update-db-1.8.8-1.9.0.inc.php
  28. 12
      vendor/chamilo/chash/tests/Chash/Tests/ConsoleTest.php
  29. 5
      vendor/chamilo/chash/tests/Chash/Tests/Helpers/ConfigurationHelperTest.php
  30. 186
      vendor/composer/ClassLoader.php
  31. 41
      vendor/composer/autoload_classmap.php
  32. 9
      vendor/composer/autoload_psr4.php
  33. 11
      vendor/composer/autoload_real.php
  34. 10
      vendor/composer/composer/.gitignore
  35. 0
      vendor/composer/composer/bin/compile
  36. 0
      vendor/composer/composer/bin/composer
  37. 0
      vendor/composer/composer/bin/fetch-spdx-identifiers
  38. 0
      vendor/composer/composer/src/Composer/Command/DumpAutoloadCommand.php
  39. 0
      vendor/composer/composer/src/Composer/Console/Application.php
  40. 0
      vendor/composer/composer/src/Composer/Json/JsonFile.php
  41. 1648
      vendor/composer/installed.json
  42. 2
      vendor/dflydev/doctrine-orm-service-provider/.gitignore
  43. 2
      vendor/dflydev/doctrine-orm-service-provider/.travis.yml
  44. 2
      vendor/dflydev/doctrine-orm-service-provider/README.md
  45. 4
      vendor/dflydev/doctrine-orm-service-provider/changelog.md
  46. 1
      vendor/dflydev/doctrine-orm-service-provider/composer.json
  47. 10
      vendor/dflydev/doctrine-orm-service-provider/src/Dflydev/Pimple/Provider/DoctrineOrm/DoctrineOrmServiceProvider.php
  48. 3
      vendor/doctrine/annotations/.gitignore
  49. 3
      vendor/doctrine/cache/.gitignore
  50. 1
      vendor/doctrine/collections/.gitignore
  51. 9
      vendor/doctrine/common/.gitignore
  52. 3
      vendor/doctrine/common/.gitmodules
  53. 2
      vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
  54. 3
      vendor/doctrine/common/tests/.gitignore
  55. 15
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php
  56. 8
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
  57. 13
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php
  58. 22
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
  59. 2
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
  60. 2
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php
  61. 2
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
  62. 48
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
  63. 11
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php
  64. 11
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
  65. 18
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
  66. 1
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
  67. 13
      vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php
  68. 8
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php
  69. 14
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php
  70. 2
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php
  71. 20
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
  72. 8
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
  73. 8
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
  74. 16
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
  75. 0
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php
  76. 0
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php
  77. 2
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Version.php
  78. 8
      vendor/doctrine/migrations/.gitignore
  79. 4
      vendor/doctrine/migrations/.travis.yml
  80. 1
      vendor/doctrine/migrations/build.properties.dev
  81. 67
      vendor/doctrine/migrations/build.xml
  82. 10
      vendor/doctrine/migrations/lib/Doctrine/DBAL/Migrations/AbstractMigration.php
  83. 4
      vendor/doctrine/migrations/lib/Doctrine/DBAL/Migrations/Tools/Console/Command/AbstractCommand.php
  84. 2
      vendor/doctrine/migrations/lib/Doctrine/DBAL/Migrations/Tools/Console/Command/ExecuteCommand.php
  85. 1
      vendor/doctrine/migrations/lib/Doctrine/DBAL/Migrations/Tools/Console/Command/VersionCommand.php
  86. 9
      vendor/doctrine/migrations/package.php
  87. 0
      vendor/doctrine/orm/bin/doctrine
  88. 0
      vendor/doctrine/orm/bin/doctrine.php
  89. 0
      vendor/doctrine/orm/docs/bin/generate-docs.sh
  90. 2
      vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php
  91. 0
      vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php
  92. 2
      vendor/evenement/evenement/.gitignore
  93. 1
      vendor/ezyang/htmlpurifier/.gitattributes
  94. 24
      vendor/ezyang/htmlpurifier/.gitignore
  95. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README
  96. 0
      vendor/ezyang/htmlpurifier/maintenance/compile-doxygen.sh
  97. 0
      vendor/ezyang/htmlpurifier/maintenance/flush-definition-cache.php
  98. 0
      vendor/ezyang/htmlpurifier/maintenance/generate-entity-file.php
  99. 0
      vendor/ezyang/htmlpurifier/maintenance/generate-standalone.php
  100. 0
      vendor/ezyang/htmlpurifier/maintenance/merge-library.php
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,6 @@
/tests/phpunit_report
/nbproject/
/vendor/
/docs/build
composer.phar

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInitd3dd5c326d3e3d13b67daf6fbedc97d2::getLoader();
return ComposerAutoloaderInit12fc675918971fe55c8142ceb23d2d09::getLoader();

@ -0,0 +1,6 @@
vendor/
Resources/docs/code-coverage
phpunit.xml
Resources/public/js/bootstrap.compiled*.js
Resources/public/css/bootstrap.compiled*.css

@ -99,3 +99,7 @@ License
- The bundle is licensed under the [MIT License](http://opensource.org/licenses/MIT)
- The CSS and Javascript from the Twitter Bootstrap are licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/braincrafted/bootstrap-bundle/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

@ -0,0 +1,4 @@
vendor/
phpunit.xml
composer.lock
*.DS_Store

@ -0,0 +1,7 @@
# IDE settings
.idea
.idea/*
.idea/dictionaries/*
.idea/cssxfire.xml
/vendor

@ -16,6 +16,8 @@ Note: If you don't have Composer installed, check http://getcomposer.org/downloa
Usage
====================
Here are a few examples of how you can use Chash:
In a Chamilo installation folder located in "/var/www/chamilo"
cd /var/www/chamilo
@ -41,56 +43,61 @@ Inside a chamilo folder execute db:sql_cli in order to enter to the SQL client o
php /path/chash.php db:sql_cli --conf=main/inc/conf/configuration.php
Building the chash.phar file
====================
If you have configured Chash globally (see below), from any Chamilo directory:
In order to generate the executable chash.phar file. You have to set first this php setting (in your cli php configuration file).
chash translation:disable french
For example in Ubuntu /etc/php5/cli/php.ini
phar.readonly = Off
Building the chash.phar file
====================
You need to download the third parties libraries via composer:
This procedure is only required once, and is generally for developers. If you update chash frequently, you'll have to go through this each time you update, but never more than that.
composer update --no-dev --prefer-dist
You need to have curl (in order to download packages required to build chash.phar)
apt-get install php5-curl
If you don't have composer installed on your computer, you can just do the following to download and install it and run the command above (make sure you have PHP5 enabled on the command line):
curl -sS https://getcomposer.org/installer | php
php5 composer.phar update --no-dev --prefer-dist
Remember to add execution permissions to the phar file.
In order to generate the executable chash.phar file. You have to set first this php setting (in your cli php configuration file).
For example in Ubuntu /etc/php5/cli/php.ini
You need to have curl (in order to download packages)
phar.readonly = Off
apt-get install php5-curl
(or you can also use the "-d phar.readonly=0" option as described below)
You need to download the required third parties libraries via composer (this might take a few minutes):
cd chash
composer update --no-dev --prefer-dist
Then you can call the php createPhar.php file. A new chash.phar file will be created.
Example:
In detail:
cd chash
composer update --no-dev
php -d phar.readonly=0 createPhar.php
chmod +x chash.phar
sudo ln -s /path/to/chash.phar /usr/local/bin/chash
Then you can call the chash.phar file in your Chamilo installation
cd /var/www/chamilo
chash
If you're using php 5.3 with suhosin the phar will not be executed you can try this:
If you're using php 5.3 with suhosin, the phar will not be executed. You can try this:
php -d suhosin.executor.include.whitelist="phar" chash.phar
or you can change this setting in your /etc/php5/cli/conf.d/suhosin.ini file (look for "executor"), although this might increase the vulnerability of your system.
or you can change this setting in your /etc/php5/cli/conf.d/suhosin.ini file
(look for "executor"), although this might increase the vulnerability of your
system. The location of the file may vary depending on your operating system.
Make it global
====================
To get the most out of Chash, you should move the chash.phar file to your
/usr/local/bin directory. You can do this getting inside the directory where
you put chash.phar and doing:
To get the most out of Chash, you should move the chash.phar file to
(or link from) your /usr/local/bin directory. You can do this getting inside
the directory where you put chash.phar and doing:
chmod +x chash.phar
sudo ln -s /path/to/chash.phar /usr/local/bin/chash
@ -100,45 +107,81 @@ typing
chash
It will give you the details of what command you can use to run it properly.
It will give you the details of the commands you can use to run it properly.
The most useful command to us until now has been the "chash database:sql" command,
The most useful command to us until now has been the "chash db:sql_cli" command,
which puts you directly into a MySQL client session.
Available commands:
====================
Available commands:
help Displays help for a command
list Lists commands
selfupdate Updates chash to the latest version
tasl Creates a sub-language
tdl Disables a (enabled) language
tel Enables a (disabled) language
tl Gets all languages as a list
tpl Gets or sets the platform language
usl Sets the users language to the one given
chamilo
chamilo:install Execute a Chamilo installation to a specified version
chamilo:status Show the information of the current Chamilo installation
chamilo:upgrade Execute a chamilo migration to a specified version or the latest available version.
chamilo:wipe Prepares a portal for a new installation
chamilo:install Execute a Chamilo installation to a specified version.
chamilo:status Show the information of the current Chamilo installation
chamilo:upgrade Execute a chamilo migration to a specified version or the latest available version
chamilo:wipe Prepares a portal for a new installation
chash
chash:self-update Updates chash to the latest version
chash:setup Setups the migration.yml
db
db:drop_databases Drops all databases from the current Chamilo install
db:dump Outputs a dump of the database
db:full_backup Generates a .tgz from the Chamilo files and database
db:restore Allows you to restore an SQL dump right into the active database of a given Chamilo installation (which will also erase all previous data in that database)
db:show_conn_info Shows database connection credentials for the current Chamilo install
db:sql_cli Enters to the SQL command line
db:sql_count Count the number of rows in a specific table
db:drop_databases Drops all databases from the current Chamilo install
db:dump Outputs a dump of the database
db:full_backup Generates a .tgz from the Chamilo files and database
db:restore Allows you to restore an SQL dump right into the active database of a given Chamilo installation (which will also erase all previous data in that database)
db:show_conn_info Shows database connection credentials for the current Chamilo install
db:sql_cli Enters to the SQL command line
db:sql_count Count the number of rows in a specific table
dbal
dbal:import Import SQL file(s) directly to Database.
dbal:run-sql Executes arbitrary SQL directly from the command line.
files
files:clean_archives Cleans the archives directory
files:clean_config_files Cleans the config files to help you re-install
files:show_mail_conf Returns the current mail config
files:clean_config_files Cleans the config files to help you re-install
files:clean_data_files Cleans the data directory
files:clean_deleted_documents Cleans the documents that were deleted but left as _DELETED_
files:clean_temp_folder Cleans the temp directory.
files:generate_temp_folders Generate temp folder structure: twig
files:set_permissions_after_install Set permissions
files:show_mail_conf Returns the current mail config
migrations
migrations:diff Generate a migration by comparing your current database to your mapping information.
migrations:execute Execute a single migration version up or down manually.
migrations:generate Generate a blank migration class.
migrations:migrate Execute a migration to a specified version or the latest available version.
migrations:status View the status of a set of migrations.
migrations:version Manually add and delete migration versions from the version table.
translation
translation:export_language Exports a Chamilo language package
translation:import_language Import a Chamilo language package
translation:platform_language Gets or sets the platform language
translation:add_sub_language Creates a sub-language
translation:disable Disables a (enabled) language
translation:enable Enables a (disabled) language
translation:export_language Exports a Chamilo language package
translation:import_language Import a Chamilo language package
translation:list Gets all languages as a list
translation:platform_language Gets or sets the platform language
translation:terms_package Generates a package of given language terms
user
user:change_pass Updates the user password to the one given
user:disable_admins Makes the given user admin on the main portal
user:make_admin Makes the given user admin on the main portal
user:reset_login Outputs login link for given username
user:set_language Sets the users language to the one given
user:change_pass Updates the user password to the one given
user:disable_admins Makes the given user admin on the main portal
user:make_admin Makes the given user admin on the main portal
user:reset_login Outputs login link for given username
user:set_language Sets the users language to the one given
Licensing
=========
@ -157,3 +200,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Mail: info@chamilo.org
Misc
====
[![Build Status](https://api.travis-ci.org/chamilo/chash.png)](https://travis-ci.org/chamilo/chash)

@ -6,16 +6,12 @@
* https://speakerdeck.com/hhamon/symfony-extending-the-console-component
* http://symfony.com/doc/2.0/components/console/introduction.html
*
* @author Yannick Warnier <yannick.warnier@beeznest.com>
* @author Julio Montoya <gugli100@gmail.com>
* @version 2.0
* @author Yannick Warnier <yannick.warnier@beeznest.com>
* @license This script is provided under the terms of the GNU/GPLv3+ license
*/
/**
* Security check: do not allow any other calling method than command-line
*/
/* Security check: do not allow any other calling method than command-line */
if (PHP_SAPI != 'cli') {
die("Chash cannot be called by any other method than the command line.");
}
@ -39,7 +35,7 @@ $application->addCommands(
array(
// DBAL Commands.
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
//new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// Migrations Commands.
new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(),
@ -55,6 +51,7 @@ $application->addCommands(
new Chash\Command\Chash\SelfUpdateCommand(),
new Chash\Command\Database\RunSQLCommand(),
new Chash\Command\Database\ImportCommand(),
new Chash\Command\Database\DumpCommand(),
new Chash\Command\Database\RestoreCommand(),
new Chash\Command\Database\SQLCountCommand(),
@ -63,11 +60,13 @@ $application->addCommands(
new Chash\Command\Database\ShowConnInfoCommand(),
new Chash\Command\Files\CleanDataFilesCommand(),
new Chash\Command\Files\CleanDeletedDocumentsCommand(),
new Chash\Command\Files\CleanTempFolderCommand(),
new Chash\Command\Files\CleanConfigFilesCommand(),
new Chash\Command\Files\MailConfCommand(),
new Chash\Command\Files\SetPermissionsAfterInstallCommand(),
new Chash\Command\Files\GenerateTempFileStructureCommand(),
new Chash\Command\Files\ConvertVideosCommand(),
new Chash\Command\Installation\InstallCommand(),
new Chash\Command\Installation\WipeCommand(),
@ -81,6 +80,7 @@ $application->addCommands(
new Chash\Command\Translation\ImportLanguageCommand(),
new Chash\Command\Translation\ListLanguagesCommand(),
new Chash\Command\Translation\PlatformLanguageCommand(),
new Chash\Command\Translation\TermsPackageCommand(),
new Chash\Command\User\ChangePassCommand(),
new Chash\Command\User\DisableAdminsCommand(),
@ -90,8 +90,3 @@ $application->addCommands(
)
);
$application->run();
//Interactive shell
//$shell = new Console\Shell($application);
//$shell->run();

@ -1,7 +1,9 @@
{
"name": "chamilo/chash",
"type": "library",
"description" : "Chamilo Shell",
"homepage": "http://www.chamilo.org",
"license": "GPL-3.0",
"support": {
"forum": "http://www.chamilo.org/forum",
"irc": "irc://irc.freenode.org/chamilo"
@ -26,6 +28,7 @@
"alchemy/zippy": "~0.1"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
"phpunit/phpunit": "3.7.*",
"mikey179/vfsstream": ">=1.2"
}
}

569
vendor/chamilo/chash/composer.lock generated vendored

File diff suppressed because it is too large Load Diff

@ -4,11 +4,13 @@
* phar.readonly = Off
*/
error_reporting(-1);
$phar = new Phar('chash.phar');
$phar->setSignatureAlgorithm(\Phar::SHA1);
$phar->startBuffering();
$phar->buildFromDirectory(__DIR__, '/\.php$/');
$phar->buildFromDirectory(__DIR__, '/\.sql/');
$defaultStub = $phar->createDefaultStub('chash.php');
@ -18,4 +20,4 @@ $stub = "#!/usr/bin/env php \n".$defaultStub;
// Add the stub
$phar->setStub($stub);
$phar->stopBuffering();
$phar->stopBuffering();

@ -0,0 +1,122 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Chash\Command\Database;
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console;
/**
* Task for executing arbitrary SQL that can come from a file or directly from
* the command line.
*
*
* @link www.doctrine-project.org
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class ImportCommand extends Console\Command\Command
{
/**
* @see Console\Command\Command
*/
protected function configure()
{
$this
->setName('dbal:import')
->setDescription('Import SQL file(s) directly to Database.')
->setDefinition(array(
new InputArgument(
'file', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'File path(s) of SQL to be executed.'
)
))
->setHelp(<<<EOT
Import SQL file(s) directly to Database.
EOT
);
}
/**
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$conn = $this->getHelper('db')->getConnection();
if (($fileNames = $input->getArgument('file')) !== null) {
foreach ((array) $fileNames as $fileName) {
if ( ! file_exists($fileName)) {
throw new \InvalidArgumentException(
sprintf("SQL file '<info>%s</info>' does not exist.", $fileName)
);
} else if ( ! is_readable($fileName)) {
throw new \InvalidArgumentException(
sprintf("SQL file '<info>%s</info>' does not have read permissions.", $fileName)
);
}
$output->write(sprintf("Processing file '<info>%s</info>'... ", $fileName));
$sql = file_get_contents($fileName);
if ($conn instanceof \Doctrine\DBAL\Driver\PDOConnection) {
// PDO Drivers
try {
$lines = 0;
$stmt = $conn->prepare($sql);
$stmt->execute();
do {
// Required due to "MySQL has gone away!" issue
$stmt->fetch();
$stmt->closeCursor();
$lines++;
} while ($stmt->nextRowset());
$output->write(sprintf('%d statements executed!', $lines) . PHP_EOL);
} catch (\PDOException $e) {
$output->write('error!' . PHP_EOL);
throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
}
} else {
// Non-PDO Drivers (ie. OCI8 driver)
$stmt = $conn->prepare($sql);
$rs = $stmt->execute();
if ($rs) {
$output->writeln('OK!' . PHP_EOL);
} else {
$error = $stmt->errorInfo();
$output->write('error!' . PHP_EOL);
throw new \RuntimeException($error[2], $error[0]);
}
$stmt->closeCursor();
}
}
}
}
}

@ -0,0 +1,85 @@
<?php
namespace Chash\Command\Files;
use Chash\Command\Database\CommonChamiloDatabaseCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class CleanDeletedDocmentsCommand
* Clean the courses/[CODE]/documents/ directory, removing all documents and folders marked DELETED
* @package Chash\Command\Files
*/
class CleanDeletedDocumentsCommand extends CommonChamiloDatabaseCommand
{
/**
*
*/
protected function configure()
{
parent::configure();
$this
->setName('files:clean_deleted_documents')
->setDescription('Cleans the documents that were deleted but left as _DELETED_')
->addOption(
'size',
null,
InputOption::VALUE_NONE,
'Show the total size of space that will be freed. Requires more processing'
)
->addOption(
'list',
null,
InputOption::VALUE_NONE,
'Show the complete list of files to be deleted before asking for confirmation'
);
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return bool|int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
$files = $this->getConfigurationHelper()->getDeletedDocuments();
if ($input->isInteractive()) {
$this->writeCommandHeader($output, 'Cleaning deleted documents.');
$list = $input->getOption('list'); //1 if the option was set
if ($list) {
if (count($files) > 0) {
foreach ($files as $file) {
$output->writeln($file->getRealpath());
}
} else {
$output->writeln('No file to be deleted in courses/ directory');
return;
}
}
$stats = $input->getOption('size'); //1 if the option was set
if ($stats) {
$size = 0;
foreach ($files as $file) {
$size += $file->getSize();
}
$output->writeln('Total size used by deleted documents: '.round(((float)$size/1024)/1024,2).'MB');
}
$dialog = $this->getHelperSet()->get('dialog');
if (!$dialog->askConfirmation(
$output,
'<question>Are you sure you want to clean the Chamilo deleted documents? (y/N)</question>',
false
)
) {
return;
}
}
$this->removeFiles($files, $output);
}
}

@ -0,0 +1,179 @@
<?php
namespace Chash\Command\Files;
use Chash\Command\Database\CommonChamiloDatabaseCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Filesystem\Filesystem;
/**
* Class ConvertVideosCommand
* Convert all videos found in the given directory (recursively) to the given format, using ffmpeg
* @package Chash\Command\Files
*/
class ConvertVideosCommand extends CommonChamiloDatabaseCommand
{
public $excluded = array();
public $ext;
public $origExt;
/**
*
*/
protected function configure()
{
parent::configure();
$this
->setName('files:convert_videos')
->setDescription('Converts all videos found in the given directory (recursively) to the given format, using the ffmpeg command line')
->addArgument(
'source',
InputArgument::REQUIRED,
'The directory containing the videos, as an absolute path'
)
->addOption(
'ext',
null,
InputOption::VALUE_REQUIRED,
'The extension of the files to be found and converted - defaults to "webm"'
)
->addOption(
'orig-ext',
null,
InputOption::VALUE_REQUIRED,
'The extension that we want to add to the original files. Defaults to "orig", so video.webm will be saved as video.orig.webm. Use "none" to skip saving the original.'
)
->addOption(
'fps',
null,
InputOption::VALUE_REQUIRED,
'The fps we want the final videos to be outputted in. Defaults to 24'
)
->addOption(
'bitrate',
null,
InputOption::VALUE_REQUIRED,
'The bitrate (~image quality) we want to export in, expressed in Kbits. Defaults to 512Kbits.'
);
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return bool|int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
if ($input->isInteractive()) {
$this->writeCommandHeader($output, 'Looking for videos...');
$confPath = $this->getConfigurationHelper()->getConfigurationFilePath();
$sysPath = $this->getConfigurationHelper()->getSysPathFromConfigurationFile($confPath);
$dir = $input->getArgument('source'); //1 if the option was set
if (substr($dir,0,1) != '/') {
$dir = $sysPath . $dir;
}
if (!is_dir($dir)) {
$output->writeln($dir. ' was not confirmed as a directory (if not starting with /, it is considered as relative to Chamilo\'s root folder)');
return;
}
$this->ext = $input->getOption('ext');
if (empty($this->ext)) {
$this->ext = 'webm';
}
$this->origExt = $input->getOption('orig-ext');
if (empty($this->origExt)) {
$this->origExt = 'orig';
}
$fps = $input->getOption('fps');
if (empty($fps)) {
$fps = '24';
}
$bitRate = $input->getOption('bitrate');
if (empty($bitRate)) {
$bitRate = '512';
}
$vcodec = 'copy';
if ($this->ext == 'webm') {
$vcodec = 'libvpx';
}
// Find the files we want to treat, using Finder selectors
$finder = new Finder();
$filter = function (\SplFileInfo $file, $ext, $orig)
{
$combinedExt = '.'.$orig.'.'.$ext;
$combinedExtLength = strlen($combinedExt);
$extLength = strlen('.' . $ext);
if (substr($file->getRealPath(),-$combinedExtLength) == $combinedExt) {
return false;
}
if (is_file(substr($file->getRealPath(),0,-$extLength) . $combinedExt)) {
$this->excluded[] = $file;
return false;
}
};
$finder->sortByName()->files()->in($dir)->name('*.'.$this->ext)->filter($filter, $this->ext, $this->origExt);
// Print the list of matching files we found
if (count($finder) > 0) {
$output->writeln('Videos found for conversion: ');
foreach ($finder as $file) {
$output->writeln($file->getRealpath());
}
} else {
if (count($this->excluded) > 0) {
$output->writeln('The system has detected several videos already converted: ');
foreach ($this->excluded as $file) {
$output->writeln('- '.$file->getRealPath());
}
}
$output->writeln('No video left to convert');
return;
}
$dialog = $this->getHelperSet()->get('dialog');
if (!$dialog->askConfirmation(
$output,
'<question>All listed videos will be altered and a copy of the original will be taken with a .orig.webm extension. Are you sure you want to proceed? (y/N)</question>',
false
)
) {
return;
}
$fs = new Filesystem();
$time = time();
$counter = 0;
$sizeNew = $sizeOrig = 0;
foreach ($finder as $file) {
$sizeOrig += $file->getSize();
$origName = $file->getRealPath();
$newName = substr($file->getRealPath(),0,-4).'orig.webm';
$fs->rename($origName, $newName);
$out = array();
$newNameCommand = preg_replace('/\s/','\ ',$newName);
$newNameCommand = preg_replace('/\(/','\(',$newNameCommand);
$newNameCommand = preg_replace('/\)/','\)',$newNameCommand);
$origNameCommand = preg_replace('/\s/','\ ',$origName);
$origNameCommand = preg_replace('/\(/','\(',$origNameCommand);
$origNameCommand = preg_replace('/\)/','\)',$origNameCommand);
$output->writeln('ffmpeg -i ' . $newNameCommand . ' -b ' . $bitRate . 'k -f ' . $this->ext . ' -vcodec ' . $vcodec . ' -acodec copy -r ' . $fps . ' ' . $origNameCommand);
$exec = @system('ffmpeg -i ' . $newNameCommand . ' -b ' . $bitRate . 'k -f ' . $this->ext . ' -vcodec ' . $vcodec . ' -acodec copy -r ' . $fps . ' ' . $origNameCommand, $out);
$sizeNew += filesize($origName);
$counter ++;
}
}
$output->writeln('');
$output->writeln('Done converting all videos from '.$dir);
$output->writeln('Total videos converted: ' . $counter . ' videos in ' . (time() - $time) .' seconds');
$output->writeln('Total size of old videos combined: ' . round($sizeOrig/(1024*1024)).'M');
$output->writeln('Total size of all new videos combined: ' . round($sizeNew/(1024*1024)).'M');
//$this->removeFiles($files, $output);
}
}

@ -880,6 +880,16 @@ class CommonCommand extends AbstractCommand
}
$em = \Doctrine\ORM\EntityManager::create($params, $config);
} else {
$databaseName = $params['dbname'];
switch ($dbInfo['database']) {
case 'statistics_database':
$databaseName = isset($_configuration['statistics_database']) ? $_configuration['statistics_database'] : $databaseName;
break;
case 'user_personal_database':
$databaseName = isset($_configuration['user_personal_database']) ? $_configuration['user_personal_database'] : $databaseName;
break;
}
$params['dbname'] = $databaseName;
$em = \Doctrine\ORM\EntityManager::create($params, $config);
}
}
@ -898,7 +908,7 @@ class CommonCommand extends AbstractCommand
{
$dryRun = $this->getConfigurationHelper()->getDryRun();
if (empty($files)) {
if (count($files) < 1) {
$output->writeln('<comment>No files found.</comment>');
return 0;
}

@ -8,6 +8,8 @@ use Doctrine\DBAL\Migrations\Tools\Console\Command\AbstractCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console;
use Symfony\Component\Yaml\Dumper;
@ -53,12 +55,12 @@ class InstallCommand extends CommonCommand
/**
* Executes a command via CLI
*
* @param Console\Input\InputInterface $input
* @param Console\Output\OutputInterface $output
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output)
{
// Test string
// sudo php /var/www/chash/chash.php chamilo:install --download-package --sitename=Chamilo --institution=Chami --institution_url=http://localhost/chamilo-test --encrypt_method=sha1 --permissions_for_new_directories=0777 --permissions_for_new_files=0777 --firstname=John --lastname=Doe --username=admin --password=admin --email=admin@example.com --language=english --phone=666 --driver=pdo_mysql --host=localhost --port=3306 --dbname=chamilo_test --dbuser=root --dbpassword=root master /var/www/chamilo-test

@ -5,6 +5,8 @@ namespace Chash\Command\Installation;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console;
use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Yaml\Parser;
@ -43,7 +45,6 @@ class UpgradeCommand extends CommonCommand
->addOption('update-installation', null, InputOption::VALUE_OPTIONAL, 'Updates the portal with the current zip file. http:// or /var/www/file.zip')
->addOption('temp-folder', null, InputOption::VALUE_OPTIONAL, 'The temp folder', '/tmp')
->addOption('download-package', null, InputOption::VALUE_OPTIONAL, 'Download the chamilo package', 'true')
->addOption('silent', null, InputOption::VALUE_NONE, 'Execute the migration without asking questions')
->addOption('linux-user', null, InputOption::VALUE_OPTIONAL, 'user', 'www-data')
->addOption('linux-group', null, InputOption::VALUE_OPTIONAL, 'group', 'www-data')
->addOption('custom-package', null, InputOption::VALUE_OPTIONAL, 'Custom zip package location.', '')
@ -55,12 +56,12 @@ class UpgradeCommand extends CommonCommand
/**
* Executes a command via CLI
*
* @param Console\Input\InputInterface $input
* @param Console\Output\OutputInterface $output
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output)
{
$startTime = time();
@ -107,7 +108,7 @@ class UpgradeCommand extends CommonCommand
$version = $originalVersion = $input->getArgument('version');
$path = $input->getOption('path');
$dryRun = $input->getOption('dry-run');
$silent = $input->getOption('silent') == true;
$silent = !$input->isInteractive();
$tempFolder = $input->getOption('temp-folder');
$downloadPackage = $input->getOption('download-package') == 'true' ? true : false;
@ -319,6 +320,7 @@ class UpgradeCommand extends CommonCommand
$this->setExtraDatabaseSettings($extraDatabaseSettings);
$this->setDoctrineSettings();
$conn = $this->getConnection();
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
if ($conn) {
$output->writeln("<comment>Connection to the database established.</comment>");
@ -341,7 +343,7 @@ class UpgradeCommand extends CommonCommand
if (isset($versionInfo['require_update']) && $versionInfo['require_update'] == true) {
// Greater than my current version.
$this->startMigration($courseList, $path, $versionItem, $dryRun, $output, $removeUnusedTables);
$this->startMigration($courseList, $path, $versionItem, $dryRun, $output, $removeUnusedTables, $input);
$oldVersion = $versionItem;
$output->writeln("----------------------------------------------------------------");
} else {
@ -400,13 +402,22 @@ class UpgradeCommand extends CommonCommand
* @param string $path
* @param string $toVersion
* @param bool $dryRun
* @param Console\Output\OutputInterface $output
* @param OutputInterface $output
* @param bool $removeUnusedTables
* @param InputInterface $mainInput
*
* @return bool
* @throws \Exception
*/
public function startMigration($courseList, $path, $toVersion, $dryRun, Console\Output\OutputInterface $output, $removeUnusedTables = false)
{
public function startMigration(
$courseList,
$path,
$toVersion,
$dryRun,
OutputInterface $output,
$removeUnusedTables = false,
InputInterface $mainInput
) {
// Cleaning query list.
$this->queryList = array();
@ -445,9 +456,13 @@ class UpgradeCommand extends CommonCommand
$output->writeln("<comment>Executing migrations:migrate ".$versionInfo['hook_to_doctrine_version']." --configuration=".$this->getMigrationConfigurationFile()."<comment>");
$input = new ArrayInput($arguments);
if ($this->commandLine == false) {
$input->setInteractive(false);
} else {
$input->setInteractive($mainInput->isInteractive());
}
$command->run($input, $output);
$output->writeln("<comment>Migration ended successfully</comment>");
@ -546,7 +561,7 @@ class UpgradeCommand extends CommonCommand
* Process the queryList array and executes queries to the correct section (main, user, course, etc)
*
* @param array $courseList
* @param Console\Output\OutputInterface $output
* @param OutputInterface $output
* @param $path
* @param $version
* @param $dryRun
@ -640,7 +655,7 @@ class UpgradeCommand extends CommonCommand
* Reads a sql file and adds queries in the queryList array.
*
* @param string $sqlFilePath
* @param Console\Output\OutputInterface $output
* @param OutputInterface $output
* @param string type
*/
public function fillQueryList($sqlFilePath, $output, $type)
@ -716,13 +731,13 @@ class UpgradeCommand extends CommonCommand
}
$databaseSection = array(
'main' => array(
'main' => array(
array(
'database' => 'main_database',
'status' => 'waiting'
)
),
'user' => array(
'user' => array(
array(
'database' => 'user_personal_database',
'status' => 'waiting'
@ -751,7 +766,7 @@ class UpgradeCommand extends CommonCommand
}
/**
* @param Console\Output\OutputInterface $output
* @param OutputInterface $output
* @param array $courseList
* @param string $path
* @param string $version
@ -796,7 +811,7 @@ class UpgradeCommand extends CommonCommand
}
/**
* @param Console\Output\OutputInterface $output
* @param OutputInterface $output
* @param array $courseList
* @param string $path
* @param string $section
@ -818,7 +833,7 @@ class UpgradeCommand extends CommonCommand
*
* @param string $file
* @param string $section
* @param Console\Output\OutputInterface $output
* @param OutputInterface $output
*
* @return array|bool
*/
@ -874,7 +889,7 @@ class UpgradeCommand extends CommonCommand
/**
* Creates the course tables with the prefix c_
* @param Console\Output\OutputInterface $output
* @param OutputInterface $output
* @param string $dryRun
* @return int
*/

@ -6,6 +6,8 @@ use Doctrine\DBAL\Migrations\Tools\Console\Command\AbstractCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console;
/**
@ -25,12 +27,12 @@ class WipeCommand extends CommonCommand
/**
* Executes a command via CLI
*
* @param Console\Input\InputInterface $input
* @param Console\Output\OutputInterface $output
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output)
{
// Arguments
$path = $input->getArgument('path');

@ -0,0 +1,230 @@
<?php
/**
* This script contains the TermsPackage command, made to simplify the live of
* translators by providing them with a list of the 10,000 most used words in
* their own language to make sure they can have a strong first impact.
* To make this work, you will have to have the original 10,000 most used words
* in English. You can either get them by sending an e-mail to ywarnier@chamilo.org
* or by starting the langstats scripts (check main/cron/lang/ and
* main/inc/global.inc.php ~600), then collecting the variables with the scripts
* in main/cron/lang/
* The present command serves only at the end of this process, to generate the
* corresponding language packages in other languages than English
* @package chamilo.chash.translation
*/
namespace Chash\Command\Translation;
use Chash\Command\Database\CommonChamiloDatabaseCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class ExportLanguageCommand
* @package Chash\Command\Translation
*/
class TermsPackageCommand extends CommonChamiloDatabaseCommand
{
/**
* Set the input variables and what will be shown in command helper
*/
protected function configure()
{
parent::configure();
$this
->setName('translation:terms_package')
->setDescription('Generates a package of given language terms')
//(provided in English), in a specific destination language. It requires a Chamilo installation to work as it needs the existing main/lang/ folder to produce the destination language files with as much data as possible.')
->addArgument(
'source',
InputArgument::REQUIRED,
'The directory containing the reference files and terms, in English'
)
->addArgument(
'language',
InputArgument::REQUIRED,
'The language in which you want the package of files and terms'
)
->addArgument(
'dest',
InputArgument::REQUIRED,
'The directory in which you want the package files to be put'
)
->addOption(
'tgz',
null,
InputOption::VALUE_NONE,
'Add this option to compress the files (including the directories and the original English form) into one .tar.gz file ready for shipping'
)
->addOption(
'new',
null,
InputOption::VALUE_NONE,
'Allow new languages (languages that do not exist yet). This will generate empty (but usable) translation files.'
);
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
$source = $input->getArgument('source');
$language = $input->getArgument('language');
$destination = $input->getArgument('dest');
$tgz = $input->getOption('tgz');
$allowNew = $input->getOption('new');
$_configuration = $this->getHelper('configuration')->getConfiguration();
$baseDir = $_configuration['root_sys'];
if (substr($baseDir,-1,1) != '/') {
$baseDir .= '/';
}
if (substr($source,-1,1) != '/') {
$source .= '/';
}
if (substr($destination,-1,1) != '/') {
$destination .= '/';
}
if (!is_dir($source)) {
$output->writeln('The directory '.$source.' does not seem to exist. The source directory must exist and contain the language files, similar to e.g. /var/www/chamilo/main/lang/english');
exit;
}
// Generate a folder name for saving the *partial* files in the original language - use suffix "_partial
$origLang = substr(substr($source,0,-1),strrpos(substr($source,0,-1),'/')).'_partial';
if (!is_dir($destination)) {
$output->writeln('The directory '.$destination.' does not seem to exist. The destination directory must exist in order for this script to write the results in a safe place');
exit;
}
if (!is_writeable($destination)) {
$output->writeln('The destination directory must be writeable. '.$destination.' seems not to be writeable now.');
exit;
}
if (empty($language)) {
$output->writeln('The destination language must be provided for this script to work. Received '.$language.', which could not be identified.');
exit;
}
$langDir = $baseDir.'main/lang/';
$listDir = scandir($langDir);
$langs = array();
foreach ($listDir as $lang) {
if (substr($lang,0,1) == '.') { continue; }
if (!is_dir($langDir.$lang)) { continue; }
$langs[] = $lang;
}
$new = false;
if (!in_array($language, $langs)) {
if (!$allowNew) {
$output->writeln('The destination language must be expressed as one of the directories available in your Chamilo installation. If you are exporting for the creation of a new language, use the --new option to ignore this warning');
exit;
} else {
$new = true;
}
}
if (is_dir($destination.$language)) {
if (!is_writeable($destination.$language)) {
$output->writeln('Destination directory '.$destination.$language.' already exists but is not writeable. Please make sure whoever launches this script has privileges to write in there.');
exit;
}
$output->writeln('Destination directory '.$destination.$language.' already exists. We recommend using an empty directory. Files in this directory will be overwritten if necessary. Sorry.');
} elseif (!@mkdir($destination.$language)) {
$output->writeln('For some reason, the directory creation returned an error for '.$destination.$language);
exit;
}
if (is_dir($destination.$origLang)) {
if (!is_writeable($destination.$origLang)) {
$output->writeln('Destination directory '.$destination.$origLang.' already exists but is not writeable. Please make sure whoever launches this script has privileges to write in there.');
exit;
}
$output->writeln('Destination directory '.$destination.$origLang.' already exists. We recommend using an empty directory. Files in this directory will be overwritten if necessary. Sorry.');
} elseif (!@mkdir($destination.$origLang)) {
$output->writeln('For some reason, the directory creation returned an error for '.$destination.$origLang);
exit;
}
// Start working on those files!
$listFiles = scandir($source);
$countVars = 0;
$countTranslatedVars = 0;
$countWords = 0;
$countTranslatedWords = 0;
$fileString = '<?php'."\n";
foreach ($listFiles as $file) {
if (substr($file,-1,1) == '.') { continue; }
$destFileLines = $fileString;
$origFileLines = $fileString;
$partialSourceFile = $langDir.$language.'/'.$file;
$output->writeln('Source File 2 = '.$partialSourceFile);
$sourceVars = $this->_getLangVars($source.$file);
$source2Vars = array();
if (is_file($partialSourceFile)) {
$source2Vars = $this->_getLangVars($partialSourceFile);
}
$source2Keys = array_keys($source2Vars);
foreach ($sourceVars as $var => $val) {
if (in_array($var, $source2Keys)) {
$destFileLines .= '$'.$var.'='.$source2Vars[$var]."\n";
$origFileLines .= '$'.$var.'='.$val."\n";
$countTranslatedVars++;
$countTranslatedWords += str_word_count($sourceVars[$var]);
} else {
$destFileLines .= '$'.$var.'="";'."\n";
$origFileLines .= '$'.$var.'='.$val."\n";
}
$countVars++;
$countWords += str_word_count($sourceVars[$var]);
}
$output->writeln('Writing to file '.$destination.$language.'/'.$file);
$w = file_put_contents($destination.$language.'/'.$file, $destFileLines);
$w = file_put_contents($destination.$origLang.'/'.$file, $origFileLines);
}
$output->writeln('Written translation files for packaging in '.$destination.$language.'.');
$output->writeln('Found '.$countVars.' variables, of which '.$countTranslatedVars.' were already translated (and '.($countVars-$countTranslatedVars).' are missing).');
$output->writeln('In words, there are '.$countWords.' words in total, of which only '.($countWords - $countTranslatedWords).' still need translating.');
if ($tgz) {
$output->writeln('Compressing as .tar.gz...');
chdir($destination);
exec('tar zcf '.$destination.$language.'.tar.gz '.$language);
$output->writeln('Written to '.$destination.$language.'.tar.gz');
$output->writeln('Removing work directory '.$destination.$language);
exec('rm -rf '.$destination.$language);
}
$output->writeln('Finished exporting language package.');
if (!$tgz) {
$output->writeln('Please make sure you review your work directory for possible cleaning.');
}
}
/**
* Gets all the variables in a language file as a hash
* This is a copy of the get_all_language_variable_in_file method in main/admin/sub_language.class.php
* @param string $file The asbolute path to the file from which to extract variables
* @return array Named array of variable => translation
*/
private function _getLangVars($file) {
$res_list = array();
if (!is_readable($file)) {
return $res_list;
}
$info_file = file($file);
foreach ($info_file as $line) {
if (substr($line, 0, 1) != '$') {
continue;
}
list($var, $val) = preg_split('/=/', $line, 2);
$var = trim($var);
$val = trim($val);
//remove the $ prefix
$var = substr($var, 1);
$res_list[$var] = $val;
}
return $res_list;
}
}

@ -47,6 +47,7 @@ class ConfigurationHelper extends Helper
public function chamiloVersions()
{
$versionList = array(
'1.8.6.2',
'1.8.7',
'1.8.8',
'1.8.8.2',
@ -334,6 +335,25 @@ class ConfigurationHelper extends Helper
return $finder;
}
/**
* Gets the documents and folders marked DELETED
* @return array
*/
public function getDeletedDocuments()
{
$finder = new Finder();
$sysPath = $this->getSysPath();
if (is_dir($sysPath.'courses')) {
$finder->in($sysPath.'courses/')->name('*DELETED*');
}
if (is_dir($sysPath.'data/courses')) {
$finder->in($sysPath.'data/courses/')->name('*DELETED*');
}
return $finder;
}
/**
* @return Finder

@ -289,11 +289,16 @@ UPDATE settings_current SET variable='chamilo_database_version' WHERE variable='
UPDATE settings_current SET selected_value = '1.8.8.14911' WHERE variable = 'chamilo_database_version';
-- xxSTATSxx
DROP PROCEDURE IF EXISTS AddColumnUnlessExists;
CREATE PROCEDURE AddColumnUnlessExists( IN dbName tinytext, IN tableName tinytext, IN fieldName tinytext, IN fieldDef text) BEGIN IF NOT EXISTS ( SELECT * FROM information_schema.COLUMNS WHERE column_name = fieldName and table_name = tableName and table_schema=dbName) THEN set @ddl=CONCAT('ALTER TABLE ',dbName,'.',tableName, ' ADD COLUMN ', fieldName, ' ',fieldDef); prepare stmt from @ddl; execute stmt; END IF;end;
call AddColumnUnlessExists(Database(), 'track_e_exercices', 'orig_lp_item_view_id', 'INT NOT NULL DEFAULT 0');
-- xxUSERxx
DROP PROCEDURE IF EXISTS dropIndexIfExists;
CREATE PROCEDURE dropIndexIfExists(in theTable varchar(128), in theIndexName varchar(128) ) BEGIN IF((SELECT COUNT(*) AS index_exists FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE() and table_name = theTable AND index_name = theIndexName) > 0) THEN SET @s = CONCAT('DROP INDEX `' , theIndexName , '` ON `' , theTable, '`'); PREPARE stmt FROM @s; EXECUTE stmt; END IF; END;
ALTER TABLE personal_agenda MODIFY id INT NOT NULL;
--ALTER TABLE personal_agenda DROP PRIMARY KEY;
ALTER TABLE personal_agenda ADD PRIMARY KEY (id);
call dropIndexIfExists('personal_agenda', 'idx_personal_agenda_user');

@ -19,11 +19,9 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
try {
if (!empty($courseList)) {
foreach ($courseList as $row_course) {
$prefix = $upgrade->getTablePrefix($_configuration, $row_course['db_name']);
$output->writeln('Updating course db: '.$row_course['db_name']);
$prefix = $upgrade->getTablePrefix($_configuration, $row_course['db_name']);
$table_lp_item_view = $prefix."lp_item_view";
$table_lp_view = $prefix."lp_view";
$table_lp_item = $prefix."lp_item";
@ -37,10 +35,11 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
}
if (empty($courseConnection)) {
$output->writeln("<info> We can't established a DB connection for this course: ".$row_course['db_name']);
$output->writeln("<info>We can't established a DB connection for this course: ".$row_course['db_name']);
}
// 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
/* 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
FROM $table_lp_item_view iv INNER JOIN $table_lp_view v
@ -49,7 +48,6 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
WHERE item_type = 'quiz'";
$result = $courseConnection->executeQuery($query);
//$output->writeln($query);
$rows = $result->fetchAll();
if (count($rows) > 0) {
@ -71,7 +69,9 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
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']} ";
WHERE item_type = 'quiz' AND
user_id = {$row['user_id']} AND
path = {$row['exercise_id']} ";
$sub_result = $courseConnection->executeQuery($sql);
$sub_rows = $sub_result->fetchAll();
$lp_item_view_id_list = array();
@ -82,10 +82,10 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
foreach ($exe_list as $exe_id) {
$lp_item_view_id = $lp_item_view_id_list[$i];
$update = "UPDATE track_e_exercices SET orig_lp_item_view_id = '$lp_item_view_id' WHERE exe_id = $exe_id ";
$update = "UPDATE track_e_exercices SET orig_lp_item_view_id = '$lp_item_view_id'
WHERE exe_id = $exe_id ";
$statsConnection->executeQuery($update);
$output->writeln($update);
}
}
}
@ -98,35 +98,42 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
$output->writeln('<comment>Updating main/stat/user db:</comment>');
$sql = "INSERT INTO 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') ";
$sql = "INSERT INTO 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') ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$id = $mainConnection->lastInsertId();
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '1', 'AtOnce',1) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '8', 'Daily',2) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '0', 'No',3) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$sql = "INSERT INTO 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')";
VALUES (4, 'mail_notify_message', 'MailNotifyMessage',1,1,'1')";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$id = $mainConnection->lastInsertId();
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '1', 'AtOnce',1) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '8', 'Daily',2) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '0', 'No',3) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
@ -136,13 +143,16 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
$output->writeln($sql);
$id = $mainConnection->lastInsertId();
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '1', 'AtOnce',1) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '8', 'Daily',2) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) ";
$sql = "INSERT INTO user_field_options (field_id, option_value, option_display_text, option_order)
VALUES ($id, '0', 'No',3) ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
@ -157,11 +167,13 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
// Adding course to default URL just in case.
// Check if already exists
$sql = "SELECT course_code FROM access_url_rel_course WHERE course_code = '".$row['code']."' AND access_url_id = 1";
$sql = "SELECT course_code FROM access_url_rel_course
WHERE course_code = '".$row['code']."' AND access_url_id = 1";
$result = $mainConnection->executeQuery($sql);
if ($result->rowCount() == 0) {
$sql = "INSERT INTO access_url_rel_course SET course_code = '".$row['code']."', access_url_id = '1' ";
$sql = "INSERT INTO access_url_rel_course
SET course_code = '".$row['code']."', access_url_id = '1' ";
$mainConnection->executeQuery($sql);
$output->writeln($sql);
}
@ -178,5 +190,4 @@ $update = function($_configuration, $mainConnection, $courseList, $dryRun, $outp
$mainConnection->rollback();
throw $e;
}
};

@ -38,7 +38,6 @@ UNLOCK TABLES;
CREATE TABLE IF NOT EXISTS announcement_rel_group (group_id int NOT NULL, announcement_id int NOT NULL, PRIMARY KEY (group_id, announcement_id));
CREATE TABLE IF NOT EXISTS group_rel_group ( id int NOT NULL AUTO_INCREMENT, group_id int NOT NULL, subgroup_id int NOT NULL, relation_type int NOT NULL, PRIMARY KEY (id));
CREATE TABLE IF NOT EXISTS chat (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, from_user INTEGER, to_user INTEGER, message TEXT NOT NULL, sent DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', recd INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (id));
CREATE TABLE IF NOT EXISTS track_course_ranking (id int unsigned not null PRIMARY KEY AUTO_INCREMENT, c_id int unsigned not null, session_id int unsigned not null default 0, url_id int unsigned not null default 0, accesses int unsigned not null default 0, total_score int unsigned not null default 0, users int unsigned not null default 0, creation_date datetime not null);
CREATE TABLE IF NOT EXISTS user_rel_course_vote ( id int unsigned not null AUTO_INCREMENT PRIMARY KEY, c_id int unsigned not null, user_id int unsigned not null, session_id int unsigned not null default 0, url_id int unsigned not null default 0, vote int unsigned not null default 0);
CREATE TABLE IF NOT EXISTS grade_model (id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT, default_lowest_eval_exclude TINYINT default null, default_external_eval_prefix VARCHAR(140) default null, PRIMARY KEY (id));
CREATE TABLE IF NOT EXISTS grade_components (id INTEGER NOT NULL AUTO_INCREMENT, percentage VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, acronym VARCHAR(255) NOT NULL, grade_model_id INTEGER NOT NULL, PRIMARY KEY (id));
@ -53,11 +52,12 @@ CREATE TABLE IF NOT EXISTS skill_profile ( id INTEGER NOT NULL AUTO_INCREMENT,
CREATE TABLE IF NOT EXISTS skill_rel_profile ( id INTEGER NOT NULL AUTO_INCREMENT, skill_id INTEGER NOT NULL, profile_id INTEGER NOT NULL, PRIMARY KEY (id));
CREATE TABLE IF NOT EXISTS course_type (id int unsigned not null auto_increment primary key, name varchar(50) not null, translation_var char(40) default 'UndefinedCourseTypeLabel', description TEXT default '', props text default '');
CREATE TABLE IF NOT EXISTS usergroup_rel_question (id int unsigned not null auto_increment primary key, c_id int unsigned not null, question_id int unsigned not null, usergroup_id int unsigned not null, coefficient float(6,2));
CREATE TABLE IF NOT EXISTS track_course_ranking (id int unsigned not null PRIMARY KEY AUTO_INCREMENT, c_id int unsigned not null, session_id int unsigned not null default 0, url_id int unsigned not null default 0, accesses int unsigned not null default 0, total_score int unsigned not null default 0, users int unsigned not null default 0, creation_date datetime not null);
CREATE TABLE IF NOT EXISTS track_stored_values (id int unsigned not null AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, sco_id INT NOT NULL, course_id CHAR(40) NOT NULL, sv_key CHAR(64) NOT NULL, sv_value TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS track_stored_values_stack (id int unsigned not null AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, sco_id INT NOT NULL, stack_order INT NOT NULL, course_id CHAR(40) NOT NULL, sv_key CHAR(64) NOT NULL, sv_value TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS track_e_attempt_coeff ( id int unsigned not null auto_increment primary key, attempt_id INT NOT NULL, marks_coeff float(6,2));
LOCK TABLES group_rel_group WRITE, course_rel_user WRITE, session_rel_course_rel_user WRITE, course WRITE, gradebook_category WRITE, gradebook_link WRITE, chat WRITE, track_course_ranking WRITE, user_rel_course_vote WRITE, user WRITE;
LOCK TABLES track_stored_values WRITE, track_stored_values_stack WRITE, group_rel_group WRITE, course_rel_user WRITE, session_rel_course_rel_user WRITE, course WRITE, gradebook_category WRITE, gradebook_link WRITE, chat WRITE, track_course_ranking WRITE, user_rel_course_vote WRITE, user WRITE;
call AddColumnUnlessExists(Database(), 'course_rel_user', 'legal_agreement', 'INTEGER DEFAULT 0');
call AddColumnUnlessExists(Database(), 'session_rel_course_rel_user', 'legal_agreement', 'INTEGER DEFAULT 0');
@ -72,6 +72,11 @@ ALTER TABLE gradebook_link MODIFY COLUMN weight FLOAT NOT NULL;
ALTER TABLE course MODIFY COLUMN disk_quota bigint unsigned DEFAULT NULL;
ALTER TABLE user MODIFY COLUMN username VARCHAR(100) NOT NULL;
ALTER TABLE track_stored_values ADD KEY (user_id, sco_id, course_id, sv_key);
ALTER TABLE track_stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key);
ALTER TABLE track_stored_values_stack ADD KEY (user_id, sco_id, course_id, sv_key, stack_order);
ALTER TABLE track_stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv_key, stack_order);
call dropIndexIfExists('chat','idx_chat_to_user');
call dropIndexIfExists('chat','idx_chat_from_user');
call dropIndexIfExists('group_rel_group','group_id');
@ -99,7 +104,7 @@ ALTER TABLE user_rel_course_vote ADD INDEX idx_ucv_uid (user_id);
ALTER TABLE user_rel_course_vote ADD INDEX idx_ucv_cuid (user_id, c_id);
UNLOCK TABLES;
LOCK TABLES settings_options WRITE, user_field WRITE, gradebook_evaluation WRITE, gradebook_category WRITE, settings_current WRITE, event_email_template WRITE, event_sent WRITE, user_rel_event_type WRITE, usergroup_rel_session WRITE, usergroup_rel_course WRITE, usergroup_rel_user WRITE, admin WRITE, reservation_category_rights WRITE, course WRITE, user_api_key WRITE, track_e_default WRITE, track_e_exercices WRITE;
LOCK TABLES settings_options WRITE, user_field WRITE, gradebook_evaluation WRITE, gradebook_category WRITE, settings_current WRITE, event_email_template WRITE, event_sent WRITE, user_rel_event_type WRITE, usergroup_rel_session WRITE, usergroup_rel_course WRITE, usergroup_rel_user WRITE, admin WRITE, reservation_category_rights WRITE, course WRITE, user_api_key WRITE;
ALTER TABLE gradebook_category ADD COLUMN grade_model_id INT DEFAULT 0;
ALTER TABLE settings_current ADD COLUMN access_url_locked INTEGER NOT NULL DEFAULT 0;
@ -114,7 +119,6 @@ ALTER TABLE user_api_key ADD COLUMN created_date datetime DEFAULT NULL;
ALTER TABLE user_api_key ADD COLUMN validity_start_date datetime DEFAULT NULL;
ALTER TABLE user_api_key ADD COLUMN validity_end_date datetime DEFAULT NULL;
ALTER TABLE user_api_key ADD COLUMN description text DEFAULT NULL;
ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT NOT NULL DEFAULT '';
call dropIndexIfExists('event_email_template', 'event_name_index');
call dropIndexIfExists('event_sent', 'event_name_index');
@ -123,24 +127,10 @@ call dropIndexIfExists('user_rel_event_type', 'event_name_index');
ALTER TABLE user_rel_event_type ADD INDEX event_name_index (event_type_name);
ALTER TABLE event_email_template ADD INDEX event_name_index (event_type_name);
ALTER TABLE event_sent ADD INDEX event_name_index (event_type_name);
ALTER TABLE track_e_default MODIFY COLUMN default_value TEXT;
ALTER TABLE gradebook_evaluation MODIFY COLUMN weight FLOAT NOT NULL;
UNLOCK TABLES;
LOCK TABLES track_e_default WRITE, track_stored_values WRITE, track_stored_values_stack WRITE, track_e_attempt WRITE, track_e_attempt_recording WRITE, track_e_hotpotatoes WRITE, personal_agenda WRITE;
ALTER TABLE track_stored_values ADD KEY (user_id, sco_id, course_id, sv_key);
ALTER TABLE track_stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key);
ALTER TABLE track_stored_values_stack ADD KEY (user_id, sco_id, course_id, sv_key, stack_order);
ALTER TABLE track_stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv_key, stack_order);
ALTER TABLE track_e_attempt ADD COLUMN filename VARCHAR(255) DEFAULT NULL;
ALTER TABLE track_e_default ADD COLUMN c_id INTEGER DEFAULT NULL;
ALTER TABLE track_e_attempt_recording ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id);
ALTER TABLE track_e_attempt ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id);
ALTER TABLE track_e_hotpotatoes ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id);
ALTER TABLE personal_agenda ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0;
UNLOCK TABLES;
INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) values (1, 'already_logged_in','Already logged in',0,0), (1, 'update_type','Update script type',0,0), (1, 'google_calendar_url','Google Calendar URL',0,0), (1, 'user_chat_status','User chat status', 0, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('filter_terms', NULL, 'textarea', 'Security', '', 'FilterTermsTitle', 'FilterTermsComment', NULL, NULL, 0), ('header_extra_content', NULL, 'textarea', 'Tracking', '', 'HeaderExtraContentTitle', 'HeaderExtraContentComment', NULL, NULL, 1),('footer_extra_content', NULL, 'textarea', 'Tracking', '', 'FooterExtraContentTitle', 'FooterExtraContentComment', NULL, NULL,1), ('show_documents_preview', NULL, 'radio', 'Tools', 'false', 'ShowDocumentPreviewTitle', 'ShowDocumentPreviewComment', NULL, NULL, 1), ('htmlpurifier_wiki',NULL,'radio','Editor','false','HtmlPurifierWikiTitle','HtmlPurifierWikiComment',NULL,NULL, 0), ('cas_activate', NULL, 'radio', 'CAS', 'false', 'CasMainActivateTitle', 'CasMainActivateComment', NULL, NULL, 0), ('cas_server', NULL, 'textfield', 'CAS', '', 'CasMainServerTitle', 'CasMainServerComment', NULL, NULL, 0), ('cas_server_uri', NULL, 'textfield', 'CAS', '', 'CasMainServerURITitle', 'CasMainServerURIComment', NULL, NULL, 0), ('cas_port', NULL, 'textfield', 'CAS', '', 'CasMainPortTitle', 'CasMainPortComment', NULL, NULL, 0), ('cas_protocol', NULL, 'radio', 'CAS', '', 'CasMainProtocolTitle', 'CasMainProtocolComment', NULL, NULL, 0), ('cas_add_user_activate', NULL, 'radio', 'CAS', 'false', 'CasUserAddActivateTitle', 'CasUserAddActivateComment', NULL, NULL, 0), ('update_user_info_cas_with_ldap', NULL, 'radio', 'CAS', 'true', 'UpdateUserInfoCasWithLdapTitle', 'UpdateUserInfoCasWithLdapComment', NULL, NULL, 0), ('use_custom_pages', NULL, 'radio','Platform','false','UseCustomPagesTitle','UseCustomPagesComment', NULL, NULL, 1);
@ -203,26 +193,43 @@ DELETE FROM settings_current WHERE variable = 'read_more_limit';
DELETE FROM settings_current WHERE variable = 'user_order_by';
DELETE FROM settings_options WHERE variable = 'user_order_by';
DROP PROCEDURE IF EXISTS dropIndexIfExists;
DROP PROCEDURE IF EXISTS AddColumnUnlessExists;
-- Do not move this query
UPDATE settings_current SET selected_value = '1.9.0.18715b' WHERE variable = 'chamilo_database_version';
-- xxSTATSxx
LOCK TABLES track_e_default WRITE, track_e_attempt WRITE, track_e_attempt_recording WRITE, track_e_hotpotatoes WRITE, track_e_exercices WRITE;
ALTER TABLE track_e_attempt ADD COLUMN filename VARCHAR(255) DEFAULT NULL;
ALTER TABLE track_e_default ADD COLUMN c_id INTEGER DEFAULT NULL;
ALTER TABLE track_e_attempt_recording ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id);
ALTER TABLE track_e_attempt ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id);
ALTER TABLE track_e_hotpotatoes ADD COLUMN id INTEGER NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id);
ALTER TABLE track_e_default MODIFY COLUMN default_value TEXT;
ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT NOT NULL DEFAULT '';
UNLOCK TABLES;
-- xxUSERxx
LOCK TABLES personal_agenda WRITE;
ALTER TABLE personal_agenda ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0;
UNLOCK TABLES;
-- xxCOURSExx
CREATE TABLE IF NOT EXISTS metadata (c_id INT NOT NULL, eid VARCHAR(250) NOT NULL, mdxmltext TEXT default '', md5 CHAR(32) default '', htmlcache1 TEXT default '', htmlcache2 TEXT default '', indexabletext TEXT default '', PRIMARY KEY (c_id, eid))
ALTER TABLE lp ADD COLUMN hide_toc_frame INT NOT NULL DEFAULT 0;
ALTER TABLE lp ADD COLUMN seriousgame_mode INT NOT NULL DEFAULT 0;
ALTER TABLE lp_item_view MODIFY COLUMN suspend_data longtext;
ALTER TABLE quiz ADD COLUMN review_answers INT NOT NULL DEFAULT 0;
ALTER TABLE student_publication ADD COLUMN contains_file INT NOT NULL DEFAULT 1;
ALTER TABLE student_publication ADD COLUMN allow_text_assignment INT NOT NULL DEFAULT 0;
ALTER TABLE quiz ADD COLUMN random_by_category INT NOT NULL DEFAULT 0;
ALTER TABLE quiz ADD COLUMN text_when_finished TEXT DEFAULT NULL;
ALTER TABLE quiz ADD COLUMN display_category_name INT NOT NULL DEFAULT 1;
ALTER TABLE quiz ADD COLUMN pass_percentage INT DEFAULT NULL;
ALTER TABLE quiz_answer ADD COLUMN answer_code char(10) default '';
ALTER TABLE quiz_question ADD COLUMN question_code char(10) default '';
INSERT INTO course_setting (variable, value, category) VALUES ('allow_public_certificates', 0, 'certificates');
CREATE TABLE IF NOT EXISTS metadata (c_id INT NOT NULL, eid VARCHAR(250) NOT NULL, mdxmltext TEXT default '', md5 CHAR(32) default '', htmlcache1 TEXT default '', htmlcache2 TEXT default '', indexabletext TEXT default '', PRIMARY KEY (c_id, eid));
ALTER TABLE {prefix}lp ADD COLUMN hide_toc_frame INT NOT NULL DEFAULT 0;
ALTER TABLE {prefix}lp ADD COLUMN seriousgame_mode INT NOT NULL DEFAULT 0;
ALTER TABLE {prefix}lp_item_view MODIFY COLUMN suspend_data longtext;
ALTER TABLE {prefix}quiz ADD COLUMN review_answers INT NOT NULL DEFAULT 0;
ALTER TABLE {prefix}student_publication ADD COLUMN contains_file INT NOT NULL DEFAULT 1;
ALTER TABLE {prefix}student_publication ADD COLUMN allow_text_assignment INT NOT NULL DEFAULT 0;
ALTER TABLE {prefix}quiz ADD COLUMN random_by_category INT NOT NULL DEFAULT 0;
ALTER TABLE {prefix}quiz ADD COLUMN text_when_finished TEXT DEFAULT NULL;
ALTER TABLE {prefix}quiz ADD COLUMN display_category_name INT NOT NULL DEFAULT 1;
ALTER TABLE {prefix}quiz ADD COLUMN pass_percentage INT DEFAULT NULL;
ALTER TABLE {prefix}quiz_answer ADD COLUMN answer_code char(10) default '';
ALTER TABLE {prefix}quiz_question ADD COLUMN question_code char(10) default '';
INSERT INTO {prefix}course_setting (variable, value, category) VALUES ('allow_public_certificates', 0, 'certificates');

@ -13,8 +13,10 @@ $update = function ($_configuration, $mainConnection, $courseList, $dryRun, $out
/** @var \Doctrine\DBAL\Connection $userConnection */
$userConnection = $upgrade->getHelper($databaseList['user'][0]['database'])->getConnection();
/** @var \Doctrine\DBAL\Connection $mainConnection */
$mainConnection = $upgrade->getHelper($databaseList['main'][0]['database'])->getConnection();
/** @var \Doctrine\DBAL\Connection $statsConnection */
$statsConnection = $upgrade->getHelper($databaseList['stats'][0]['database'])->getConnection();
@ -71,6 +73,12 @@ $update = function ($_configuration, $mainConnection, $courseList, $dryRun, $out
if (!empty($rows)) {
$output->writeln('Moving users from class_user to usergroup_rel_user ');
foreach ($rows as $row) {
if (empty($mapping_classes[$row['class_id']])) {
// Cover a special case where data would not be
// consistent - see BT#7254
$output->writeln("<comment>Warning: data inconsistency: \$mapping_classes[".$row['class_id']."] was not defined, suggesting that this class ID was still used in class_user although the class had been removed</comment>");
continue;
}
$values = array(
'usergroup_id' => $mapping_classes[$row['class_id']],
'user_id' => $row['user_id']
@ -100,6 +108,12 @@ $update = function ($_configuration, $mainConnection, $courseList, $dryRun, $out
$subResult = $mainConnection->executeQuery($sql_course);
$courseInfo = $subResult->fetch();
$course_id = $courseInfo['id'];
if (empty($mapping_classes[$row['class_id']])) {
// Cover a special case where data would not be
// consistent - see BT#7254
$output->writeln("<comment>Warning: data inconsistency: \$mapping_classes[".$row['class_id']."] was not defined, suggesting that this class ID was still used in course_rel_class although the class had been removed</comment>");
continue;
}
$values = array(
'usergroup_id' => $mapping_classes[$row['class_id']],
'course_id' => $course_id
@ -115,9 +129,9 @@ $update = function ($_configuration, $mainConnection, $courseList, $dryRun, $out
}
}
//Moving Stats DB to the main DB
// Moving Stats DB to the main DB.
$stats_table = array(
$statsTable = array(
"track_c_browsers",
"track_c_countries",
"track_c_os",
@ -143,37 +157,39 @@ $update = function ($_configuration, $mainConnection, $courseList, $dryRun, $out
"track_stored_values_stack",
);
// No rename we assume that stats are in the main db
/*
foreach ($stats_table as $stat_table) {
$sql = "ALTER TABLE $dbStatsForm.$stat_table RENAME $dbNameForm.$stat_table";
Database::query($sql);
$output->writeln($sql);
if (isset($_configuration['statistics_database'])) {
$statSchemaManager = $statsConnection->getSchemaManager();
if ($_configuration['main_database'] != $_configuration['statistics_database']) {
foreach ($statsTable as $table) {
if ($statSchemaManager->tablesExist($table)) {
$newTable = $_configuration['main_database'].'.'.$table;
$statSchemaManager->renameTable($table, $newTable);
$output->writeln("<comment>Renaming $table to: </comment>".$newTable);
}
}
}
}
iDatabase::select_db($dbNameForm);
$statsConnection->
*/
//Moving user database to the main database
$users_tables = array(
// Moving user database to the main database.
$usersTables = array(
"personal_agenda",
"personal_agenda_repeat",
"personal_agenda_repeat_not",
"user_course_category"
);
// No rename we asumme that stats are in the main db
/*
if ($dbNameForm != $dbUserForm) {
iDatabase::select_db($dbUserForm);
foreach ($users_tables as $table) {
$sql = "ALTER TABLE $dbUserForm.$table RENAME $dbNameForm.$table";
iDatabase::query($sql);
$output->writeln($sql);
$userSchemaManager = $userConnection->getSchemaManager();
if (isset($_configuration['user_personal_database'])) {
if ($_configuration['main_database'] != $_configuration['user_personal_database']) {
foreach ($usersTables as $table) {
if ($userSchemaManager->tablesExist($table)) {
$newTable = $_configuration['main_database'].'.'.$table;
$userSchemaManager->renameTable($table, $newTable);
$output->writeln("<comment>Renaming $table to: </comment>".$newTable);
}
}
}
iDatabase::select_db($dbNameForm);
}*/
}
// Adding admin user in the access_url_rel_user table.
$sql = "SELECT user_id FROM admin WHERE user_id = 1";
@ -466,7 +482,7 @@ $update = function ($_configuration, $mainConnection, $courseList, $dryRun, $out
// Only create the folder once
if (!isset($work_dir_created[$work_key])) {
//2.1 Creating a new work folder
// 2.1 Creating a new work folder:
$sql = "INSERT INTO $work_table SET
c_id = '$courseId',
url = 'work/".$dir_name."',
@ -516,14 +532,22 @@ $update = function ($_configuration, $mainConnection, $courseList, $dryRun, $out
}
// 3.0 Moving subfolders to the root.
$sql = "SELECT * FROM $work_table WHERE parent_id <> 0 AND filetype ='folder' AND c_id = $courseId";
$sql = "SELECT * FROM $work_table
WHERE parent_id <> 0 AND filetype ='folder' AND c_id = $courseId";
$result = $mainConnection->executeQuery($sql);
$work_list = $result->fetchAll();
if (!empty($work_list)) {
foreach ($work_list as $work_folder) {
$folder_id = $work_folder['id'];
check_work($mainConnection, $folder_id, $work_folder['url'], $work_table, $base_work_dir, $courseId);
check_work(
$mainConnection,
$folder_id,
$work_folder['url'],
$work_table,
$base_work_dir,
$courseId
);
}
}
}
@ -590,6 +614,12 @@ function check_work($mainConnection, $folder_id, $work_url, $work_table, $base_w
}
}
/**
* @param string $base_work_dir
* @param string $desired_dir_name
* @param array $portalSettings
* @return bool|string
*/
function create_unexisting_work_directory($base_work_dir, $desired_dir_name, $portalSettings)
{
$nb = '';

@ -10,18 +10,6 @@ class ConsoleTest extends PHPUnit_Framework_TestCase
public function setUp()
{
$configurationFileContent = file_get_contents(__DIR__.'/../Resources/configuration.php');
vfsStreamWrapper::register();
$structure = array(
'chamilo' => array(
'config' => array(
'configuration.php' => $configurationFileContent,
),
'tests' => array(),
'data' => array('courses')
)
);
vfsStream::setup('root', null, $structure);
}
public function testListCommand()

@ -1,5 +1,5 @@
<?php
require_once 'vfsStream/vfsStream.php';
//require_once __DIR__.'/../../../../vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php';
use Chash\Helpers\ConfigurationHelper;
@ -12,9 +12,10 @@ class ConfigurationHelperTest extends PHPUnit_Framework_TestCase
public function setUp()
{
/*
vfsStreamWrapper::register();
vfsStreamWrapper::setRoot(new vfsStreamDirectory('chamilo'));
*/
}
public function testGetConfigurationPath()

@ -42,19 +42,36 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
private $prefixes = array();
private $fallbackDirs = array();
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
public function getPrefixes()
{
return call_user_func_array('array_merge', $this->prefixes);
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirs;
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
@ -75,23 +92,24 @@ class ClassLoader
}
/**
* Registers a set of classes, merging with any others previously set.
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
* @param bool $prepend Prepend the location(s)
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirs = array_merge(
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirs
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirs = array_merge(
$this->fallbackDirs,
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
@ -100,38 +118,104 @@ class ClassLoader
}
$first = $prefix[0];
if (!isset($this->prefixes[$first][$prefix])) {
$this->prefixes[$first][$prefix] = (array) $paths;
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixes[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixes[$first][$prefix]
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixes[$first][$prefix] = array_merge(
$this->prefixes[$first][$prefix],
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of classes, replacing any others previously set.
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-0 base directories
* @param bool $prepend Whether to prepend the directories
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirs = (array) $paths;
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
return;
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*/
public function setPsr4($prefix, $paths) {
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
$this->prefixes[substr($prefix, 0, 1)][$prefix] = (array) $paths;
}
/**
@ -202,45 +286,69 @@ class ClassLoader
$class = substr($class, 1);
}
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php';
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
if (0 === strpos($class, $prefix)) {
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$classPath = strtr(substr($class, 0, $pos), '\\', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$className = substr($class, $pos + 1);
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$classPath = null;
$className = $class;
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . '.php';
}
$classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php';
$first = $class[0];
if (isset($this->prefixes[$first])) {
foreach ($this->prefixes[$first] as $prefix => $dirs) {
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
foreach ($this->fallbackDirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
// Remember that this class does not exist.
return $this->classMap[$class] = false;
}
}

@ -84,7 +84,7 @@ return array(
'CourseSelectForm' => $baseDir . '/main/coursecopy/classes/CourseSelectForm.class.php',
'CourseSession' => $baseDir . '/main/coursecopy/classes/CourseSession.class.php',
'CoursesController' => $baseDir . '/main/auth/courses_controller.php',
'Cpdf' => $baseDir . '/main/inc/lib/phpdocx/pdf/lib/class.pdf.php',
'Cpdf' => $baseDir . '/main/inc/lib/ezpdf/class.pdf.php',
'CreateChartRels' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateChartRels.inc',
'CreateDocx' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateDocx.inc',
'CreateElement' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateElement.inc',
@ -224,7 +224,7 @@ return array(
'ForumThreadLink' => $baseDir . '/main/gradebook/lib/be/forumthreadlink.class.php',
'ForumTopic' => $baseDir . '/main/coursecopy/classes/ForumTopic.class.php',
'Frame' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php',
'FrameFiller' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'FrameFiller' => $vendorDir . '/jmontoyaa/phpqrcode/qrencode.php',
'FrameList' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php',
'FrameListIterator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php',
'FrameTreeIterator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php',
@ -504,21 +504,21 @@ return array(
'PortfolioShare' => $baseDir . '/main/inc/lib/portfolio.class.php',
'Positioner' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/positioner.cls.php',
'Promotion' => $baseDir . '/main/inc/lib/promotion.lib.php',
'QRbitstream' => $vendorDir . '/jmontoyaa/phpqrcode/qrbitstream.php',
'QRcode' => $vendorDir . '/jmontoyaa/phpqrcode/bindings/tcpdf/qrcode.php',
'QRencode' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRbitstream' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRcode' => $vendorDir . '/jmontoyaa/phpqrcode/qrencode.php',
'QRencode' => $vendorDir . '/jmontoyaa/phpqrcode/qrencode.php',
'QRimage' => $vendorDir . '/jmontoyaa/phpqrcode/qrimage.php',
'QRinput' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRinputItem' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRmask' => $vendorDir . '/jmontoyaa/phpqrcode/qrmask.php',
'QRrawcode' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRinput' => $vendorDir . '/jmontoyaa/phpqrcode/qrinput.php',
'QRinputItem' => $vendorDir . '/jmontoyaa/phpqrcode/qrinput.php',
'QRmask' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRrawcode' => $vendorDir . '/jmontoyaa/phpqrcode/qrencode.php',
'QRrs' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRrsItem' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRrsblock' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRspec' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRrsblock' => $vendorDir . '/jmontoyaa/phpqrcode/qrencode.php',
'QRspec' => $vendorDir . '/jmontoyaa/phpqrcode/qrspec.php',
'QRsplit' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRtools' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRvect' => $vendorDir . '/jmontoyaa/phpqrcode/qrvect.php',
'QRtools' => $vendorDir . '/jmontoyaa/phpqrcode/qrtools.php',
'QRvect' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'Question' => $baseDir . '/main/exercice/question.class.php',
'QuickformElement' => $baseDir . '/main/inc/lib/pear/HTML/QuickForm/Renderer/Object.php',
'QuickformFlexyElement' => $baseDir . '/main/inc/lib/pear/HTML/QuickForm/Renderer/ObjectFlexy.php',
@ -537,6 +537,7 @@ return array(
'ResultTable' => $baseDir . '/main/gradebook/lib/fe/resulttable.class.php',
'ResultsDataGenerator' => $baseDir . '/main/gradebook/lib/results_data_generator.class.php',
'Rights' => $baseDir . '/main/inc/lib/rights.lib.php',
'S3SoapClient' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeS3.class.php',
'SVG' => $vendorDir . '/mpdf/mpdf/classes/svg.php',
'ScoreDisplay' => $baseDir . '/main/gradebook/lib/scoredisplay.class.php',
'ScoreDisplayForm' => $baseDir . '/main/gradebook/lib/fe/scoredisplayform.class.php',
@ -735,9 +736,15 @@ return array(
'document_processor' => $baseDir . '/main/inc/lib/search/tool_processors/document_processor.class.php',
'elFinder' => $baseDir . '/main/inc/lib/elfinder/php/elFinder.class.php',
'elFinderConnector' => $baseDir . '/main/inc/lib/elfinder/php/elFinderConnector.class.php',
'elFinderPluginAutoResize' => $baseDir . '/main/inc/lib/elfinder/php/plugins/AutoResize/plugin.php',
'elFinderPluginNormalizer' => $baseDir . '/main/inc/lib/elfinder/php/plugins/Normalizer/plugin.php',
'elFinderPluginWatermark' => $baseDir . '/main/inc/lib/elfinder/php/plugins/Watermark/plugin.php',
'elFinderVolumeDriver' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeDriver.class.php',
'elFinderVolumeFTP' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeFTP.class.php',
'elFinderVolumeFTPIIS' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeFTPIIS.class.php',
'elFinderVolumeLocalFileSystem' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeLocalFileSystem.class.php',
'elFinderVolumeMySQL' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeMySQL.class.php',
'elFinderVolumeS3' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeS3.class.php',
'eventController' => $baseDir . '/main/admin/event_controller.php',
'form' => $vendorDir . '/mpdf/mpdf/classes/form.php',
'getid3' => $baseDir . '/main/inc/lib/getid3/getid3.php',
@ -763,8 +770,8 @@ return array(
'link_processor' => $baseDir . '/main/inc/lib/search/tool_processors/link_processor.class.php',
'mPDF' => $vendorDir . '/mpdf/mpdf/mpdf.php',
'meter' => $vendorDir . '/mpdf/mpdf/classes/meter.php',
'nusoap_base' => $baseDir . '/main/inc/lib/nusoap/nusoap.php',
'nusoap_client' => $baseDir . '/main/inc/lib/nusoap/class.soapclient.php',
'nusoap_base' => $baseDir . '/main/inc/lib/nusoap/class.nusoap_base.php',
'nusoap_client' => $baseDir . '/main/inc/lib/nusoap/nusoap.php',
'nusoap_client_mime' => $baseDir . '/main/inc/lib/nusoap/nusoapmime.php',
'nusoap_fault' => $baseDir . '/main/inc/lib/nusoap/class.soap_fault.php',
'nusoap_parser' => $baseDir . '/main/inc/lib/nusoap/class.soap_parser.php',
@ -786,7 +793,7 @@ return array(
'php4DomProcessingInstruction' => $baseDir . '/main/auth/cas/lib/CAS/domxml-php4-to-php5.php',
'php4DomXsltStylesheet' => $baseDir . '/main/auth/cas/lib/CAS/domxml-php4-to-php5.php',
'phpCAS' => $baseDir . '/main/auth/cas/lib/CAS.php',
'qrstr' => $vendorDir . '/jmontoyaa/phpqrcode/qrconst.php',
'qrstr' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'quiz_processor' => $baseDir . '/main/inc/lib/search/tool_processors/quiz_processor.class.php',
'scorm' => $baseDir . '/main/newscorm/scorm.class.php',
'scormItem' => $baseDir . '/main/newscorm/scormItem.class.php',
@ -798,7 +805,7 @@ return array(
'soap_parser' => $baseDir . '/main/inc/lib/nusoap/class.soap_parser.php',
'soap_server' => $baseDir . '/main/inc/lib/nusoap/class.soap_server.php',
'soap_transport_http' => $baseDir . '/main/inc/lib/nusoap/class.soap_transport_http.php',
'soapclient' => $baseDir . '/main/inc/lib/nusoap/class.soapclient.php',
'soapclient' => $baseDir . '/main/inc/lib/nusoap/nusoap.php',
'soapclientmime' => $baseDir . '/main/inc/lib/nusoap/nusoapmime.php',
'soapval' => $baseDir . '/main/inc/lib/nusoap/class.soap_val.php',
'sso' => $baseDir . '/main/auth/sso/sso.class.php',

@ -0,0 +1,9 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd3dd5c326d3e3d13b67daf6fbedc97d2
class ComposerAutoloaderInit12fc675918971fe55c8142ceb23d2d09
{
private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInitd3dd5c326d3e3d13b67daf6fbedc97d2
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd3dd5c326d3e3d13b67daf6fbedc97d2', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit12fc675918971fe55c8142ceb23d2d09', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitd3dd5c326d3e3d13b67daf6fbedc97d2', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit12fc675918971fe55c8142ceb23d2d09', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
@ -31,6 +31,11 @@ class ComposerAutoloaderInitd3dd5c326d3e3d13b67daf6fbedc97d2
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);

@ -0,0 +1,10 @@
/.settings
/.project
/.buildpath
/composer.phar
/vendor
/nbproject
phpunit.xml
.vagrant
Vagrantfile
.idea

File diff suppressed because it is too large Load Diff

@ -7,6 +7,6 @@ php:
- 5.5
before_script:
- composer install --dev
- composer install --prefer-source
script: phpunit --coverage-text --verbose

@ -230,6 +230,8 @@ Configuration
String or array describing metadata cache implementation.
* **result_cache** (Default: setting specified by orm.default_cache):
String or array describing result cache implementation.
* **types**
An array of custom types in the format of 'typeName' => 'Namespace\To\Type\Class'
* **orm.ems.options**:
Array of Entity Manager configuration sets indexed by each Entity Manager's
name. Each value should look like **orm.em.options**.

@ -1,3 +1,7 @@
## v1.0.4 (2013-12-11)
* @mrkrstphr: Custom types (#21)
## v1.0.3 (2013-10-25)
* @tdbui83: Redis cache (#20)

@ -2,6 +2,7 @@
"name": "dflydev/doctrine-orm-service-provider",
"description": "Doctrine ORM Service Provider",
"keywords": ["pimple", "cilex", "silex", "doctrine", "orm"],
"homepage": "http://dflydev.com/projects/doctrine-orm-service-provider/",
"license": "MIT",
"authors": [
{

@ -21,6 +21,7 @@ use Doctrine\Common\Cache\XcacheCache;
use Doctrine\Common\Cache\RedisCache;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\Driver;
@ -46,6 +47,7 @@ class DoctrineOrmServiceProvider
$app['orm.em.default_options'] = array(
'connection' => 'default',
'mappings' => array(),
'types' => array()
);
$app['orm.ems.options.initializer'] = $app->protect(function () use ($app) {
@ -163,6 +165,14 @@ class DoctrineOrmServiceProvider
}
$config->setMetadataDriverImpl($chain);
foreach ((array) $options['types'] as $typeName => $typeClass) {
if (Type::hasType($typeName)) {
Type::overrideType($typeName, $typeClass);
} else {
Type::addType($typeName, $typeClass);
}
}
$configs[$name] = $config;
}

@ -0,0 +1,3 @@
vendor/
composer.lock
composer.phar

@ -0,0 +1,3 @@
vendor/
build/
phpunit.xml

@ -0,0 +1,9 @@
build/
logs/
reports/
dist/
tests/Doctrine/Tests/Common/Proxy/generated/
vendor/
.idea
doctrine-common-*.tar
doctrine-common-*.tar.gz

@ -0,0 +1,3 @@
[submodule "lib/vendor/doctrine-build-common"]
path = lib/vendor/doctrine-build-common
url = git://github.com/doctrine/doctrine-build-common.git

@ -115,8 +115,8 @@ abstract class AbstractProxyFactory
? $this->definitions[$className]
: $this->getProxyDefinition($className);
$fqcn = $definition->proxyClassName;
$proxy = new $fqcn($definition->initializer, $definition->cloner);
foreach ($definition->identifierFields as $idField) {
$definition->reflectionFields[$idField]->setValue($proxy, $identifier[$idField]);
}

@ -0,0 +1,3 @@
Doctrine/Tests/Proxies/
Doctrine/Tests/ORM/Proxy/generated/
Doctrine/Tests/ORM/Tools/Export/export

@ -548,15 +548,16 @@ class Connection implements DriverConnection
{
$this->connect();
if ( ! is_int(key($types))) {
$types = $this->extractTypeValues($data, $types);
if (empty($data)) {
return $this->executeUpdate('INSERT INTO ' . $tableName . ' ()' . ' VALUES ()');
}
$query = 'INSERT INTO ' . $tableName
. ' (' . implode(', ', array_keys($data)) . ')'
. ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')';
return $this->executeUpdate($query, array_values($data), $types);
return $this->executeUpdate(
'INSERT INTO ' . $tableName . ' (' . implode(', ', array_keys($data)) . ')' .
' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')',
array_values($data),
is_int(key($types)) ? $types : $this->extractTypeValues($data, $types)
);
}
/**

@ -169,6 +169,9 @@ class MysqliStatement implements \IteratorAggregate, Statement
if (null === $this->_columnNames) {
$meta = $this->_stmt->result_metadata();
if (false !== $meta) {
// We have a result.
$this->_stmt->store_result();
$columnNames = array();
foreach ($meta->fetch_fields() as $col) {
$columnNames[] = $col->name;
@ -191,11 +194,6 @@ class MysqliStatement implements \IteratorAggregate, Statement
}
}
// We have a result.
if (false !== $this->_columnNames) {
$this->_stmt->store_result();
}
return true;
}

@ -64,15 +64,18 @@ class Driver implements \Doctrine\DBAL\Driver
$dsn .= '(PORT=1521)';
}
$database = 'SID=' . $params['dbname'];
$pooled = '';
if (isset($params['service']) && $params['service'] == true) {
$dsn .= '))(CONNECT_DATA=(SERVICE_NAME=' . $params['dbname'] . '))';
} else {
$dsn .= '))(CONNECT_DATA=(SID=' . $params['dbname'] . '))';
$database = 'SERVICE_NAME=' . $params['dbname'];
}
if (isset($params['pooled']) && $params['pooled'] == true) {
$dsn .= '(SERVER=POOLED)';
$pooled = '(SERVER=POOLED)';
}
$dsn .= ')';
$dsn .= '))(CONNECT_DATA=(' . $database . ')' . $pooled . '))';
} else {
$dsn .= $params['dbname'];
}

@ -53,10 +53,11 @@ class Driver implements \Doctrine\DBAL\Driver
*/
private function _constructPdoDsn(array $params)
{
$dsn = 'oci:';
$dsn = 'oci:dbname=';
if (isset($params['host']) && $params['host'] != '') {
$dsn .= 'dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)' .
'(HOST=' . $params['host'] . ')';
$dsn .= '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)' .
'(HOST=' . $params['host'] . ')';
if (isset($params['port'])) {
$dsn .= '(PORT=' . $params['port'] . ')';
@ -64,13 +65,20 @@ class Driver implements \Doctrine\DBAL\Driver
$dsn .= '(PORT=1521)';
}
$database = 'SID=' . $params['dbname'];
$pooled = '';
if (isset($params['service']) && $params['service'] == true) {
$dsn .= '))(CONNECT_DATA=(SERVICE_NAME=' . $params['dbname'] . ')))';
} else {
$dsn .= '))(CONNECT_DATA=(SID=' . $params['dbname'] . ')))';
$database = 'SERVICE_NAME=' . $params['dbname'];
}
if (isset($params['pooled']) && $params['pooled'] == true) {
$pooled = '(SERVER=POOLED)';
}
$dsn .= '))(CONNECT_DATA=(' . $database . ')' . $pooled . '))';
} else {
$dsn .= 'dbname=' . $params['dbname'];
$dsn .= $params['dbname'];
}
if (isset($params['charset'])) {

@ -1284,7 +1284,7 @@ abstract class AbstractPlatform
if ($this->supportsCommentOnStatement()) {
foreach ($table->getColumns() as $column) {
if ($this->getColumnComment($column)) {
$sql[] = $this->getCommentOnColumnSQL($tableName, $column->getName(), $this->getColumnComment($column));
$sql[] = $this->getCommentOnColumnSQL($tableName, $column->getQuotedName($this), $this->getColumnComment($column));
}
}
}

@ -391,7 +391,7 @@ class DB2Platform extends AbstractPlatform
/* @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */
$column = $columnDiff->column;
$queryParts[] = 'ALTER ' . ($columnDiff->oldColumnName) . ' '
$queryParts[] = 'ALTER ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}

@ -410,7 +410,7 @@ class DrizzlePlatform extends AbstractPlatform
$column = $columnDiff->column;
$columnArray = $column->toArray();
$columnArray['comment'] = $this->getColumnComment($column);
$queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' '
$queryParts[] = 'CHANGE ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}

@ -115,6 +115,22 @@ class MySqlPlatform extends AbstractPlatform
return 'DATEDIFF(' . $date1 . ', ' . $date2 . ')';
}
/**
* {@inheritDoc}
*/
public function getDateAddHourExpression($date, $hours)
{
return 'DATE_ADD(' . $date . ', INTERVAL ' . $hours . ' HOUR)';
}
/**
* {@inheritDoc}
*/
public function getDateSubHourExpression($date, $hours)
{
return 'DATE_SUB(' . $date . ', INTERVAL ' . $hours . ' HOUR)';
}
/**
* {@inheritDoc}
*/
@ -541,7 +557,7 @@ class MySqlPlatform extends AbstractPlatform
$column = $columnDiff->column;
$columnArray = $column->toArray();
$columnArray['comment'] = $this->getColumnComment($column);
$queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' '
$queryParts[] = 'CHANGE ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
@ -556,6 +572,12 @@ class MySqlPlatform extends AbstractPlatform
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
if (isset($diff->addedIndexes['primary'])) {
$keyColumns = array_unique(array_values($diff->addedIndexes['primary']->getColumns()));
$queryParts[] = 'ADD PRIMARY KEY (' . implode(', ', $keyColumns) . ')';
unset($diff->addedIndexes['primary']);
}
$sql = array();
$tableSql = array();
@ -582,17 +604,33 @@ class MySqlPlatform extends AbstractPlatform
$table = $diff->name;
foreach ($diff->removedIndexes as $remKey => $remIndex) {
// Dropping primary keys requires to unset autoincrement attribute on the particular column first.
if ($remIndex->isPrimary() && $diff->fromTable instanceof Table) {
foreach ($remIndex->getColumns() as $columnName) {
$column = $diff->fromTable->getColumn($columnName);
if ($column->getAutoincrement() === true) {
$column->setAutoincrement(false);
$sql[] = 'ALTER TABLE ' . $table . ' MODIFY ' .
$this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
}
}
foreach ($diff->addedIndexes as $addKey => $addIndex) {
if ($remIndex->getColumns() == $addIndex->getColumns()) {
$type = '';
if ($addIndex->isUnique()) {
$type = 'UNIQUE ';
$indexClause = 'INDEX ' . $addIndex->getName();
if ($addIndex->isPrimary()) {
$indexClause = 'PRIMARY KEY';
} elseif ($addIndex->isUnique()) {
$indexClause = 'UNIQUE INDEX ' . $addIndex->getName();
}
$query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', ';
$query .= 'ADD ' . $type . 'INDEX ' . $addIndex->getName();
$query .= 'ADD ' . $indexClause;
$query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex->getQuotedColumns($this)) . ')';
$sql[] = $query;

@ -505,7 +505,8 @@ LEFT JOIN user_cons_columns r_cols
AND cols.position = r_cols.position
WHERE alc.constraint_name = cols.constraint_name
AND alc.constraint_type = 'R'
AND alc.table_name = '".$table."'";
AND alc.table_name = '".$table."'
ORDER BY alc.constraint_name ASC, cols.position ASC";
}
/**
@ -613,7 +614,13 @@ LEFT JOIN user_cons_columns r_cols
* Do not add query part if only comment has changed
*/
if ( ! ($columnHasChangedComment && count($columnDiff->changedProperties) === 1)) {
$fields[] = $column->getQuotedName($this). ' ' . $this->getColumnDeclarationSQL('', $column->toArray());
$columnInfo = $column->toArray();
if ( ! $columnDiff->hasChanged('notnull')) {
$columnInfo['notnull'] = false;
}
$fields[] = $column->getQuotedName($this) . ' ' . $this->getColumnDeclarationSQL('', $columnInfo);
}
if ($columnHasChangedComment) {

@ -418,10 +418,10 @@ class PostgreSqlPlatform extends AbstractPlatform
continue;
}
$oldColumnName = $columnDiff->oldColumnName;
$oldColumnName = $columnDiff->getOldColumnName()->getQuotedName($this);
$column = $columnDiff->column;
if ($columnDiff->hasChanged('type')) {
if ($columnDiff->hasChanged('type') || $columnDiff->hasChanged('precision') || $columnDiff->hasChanged('scale')) {
$type = $column->getType();
// here was a server version check before, but DBAL API does not support this anymore.
@ -430,7 +430,10 @@ class PostgreSqlPlatform extends AbstractPlatform
}
if ($columnDiff->hasChanged('default')) {
$query = 'ALTER ' . $oldColumnName . ' SET ' . $this->getDefaultValueDeclarationSQL($column->toArray());
$defaultClause = null === $column->getDefault()
? ' DROP DEFAULT'
: ' SET' . $this->getDefaultValueDeclarationSQL($column->toArray());
$query = 'ALTER ' . $oldColumnName . $defaultClause;
$sql[] = 'ALTER TABLE ' . $diff->name . ' ' . $query;
}
@ -484,7 +487,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$sql[] = 'ALTER TABLE ' . $diff->name . ' RENAME TO ' . $diff->newName;
}
$sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff), $commentsSQL);
$sql = array_merge($this->getPreAlterTableIndexForeignKeySQL($diff), $sql, $this->getPostAlterTableIndexForeignKeySQL($diff), $commentsSQL);
}
return array_merge($sql, $tableSql, $columnSql);

@ -202,10 +202,8 @@ class SQLServerPlatform extends AbstractPlatform
$column['notnull'] = true;
}
/**
* Build default constraints SQL statements
*/
if ( ! empty($column['default']) || is_numeric($column['default'])) {
// Build default constraints SQL statements.
if (isset($column['default'])) {
$defaultConstraintsSql[] = 'ALTER TABLE ' . $tableName .
' ADD' . $this->getDefaultConstraintDeclarationSQL($tableName, $column);
}
@ -276,7 +274,7 @@ class SQLServerPlatform extends AbstractPlatform
*/
public function getDefaultConstraintDeclarationSQL($table, array $column)
{
if (empty($column['default']) && ! is_numeric($column['default'])) {
if ( ! isset($column['default'])) {
throw new \InvalidArgumentException("Incomplete column definition. 'default' required.");
}
@ -369,7 +367,7 @@ class SQLServerPlatform extends AbstractPlatform
$columnDef = $column->toArray();
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef);
if ( ! empty($columnDef['default']) || is_numeric($columnDef['default'])) {
if (isset($columnDef['default'])) {
$columnDef['name'] = $column->getQuotedName($this);
$queryParts[] = 'ADD' . $this->getDefaultConstraintDeclarationSQL($diff->name, $columnDef);
}
@ -400,7 +398,7 @@ class SQLServerPlatform extends AbstractPlatform
* if default value has changed and another
* default constraint already exists for the column.
*/
if ($columnDefaultHasChanged && ( ! empty($fromColumnDefault) || is_numeric($fromColumnDefault))) {
if ($columnDefaultHasChanged && null !== $fromColumnDefault) {
$queryParts[] = 'DROP CONSTRAINT ' .
$this->generateDefaultConstraintName($diff->name, $columnDiff->oldColumnName);
}
@ -408,7 +406,7 @@ class SQLServerPlatform extends AbstractPlatform
$queryParts[] = 'ALTER COLUMN ' .
$this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef);
if ($columnDefaultHasChanged && (! empty($columnDef['default']) || is_numeric($columnDef['default']))) {
if ($columnDefaultHasChanged && isset($columnDef['default'])) {
$columnDef['name'] = $column->getQuotedName($this);
$queryParts[] = 'ADD' . $this->getDefaultConstraintDeclarationSQL($diff->name, $columnDef);
}
@ -427,7 +425,7 @@ class SQLServerPlatform extends AbstractPlatform
* Drop existing default constraint for the old column name
* if column has default value.
*/
if ( ! empty($columnDef['default']) || is_numeric($columnDef['default'])) {
if (isset($columnDef['default'])) {
$queryParts[] = 'DROP CONSTRAINT ' .
$this->generateDefaultConstraintName($diff->name, $oldColumnName);
}
@ -438,7 +436,7 @@ class SQLServerPlatform extends AbstractPlatform
/**
* Readd default constraint for the new column name.
*/
if ( ! empty($columnDef['default']) || is_numeric($columnDef['default'])) {
if (isset($columnDef['default'])) {
$columnDef['name'] = $column->getQuotedName($this);
$queryParts[] = 'ADD' . $this->getDefaultConstraintDeclarationSQL($diff->name, $columnDef);
}

@ -543,7 +543,6 @@ class SqlitePlatform extends AbstractPlatform
'decimal' => 'decimal',
'numeric' => 'decimal',
'blob' => 'blob',
'integer unsigned' => 'integer',
);
}

@ -19,8 +19,6 @@
namespace Doctrine\DBAL;
use Doctrine\DBAL\Connection;
/**
* Utility class that parses sql statements with regard to types and parameters.
*
@ -34,8 +32,9 @@ class SQLParserUtils
const NAMED_TOKEN = '(?<!:):[a-zA-Z_][a-zA-Z0-9_]*';
// Quote characters within string literals can be preceded by a backslash.
const ESCAPED_SINGLE_QUOTED_TEXT = "'(?:[^'\\\\]|\\\\'|\\\\\\\\)*'";
const ESCAPED_DOUBLE_QUOTED_TEXT = '"(?:[^"\\\\]|\\\\"|\\\\\\\\)*"';
const ESCAPED_SINGLE_QUOTED_TEXT = "'(?:[^'\\\\]|\\\\'?)*'";
const ESCAPED_DOUBLE_QUOTED_TEXT = '"(?:[^"\\\\]|\\\\"?)*"';
const ESCAPED_BACKTICK_QUOTED_TEXT = '`(?:[^`\\\\]|\\\\`?)*`';
/**
* Gets an array of the placeholders in an sql statements as keys and their positions in the query string.
@ -194,8 +193,10 @@ class SQLParserUtils
*/
static private function getUnquotedStatementFragments($statement)
{
$literal = self::ESCAPED_SINGLE_QUOTED_TEXT . '|' . self::ESCAPED_DOUBLE_QUOTED_TEXT;
preg_match_all("/([^'\"]+)(?:$literal)?/s", $statement, $fragments, PREG_OFFSET_CAPTURE);
$literal = self::ESCAPED_SINGLE_QUOTED_TEXT . '|' .
self::ESCAPED_DOUBLE_QUOTED_TEXT . '|' .
self::ESCAPED_BACKTICK_QUOTED_TEXT;
preg_match_all("/([^'\"`]+)(?:$literal)?/s", $statement, $fragments, PREG_OFFSET_CAPTURE);
return $fragments[1];
}

@ -71,4 +71,12 @@ class ColumnDiff
{
return in_array($propertyName, $this->changedProperties);
}
/**
* @return \Doctrine\DBAL\Schema\Identifier
*/
public function getOldColumnName()
{
return new Identifier($this->oldColumnName);
}
}

@ -322,11 +322,11 @@ class Comparator
*/
public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2)
{
if (array_map('strtolower', $key1->getLocalColumns()) != array_map('strtolower', $key2->getLocalColumns())) {
if (array_map('strtolower', $key1->getUnquotedLocalColumns()) != array_map('strtolower', $key2->getUnquotedLocalColumns())) {
return true;
}
if (array_map('strtolower', $key1->getForeignColumns()) != array_map('strtolower', $key2->getForeignColumns())) {
if (array_map('strtolower', $key1->getUnquotedForeignColumns()) != array_map('strtolower', $key2->getUnquotedForeignColumns())) {
return true;
}
@ -367,7 +367,15 @@ class Comparator
$changedProperties[] = 'notnull';
}
if ($column1->getDefault() != $column2->getDefault()) {
$column1Default = $column1->getDefault();
$column2Default = $column2->getDefault();
if ($column1Default != $column2Default ||
// Null values need to be checked additionally as they tell whether to create or drop a default value.
// null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
(null === $column1Default && null !== $column2Default) ||
(null === $column2Default && null !== $column1Default)
) {
$changedProperties[] = 'default';
}

@ -41,7 +41,7 @@ class DrizzleSchemaManager extends AbstractSchemaManager
$options = array(
'notnull' => !(bool)$tableColumn['IS_NULLABLE'],
'length' => (int)$tableColumn['CHARACTER_MAXIMUM_LENGTH'],
'default' => empty($tableColumn['COLUMN_DEFAULT']) ? null : $tableColumn['COLUMN_DEFAULT'],
'default' => isset($tableColumn['COLUMN_DEFAULT']) ? $tableColumn['COLUMN_DEFAULT'] : null,
'autoincrement' => (bool)$tableColumn['IS_AUTO_INCREMENT'],
'scale' => (int)$tableColumn['NUMERIC_SCALE'],
'precision' => (int)$tableColumn['NUMERIC_PRECISION'],

@ -163,6 +163,26 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
return $columns;
}
/**
* Returns unquoted representation of local table column names for comparison with other FK
*
* @return array
*/
public function getUnquotedLocalColumns()
{
return array_map(array($this, 'trimQuotes'), $this->getLocalColumns());
}
/**
* Returns unquoted representation of foreign table column names for comparison with other FK
*
* @return array
*/
public function getUnquotedForeignColumns()
{
return array_map(array($this, 'trimQuotes'), $this->getForeignColumns());
}
/**
* {@inheritdoc}
*

@ -113,10 +113,16 @@ class OracleSchemaManager extends AbstractSchemaManager
$tableColumn['column_name'] = '';
}
if (stripos($tableColumn['data_default'], 'NULL') !== null) {
if ($tableColumn['data_default'] === 'NULL') {
$tableColumn['data_default'] = null;
}
if (null !== $tableColumn['data_default']) {
// Default values returned from database are enclosed in single quotes.
// Sometimes trailing spaces are also encountered.
$tableColumn['data_default'] = trim(trim($tableColumn['data_default']), "'");
}
$precision = null;
$scale = null;

@ -343,6 +343,14 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
break;
case 'bool':
case 'boolean':
if ($tableColumn['default'] === 'true') {
$tableColumn['default'] = true;
}
if ($tableColumn['default'] === 'false') {
$tableColumn['default'] = false;
}
$length = null;
break;
case 'text':

@ -244,16 +244,22 @@ class SqliteSchemaManager extends AbstractSchemaManager
*/
protected function _getPortableTableColumnDefinition($tableColumn)
{
$e = explode('(', $tableColumn['type']);
$tableColumn['type'] = $e[0];
if (isset($e[1])) {
$length = trim($e[1], ')');
$parts = explode('(', $tableColumn['type']);
$tableColumn['type'] = $parts[0];
if (isset($parts[1])) {
$length = trim($parts[1], ')');
$tableColumn['length'] = $length;
}
$dbType = strtolower($tableColumn['type']);
$length = isset($tableColumn['length']) ? $tableColumn['length'] : null;
$unsigned = (boolean) isset($tableColumn['unsigned']) ? $tableColumn['unsigned'] : false;
$unsigned = false;
if (strpos($dbType, ' unsigned') !== false) {
$dbType = str_replace(' unsigned', '', $dbType);
$unsigned = true;
}
$fixed = false;
$type = $this->_platform->getDoctrineTypeMapping($dbType);
$default = $tableColumn['dflt_value'];

@ -34,7 +34,7 @@ class Version
/**
* Current Doctrine Version.
*/
const VERSION = '2.4.1';
const VERSION = '2.4.2';
/**
* Compares a Doctrine version with the current one.

@ -0,0 +1,8 @@
build.properties
build/
logs/
reports/
dist/
tests/phpunit.xml
vendor/
composer.lock

@ -3,5 +3,7 @@ language: php
php:
- 5.3
- 5.4
- 5.5
before_script: "composer install --dev"
install:
- "composer install --dev"

@ -1,4 +1,5 @@
version=2.0.0ALPHA1
version.stripped=2.0.0
stability=alpha
build.dir=build
dist.dir=dist

@ -17,7 +17,7 @@
<!--
Fileset for the sources of the Doctrine Common dependency.
-->
<fileset id="common-sources" dir="./lib/vendor/doctrine-common/lib">
<fileset id="common-sources" dir="vendor/doctrine/common/lib">
<include name="Doctrine/Common/**"/>
</fileset>
@ -31,15 +31,22 @@
<!--
Fileset for the sources of the Doctrine DBAL package.
-->
<fileset id="dbal-sources" dir="./lib/vendor/doctrine-dbal/lib">
<fileset id="dbal-sources" dir="vendor/doctrine/dbal/lib">
<include name="Doctrine/DBAL/**"/>
</fileset>
<!--
Fileset for source of the Symfony YAML and Console components.
Fileset for source of the Symfony Console components.
-->
<fileset id="symfony-sources" dir="./lib/vendor">
<include name="Symfony/Components/**"/>
<fileset id="symfony-console-sources" dir="vendor/symfony/console">
<include name="Symfony/Component/**"/>
</fileset>
<!--
Fileset for source of the Symfony YAML components.
-->
<fileset id="symfony-yaml-sources" dir="vendor/symfony/yaml">
<include name="Symfony/Component/**"/>
</fileset>
<!--
@ -74,19 +81,17 @@
<target name="build-migrations" depends="test">
<copy todir="${build.dir}/migrations">
<fileset refid="shared-artifacts"/>
</copy>
<copy todir="${build.dir}/migrations">
<fileset refid="common-sources"/>
<fileset refid="dbal-sources" />
<fileset refid="migrations-sources"/>
<fileset refid="symfony-console-sources"/>
<fileset refid="symfony-yaml-sources"/>
</copy>
<copy todir="${build.dir}/migrations/Doctrine">
<fileset refid="symfony-sources"/>
</copy>
<exec command="sed 's/${version}-DEV/${version}/' ${build.dir}/migrations/Doctrine/DBAL/Migrations/Version.php > ${build.dir}/migrations/Doctrine/DBAL/Migrations/Version2.php" passthru="true" />
<exec command="mv ${build.dir}/migrations/Doctrine/DBAL/Migrations/Version2.php ${build.dir}/migrations/Doctrine/DBAL/Migrations/Version.php" passthru="true" />
<exec command="sed 's/${version.stripped}-DEV/${version}/' ${build.dir}/migrations/Doctrine/DBAL/Migrations/MigrationsVersion.php > ${build.dir}/migrations/Doctrine/DBAL/Migrations/MigrationsVersion2.php" passthru="true" />
<move file="${build.dir}/migrations/Doctrine/DBAL/Migrations/MigrationsVersion2.php" tofile="${build.dir}/migrations/Doctrine/DBAL/Migrations/MigrationsVersion.php" overwrite="true"/>
<pharpackage destfile="${build.dir}/doctrine-migrations.phar" basedir="${build.dir}/migrations" stub="./phar-cli-stub.php">
<pharpackage destfile="${build.dir}/doctrine-migrations.phar" basedir="${build.dir}/migrations" stub="./phar-cli-stub.php" compression="gzip">
<fileset dir="${build.dir}/migrations">
<include name="**/**" />
</fileset>
@ -108,7 +113,8 @@
Runs the full test suite.
-->
<target name="test" depends="prepare">
<if><equals arg1="${test.phpunit_generate_coverage}" arg2="1" />
<if>
<equals arg1="${test.phpunit_generate_coverage}" arg2="1" />
<then>
<property name="test.phpunit_coverage_file" value="${build.dir}/logs/clover.xml" />
</then>
@ -117,13 +123,14 @@
</else>
</if>
<exec command="phpunit --configuration ${test.phpunit_configuration_option} ${test.phpunit_coverage_option} --log-junit ${project.basedir}/${build.dir}/logs/testsuites.xml Doctrine/DBAL/Migrations/Tests/" dir="./tests" passthru="true" />
<exec command="phpunit --configuration ${test.phpunit_configuration_option} ${test.phpunit_coverage_option} --log-junit ${project.basedir}/${build.dir}/logs/testsuites.xml ./tests/Doctrine/DBAL/Migrations/Tests/" passthru="true" />
<phpunitreport infile="${build.dir}/logs/testsuites.xml" format="frames" todir="${report.dir}/tests" />
<tstamp/>
<copy file="${build.dir}/logs/testsuites.xml" tofile="${log.archive.dir}/latest/log.xml" overwrite="true"/>
<if><equals arg1="${test.pmd_reports}" arg2="1" />
<if>
<equals arg1="${test.pmd_reports}" arg2="1" />
<then>
<exec command="${test.pdepend_exec} --jdepend-xml=${build.dir}/logs/jdepend.xml ./lib/Doctrine" />
<exec command="${test.phpmd_exec} ./lib/Doctrine xml codesize --reportfile ${build.dir}/logs/phpmd.xml" />
@ -140,21 +147,21 @@
<target name="build-packages" depends="build-migrations">
<taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2" />
<d51pearpkg2 baseinstalldir="/" dir="${build.dir}/migrations">
<name>DoctrineMigrations</name>
<summary>Doctrine Database Migrations</summary>
<channel>pear.doctrine-project.org</channel>
<description>The Doctrine migrations offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is easy to use and a very powerful tool!</description>
<lead user="jwage" name="Jonathan H. Wage" email="jonwage@gmail.com" />
<license>LGPL</license>
<version release="${version}" api="${version}" />
<stability release="${stability}" api="${stability}" />
<notes>-</notes>
<dependencies>
<php minimum_version="5.3.0" />
<pear minimum_version="1.6.0" recommended_version="1.6.1" />
</dependencies>
<name>DoctrineMigrations</name>
<summary>Doctrine Database Migrations</summary>
<channel>pear.doctrine-project.org</channel>
<description>The Doctrine migrations offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is easy to use and a very powerful tool!</description>
<lead user="jwage" name="Jonathan H. Wage" email="jonwage@gmail.com" />
<license>LGPL</license>
<version release="${version.stripped}" api="${version.stripped}" />
<stability release="${stability}" api="${stability}" />
<notes>-</notes>
<dependencies>
<php minimum_version="5.3.0" />
<pear minimum_version="1.6.0" recommended_version="1.6.1" />
</dependencies>
</d51pearpkg2>
<exec command="pear package" dir="${build.dir}/migrations" passthru="true" />
<exec command="mv DoctrineMigrations-${version}.tgz ../../dist" dir="${build.dir}/migrations" passthru="true" />
<move file="${build.dir}/migrations/DoctrineMigrations-${version.stripped}.tgz" todir="${dist.dir}" overwrite="true"/>
</target>
</project>

@ -55,14 +55,14 @@ abstract class AbstractMigration
protected $connection;
/**
* Reference to the SchemaManager instance referened by $_connection
* Reference to the SchemaManager instance referenced by $_connection
*
* @var \Doctrine\DBAL\Schema\AbstractSchemaManager
*/
protected $sm;
/**
* Reference to the DatabasePlatform instance referenced by $_conection
* Reference to the DatabasePlatform instance referenced by $_connection
*
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
@ -116,7 +116,7 @@ abstract class AbstractMigration
}
/**
* Print a warning message if the condition evalutes to TRUE.
* Print a warning message if the condition evaluates to TRUE.
*
* @param boolean $condition
* @param string $message
@ -131,7 +131,7 @@ abstract class AbstractMigration
}
/**
* Abort the migration if the condition evalutes to TRUE.
* Abort the migration if the condition evaluates to TRUE.
*
* @param boolean $condition
* @param string $message
@ -148,7 +148,7 @@ abstract class AbstractMigration
}
/**
* Skip this migration (but not the next ones) if condition evalutes to TRUE.
* Skip this migration (but not the next ones) if condition evaluates to TRUE.
*
* @param boolean $condition
* @param string $message

@ -78,8 +78,8 @@ abstract class AbstractCommand extends Command
return $output->writeln($message);
});
if ($this->getApplication()->getHelperSet()->has('db')) {
$conn = $this->getHelper('db')->getConnection();
if ($this->getApplication()->getHelperSet()->has('connection')) {
$conn = $this->getHelper('connection')->getConnection();
} elseif ($input->getOption('db-configuration')) {
if ( ! file_exists($input->getOption('db-configuration'))) {
throw new \InvalidArgumentException("The specified connection file is not a valid file.");

@ -61,7 +61,7 @@ You can output the would be executed SQL statements to a file with <comment>--wr
<info>%command.full_name% YYYYMMDDHHMMSS --write-sql</info>
Or you can also execute the migration without a warning message wich you need to interact with:
Or you can also execute the migration without a warning message which you need to interact with:
<info>%command.full_name% --no-interaction</info>
EOT

@ -61,7 +61,6 @@ EOT
public function execute(InputInterface $input, OutputInterface $output)
{
$configuration = $this->getMigrationConfiguration($input, $output);
$migration = new Migration($configuration);
if ($input->getOption('add') === false && $input->getOption('delete') === false) {
throw new \InvalidArgumentException('You must specify whether you want to --add or --delete the specified version.');

@ -26,10 +26,11 @@ $p->setSignatureAlgorithm(Phar::SHA1);
$p->startBuffering();
$dirs = array(
'./lib' => '/Doctrine\/DBAL\/Migrations/',
'./lib/vendor/doctrine-dbal/lib' => '/Doctrine/',
'./lib/vendor/doctrine-common/lib' => '/Doctrine/',
'./lib/vendor' => '/Symfony/'
__DIR__ . '/lib' => '/Doctrine\/DBAL\/Migrations/',
__DIR__ . '/vendor/doctrine/dbal/lib' => '/Doctrine/',
__DIR__ . '/vendor/doctrine/common/lib' => '/Doctrine/',
__DIR__ . '/vendor/symfony/console' => '/Symfony/',
__DIR__ . '/vendor/symfony/yaml' => '/Symfony/',
);
foreach ($dirs as $dir => $filter) {

@ -69,7 +69,7 @@ class ConcatFunction extends FunctionNode
$parser->match(Lexer::T_COMMA);
$this->secondStringPrimary = $parser->StringPrimary();
$this->secondStringPrimary = $parser->StringPrimary();
$this->concatExpressions[] = $this->secondStringPrimary;
while ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) {

@ -0,0 +1,2 @@
composer.lock
vendor

@ -0,0 +1 @@
configdoc/usage.xml -crlf

@ -0,0 +1,24 @@
tags
conf/
test-settings.php
config-schema.php
library/HTMLPurifier/DefinitionCache/Serializer/*/
library/standalone/
library/HTMLPurifier.standalone.php
library/HTMLPurifier*.tgz
library/package*.xml
smoketests/test-schema.html
configdoc/*.html
configdoc/configdoc.xml
docs/doxygen*
*.phpt.diff
*.phpt.exp
*.phpt.log
*.phpt.out
*.phpt.php
*.phpt.skip.php
*.htmlt.ini
*.patch
/*.php
vendor
composer.lock

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save