diff --git a/.gitignore b/.gitignore index 726221d73c..9220a0677d 100755 --- a/.gitignore +++ b/.gitignore @@ -20,13 +20,15 @@ var/log/* /app/config/configuration.php # Courses -app/courses/* +var/courses/* +!var/courses/.gitkeep # Home app/home/* # Upload content -app/upload/* +var/upload/* +!var/upload/.gitkeep # Logs and databases # *.log diff --git a/.travis.yml b/.travis.yml index 3242865e58..724003eb01 100755 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ cache: - $HOME/.composer/cache/files php: - 7.1 - + env: global: - VHOST_URL=localhost @@ -85,7 +85,7 @@ before_install: - ./node_modules/.bin/encore dev # Install chamilo - php -d date.timezone="Europe/Paris" $TRAVIS_BUILD_DIR/chash/chash.php chash:chamilo_install $CHAMILO_VERSION $TRAVIS_BUILD_DIR --no-interaction --sitename="Chamilo" --site_url="http://$VHOST_URL/" --institution="Chamilo" --institution_url="https://chamilo.org" --encrypt_method="sha1" --firstname="John" --lastname="Doe" --language="english" --driver="pdo_mysql" --host="localhost" --port="3306" --dbname="chamilo" --dbuser="root" --permissions_for_new_directories="0777" --permissions_for_new_files="0666" --linux-user="www-data" --linux-group="www-data" --username="admin" --password="admin" --email="admin@example.com" --phone="555-5555" - - sudo chmod -R 777 var/cache var/log app/courses app/upload + - sudo chmod -R 777 var/cache var/log var/courses var/upload # Check chamilo status - php -d date.timezone="Europe/Paris" $TRAVIS_BUILD_DIR/chash/chash.php chash:chamilo_status # Permissions diff --git a/composer.json b/composer.json index 972abfb145..6fb1a94edf 100755 --- a/composer.json +++ b/composer.json @@ -147,6 +147,7 @@ "aferrandini/phpqrcode": "1.0.1", "alchemy/zippy": "~0.4", "mpdf/mpdf": "~7.0", + "oneup/flysystem-bundle": "~3.0", "studio-42/elfinder": "2.1.*", "jbroadway/urlify": "1.1.0-stable", "ircmaxell/password-compat": "~1.0.4", @@ -172,7 +173,8 @@ "lunetics/locale-bundle": "2.5.*", "hwi/oauth-bundle": "^0.6.0", "php-http/guzzle6-adapter": "^1.1", - "php-http/httplug-bundle": "^1.8" + "php-http/httplug-bundle": "^1.8", + "symfony/apache-pack": "^1.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.7", diff --git a/config/bundles.php b/config/bundles.php index 51d6085fc2..a4cebb8c10 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -65,4 +65,5 @@ return [ Sylius\Bundle\SettingsBundle\SyliusSettingsBundle::class => ['all' => true], Lunetics\LocaleBundle\LuneticsLocaleBundle::class => ['all' => true], Http\HttplugBundle\HttplugBundle::class => ['all' => true], + Oneup\FlysystemBundle\OneupFlysystemBundle::class => ['all' => true], ]; diff --git a/config/packages/oneup_flysystem.yaml b/config/packages/oneup_flysystem.yaml new file mode 100644 index 0000000000..9fdfd8fc2b --- /dev/null +++ b/config/packages/oneup_flysystem.yaml @@ -0,0 +1,18 @@ +oneup_flysystem: + adapters: + courses_adapter: + local: + directory: '%kernel.project_dir%/var/courses' + +# s3.adapter: +# awss3v3: +# client: s3_client # add service "s3_client" +# bucket: ~ +# prefix: ~ + filesystems: + courses: + adapter: courses_adapter + visibility: private + cache: ~ + alias: ~ + mount: ~ \ No newline at end of file diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index b1d0557ed4..cccbc7352a 100755 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -101,9 +101,9 @@ if (!is_dir(_MPDF_TEMP_PATH)) { mkdir(_MPDF_TEMP_PATH, api_get_permissions_for_new_directories(), true); } -if (file_exists(api_get_path(SYS_PATH).'.env')) { +if (file_exists(__DIR__.'/../../.env')) { // Get settings from .env file created when installation chamilo - (new Dotenv())->load(api_get_path(SYS_PATH).'.env'); + (new Dotenv())->load(__DIR__.'/../../.env'); $kernel->boot(); $container = $kernel->getContainer(); $doctrine = $container->get('doctrine'); diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 73e2bad557..617111a5bb 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -2,10 +2,11 @@ /* For licensing terms, see /license.txt */ use ChamiloSession as Session; +use Chamilo\CoreBundle\Entity\SettingsCurrent; +use Chamilo\CoreBundle\Framework\Container; use Chamilo\CourseBundle\Entity\CItemProperty; use Chamilo\UserBundle\Entity\User; use Symfony\Component\Finder\Finder; -use Chamilo\CoreBundle\Entity\SettingsCurrent; /** * This is a code library for Chamilo. @@ -699,7 +700,7 @@ function api_get_path($path = '', $configuration = []) $course_folder = 'courses/'; static $root_web = ''; - $root_sys = $_configuration['root_sys']; + $root_sys = Container::getRootDir(); // If no $root_web has been set so far *and* no custom config has been passed to the function // then re-use the previously-calculated (run-specific) $root_web and skip this complex calculation @@ -775,7 +776,7 @@ function api_get_path($path = '', $configuration = []) SYS_HOME_PATH => 'app/home/', WEB_HOME_PATH => 'app/home/', REL_HOME_PATH => 'app/home/', - SYS_APP_PATH => 'app/', + SYS_APP_PATH => 'var/', WEB_APP_PATH => 'app/', SYS_UPLOAD_PATH => 'app/upload/', SYS_INC_PATH => 'inc/', diff --git a/src/CoreBundle/Entity/Course.php b/src/CoreBundle/Entity/Course.php index c1aceb8710..3cb4887d35 100644 --- a/src/CoreBundle/Entity/Course.php +++ b/src/CoreBundle/Entity/Course.php @@ -1211,14 +1211,6 @@ class Course return $this; } - /** - * @return string - */ - public function getAbsoluteSysCoursePath() - { - return realpath(__DIR__.'/../../../app/courses/'.$this->getDirectory()).'/'; - } - /** * @return bool */ diff --git a/src/CoreBundle/Resources/config/services.yml b/src/CoreBundle/Resources/config/services.yml index 31dd15daee..e7de24ef72 100644 --- a/src/CoreBundle/Resources/config/services.yml +++ b/src/CoreBundle/Resources/config/services.yml @@ -37,7 +37,10 @@ services: # Course voter checks if a user has permissions to do actions in a course chamilo_core.security.authorization.voter.course_voter: class: Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter - arguments: ['@doctrine.orm.entity_manager', '@chamilo_core.entity.manager.course_manager', '@service_container'] + arguments: + - '@doctrine.orm.entity_manager' + - '@chamilo_core.entity.manager.course_manager' + - '@service_container' public: false tags: - {name: security.voter} diff --git a/src/CourseBundle/Event/CourseAccess.php b/src/CourseBundle/Event/CourseAccess.php new file mode 100644 index 0000000000..f309eb22a7 --- /dev/null +++ b/src/CourseBundle/Event/CourseAccess.php @@ -0,0 +1,44 @@ +user = $user; + $this->course = $course; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @return Course + */ + public function getCourse() + { + return $this->course; + } +} diff --git a/src/CourseBundle/Event/SessionAccess.php b/src/CourseBundle/Event/SessionAccess.php new file mode 100644 index 0000000000..09465cc662 --- /dev/null +++ b/src/CourseBundle/Event/SessionAccess.php @@ -0,0 +1,51 @@ +user = $user; + $this->course = $course; + $this->session = $session; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @return Course + */ + public function getCourse() + { + return $this->course; + } + + /** + * @return Session + */ + public function getSession() + { + return $this->session; + } +} diff --git a/src/CourseBundle/EventListener/CourseListener.php b/src/CourseBundle/EventListener/CourseListener.php index 0804211587..0c3f9f4bd6 100644 --- a/src/CourseBundle/EventListener/CourseListener.php +++ b/src/CourseBundle/EventListener/CourseListener.php @@ -78,7 +78,6 @@ class CourseListener // Group $groupId = intval($request->get('gidReq')); - if (empty($sessionId)) { // Check if user is allowed to this course // See CourseVoter.php @@ -158,10 +157,7 @@ class CourseListener $dispatcher = $this->container->get('event_dispatcher'); if (empty($sessionId)) { - $dispatcher->dispatch( - 'chamilo_course.course.access', - new CourseAccess($user, $course) - ); + $dispatcher->dispatch('chamilo_course.course.access', new CourseAccess($user, $course)); } else { $dispatcher->dispatch( 'chamilo_course.course.access',