コード例 #1
0
 /**
  * update
  *
  * @param string $boardId board id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($boardId)
 {
     $config = $this->configHandler->get($boardId);
     $permissionNames = [];
     $permissionNames['read'] = ['readMode', 'readRating', 'readUser', 'readExcept'];
     $permissionNames['list'] = ['listMode', 'listRating', 'listUser', 'listExcept'];
     $permissionNames['create'] = ['createMode', 'createRating', 'createUser', 'createExcept'];
     $permissionNames['manage'] = ['manageMode', 'manageRating', 'manageUser', 'manageExcept'];
     $inputs = Input::except(array_merge(['_token'], $permissionNames['read'], $permissionNames['list'], $permissionNames['create'], $permissionNames['manage']));
     //$inputs['extensions'] = isset($inputs['extensions']) ? $inputs['extensions'] : [];
     foreach ($inputs as $key => $value) {
         $config->set($key, $value);
     }
     $config = $this->instanceManager->updateConfig($config->getPureAll());
     // 확장 기능 사용
     //$this->extensionHandler->activate($inputs['extensions'], $config);
     // permission update
     $grant = new Grant();
     foreach ($this->permissionHandler->getActions() as $action) {
         $permInputs = Input::only($permissionNames[$action]);
         if ($permInputs[$action . 'Mode'] == 'manual') {
             $grant = $this->permissionHandler->createGrant($grant, $action, [Grant::RATING_TYPE => $permInputs[$action . 'Rating'], Grant::GROUP_TYPE => isset($permInputs[$action . 'Group']) ? $permInputs[$action . 'Group'] : [], Grant::USER_TYPE => explode(',', $permInputs[$action . 'User']), Grant::EXCEPT_TYPE => explode(',', $permInputs[$action . 'Except'])]);
         }
     }
     $this->permissionHandler->set($boardId, $grant);
     return Redirect::to($this->urlHandler->managerUrl('edit', ['boardId' => $boardId]));
 }
コード例 #2
0
 /**
  * download file
  *
  * @param string $url url
  * @param string $id  id
  * @throws \Xpressengine\Storage\Exceptions\NotExistsException
  * @return void
  */
 public function fileDownload($url, $id)
 {
     $permission = $this->permissionHandler->get($this->boardId);
     if ($permission->unables(ACTION::READ) === true) {
         throw new AccessDeniedHttpException();
     }
     /** @var \Xpressengine\Storage\Storage $storage */
     $storage = app('xe.storage');
     $file = $storage->get($id);
     header('Content-type: ' . $file->mime);
     $storage->download($file);
 }
コード例 #3
0
ファイル: plugin.php プロジェクト: khongchi/plugin-board
 /**
  * @return void
  */
 public function install()
 {
     // create default config
     /**
      * @var $configManager ConfigManager
      * @var $dynamicFieldHandler DynamicFieldHandler
      * @var $documentHandler DocumentHandler
      */
     $configManager = app('xe.config');
     $dynamicFieldHandler = app('xe.dynamicField');
     $documentHandler = app('xe.document');
     $configHandler = new ConfigHandler($configManager, $dynamicFieldHandler->getConfigHandler(), $documentHandler->getConfigHandler());
     $configHandler->getDefault();
     // create default permission
     /**
      * @var $permission PermissionFactory
      * @var $group Assignor
      */
     $permission = app('xe.permission');
     $group = app('xe.member.groups');
     $action = new Action();
     $permission = new PermissionHandler($permission, $group, $action, $configHandler);
     $permission->setDefault($permission->getDefault());
     // create slug database table
     $m = new Migrations\BoardMigration();
     $m->install();
     // put board translation source
     /** @var Translator $trans */
     $trans = app('xe.translator');
     $trans->putFromLangDataSource('board', base_path('plugins/board/langs/lang.php'));
     // set config for counter
     /** @var Counter $counter */
     $counter = app('xe.counter');
     $counter->getConfigHandler()->set(ReadCounter::COUNTER_NAME, Counter::TYPE_SESSION);
     $counter->getConfigHandler()->set(VoteCounter::COUNTER_NAME, Counter::TYPE_ID);
 }