저자: XE Developers (developers@xpressengine.com)
상속: extends HttpXpressengineException
예제 #1
0
 public function edit(Request $request, ThemeHandler $themeHandler)
 {
     $editable = session('theme.editable');
     if (!$editable) {
         return \XePresenter::make('theme.edit-auth');
     }
     $themeId = $request->get('theme');
     $fileName = $request->get('file');
     // TODO: validate themeid, fileName
     if ($themeId === null) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('잘못된 요청입니다.');
         throw $e;
     }
     $theme = \XeTheme::getTheme($themeId);
     /** @var ThemeEntityInterface $theme */
     $files = $theme->getEditFiles();
     if (empty($files)) {
         return \XePresenter::make('theme.edit', ['theme' => $theme, 'files' => $files]);
     }
     if ($fileName === null) {
         $fileName = key($files);
     }
     $filePath = realpath($files[$fileName]);
     $editFile = ['fileName' => $fileName, 'path' => $filePath];
     if ($themeHandler->hasCache($filePath)) {
         $editFile['hasCache'] = true;
         $fileContent = file_get_contents($themeHandler->getCachePath($filePath));
     } else {
         $editFile['hasCache'] = false;
         $fileContent = file_get_contents($filePath);
     }
     $editFile['content'] = $fileContent;
     return \XePresenter::make('theme.edit', ['theme' => $theme, 'files' => $files, 'editFile' => $editFile]);
 }
예제 #2
0
 public function edit(Request $request)
 {
     $themeId = $request->get('theme');
     $fileName = $request->get('file');
     $type = $request->get('type', 'views');
     // TODO: validate themeid, fileName
     if ($themeId === null) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('잘못된 요청입니다.');
         throw $e;
     }
     $theme = \XeTheme::getTheme($themeId);
     /** @var ThemeEntityInterface $theme */
     $files = $theme->getEditFiles();
     if (empty($files)) {
         return \XePresenter::make('theme.edit', ['theme' => $theme, 'files' => $files]);
     }
     if ($fileName === null) {
         $fileName = key($files[$type]);
     }
     if (!is_writable($files[$type][$fileName])) {
         \View::share('_alert', ['type' => 'danger', 'message' => '파일을 수정할 권한이 없습니다. 웹서버의 계정이 편집할 파일의 쓰기(w)권한을 가지고 있어야 합니다.']);
     }
     $fileContent = file_get_contents($files[$type][$fileName]);
     $editFile = ['fileName' => $fileName, 'path' => $files[$type][$fileName], 'content' => $fileContent];
     return \XePresenter::make('theme.edit', ['theme' => $theme, 'files' => $files, 'editFile' => $editFile, 'type' => $type]);
 }
 public function postEdit($id)
 {
     $input = Input::only(['name', 'description']);
     $validator = Validator::make($input, ['name' => 'Required']);
     if ($validator->fails()) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage($validator->errors()->first());
         throw $e;
     }
     XeDB::beginTransaction();
     try {
         $group = $this->groups->find($id);
         $group->fill($input);
         $this->groups->update($group);
     } catch (Exception $e) {
         XeDB::rollBack();
         throw $e;
     }
     XeDB::commit();
     return redirect()->route('manage.group.index')->with('alert', ['type' => 'success', 'message' => '수정되었습니다.']);
 }
예제 #4
0
 public function getEdit(Request $request)
 {
     $themeId = $request->get('theme');
     $fileName = $request->get('file');
     $type = $request->get('type', 'template');
     // TODO: validate themeid, fileName
     if ($themeId === null) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('잘못된 요청입니다.');
         throw $e;
     }
     $theme = \Theme::getTheme($themeId);
     /** @var ThemeEntity $theme */
     $files = $theme->getEditFiles();
     if ($fileName === null) {
         $fileName = key($files[$type]);
     }
     if (!is_writable($files[$type][$fileName])) {
         \Session::flash('alert', ['type' => 'danger', 'message' => '파일을 수정할 권한이 없습니다.']);
     }
     $fileContent = file_get_contents($files[$type][$fileName]);
     $editFile = ['fileName' => $fileName, 'path' => $files[$type][$fileName], 'content' => $fileContent];
     return \Presenter::make('theme.edit', ['theme' => $theme, 'files' => $files, 'editFile' => $editFile, 'type' => $type]);
 }
 public function postDeleteMail(Request $request)
 {
     $validate = Validator::make($request->all(), ['memberId' => 'required', 'address' => 'required']);
     if ($validate->fails()) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('잘못된 요청입니다.');
         throw $e;
     }
     $address = $request->get('address');
     $memberId = $request->get('memberId');
     $mail = $this->handler->findMailByAddress($address);
     if ($mail === null) {
         throw new EmailNotFoundException();
     }
     $result = $this->handler->deleteMail($mail);
     return Presenter::makeApi(['type' => 'success', 'address' => $address]);
 }
예제 #6
0
 /**
  * confirm email
  *
  * @param Request $request
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function postConfirmMail(Request $request)
 {
     $pendingEmail = $this->handler->pendingEmails()->find($request->get('id'));
     if ($pendingEmail === null) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('존재하지 않거나 이미 승인된 이메일입니다.');
         throw $e;
     }
     $user = $pendingEmail->user;
     $address = $pendingEmail->address;
     XeDB::beginTransaction();
     try {
         // create pending email
         $email = $this->handler->emails()->create($user, compact('address'));
         // remove pending email
         $this->handler->pendingEmails()->delete($pendingEmail);
     } catch (Exception $e) {
         XeDB::rollBack();
         throw $e;
     }
     XeDB::commit();
     return XePresenter::makeApi(['mail' => $email]);
 }