123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675 |
- <?php
- use Doctrine\Common\Persistence\AbstractManagerRegistry;
- use FranMoreno\Silex\Provider\PagerfantaServiceProvider;
- use Silex\Application;
- use Silex\ServiceProviderInterface;
- use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
- if (is_writable($app['sys_temp_path'])) {
-
- if ($app['debug']) {
- $app->register(
- new Silex\Provider\MonologServiceProvider(),
- array(
- 'monolog.logfile' => $app['chamilo.log'],
- 'monolog.name' => 'chamilo',
- )
- );
- }
- }
- $app->register(new Silex\Provider\SecurityServiceProvider(), array(
- 'security.firewalls' => array(
- 'login' => array(
- 'pattern' => '^/login$',
- 'anonymous' => true
- ),
- 'admin' => array(
-
- 'pattern' => '^/.*$',
- 'form' => array(
- 'login_path' => '/login',
- 'check_path' => '/admin/login_check',
- 'default_target_path' => '/userportal',
- 'username_parameter' => 'username',
- 'password_parameter' => 'password',
- ),
- 'logout' => array(
- 'logout_path' => '/admin/logout',
- 'target' => '/'
- ),
- 'users' => $app->share(function() use ($app) {
- return $app['orm.em']->getRepository('Entity\User');
- }),
- 'anonymous' => true
- ),
- )
- ));
- $app['security.encoder.digest'] = $app->share(function($app) {
-
-
-
- return new MessageDigestPasswordEncoder($app['configuration']['password_encryption'], false, 1);
- });
- $app['security.authentication.success_handler.admin'] = $app->share(function($app) {
- return new ChamiloLMS\Component\Auth\LoginSuccessHandler($app['url_generator'], $app['security']);
- });
- $app['security.authentication.logout_handler.admin'] = $app->share(function($app) {
- return new ChamiloLMS\Component\Auth\LogoutSuccessHandler($app['url_generator'], $app['security']);
- });
- $app['security.role_hierarchy'] = array(
- 'ROLE_ADMIN' => array('ROLE_QUESTION_MANAGER', 'ROLE_TEACHER', 'ROLE_ALLOWED_TO_SWITCH'),
- 'ROLE_TEACHER' => array('ROLE_STUDENT'),
- 'ROLE_RRHH' => array('ROLE_TEACHER'),
- 'ROLE_QUESTION_MANAGER' => array('ROLE_QUESTION_MANAGER'),
- 'ROLE_SESSION_MANAGER' => array('ROLE_SESSION_MANAGER'),
- 'ROLE_STUDENT' => array('ROLE_STUDENT'),
- 'ROLE_ANONYMOUS' => array('ROLE_ANONYMOUS'),
- 'ROLE_JURY_PRESIDENT' => array('ROLE_JURY_PRESIDENT', 'ROLE_JURY_MEMBER', 'ROLE_JURY_SUBSTITUTE'),
- 'ROLE_JURY_SUBSTITUTE' => array('ROLE_JURY_SUBSTITUTE', 'ROLE_JURY_MEMBER'),
- 'ROLE_JURY_MEMBER' => array('ROLE_JURY_MEMBER')
- );
- $app['security.access_rules'] = array(
-
- array('^/admin/administrator', 'ROLE_ADMIN'),
- array('^/main/admin/.*', 'ROLE_ADMIN'),
- array('^/admin/questionmanager', 'ROLE_QUESTION_MANAGER'),
- array('^/main/.*', array('ROLE_STUDENT')),
- array('^/admin/director', 'ROLE_DIRECTOR'),
- array('^/tool/.*', array('ROLE_ADMIN','ROLE_TEACHER')),
- array('^/admin/jury_president', 'ROLE_JURY_PRESIDENT'),
- array('^/admin/jury_member', 'ROLE_JURY_MEMBER')
-
- );
- $app->register(new Silex\Provider\ServiceControllerServiceProvider());
- $app->register(new Silex\Provider\ValidatorServiceProvider());
- $app->register(new Silex\Provider\TranslationServiceProvider(), array(
- 'locale' => 'en',
- 'locale_fallback' => 'en'
- ));
- $app->register(new Silex\Provider\FormServiceProvider());
- $app->register(new Silex\Provider\UrlGeneratorServiceProvider());
- class ManagerRegistry extends AbstractManagerRegistry
- {
- protected $container;
- protected function getService($name)
- {
- return $this->container[$name];
- }
- protected function resetService($name)
- {
- unset($this->container[$name]);
- }
- public function getAliasNamespace($alias)
- {
- throw new \BadMethodCallException('Namespace aliases not supported.');
- }
- public function setContainer(Application $container)
- {
- $this->container = $container;
- }
- }
- $app['form.extensions'] = $app->share($app->extend('form.extensions', function ($extensions, $app) {
- $managerRegistry = new ManagerRegistry(null, array('db'), array('orm.em'), null, null, $app['orm.proxies_namespace']);
- $managerRegistry->setContainer($app);
- $extensions[] = new \Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension($managerRegistry);
- return $extensions;
- }));
- if (isset($app['configuration']['main_database'])) {
-
- $defaultDatabaseOptions = array(
- 'db_read' => array(
- 'driver' => 'pdo_mysql',
- 'host' => $app['configuration']['db_host'],
- 'dbname' => $app['configuration']['main_database'],
- 'user' => $app['configuration']['db_user'],
- 'password' => $app['configuration']['db_password'],
- 'charset' => 'utf8',
-
- ),
- 'db_write' => array(
- 'driver' => 'pdo_mysql',
- 'host' => $app['configuration']['db_host'],
- 'dbname' => $app['configuration']['main_database'],
- 'user' => $app['configuration']['db_user'],
- 'password' => $app['configuration']['db_password'],
- 'charset' => 'utf8',
-
- ),
- );
-
- if (isset($app['configuration']['db.options'])) {
- $defaultDatabaseOptions = $app['configuration']['db.options'];
- }
- $app->register(
- new Silex\Provider\DoctrineServiceProvider(),
- array(
- 'dbs.options' => $defaultDatabaseOptions
- )
- );
- $mappings = array(
- array(
-
- 'use_simple_annotation_reader' => false,
- 'type' => 'annotation',
- 'namespace' => 'Entity',
- 'path' => api_get_path(INCLUDE_PATH).'Entity',
-
- ),
- array(
- 'use_simple_annotation_reader' => false,
- 'type' => 'annotation',
- 'namespace' => 'Gedmo',
- 'path' => api_get_path(SYS_PATH).'vendors/gedmo/doctrine-extensions/lib/Gedmo',
- )
- );
-
- $app->register(
- new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider,
- array(
-
-
-
- 'orm.auto_generate_proxies' => true,
- 'orm.proxies_dir' => $app['db.orm.proxies_dir'],
- 'orm.proxies_namespace' => 'Doctrine\ORM\Proxy\Proxy',
- 'orm.ems.default' => 'db_read',
- 'orm.ems.options' => array(
- 'db_read' => array(
- 'connection' => 'db_read',
- 'mappings' => $mappings,
- ),
- 'db_write' => array(
- 'connection' => 'db_write',
- 'mappings' => $mappings,
- ),
- ),
- )
- );
- }
- $app->register(
- new Silex\Provider\TwigServiceProvider(),
- array(
- 'twig.path' => array(
- api_get_path(SYS_CODE_PATH).'template',
- api_get_path(SYS_PLUGIN_PATH)
- ),
-
- 'twig.form.templates' => array('form_div_layout.html.twig', 'default/form/form_custom_template.tpl'),
- 'twig.options' => array(
- 'debug' => $app['debug'],
- 'charset' => 'utf-8',
- 'strict_variables' => false,
- 'autoescape' => false,
- 'cache' => $app['debug'] ? false : $app['twig.cache.path'],
- 'optimizations' => -1,
- )
- )
- );
- $app['twig'] = $app->share(
- $app->extend('twig', function ($twig) {
- $twig->addFilter('get_lang', new Twig_Filter_Function('get_lang'));
- $twig->addFilter('get_path', new Twig_Filter_Function('api_get_path'));
- $twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting'));
- $twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
- $twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate'));
- $twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
- $twig->addFilter(
- 'display_page_subheader',
- new Twig_Filter_Function('Display::page_subheader_and_translate')
- );
- $twig->addFilter('icon', new Twig_Filter_Function('Template::get_icon_path'));
- $twig->addFilter('format_date', new Twig_Filter_Function('Template::format_date'));
- return $twig;
- })
- );
- if (is_writable($app['sys_temp_path'])) {
- if ($app['show_profiler']) {
-
- $app->register(
- $p = new Silex\Provider\WebProfilerServiceProvider(),
- array(
- 'profiler.cache_dir' => $app['profiler.cache_dir'],
- )
- );
- $app->mount('/_profiler', $p);
-
-
- }
- }
- $app->register(new PagerfantaServiceProvider());
- $app['pagerfanta.view.options'] = array(
- 'routeName' => null,
- 'routeParams' => array(),
- 'pageParameter' => '[page]',
- 'proximity' => 3,
- 'next_message' => '»',
- 'prev_message' => '«',
- 'default_view' => 'twitter_bootstrap'
- );
- $app->register(new \Knp\Menu\Silex\KnpMenuServiceProvider());
- define('IMAGE_PROCESSOR', 'gd');
- $app->register(new Grom\Silex\ImagineServiceProvider(), array(
- 'imagine.factory' => 'Gd'
- ));
- $app['dbal_logger'] = $app->share(function() {
-
- });
- if ($app['debug']) {
-
- }
- $app->register(new Silex\Provider\SwiftmailerServiceProvider(), array(
- 'swiftmailer.options' => array(
- 'host' => isset($platform_email['SMTP_HOST']) ? $platform_email['SMTP_HOST'] : null,
- 'port' => isset($platform_email['SMTP_PORT']) ? $platform_email['SMTP_PORT'] : null,
- 'username' => isset($platform_email['SMTP_USER']) ? $platform_email['SMTP_USER'] : null,
- 'password' => isset($platform_email['SMTP_PASS']) ? $platform_email['SMTP_PASS'] : null,
- 'encryption' => null,
- 'auth_mode' => null
- )
- ));
- $app['mailer'] = $app->share(function ($app) {
- return new \Swift_Mailer($app['swiftmailer.transport']);
- });
- if ($app['assetic.enabled']) {
- $app->register(new SilexAssetic\AsseticServiceProvider(), array(
- 'assetic.options' => array(
- 'debug' => $app['debug'],
- 'auto_dump_assets' => $app['assetic.auto_dump_assets'],
- )
- ));
-
- $app['assetic.filter_manager'] = $app->share(
- $app->extend('assetic.filter_manager', function($fm, $app) {
- $fm->set('lessphp', new Assetic\Filter\LessphpFilter());
- return $fm;
- })
- );
- $app['assetic.asset_manager'] = $app->share(
- $app->extend('assetic.asset_manager', function($am, $app) {
- $am->set('styles', new Assetic\Asset\AssetCache(
- new Assetic\Asset\GlobAsset(
- $app['assetic.input.path_to_css'],
- array($app['assetic.filter_manager']->get('lessphp'))
- ),
- new Assetic\Cache\FilesystemCache($app['assetic.path_to_cache'])
- ));
- $am->get('styles')->setTargetPath($app['assetic.output.path_to_css']);
- $am->set('scripts', new Assetic\Asset\AssetCache(
- new Assetic\Asset\GlobAsset($app['assetic.input.path_to_js']),
- new Assetic\Cache\FilesystemCache($app['assetic.path_to_cache'])
- ));
- $am->get('scripts')->setTargetPath($app['assetic.output.path_to_js']);
- return $am;
- })
- );
- }
- $app->register(new Neutron\Silex\Provider\FilesystemServiceProvider());
- class ChamiloServiceProvider implements ServiceProviderInterface
- {
- public function register(Application $app)
- {
-
- $app['template'] = $app->share(function () use ($app) {
- $template = new Template($app);
- return $template;
- });
- $app['paths'] = $app->share(function () use ($app) {
- return array(
-
- 'root_sys' => $app['root_sys'],
- 'sys_root' => $app['root_sys'],
- 'sys_data_path' => $app['sys_data_path'],
- 'sys_config_path' => $app['sys_config_path'],
- 'sys_temp_path' => $app['sys_temp_path'],
- 'sys_log_path' => $app['sys_log_path']
- );
- });
-
- $app['chamilo.filesystem'] = $app->share(function () use ($app) {
- $filesystem = new ChamiloLMS\Component\DataFilesystem\DataFilesystem($app['paths'], $app['filesystem']);
- return $filesystem;
- });
-
- $app['page_controller'] = $app->share(function () use ($app) {
- $pageController = new PageController($app);
- return $pageController;
- });
-
- $app['mail_generator'] = $app->share(function () use ($app) {
- $mailGenerator = new ChamiloLMS\Component\Mail\MailGenerator($app['twig'], $app['mailer']);
- return $mailGenerator;
- });
-
- $app['database'] = $app->share(function () use ($app) {
- $db = new Database($app['db'], $app['dbs']);
- return $db;
- });
- }
- public function boot(Application $app)
- {
- }
- }
- $app->register(new ChamiloServiceProvider(), array());
- $app['pages.controller'] = $app->share(
- function () use ($app) {
- return new PagesController($app['pages.repository']);
- }
- );
- $app['index.controller'] = $app->share(
- function () use ($app) {
- $controller = new ChamiloLMS\Controller\IndexController($app);
- return $controller;
- }
- );
- $app['legacy.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\LegacyController($app);
- }
- );
- $app['userPortal.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\UserPortalController($app);
- }
- );
- $app['learnpath.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\LearnpathController();
- }
- );
- $app['course_home.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\CourseHomeController();
- }
- );
- $app['course_home.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\CourseHomeController();
- }
- );
- $app['introduction_tool.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\IntroductionToolController();
- }
- );
- $app['certificate.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\CertificateController();
- }
- );
- $app['user.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\UserController();
- }
- );
- $app['news.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\NewsController();
- }
- );
- $app['editor.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\EditorController();
- }
- );
- $app['question_manager.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\QuestionManager\QuestionManagerController();
- }
- );
- $app['exercise_manager.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\ExerciseController($app);
- }
- );
- $app['admin.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\AdministratorController($app);
- }
- );
- $app['role.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\Administrator\RoleController($app);
- }
- );
- $app['question_score.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\Administrator\QuestionScoreController($app);
- }
- );
- $app['question_score_name.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\Administrator\QuestionScoreNameController($app);
- }
- );
- $app['model_ajax.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\ModelAjaxController();
- }
- );
- $app['branch.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\Administrator\BranchController($app);
- }
- );
- $app['branch_director.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\Director\BranchDirectorController($app);
- }
- );
- $app['jury.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\Administrator\JuryController($app);
- }
- );
- $app['jury_president.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\JuryPresident\JuryPresidentController($app);
- }
- );
- $app['jury_member.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\JuryMember\JuryMemberController($app);
- }
- );
- $app['curriculum_category.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Tool\Curriculum\CurriculumCategoryController($app);
- }
- );
- $app['curriculum_item.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Tool\Curriculum\CurriculumItemController($app);
- }
- );
- $app['curriculum_user.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Tool\Curriculum\CurriculumUserController($app);
- }
- );
|