nick-denry / yii2-ckeditor-roxyfileman

Roxy File Manager integration with CKEditor for Yii2
MIT License
4 stars 8 forks source link

How to set upload folder for multiple user (user id)? #7

Closed kongoon closed 5 years ago

kongoon commented 5 years ago

How to set upload folder for multiple user or show only own uploaded file?

nick-denry commented 5 years ago

Current stage doesn't allow that without some extra work.

You could create your own module to override module init function like that:

namespace backend\modules\myckeditoroxyfileman;

use nickdenry\ckeditorRoxyFileman\Module as BaseModule;

class Module extends BaseModule
{
     /**
     * Initializes the module, set uploadFolder dynamically
     */
    public function init()
    {
        $this->uploadFolder = '@frontend/web/whatever/'.Yii::$app->user->id.'/whatever';
        parent::init();
    }
}

And your config:

'modules' => [
    'ckeditorRoxyFileman' => [
        'class' => 'backend\modules\myckeditoroxyfileman\Module',
        'uploadFolder' => '',
        'uploadUrl' => '/uploads/images',
    ],
],

Check if that helps. Or you could use closure if config uploadFolder param is matter to you.

kongoon commented 5 years ago

i'm try but error 404 /default but i'm fixed

namespace backend\modules\fileman;

use nickdenry\ckeditorRoxyFileman\Module as MyBaseModule;
use Yii;

class Module extends MyBaseModule
{
    public $controllerMap = [
        'default' => [
            'class' => 'nickdenry\ckeditorRoxyFileman\controllers\DefaultController',
            'viewPath' => '@vendor/nick-denry/yii2-ckeditor-roxyfileman/src/views/default'
        ],
        'management' => [
            'class' => 'nickdenry\ckeditorRoxyFileman\controllers\ManagementController',
            'viewPath' => '@vendor/nick-denry/yii2-ckeditor-roxyfilename/src/views/management'
        ]
    ];
    /**
     * Initializes the module, set uploadFolder dynamically
     */
    public function init()
    {
        $this->layoutPath = '@vendor/nick-denry/yii2-ckeditor-roxyfileman/src/views/layouts';
        $this->uploadFolder = '@backend/web/uploads/files/'.Yii::$app->user->getId();
        $this->uploadUrl = '@web/uploads/files/'.Yii::$app->user->getId();
        parent::init();
    }
}
nick-denry commented 5 years ago

@kongoon Do you solve this issue completely?