diff --git a/composer.json b/composer.json index 6966a1f23a..0d646a7b45 100755 --- a/composer.json +++ b/composer.json @@ -50,10 +50,10 @@ "ext-mbstring": "*", "ext-bcmath": "*", "twig/twig": "2.*", - "doctrine/orm": "^2.5.11", - "doctrine/dbal": "~2.5", + "doctrine/orm": "^2.6", + "doctrine/dbal": "~2.7", "doctrine/data-fixtures": "~1.0@dev", - "doctrine/doctrine-bundle": "^1.6.10", + "doctrine/doctrine-bundle": "^1.9", "doctrine/doctrine-fixtures-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^1.3", @@ -63,7 +63,7 @@ "sensiolabs/security-checker": "^4.1", "symfony/asset": "^4.0", - "symfony/expression-language": "^3.0|^4.0", + "symfony/expression-language": "^4.0", "symfony/flex": "^1.0", "symfony/form": "^3.0|^4.0", "symfony/framework-bundle": "^3.0|^4.0", @@ -72,9 +72,9 @@ "symfony/security-bundle": "^4.0", "symfony/swiftmailer-bundle": "^3.2", "symfony/translation": "^4.0", - "symfony/twig-bundle": "^3.0|^4.0", - "symfony/validator": "^3.0|^4.0", - "symfony/yaml": "^3.0|^4.0", + "symfony/twig-bundle": "^4.0", + "symfony/validator": "^4.0", + "symfony/yaml": "^4.0", "symfony/annotations-pack": "^1.0", "symfony/webpack-encore-pack": "^1.0", "symfony/apache-pack": "^1.0", @@ -82,40 +82,42 @@ "twig/extensions": "^1.5", "white-october/pagerfanta-bundle": "^1.1", "chamilo/settings-bundle": "dev-master", - "sonata-project/admin-bundle": "3.x-dev", + "sonata-project/admin-bundle": "~3.0", "sonata-project/block-bundle": "~3.0", - "sonata-project/cache": "1.x-dev", - "sonata-project/cache-bundle": "~2.1@dev", + "sonata-project/cache": "~1.0", + "sonata-project/cache-bundle": "~2.0", "sonata-project/classification-bundle": "~3.0", "sonata-project/timeline-bundle" : "~3.0", "sonata-project/core-bundle": "~3.0", - "sonata-project/datagrid-bundle": "^2.2", + "sonata-project/datagrid-bundle": "^2.3", "sonata-project/doctrine-extensions": "~1@dev", "sonata-project/doctrine-orm-admin-bundle": "~3.0", - "sonata-project/easy-extends-bundle": "~2.1@dev", + "sonata-project/easy-extends-bundle": "~2.5", "sonata-project/exporter": "~1", - "sonata-project/formatter-bundle": "~3.0", "sonata-project/intl-bundle": "~2.4.0", "sonata-project/media-bundle": "~3.0", "sonata-project/notification-bundle": "~3.0", "sonata-project/page-bundle": "~3.0", "sonata-project/seo-bundle": "~2.0", - "sonata-project/sonata-composer": "dev-master", "sonata-project/user-bundle": "~4.0", + "sonata-project/formatter-bundle": "~3.0", + + "egeloen/ckeditor-bundle": "~5.0|~6.0", - "stephpy/timeline-bundle": "~2.5", + "stephpy/timeline-bundle": "~3.0", "stof/doctrine-extensions-bundle": "~1.0", "sunra/php-simple-html-dom-parser": "~1.5.0", - "sylius/resource-bundle": "1.0.4", - "sylius/resource": "~1.0", + "sylius/resource-bundle": "dev-master", + "sylius/resource": "dev-master", + "sylius/registry": "dev-master", "friendsofsymfony/jsrouting-bundle": "~2.0", "gedmo/doctrine-extensions": "~2.4", "gregwar/captcha-bundle": "^2.0", - "helios-ag/fm-elfinder-bundle": "~6.0", + "helios-ag/fm-elfinder-bundle": "~8.0", - "knplabs/gaufrette": "~0.3", + "knplabs/gaufrette": "~0.5", "knplabs/doctrine-behaviors": "~1.5", "knplabs/knp-components": "^1.3", @@ -147,22 +149,23 @@ "graphp/graphviz": "~0.2.0", "graphp/algorithms": "~0.8.0", "php-ffmpeg/php-ffmpeg": "0.5.1", - "imagine/imagine": "~0.6", + "imagine/imagine": "~0.7", "jeroendesloovere/vcard": "~1.5", "jimmiw/php-time-ago": "2.0.*", "phpoffice/phpword": "^0.14.0", "kigkonsult/icalcreator": "2.24", "essence/essence": "~3.0", "paragonie/random-lib": "2.0.0", - "lunetics/locale-bundle": "2.5.*", - "hwi/oauth-bundle": "^0.6.0", + "lunetics/locale-bundle": "^2.6", + "hwi/oauth-bundle": "~0.6", "php-http/guzzle6-adapter": "^1.1", "php-http/httplug-bundle": "^1.8", - "knplabs/knp-menu-bundle": "^2.0" + "knplabs/knp-menu-bundle": "^2.0", + "symfony/requirements-checker": "^1.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.7", - "symfony/browser-kit": "^3.0|^4.0", + "symfony/browser-kit": "^4.0", "symfony/css-selector": "^4.0", "symfony/debug-bundle": "^4.0", "symfony/dotenv": "^4.0", @@ -192,7 +195,8 @@ "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd", - "security-checker security:check": "script" + "security-checker security:check": "script", + "requirements-checker": "script" } } } diff --git a/config/bundles.php b/config/bundles.php index 251792f228..0aa7c67567 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -32,9 +32,6 @@ return [ Spy\TimelineBundle\SpyTimelineBundle::class => ['all' => true], Sonata\IntlBundle\SonataIntlBundle::class => ['all' => true], Sonata\TimelineBundle\SonataTimelineBundle::class => ['all' => true], - Knp\Bundle\MarkdownBundle\KnpMarkdownBundle::class => ['all' => true], - Ivory\CKEditorBundle\IvoryCKEditorBundle::class => ['all' => true], - Sonata\FormatterBundle\SonataFormatterBundle::class => ['all' => true], JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true], Sonata\MediaBundle\SonataMediaBundle::class => ['all' => true], FOS\JsRoutingBundle\FOSJsRoutingBundle::class => ['all' => true], @@ -56,7 +53,6 @@ return [ Chamilo\MediaBundle\ChamiloMediaBundle::class => ['all' => true], Chamilo\NotificationBundle\ChamiloNotificationBundle::class => ['all' => true], Chamilo\SettingsBundle\ChamiloSettingsBundle::class => ['all' => true], - HWI\Bundle\OAuthBundle\HWIOAuthBundle::class => ['all' => true], winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true], Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true], Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true], @@ -65,4 +61,8 @@ return [ Http\HttplugBundle\HttplugBundle::class => ['all' => true], Oneup\FlysystemBundle\OneupFlysystemBundle::class => ['all' => true], Sonata\CacheBundle\SonataCacheBundle::class => ['all' => true], + Ivory\CKEditorBundle\IvoryCKEditorBundle::class => ['all' => true], + Knp\Bundle\MarkdownBundle\KnpMarkdownBundle::class => ['all' => true], + Sonata\FormatterBundle\SonataFormatterBundle::class => ['all' => true], + HWI\Bundle\OAuthBundle\HWIOAuthBundle::class => ['all' => true], ]; diff --git a/config/packages/chamilo.yaml b/config/packages/chamilo.yaml index 1e880f80ae..a31240fb56 100644 --- a/config/packages/chamilo.yaml +++ b/config/packages/chamilo.yaml @@ -68,7 +68,6 @@ sonata_doctrine_orm_admin: sylius_settings: driver: doctrine/orm - # Course settings chamilo_course: driver: doctrine/orm diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 312028579f..08dcaccd8e 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -14,6 +14,8 @@ doctrine: naming_strategy: doctrine.orm.naming_strategy.underscore auto_mapping: true mappings: + SonataUserBundle: ~ + FOSUserBundle: ~ # App: # is_bundle: false # type: annotation diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 2d7a5fd013..f2223384e1 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -13,7 +13,7 @@ framework: session: # handler_id set to null will use default session handler from php.ini handler_id: ~ - name: ch_sid + name: chamilo2 fragments: ~ http_method_override: true assets: diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 16356d40c8..4b20312d1f 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -1,16 +1,21 @@ # To get started with security, check out the documentation: # http://symfony.com/doc/current/book/security.html security: + encoders: + FOS\UserBundle\Model\UserInterface: + id: chamilo_user.security.encoder + + # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers + providers: + fos_userbundle: + id: fos_user.user_provider.username + access_control: - {path: ^/administrator, role: ROLE_ADMIN} - {path: ^/efconnect, role: ROLE_USER} - {path: ^/elfinder, role: ROLE_USER} - {path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY} - encoders: - FOS\UserBundle\Model\UserInterface: - id: chamilo_user.security.encoder - role_hierarchy: ROLE_SONATA_ADMIN: ROLE_USER ROLE_ADMIN: @@ -37,14 +42,10 @@ security: - ROLE_SONATA_PAGE_ADMIN_BLOCK_EDIT ROLE_ANONYMOUS: [ROLE_ANONYMOUS] - access_decision_manager: + #access_decision_manager: # strategy can be: affirmative, unanimous or consensus - strategy: unanimous - - # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers - providers: - fos_userbundle: - id: fos_user.user_provider.username + # only grant access if none of the voters has denied access + #strategy: unanimous firewalls: # disables authentication for assets and the profiler, adapt it according to your needs @@ -52,24 +53,24 @@ security: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false admin: - pattern: .* - context: user + pattern: ^/ + context: admin + anonymous: true form_login: provider: fos_userbundle csrf_token_generator: security.csrf.token_manager login_path: /login use_forward: false check_path: /login_check - success_handler: chamilo_core.listener.login_success_handler - failure_path: null - remember_me: - secret: '%secret%' - lifetime: 604800 # 1 week in seconds - path: / +# success_handler: chamilo_core.listener.login_success_handler + failure_path: null +# remember_me: +# secret: '%secret%' +# lifetime: 604800 # 1 week in seconds +# path: / logout: path: /logout target: / - anonymous: ~ switch_user: false oauth: resource_owners: diff --git a/config/packages/sonata_formatter.yaml b/config/packages/sonata_formatter.yaml index 82f47c7c7a..0f39b3cf13 100644 --- a/config/packages/sonata_formatter.yaml +++ b/config/packages/sonata_formatter.yaml @@ -1,4 +1,5 @@ sonata_formatter: + default_formatter: text formatters: markdown: service: sonata.formatter.text.markdown diff --git a/config/packages/sonata_page.yaml b/config/packages/sonata_page.yaml index 749abc7738..cc035056a2 100644 --- a/config/packages/sonata_page.yaml +++ b/config/packages/sonata_page.yaml @@ -1,13 +1,15 @@ # more information can be found here http://sonata-project.org/bundles/page sonata_page: + slugify_service: sonata.core.slugify.cocur + multisite: host_with_path_by_locale # host + use_streamed_response: false # set the value to false in debug mode or if the reverse proxy does not handle streamed response + class: page: Chamilo\PageBundle\Entity\Page site: Chamilo\PageBundle\Entity\Site block: Chamilo\PageBundle\Entity\Block snapshot: Chamilo\PageBundle\Entity\Snapshot - multisite: host_with_path_by_locale # host - use_streamed_response: false # set the value to false in debug mode or if the reverse proxy does not handle streamed response ignore_uri_patterns: - ^/administration(.*) # sonata admin - ^/admin(.*) # chamilo admin diff --git a/config/routes.yaml b/config/routes.yaml index 83aac34281..55a69dd147 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -10,7 +10,7 @@ logout: path: /logout sonata_user_admin_security_logout: - path: /logout + path: /administration/logout _admin: resource: routes/sonata_admin.yaml prefix: /administration diff --git a/config/routes/hwi_oauth.yaml b/config/routes/hwi_oauth.yaml index 3c509b6596..3a6dae1913 100644 --- a/config/routes/hwi_oauth.yaml +++ b/config/routes/hwi_oauth.yaml @@ -1,21 +1,21 @@ # HWIOAuthBundle routes -hwi_oauth_redirect: - resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml" - prefix: /connect - -hwi_oauth_connect: - resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml" - prefix: /connect - -hwi_oauth_login: - resource: "@HWIOAuthBundle/Resources/config/routing/login.xml" - prefix: /connect - -facebook_login: - path: /connect/facebook - -google_login: - path: /connect/google - -github_login: - path: /connect/github +#hwi_oauth_redirect: +# resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml" +# prefix: /connect +# +#hwi_oauth_connect: +# resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml" +# prefix: /connect +# +#hwi_oauth_login: +# resource: "@HWIOAuthBundle/Resources/config/routing/login.xml" +# prefix: /connect +# +#facebook_login: +# path: /connect/facebook +# +#google_login: +# path: /connect/google +# +#github_login: +# path: /connect/github diff --git a/config/services.yaml b/config/services.yaml index 9aa5af20e1..4f239f03fc 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -20,26 +20,3 @@ parameters: sonata_media.cdn.host: /uploads/media sonata_page.varnish.command: 'if [ ! -r "/etc/varnish/secret" ]; then echo "VALID ERROR :/"; else varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 {{ COMMAND }} "{{ EXPRESSION }}"; fi;' router.request_context.base_url: '%url_append%' -services: - # default configuration for services in *this* file - _defaults: - autowire: true # Automatically injects dependencies in your services. - autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. - public: false # Allows optimizing the container by removing unused services; this also means - # fetching services directly from the container via $container->get() won't work. - # The best practice is to be explicit about your dependencies anyway. - - # makes classes in src/ available to be used as services - # this creates a service per class whose id is the fully-qualified class name -# Chamilo\: -# resource: '../src/*' -# exclude: '../src/{Entity,Migrations,Tests}' - - # controllers are imported separately to make sure services can be injected - # as action arguments even if you don't extend any base controller class -# App\Controller\: -# resource: '../src/Controller' -# tags: ['controller.service_arguments'] - - # add more service definitions when explicit configuration is needed - # please note that last definitions always *replace* previous ones diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index 4bae766a67..f81c81c7b1 100755 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -595,4 +595,5 @@ try { var_dump($e->getCode()); var_dump($e->getLine()); var_dump($e->getTraceAsString()); + exit; } diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index 711850286d..ba0c344a49 100755 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -354,7 +354,6 @@ if (!empty($_SESSION['_user']['user_id']) && !($login || $logout)) { $password, $uData['salt'] ); - // Check the user's password if (($validPassword || $cas_login) && (trim($login) == $uData['username']) diff --git a/src/CoreBundle/Controller/FrontController.php b/src/CoreBundle/Controller/FrontController.php index 49bb625f5a..a98422fcac 100644 --- a/src/CoreBundle/Controller/FrontController.php +++ b/src/CoreBundle/Controller/FrontController.php @@ -28,8 +28,8 @@ class FrontController extends Controller public function editorTemplates() { $editor = new CkEditor( - $this->container->get('translator.default'), - $this->container->get('router') + $this->get('translator.default'), + $this->get('router') ); $templates = $editor->simpleFormatTemplates(); @@ -78,7 +78,7 @@ class FrontController extends Controller $connector = new Connector( $this->container->get('doctrine')->getManager(), [], - $this->container->get('router'), + $this->get('router'), $this->container->get('translator.default'), $this->container->get('security.authorization_checker'), $this->getUser(), diff --git a/src/CoreBundle/Controller/IndexController.php b/src/CoreBundle/Controller/IndexController.php index ef9d5b38cd..c6684d32af 100644 --- a/src/CoreBundle/Controller/IndexController.php +++ b/src/CoreBundle/Controller/IndexController.php @@ -41,34 +41,9 @@ class IndexController extends BaseController /** @var \PageController $pageController */ //$pageController = $this->get('page_controller'); $pageController = new PageController(); - /* - if (api_get_setting('display_categories_on_homepage') == 'true') { - //$template->assign('course_category_block', $pageController->return_courses_in_categories()); - } - - if (!api_is_anonymous()) { - if (api_is_platform_admin()) { - $pageController->setCourseBlock(); - } else { - $pageController->return_teacher_link(); - } - } - - // Hot courses & announcements - $hotCourses = null; - $announcementsBlock = null; - - // Navigation links - //$pageController->returnNavigationLinks($template->getNavigationLinks()); - $pageController->returnNotice(); - $pageController->returnHelp(); - - if (api_is_platform_admin() || api_is_drh()) { - $pageController->returnSkillsLinks(); - }*/ - - $sessionHandler = $request->getSession(); - $sessionHandler->remove('coursesAlreadyVisited'); + + //$sessionHandler = $request->getSession(); + //$sessionHandler->remove('coursesAlreadyVisited'); $user = $this->getUser(); $userId = 0; @@ -114,7 +89,7 @@ class IndexController extends BaseController $user->addAttribute($smallSize); $userManager->updateUser($user); */ - $this->get('session')->remove('id_session'); + //$this->get('session')->remove('id_session'); return $this->render( '@ChamiloCore/Index/index.html.twig', diff --git a/src/CoreBundle/EventListener/LegacyListener.php b/src/CoreBundle/EventListener/LegacyListener.php index 77b3c7c323..0dd68df266 100644 --- a/src/CoreBundle/EventListener/LegacyListener.php +++ b/src/CoreBundle/EventListener/LegacyListener.php @@ -31,22 +31,6 @@ class LegacyListener } $request = $event->getRequest(); - $controller = $request->get('_controller'); - // Only process legacy listener when loading legacy controller - /*if ($controller != 'Chamilo\CoreBundle\Controller\LegacyController::classicAction') { - return; - }*/ - - /*$skipControllers = [ - 'web_profiler.controller.profiler:toolbarAction', // - 'fos_js_routing.controller:indexAction'// - ]; - - // Skip legacy listener - if (in_array($controller, $skipControllers)) { - return; - }*/ - $session = $request->getSession(); /** @var ContainerInterface $container */ @@ -58,7 +42,7 @@ class LegacyListener Container::setRequest($request); // Legacy way of detect current access_url - $installed = $this->container->getParameter('installed'); + $installed = $container->getParameter('installed'); $urlId = 1; if (!empty($installed)) { diff --git a/src/CoreBundle/EventListener/LegacyLoginListener.php b/src/CoreBundle/EventListener/LegacyLoginListener.php index f16e5de85b..6eff3b932e 100644 --- a/src/CoreBundle/EventListener/LegacyLoginListener.php +++ b/src/CoreBundle/EventListener/LegacyLoginListener.php @@ -62,7 +62,7 @@ class LegacyLoginListener implements EventSubscriberInterface $username = $_SESSION['_user']['username']; $criteria = ['username' => $username]; /** @var User $user */ - $user = $container->get('sonata.user.user_manager')->findOneBy($criteria); + $user = $container->get('fos_user.user_manager')->findOneBy($criteria); if ($user) { $em = $container->get('doctrine'); /** @var User $completeUser */ diff --git a/src/CoreBundle/EventListener/LoginSuccessHandler.php b/src/CoreBundle/EventListener/LoginSuccessHandler.php index 444c007e2f..094bf34355 100644 --- a/src/CoreBundle/EventListener/LoginSuccessHandler.php +++ b/src/CoreBundle/EventListener/LoginSuccessHandler.php @@ -42,6 +42,25 @@ class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface Request $request, TokenInterface $token ) { + + $url = $this->router->generate('home'); + + if (!empty($url)) { + $response = new RedirectResponse($url); + } + + // Redirect the user to where they were before the login process begun. + if (empty($response)) { + $url = $request->headers->get('referer'); + /*// if the referer is the login use the home. + if (strpos($url, 'login') !== false) { + $url = $this->router->generate('home'); + }*/ + $response = new RedirectResponse($url); + } + + return $response; + /** @var User $user */ $user = $token->getUser(); $userId = $user->getId(); @@ -65,6 +84,8 @@ class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface $session->set('is_allowedCreateCourse', true); } + error_log('siccesss'); + // Setting last login datetime $session->set('user_last_login_datetime', api_get_utc_datetime()); @@ -129,6 +150,8 @@ class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface } } + $url = $this->router->generate('home'); + if (!empty($url)) { $response = new RedirectResponse($url); } diff --git a/src/CoreBundle/EventListener/LogoutSuccessHandler.php b/src/CoreBundle/EventListener/LogoutSuccessHandler.php index 4cc4c8dc55..1329ea6965 100644 --- a/src/CoreBundle/EventListener/LogoutSuccessHandler.php +++ b/src/CoreBundle/EventListener/LogoutSuccessHandler.php @@ -23,7 +23,7 @@ class LogoutSuccessHandler implements LogoutSuccessHandlerInterface /** * @param UrlGeneratorInterface $urlGenerator * @param AuthorizationChecker $checker - * @param Storage $storage + * @param TokenStorage $storage */ public function __construct( UrlGeneratorInterface $urlGenerator, @@ -76,7 +76,6 @@ class LogoutSuccessHandler implements LogoutSuccessHandlerInterface } $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); - $query = "DELETE FROM ".$online_table." WHERE login_user_id = $userId"; Database::query($query); diff --git a/src/CoreBundle/Framework/Container.php b/src/CoreBundle/Framework/Container.php index cb8e5bb6a9..e6a1d13066 100644 --- a/src/CoreBundle/Framework/Container.php +++ b/src/CoreBundle/Framework/Container.php @@ -187,7 +187,7 @@ class Container */ public static function getUrlGenerator() { - return self::$container->get('router'); + return self::$container->get('router.default'); } /** @@ -199,7 +199,7 @@ class Container return self::$request; } - return self::$container->get('request'); + return self::$container->get('request_stack'); } public static function setRequest($request) @@ -400,7 +400,7 @@ class Container \CourseManager::setEntityManager($em); Container::setSettingsManager($container->get('chamilo.settings.manager')); - Container::setUserManager($container->get('sonata.user.user_manager')); + Container::setUserManager($container->get('fos_user.user_manager')); Container::setSiteManager($container->get('sonata.page.manager.site')); \CourseManager::setCourseSettingsManager($container->get('chamilo_course.settings.manager')); diff --git a/src/CoreBundle/Menu/LeftMenuBuilder.php b/src/CoreBundle/Menu/LeftMenuBuilder.php index 3f812a156c..c576646d79 100644 --- a/src/CoreBundle/Menu/LeftMenuBuilder.php +++ b/src/CoreBundle/Menu/LeftMenuBuilder.php @@ -401,7 +401,7 @@ class LeftMenuBuilder implements ContainerAwareInterface public function loginMenu(FactoryInterface $factory, array $options) { $menu = $factory->createItem('main'); - $translator = $this->container->get('translator.default'); + $translator = $this->container->get('translator'); $settingManager = $this->container->get('chamilo.settings.manager'); if ($settingManager->getSetting('allow_registration') == 'true') { @@ -446,7 +446,7 @@ class LeftMenuBuilder implements ContainerAwareInterface */ public function helpMenu(FactoryInterface $factory, array $options) { - $translator = $this->container->get('translator.default'); + $translator = $this->container->get('translator'); $menu = $factory->createItem('main'); $menu->addChild( $translator->trans('Forum'), diff --git a/src/CoreBundle/Menu/NavBuilder.php b/src/CoreBundle/Menu/NavBuilder.php index 7e370bc353..35c424b09a 100644 --- a/src/CoreBundle/Menu/NavBuilder.php +++ b/src/CoreBundle/Menu/NavBuilder.php @@ -3,6 +3,7 @@ namespace Chamilo\CoreBundle\Menu; +use Chamilo\FaqBundle\Entity\Category; use Chamilo\PageBundle\Entity\Page; use Chamilo\PageBundle\Entity\Site; use Knp\Menu\FactoryInterface; @@ -133,7 +134,8 @@ class NavBuilder implements ContainerAwareInterface } } - $categories = $this->container->get('Chamilo\FaqBundle\Repository\CategoryRepository')->retrieveActive(); + $categories = $this->container->get('doctrine')->getRepository('ChamiloFaqBundle:Category')->retrieveActive(); + //$categories = $this->container->get('Chamilo\FaqBundle\Repository\CategoryRepository')->retrieveActive(); if ($categories) { $faq = $menu->addChild( 'FAQ', diff --git a/src/CoreBundle/Resources/config/services.yml b/src/CoreBundle/Resources/config/services.yml index 144a649499..bc4d1b544d 100644 --- a/src/CoreBundle/Resources/config/services.yml +++ b/src/CoreBundle/Resources/config/services.yml @@ -100,7 +100,7 @@ services: # html editor chamilo_core.html_editor: class: Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor - arguments: ['@translator.default', '@router'] + arguments: ['@translator', '@router'] public: true # Listeners # chamilo.doctrine.entity_listener_resolver: diff --git a/src/CourseBundle/EventListener/CourseListener.php b/src/CourseBundle/EventListener/CourseListener.php index 31fbd9d9be..ece643b011 100644 --- a/src/CourseBundle/EventListener/CourseListener.php +++ b/src/CourseBundle/EventListener/CourseListener.php @@ -48,12 +48,10 @@ class CourseListener return; } - var_dump(get_class($request)); - $sessionHandler = $event->getRequest()->getSession(); $container = $this->container; - $translator = $container->get('translator.default'); + $translator = $container->get('translator'); $courseCode = $request->get('course'); // Detect if the course was set with a cidReq: diff --git a/src/ThemeBundle/Resources/views/Sidebar/left_menu.html.twig b/src/ThemeBundle/Resources/views/Sidebar/left_menu.html.twig index da3b2fa0d9..ffaed63565 100644 --- a/src/ThemeBundle/Resources/views/Sidebar/left_menu.html.twig +++ b/src/ThemeBundle/Resources/views/Sidebar/left_menu.html.twig @@ -4,23 +4,23 @@ {% if is_granted('IS_AUTHENTICATED_FULLY') %} {{ macro.panel( - 'Profile' | trans, - mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:profileMenu', {'automenu': 'pills', 'stacked':true}) + 'Profile' | trans, + mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:profileMenu', {'automenu': 'pills', 'stacked':true}) ) }} {{ macro.panel( - 'Courses' | trans, - mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:courseMenu', {'automenu': 'pills', 'stacked':true}) + 'Courses' | trans, + mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:courseMenu', {'automenu': 'pills', 'stacked':true}) ) }} {{ macro.panel( - 'Sessions' | trans, - mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:sessionMenu', {'automenu': 'pills', 'stacked':true}) + 'Sessions' | trans, + mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:sessionMenu', {'automenu': 'pills', 'stacked':true}) ) }} {{ macro.panel( - 'Skills' | trans, - mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:skillsMenu', {'automenu': 'pills', 'stacked':true}) + 'Skills' | trans, + mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:skillsMenu', {'automenu': 'pills', 'stacked':true}) ) }} {% else %} {# Plugin login before/after tpls #} diff --git a/src/UserBundle/Entity/User.php b/src/UserBundle/Entity/User.php index e66d611841..73b42faa53 100644 --- a/src/UserBundle/Entity/User.php +++ b/src/UserBundle/Entity/User.php @@ -14,11 +14,12 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\ORM\Mapping as ORM; use FOS\UserBundle\Model\GroupInterface; -use FOS\UserBundle\Model\UserInterface; -//use Symfony\Component\Security\Core\User\UserInterface; + +use Symfony\Component\Security\Core\User\UserInterface; use Sonata\UserBundle\Entity\BaseUser; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\HttpFoundation\File\File; +use Symfony\Component\Security\Core\User\EquatableInterface; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Mapping\ClassMetadata; @@ -79,7 +80,7 @@ use Symfony\Component\Validator\Mapping\ClassMetadata; * ) * }) */ -class User extends BaseUser implements ThemeUser //implements ParticipantInterface, ThemeUser +class User extends BaseUser implements ThemeUser, EquatableInterface //implements ParticipantInterface, ThemeUser { const COURSE_MANAGER = 1; const TEACHER = 1; @@ -330,27 +331,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa */ protected $commentedUserSkills; - /** - * @var string - * - * @ORM\Column(name="lastname", type="string", length=60, nullable=true, unique=false) - */ - //protected $lastname; - - /** - * @var string - * - * @ORM\Column(name="firstname", type="string", length=60, nullable=true, unique=false) - */ - //protected $firstname; - - /** - * @var string - * - * @ORM\Column(name="password", type="string", length=255, nullable=false, unique=false) - */ - //protected $password; - /** * @var string * @@ -378,13 +358,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa */ private $pictureUri; - /** - * ORM\ManyToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", cascade={"all"} ). - * - * @ORM\JoinColumn(name="picture_uri", referencedColumnName="id") - */ - //protected $pictureUri; - /** * @var int * @@ -481,8 +454,8 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa */ public function __construct() { - $this->status = self::STUDENT; parent::__construct(); + $this->status = self::STUDENT; $this->salt = sha1(uniqid(null, true)); $this->active = true; $this->registrationDate = new \DateTime(); @@ -517,17 +490,14 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa /** * Updates the id with the user_id. * - * @ORM\PostPersist() + * @ORM\PostPersist() + * + * @param LifecycleEventArgs $args */ public function postPersist(LifecycleEventArgs $args) { - //parent::postPersist(); - // Updates the user_id field $user = $args->getEntity(); $this->setUserId($user->getId()); - /*$em = $args->getEntityManager(); - $em->persist($user); - $em->flush();*/ } /** @@ -556,14 +526,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa return $this->id; } - /** - * @return string - */ - public function getEncoderName() - { - return "legacy_encoder"; - } - /** * @return ArrayCollection */ @@ -646,30 +608,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa );*/ } - /** - * {@inheritdoc} - */ - public function isEqualTo(UserInterface $user) - { - if (!$user instanceof User) { - return false; - } - - /*if ($this->password !== $user->getPassword()) { - return false; - }*/ - - /*if ($this->getSalt() !== $user->getSalt()) { - return false; - }*/ - - /*if ($this->username !== $user->getUsername()) { - return false; - }*/ - - return true; - } - /** * @return ArrayCollection */ @@ -1637,51 +1575,17 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa * * @return bool */ - public function isPasswordRequestNonExpired($ttl) + /*public function isPasswordRequestNonExpired($ttl) { return $this->getPasswordRequestedAt() instanceof \DateTime && $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time(); - } + }*/ public function getUsername() { return $this->username; } - /** - * Returns the creation date. - * - * @return \DateTime|null - */ - public function getCreatedAt() - { - return $this->createdAt; - } - - /** - * Sets the last update date. - * - * @param \DateTime|null $updatedAt - * - * @return User - */ - public function setUpdatedAt(\DateTime $updatedAt = null) - { - $this->updatedAt = $updatedAt; - - return $this; - } - - /** - * Returns the last update date. - * - * @return \DateTime|null - */ - public function getUpdatedAt() - { - return $this->updatedAt; - } - /** * Returns the expiration date. * @@ -1732,366 +1636,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa return $this; } - /** - * Sets the two-step verification code. - * - * @param string $twoStepVerificationCode - * - * @return User - */ - public function setTwoStepVerificationCode($twoStepVerificationCode) - { - $this->twoStepVerificationCode = $twoStepVerificationCode; - - return $this; - } - - /** - * Returns the two-step verification code. - * - * @return string - */ - public function getTwoStepVerificationCode() - { - return $this->twoStepVerificationCode; - } - - /** - * @param string $biography - * - * @return User - */ - public function setBiography($biography) - { - $this->biography = $biography; - - return $this; - } - - /** - * @return string - */ - public function getBiography() - { - return $this->biography; - } - - /** - * @param \DateTime $dateOfBirth - * - * @return User - */ - public function setDateOfBirth($dateOfBirth) - { - $this->dateOfBirth = $dateOfBirth; - - return $this; - } - - /** - * @return \DateTime - */ - public function getDateOfBirth() - { - return $this->dateOfBirth; - } - - /** - * @param string $facebookData - * - * @return User - */ - public function setFacebookData($facebookData) - { - $this->facebookData = $facebookData; - - return $this; - } - - /** - * @return string - */ - public function getFacebookData() - { - return $this->facebookData; - } - - /** - * @param string $facebookName - * - * @return User - */ - public function setFacebookName($facebookName) - { - $this->facebookName = $facebookName; - - return $this; - } - - /** - * @return string - */ - public function getFacebookName() - { - return $this->facebookName; - } - - /** - * @param string $facebookUid - * - * @return User - */ - public function setFacebookUid($facebookUid) - { - $this->facebookUid = $facebookUid; - - return $this; - } - - /** - * @return string - */ - public function getFacebookUid() - { - return $this->facebookUid; - } - - /** - * @return string - */ - public function getFirstname() - { - return $this->firstname; - } - - /** - * @param string $gender - * - * @return User - */ - public function setGender($gender) - { - $this->gender = $gender; - - return $this; - } - - /** - * @return string - */ - public function getGender() - { - return $this->gender; - } - - /** - * @param string $gplusData - * - * @return User - */ - public function setGplusData($gplusData) - { - $this->gplusData = $gplusData; - - return $this; - } - - /** - * @return string - */ - public function getGplusData() - { - return $this->gplusData; - } - - /** - * @param string $gplusName - * - * @return User - */ - public function setGplusName($gplusName) - { - $this->gplusName = $gplusName; - - return $this; - } - - /** - * @return string - */ - public function getGplusName() - { - return $this->gplusName; - } - - /** - * @param string $gplusUid - * - * @return User - */ - public function setGplusUid($gplusUid) - { - $this->gplusUid = $gplusUid; - - return $this; - } - - /** - * @return string - */ - public function getGplusUid() - { - return $this->gplusUid; - } - - /** - * @return string - */ - public function getLastname() - { - return $this->lastname; - } - - /** - * @param string $locale - * - * @return User - */ - public function setLocale($locale) - { - $this->locale = $locale; - - return $this; - } - - /** - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * @param string $timezone - * - * @return User - */ - public function setTimezone($timezone) - { - $this->timezone = $timezone; - - return $this; - } - - /** - * @return string - */ - public function getTimezone() - { - return $this->timezone; - } - - /** - * @param string $twitterData - * - * @return User - */ - public function setTwitterData($twitterData) - { - $this->twitterData = $twitterData; - - return $this; - } - - /** - * @return string - */ - public function getTwitterData() - { - return $this->twitterData; - } - - /** - * @param string $twitterName - * - * @return User - */ - public function setTwitterName($twitterName) - { - $this->twitterName = $twitterName; - - return $this; - } - - /** - * @return string - */ - public function getTwitterName() - { - return $this->twitterName; - } - - /** - * @param string $twitterUid - * - * @return User - */ - public function setTwitterUid($twitterUid) - { - $this->twitterUid = $twitterUid; - - return $this; - } - - /** - * @return string - */ - public function getTwitterUid() - { - return $this->twitterUid; - } - - /** - * @param string $website - * - * @return User - */ - public function setWebsite($website) - { - $this->website = $website; - - return $this; - } - - /** - * @return string - */ - public function getWebsite() - { - return $this->website; - } - - /** - * @param string $token - * - * @return User - */ - public function setToken($token) - { - $this->token = $token; - - return $this; - } - - /** - * @return string - */ - public function getToken() - { - return $this->token; - } - /** * @return string */ @@ -2100,60 +1644,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa return sprintf('%s %s', $this->getFirstname(), $this->getLastname()); } - /** - * @return array - */ - public function getRealRoles() - { - return $this->roles; - } - - /** - * @param array $roles - * - * @return User - */ - public function setRealRoles(array $roles) - { - $this->setRoles($roles); - - return $this; - } - - /** - * Removes sensitive data from the user. - */ - public function eraseCredentials() - { - $this->plainPassword = null; - } - - /** - * @return string - */ - public function getUsernameCanonical() - { - return $this->usernameCanonical; - } - - /** - * @return string - */ - public function getEmailCanonical() - { - return $this->emailCanonical; - } - - /** - * @return mixed - */ - public function getPlainPassword() - { - if (isset($this->plainPassword)) { - return $this->plainPassword; - } - } - /** * Returns the user roles. * @@ -2173,89 +1663,38 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa return array_unique($roles); } - /** - * Never use this to check if this user has access to anything! - * - * Use the SecurityContext, or an implementation of AccessDecisionManager - * instead, e.g. - * - * $securityContext->isGranted('ROLE_USER'); - * - * @param string $role - * - * @return bool - */ - public function hasRole($role) - { - return in_array(strtoupper($role), $this->getRoles(), true); - } - public function isAccountNonExpired() { - if (true === $this->expired) { + /*if (true === $this->expired) { return false; } if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) { return false; - } + }*/ return true; } public function isAccountNonLocked() { - return !$this->locked; + return true; + //return !$this->locked; } public function isCredentialsNonExpired() { - if (true === $this->credentialsExpired) { + /*if (true === $this->credentialsExpired) { return false; } if (null !== $this->credentialsExpireAt && $this->credentialsExpireAt->getTimestamp() < time()) { return false; - } + }*/ return true; } - public function isCredentialsExpired() - { - return !$this->isCredentialsNonExpired(); - } - - public function isExpired() - { - return !$this->isAccountNonExpired(); - } - - public function isLocked() - { - return !$this->isAccountNonLocked(); - } - - public function isSuperAdmin() - { - return $this->hasRole(static::ROLE_SUPER_ADMIN); - } - - public function isUser(UserInterface $user = null) - { - return null !== $user && $this->getId() === $user->getId(); - } - - public function removeRole($role) - { - if (false !== $key = array_search(strtoupper($role), $this->roles, true)) { - unset($this->roles[$key]); - $this->roles = array_values($this->roles); - } - - return $this; - } - /** * @param bool $boolean * @@ -2301,24 +1740,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa return $this; } - public function setSuperAdmin($boolean) - { - if (true === $boolean) { - $this->addRole(static::ROLE_SUPER_ADMIN); - } else { - $this->removeRole(static::ROLE_SUPER_ADMIN); - } - - return $this; - } - - public function setPlainPassword($password) - { - $this->plainPassword = $password; - - return $this; - } - public function setLocked($boolean) { $this->locked = $boolean; @@ -2326,13 +1747,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa return $this; } - public function setPasswordRequestedAt(\DateTime $date = null) - { - $this->passwordRequestedAt = $date; - - return $this; - } - public function setRoles(array $roles) { $this->roles = []; @@ -2344,110 +1758,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa return $this; } - /** - * Gets the groups granted to the user. - * - * @return Collection - */ - public function getGroups() - { - return $this->groups ?: $this->groups = new ArrayCollection(); - } - - public function getGroupNames() - { - $names = []; - foreach ($this->getGroups() as $group) { - $names[] = $group->getName(); - } - - return $names; - } - - public function hasGroup($name) - { - return in_array($name, $this->getGroupNames()); - } - - public function addGroup(GroupInterface $group) - { - if (!$this->getGroups()->contains($group)) { - $this->getGroups()->add($group); - } - - return $this; - } - - public function removeGroup(GroupInterface $group) - { - if ($this->getGroups()->contains($group)) { - $this->getGroups()->removeElement($group); - } - - return $this; - } - - public function addRole($role) - { - $role = strtoupper($role); - if ($role === static::ROLE_DEFAULT) { - return $this; - } - - if (!in_array($role, $this->roles, true)) { - $this->roles[] = $role; - } - - return $this; - } - - /** - * Serializes the user. - * - * The serialized data have to contain the fields used by the equals method and the username. - * - * @return string - */ - public function serialize() - { - return serialize([ - $this->password, - $this->salt, - $this->usernameCanonical, - $this->username, - $this->expired, - $this->locked, - $this->credentialsExpired, - $this->enabled, - $this->id, - ]); - } - - /** - * Unserializes the user. - * - * @param string $serialized - */ - public function unserialize($serialized) - { - $data = unserialize($serialized); - // add a few extra elements in the array to ensure that we have enough keys when unserializing - // older data which does not include all properties. - $data = array_merge($data, array_fill(0, 2, null)); - - list( - $this->password, - $this->salt, - $this->usernameCanonical, - $this->username, - $this->expired, - $this->locked, - $this->credentialsExpired, - $this->enabled, - $this->id - ) = $data; - } - /** * Get achievedSkills. * @@ -2538,31 +1848,25 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa } /** - * Get the list of HRM who have assigned this user. + * @param UserInterface $user * - * @return array + * @return bool */ - public function getHrm() - { - $em = \Database::getManager(); - $qb = $em->createQueryBuilder(); - - $hrmList = $qb - ->select('uru') - ->from('ChamiloCoreBundle:UserRelUser', 'uru') - ->innerJoin('ChamiloCoreBundle:AccessUrlRelUser', 'auru', Join::WITH, 'auru.userId = uru.friendUserId') - ->where( - $qb->expr()->eq('auru.accessUrlId', api_get_current_access_url_id()) - ) - ->andWhere( - $qb->expr()->eq('uru.userId', $this->id) - ) - ->andWhere( - $qb->expr()->eq('uru.relationType', USER_RELATION_TYPE_RRHH) - ) - ->getQuery() - ->getResult(); - - return $hrmList; + public function isEqualTo(UserInterface $user) + { + if ($this->password !== $user->getPassword()) { + return false; + } + + if ($this->salt !== $user->getSalt()) { + return false; + } + + if ($this->username !== $user->getUsername()) { + return false; + } + + return true; } + } diff --git a/yarn.lock b/yarn.lock index e45124592c..dc701c77e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3592,18 +3592,18 @@ less-loader@~2.2.3: dependencies: loader-utils "^0.2.5" -less@^2.7.2: - version "2.7.3" - resolved "https://registry.yarnpkg.com/less/-/less-2.7.3.tgz#cc1260f51c900a9ec0d91fb6998139e02507b63b" +less@^3.0.2: + version "3.0.4" + resolved "https://registry.yarnpkg.com/less/-/less-3.0.4.tgz#d27dcedbac96031c9e7b76f1da1e4b7d83760814" optionalDependencies: errno "^0.1.1" graceful-fs "^4.1.2" image-size "~0.5.0" - mime "^1.2.11" + mime "^1.4.1" mkdirp "^0.5.0" promise "^7.1.1" - request "2.81.0" - source-map "^0.5.3" + request "^2.83.0" + source-map "~0.6.0" load-json-file@^1.0.0: version "1.1.0" @@ -3933,7 +3933,7 @@ mime@1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" -mime@^1.2.11, mime@^1.5.0: +mime@^1.4.1, mime@^1.5.0: version "1.6.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" @@ -5171,7 +5171,7 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -request@2: +request@2, request@^2.83.0: version "2.85.0" resolved "https://registry.yarnpkg.com/request/-/request-2.85.0.tgz#5a03615a47c61420b3eb99b7dba204f83603e1fa" dependencies: @@ -5686,7 +5686,7 @@ source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"