Add oneup_flysystem bundle to handle data layer reading var/courses

pull/2487/head
jmontoyaa 7 years ago
parent 5a225eb247
commit db43bfe368
  1. 6
      .gitignore
  2. 2
      .travis.yml
  3. 4
      composer.json
  4. 1
      config/bundles.php
  5. 18
      config/packages/oneup_flysystem.yaml
  6. 4
      main/inc/global.inc.php
  7. 7
      main/inc/lib/api.lib.php
  8. 8
      src/CoreBundle/Entity/Course.php
  9. 5
      src/CoreBundle/Resources/config/services.yml
  10. 44
      src/CourseBundle/Event/CourseAccess.php
  11. 51
      src/CourseBundle/Event/SessionAccess.php
  12. 6
      src/CourseBundle/EventListener/CourseListener.php

6
.gitignore vendored

@ -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

@ -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

@ -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",

@ -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],
];

@ -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: ~

@ -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');

@ -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/',

@ -1211,14 +1211,6 @@ class Course
return $this;
}
/**
* @return string
*/
public function getAbsoluteSysCoursePath()
{
return realpath(__DIR__.'/../../../app/courses/'.$this->getDirectory()).'/';
}
/**
* @return bool
*/

@ -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}

@ -0,0 +1,44 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Event;
use Symfony\Component\EventDispatcher\Event;
use Chamilo\UserBundle\Entity\User;
use Chamilo\CoreBundle\Entity\Course;
/**
* Class CourseAccess
* @package Chamilo\CourseBundle\Event
*/
class CourseAccess extends Event
{
protected $user;
protected $course;
/**
* @param $user
* @param $course
*/
public function __construct($user, $course)
{
$this->user = $user;
$this->course = $course;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @return Course
*/
public function getCourse()
{
return $this->course;
}
}

@ -0,0 +1,51 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Event;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\UserBundle\Entity\User;
use Symfony\Component\EventDispatcher\Event;
/**
* Class SessionAccess
* @package Chamilo\CourseBundle\Event
*/
class SessionAccess extends Event
{
protected $user;
protected $course;
protected $session;
public function __construct($user, $course, $session)
{
$this->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;
}
}

@ -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',

Loading…
Cancel
Save