Ejemplo n.º 1
0
 /**
  * wysiwyg用のスクリプト呼び出し対応
  *
  * @return String wysiwyg js
  */
 public function wysiwygScript()
 {
     // file / image  が送信するフィールド(フォーム改ざん防止項目)
     $fields = ['Room' => ['id' => Current::read('Room.id')], 'Block' => ['key' => Current::read('Block.key'), 'room_id' => Current::read('Room.id')], 'Wysiwyg' => ['file' => ['error' => [], 'name' => [], 'size' => [], 'tmp_name' => [], 'type' => []]]];
     // NetCommonsApp.constant で定義する変数の定義
     $constants = ['NC3_URL' => h(substr(Router::url('/'), 0, -1)), 'title_icon_paths' => $this->__getTitleIconFiles(), 'lang' => Current::read('Language.code'), 'lang_js' => $this->NetCommonsHtml->url('/wysiwyg/js/langs/' . Current::read('Language.code') . '.js'), 'content_css' => [$this->NetCommonsHtml->url('/net_commons/css/style.css'), $this->NetCommonsHtml->url('/components/bootstrap/dist/css/bootstrap.css'), $this->NetCommonsHtml->url('/wysiwyg/css/style.css')], 'blockKey' => Current::read('Block.key'), 'roomId' => Current::read('Room.id'), 'book_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/book.svg'), 'fileup_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/fileup.svg'), 'tex_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/tex.svg'), 'mathjax_js' => $this->NetCommonsHtml->url('/components/MathJax/MathJax.js?config=TeX-MML-AM_CHTML'), 'file_upload_path' => $this->NetCommonsHtml->url('/wysiwyg/file/upload'), 'image_upload_path' => $this->NetCommonsHtml->url('/wysiwyg/image/upload'), 'csrfTokenPath' => $this->NetCommonsHtml->url('/net_commons/net_commons/csrfToken.json'), 'fileSecure' => $this->__secure('/wysiwyg/file/upload', $fields), 'imageSecure' => $this->__secure('/wysiwyg/image/upload', $fields), 'is_mobile' => Configure::read('isMobile')];
     // 許可するタグの設定
     if (Current::permission('html_not_limited')) {
         $constants['extended_valid_elements'] = 'script[src|title|type]';
         $constants['cleanup'] = false;
     }
     // constants 設定を JavaScriptで利用するための設定に変換する
     $this->NetCommonsHtml->scriptStart(array('inline' => false));
     echo "NetCommonsApp.service('nc3Configs', function() {";
     foreach ($constants as $key => $value) {
         if (is_array($value)) {
             echo 'this.' . $key . ' = ' . json_encode($value) . ';';
         } else {
             echo "this." . $key . " = '" . $value . "';";
         }
     }
     echo "});";
     $this->NetCommonsHtml->scriptEnd();
     return $this->_View->element('Wysiwyg.wysiwyg_js');
 }
Ejemplo n.º 2
0
 /**
  * beforeRender
  *
  * @param Controller $controller Controller
  * @return void
  * @throws NotFoundException
  */
 public function beforeRender(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested'])) {
         return;
     }
     $this->controller = $controller;
     $this->__prepare();
     //pathからページデータ取得
     if (isset($this->controller->viewVars['page'])) {
         $page = $this->controller->viewVars['page'];
     } else {
         $this->Page = ClassRegistry::init('Pages.Page');
         $page = $this->Page->getPageWithFrame(Current::read('Page.permalink'));
         if (empty($page)) {
             throw new NotFoundException();
         }
     }
     if (Current::hasSettingMode() && Current::isSettingMode() && Current::permission('page_editable')) {
         $this->controller->request->data['ContainersPage'] = Hash::combine($page, 'Container.{n}.type', 'Container.{n}.ContainersPage');
     }
     ////cancelUrlをセット
     //if (! isset($this->controller->viewVars['cancelUrl'])) {
     //	$this->controller->set('cancelUrl', $page['Page']['permalink']);
     //}
     //Pluginデータ取得
     $pluginsRoom = ClassRegistry::init('PluginManager.PluginsRoom');
     $plugins = $pluginsRoom->getPlugins($page['Page']['room_id'], Current::read('Language.id'));
     //ページHelperにセット
     $results = array('containers' => Hash::combine($page['Container'], '{n}.type', '{n}'), 'boxes' => Hash::combine($page['Box'], '{n}.id', '{n}', '{n}.container_id'), 'plugins' => $plugins);
     $this->controller->helpers['Pages.PageLayout'] = $results;
 }
 /**
  * index method
  *
  * @return void
  */
 public function index()
 {
     // 作成権限なければ emptyRender
     if (Current::permission('content_creatable')) {
         // 追加ボタン表示
         $this->view = 'Registrations/noRegistration';
     } else {
         $this->setAction('emptyRender');
     }
 }
Ejemplo n.º 4
0
 /**
  * Get announcement data
  *
  * @return array
  */
 public function getAnnouncement()
 {
     if (Current::permission('content_editable')) {
         $conditions[$this->alias . '.is_latest'] = true;
     } else {
         $conditions[$this->alias . '.is_active'] = true;
     }
     $announcement = $this->find('first', array('recursive' => 0, 'conditions' => $this->getBlockConditionById($conditions)));
     return $announcement;
 }
Ejemplo n.º 5
0
 /**
  * Get dumap
  *
  * @return array
  */
 public function getEdumap()
 {
     $conditions = array('Block.id' => Current::read('Block.id'), 'Block.room_id' => Current::read('Block.room_id'));
     if (Current::permission('content_editable')) {
         $conditions[$this->alias . '.is_latest'] = true;
     } else {
         $conditions[$this->alias . '.is_active'] = true;
     }
     $edumap = $this->find('first', array('recursive' => 0, 'conditions' => $conditions, 'order' => $this->alias . '.id DESC'));
     return $edumap;
 }
 /**
  * view method
  *
  * @return void
  */
 public function view()
 {
     $announcement = $this->Announcement->getAnnouncement();
     if (!$announcement) {
         if (Current::permission('content_editable')) {
             $announcement = $this->Announcement->createAll();
         } else {
             $this->setAction('emptyRender');
             return;
         }
     }
     $this->set('announcement', $announcement['Announcement']);
 }
Ejemplo n.º 7
0
 /**
  * SetUp Attachment behavior
  *
  * @param Model $model instance of model
  * @param array $config array of configuration settings.
  * @throws CakeException 先にOriginalKeyが登録されてないと例外
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function setup(Model $model, $config = array())
 {
     $this->__commonConfig = array('Attr' => array('AllowedFrameTargets' => array('_blank', '_self', '_parent', '_top'), 'AllowedRel' => array('alternate', 'author', 'bookmark', 'help', 'icon', 'license', 'next', 'nofollow', 'noreferrer', 'prefetch', 'prev', 'search', 'stylesheet', 'tag'), 'EnableID' => true), 'Cache' => array('SerializerPath' => $this->__cachePath), 'CSS' => array('AllowDuplicates' => true, 'AllowImportant' => true, 'AllowTricky' => true, 'DefinitionRev' => 1, 'Proprietary' => true, 'Trusted' => true), 'Core' => array('AllowHostnameUnderscore' => true, 'ConvertDocumentToFragment' => false, 'DisableExcludes' => true, 'Encoding' => 'UTF-8', 'MaintainLineNumbers' => false), 'HTML' => array('Doctype' => 'XHTML 1.0 Transitional', 'SafeIframe' => true, 'FlashAllowFullScreen' => true, 'TargetNoreferrer' => false, 'Trusted' => true), 'URI' => array('SafeIframeRegexp' => '%^(https?:)?//(www\\.youtube(?:-nocookie)?\\.com/)%'), 'Output' => array('FlashCompat' => true));
     $this->__htmlNotLimitedConfig = array('Core' => array('HiddenElements' => array()), 'HTML' => array('Proprietary' => true, 'SafeEmbed' => true), 'URI' => array('SafeIframeRegexp' => '%^(https?:)?%'));
     $this->__htmlLimitedConfig = array('CSS' => array('AllowedProperties' => array('color' => true, 'background-color' => true, 'margin' => true, 'text-align' => true, 'margin-left' => true, 'margin-right' => true, 'margin-top' => true, 'margin-bottom' => true, 'padding' => true, 'padding-left' => true, 'padding-right' => true, 'padding-top' => true, 'padding-bottom' => true, 'border' => true, 'border-left' => true, 'border-right' => true, 'border-top' => true, 'border-bottom' => true, 'border-width' => true, 'border-left-width' => true, 'border-right-width' => true, 'border-top-width' => true, 'border-bottom-width' => true, 'border-style' => true, 'border-left-style' => true, 'border-right-style' => true, 'border-top-style' => true, 'border-bottom-style' => true, 'border-color' => true, 'border-left-color' => true, 'border-right-color' => true, 'border-top-color' => true, 'border-bottom-color' => true, 'display' => true, 'float' => true, 'clear' => true, 'width' => true, 'height' => true, 'vertical-align' => true, 'overflow' => true, 'visibility' => true, 'background' => true, 'background-image' => true, 'background-repeat' => true, 'background-attachment' => true, 'background-position' => true, 'font' => true, 'font-style' => true, 'font-variant' => true, 'font-weight' => true, 'font-size' => true, 'line-height' => true, 'font-family' => true, 'text-indent' => true, 'text-decoration' => true, 'letter-spacing' => true, 'text-transform' => true, 'white-space' => true, 'table-layout' => true, 'border-spacing' => true, 'border-collapse' => true)), 'HTML' => array('Allowed' => 'div,' . 'span,' . 'h1[align],' . 'h2[align],' . 'h3[align],' . 'h4[align],' . 'h5[align],' . 'h6[align],' . 'br[clear],' . 'img[src|vspace|hspace|border|alt|height|width],' . 'ol[compact|start|type],' . 'ul[compact|type],' . 'li[type|value],' . 'a[href|target],' . 'hr[align|color|noshade|size|width],' . 'table[cellspacing|cellpadding|border|align],' . 'tbody[align|bgcolor|char|charoff|valign],' . 'tr[colspan|rowspan],' . 'td[colspan|rowspan|bgcolor|align|valign|height|width|nowrap|char|charoff' . '|abbr|axis|headers|scope],' . 'blockquote[cite],' . 'p[align],' . 'th[colspan|rowspan|bgcolor|align|valign|height|width|nowrap|char|charoff' . '|abbr|axis|headers|scope],' . 'strong,' . 'caption[align|valign],' . 'cite,' . 'code,' . 'kbd,' . 'pre[cols|width|wrap],' . 'q,' . 'small,' . 'sub,' . 'sup,' . 'object[archive|border|classid|code|codebase|codetype|data|declare|name' . '|standby|tabindex|type|usemap|align|width|height|hspace|vspace],' . 'param[name|value],' . 'em,' . 'i,' . 'iframe[src|height|width|hspace|vspace|marginheight|marginwidth' . '|allowtransparency|frameborder|border|bordercolor|allowfullscreen],' . 'col[span],' . 'colgroup[span],' . 'rb,' . 'ruby,' . 'rp,' . 'rt,' . 'wbr,' . 'embed[src|height|width|hspace|vspace|units|border|frameborder|play|loop' . '|quality|pluginspage|type|allowscriptaccess|allowfullscreen|flashvars],' . 'font[size|color|face],' . 'big,' . 'center,' . 'tt,' . 'u,' . 's,' . 'strike,' . 'noembed,' . '*[class|id|title|cite|background|style|align|dir|lang|language]'), 'URI' => array('AllowedSchemes' => array('http' => true, 'https' => true, 'mailto' => true, 'ftp' => true)));
     if (Current::permission('html_not_limited')) {
         // HTMLタグ使用権限がある場合
         $purifyConfig = $this->__htmlNotLimitedConfig;
         $customFilters = array();
     } else {
         $purifyConfig = $this->__htmlLimitedConfig;
         $customFilters = array('HTMLPurifier_Filter_Comment');
     }
     $this->__settings = Hash::merge($this->__settings, array('fields' => $config['fields'], 'config' => Hash::merge($this->__commonConfig, $purifyConfig), 'customFilters' => $customFilters));
 }
Ejemplo n.º 8
0
 /**
  * ブロックのステータスラベルを表示
  *
  * @param null|bool $isSetting 強制的にセッティングモード
  * @return string HTML
  */
 public function getBlockStatus($isSetting = null)
 {
     if (!Current::permission('block_editable')) {
         return '';
     }
     if (!isset($isSetting)) {
         $isSetting = Current::isSettingMode();
     }
     if (!$isSetting || !Current::read('Block.id')) {
         return '';
     }
     $block = Current::read('Block', array());
     $publicType = Hash::get($block, 'public_type');
     if ($publicType === Block::TYPE_PUBLIC) {
         return '';
     }
     $html = $this->__getBlockStatus();
     return $html;
 }
Ejemplo n.º 9
0
 /**
  * index method
  *
  * @throws NotFoundException
  * @return void
  */
 public function index()
 {
     if (Current::isSettingMode() && !Current::permission('page_editable')) {
         $paths = func_get_args();
         $path = implode('/', $paths);
         $this->redirect('/' . $path);
         return;
     }
     $paths = func_get_args();
     $path = implode('/', $paths);
     $page = $this->Page->getPageWithFrame($path);
     if (empty($page)) {
         throw new NotFoundException();
     }
     $this->set('page', $page);
     $page['Container'] = Hash::combine($page['Container'], '{n}.type', '{n}');
     $page['Box'] = Hash::combine($page['Box'], '{n}.id', '{n}', '{n}.container_id');
     $page['Container'] = array(Container::TYPE_MAIN => $page['Container'][Container::TYPE_MAIN]);
     $this->set('pageMainContainer', $page);
 }
Ejemplo n.º 10
0
 /**
  * 公開許可あり(承認者、承認OFF時の一般)の編集か ゲット
  *
  * @param Model $model モデル
  * @param string $contentKey コンテンツキー
  * @return bool
  */
 public function isPublishableEdit(Model $model, $contentKey)
 {
     $workflowType = Hash::get($this->settings, $model->alias . '.workflowType');
     // --- コンテンツコメント
     if ($workflowType == MailQueueBehavior::MAIL_QUEUE_WORKFLOW_TYPE_COMMENT) {
         if (!Current::permission('content_comment_publishable')) {
             // 公開権限なし
             return false;
         }
         // 登録日時
         $created = Hash::get($model->data, $model->alias . '.created');
         $isApproveAction = Hash::get($this->settings, $model->alias . '.isCommentApproveAction');
         if (isset($created)) {
             // 新規登録
             return false;
         }
         if ($isApproveAction) {
             // 承認時
             return false;
         }
         return true;
     }
     // --- 通常
     if (!Current::permission('content_publishable')) {
         // 公開権限なし
         return false;
     }
     //$contentKey = $this->__getContentKey($model);
     $keyField = $this->settings[$model->alias]['keyField'];
     $conditions = array($model->alias . '.' . $keyField => $contentKey);
     $result = $model->find('all', array('recursive' => -1, 'conditions' => $conditions, 'order' => array($model->alias . '.modified DESC'), 'callbacks' => false));
     if (count($result) <= 1) {
         // 新規登録
         return false;
     }
     // keyに対して2件以上記事がある = 編集
     // 1つ前のコンテンツのステータス
     $beforeStatus = $result[1][$model->alias]['status'];
     $status = $result[0][$model->alias]['status'];
     // 承認ONでもOFFでも、公開中の記事を編集して、公開だったら、公開の編集
     // ・承認ONで、承認者が公開中の記事を編集しても、公開許可ありの編集で、メール送らない
     // ・承認OFFで、公開中の記事を編集しても、公開許可ありの編集で、メール送らない
     // ・・公開中の記事(1つ前の記事のstatus=1)
     // ・・編集した記事が公開(status=1)
     // ※承認ONで公開中の記事を編集して、編集した記事が公開なのは、承認者だけ
     if ($beforeStatus == WorkflowComponent::STATUS_PUBLISHED && $status == WorkflowComponent::STATUS_PUBLISHED) {
         // 公開の編集
         return true;
     }
     // 公開以外の編集
     return false;
 }
 /**
  * delete method
  *
  * @throws InternalErrorException
  * @return void
  */
 public function delete()
 {
     $this->request->allowMethod('post', 'delete');
     $key = $this->request->data['CabinetFile']['key'];
     $conditions = ['CabinetFile.key' => $key, 'CabinetFile.is_latest' => 1];
     $cabinetFile = $this->CabinetFile->find('first', ['conditions' => $conditions]);
     // フォルダを削除できるのは公開権限のあるユーザだけ。
     if ($cabinetFile['CabinetFile']['is_folder'] && !Current::permission('content_publishable')) {
         return $this->throwBadRequest();
     }
     // 権限チェック
     if ($this->CabinetFile->canDeleteWorkflowContent($cabinetFile) === false) {
         return $this->throwBadRequest();
     }
     if ($this->CabinetFile->deleteFileByKey($key) === false) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
     return $this->redirect(NetCommonsUrl::actionUrl(array('controller' => 'cabinet_files', 'action' => 'index', 'frame_id' => Current::read('Frame.id'), 'block_id' => Current::read('Block.id'))));
 }
Ejemplo n.º 12
0
 /**
  * UserIdと権限から参照可能なEntryを取得するCondition配列を返す
  *
  * @return array condition
  */
 public function getConditions()
 {
     // contentReadable falseなら何も見えない
     if (!Current::permission('content_readable')) {
         $conditions = array('Video.id' => 0);
         // ありえない条件でヒット0にしてる
         return $conditions;
     }
     // デフォルト絞り込み条件
     $conditions = array('Video.block_id' => Current::read('Block.id'));
     $conditions = $this->getWorkflowConditions($conditions);
     return $conditions;
 }
Ejemplo n.º 13
0
 /**
  * コンテンツの公開権限があるかどうかのチェック
  * - 公開権限あり(content_publishable) and 編集権限あり(content_editable)
  * - 自分自身のコンテンツ+一度も公開されていない
  *
  * @param Model $model Model using this behavior
  * @param array $data コンテンツデータ
  * @return bool true:削除可、false:削除不可
  */
 public function canDeleteWorkflowContent(Model $model, $data)
 {
     if (Current::permission('content_publishable')) {
         return true;
     }
     if (!$this->canEditWorkflowContent($model, $data)) {
         return false;
     }
     if (!isset($data[$model->alias])) {
         $data[$model->alias] = $data;
     }
     $conditions = array('is_active' => true);
     if ($model->hasField('key') && isset($data[$model->alias]['key'])) {
         $conditions['key'] = $data[$model->alias]['key'];
     } else {
         return false;
     }
     $count = $model->find('count', array('recursive' => -1, 'conditions' => $conditions));
     return (int) $count === 0;
 }
Ejemplo n.º 14
0
 /**
  * Creates a `<a>` tag for add link. The type attribute defaults
  *
  * @param string $title The button's caption. Not automatically HTML encoded
  * @param mixed $url Link url
  * @param array $options Array of options and HTML attributes.
  * @return string A HTML button tag.
  */
 public function addLinkButton($title = '', $url = null, $options = array())
 {
     $output = '';
     if (!Current::permission('content_creatable')) {
         return $output;
     }
     //URLの設定
     $defaultUrl = array('plugin' => $this->_View->request->params['plugin'], 'controller' => $this->_View->request->params['controller']);
     if (!isset($url)) {
         $url = array('action' => 'add', 'block_id' => Current::read('Block.id'), 'frame_id' => Current::read('Frame.id'));
         if (isset($this->_View->viewVars['addActionController'])) {
             $url['controller'] = $this->_View->viewVars['addActionController'];
         }
     }
     $url = Hash::merge($defaultUrl, $url);
     $output = $this->LinkButton->add($title, $url, $options);
     return $output;
 }
Ejemplo n.º 15
0
 /**
  * 動画のzipダウンロード
  *
  * @return CakeResponse
  * @throws NotFoundException 表示できない記事へのアクセス
  * @throws ForbiddenException アクセス権なし
  * @see DownloadComponent::doDownload()
  */
 public function download()
 {
     // ダウンロードリンク使わないなら、400
     if (!$this->useDownloadLink) {
         return $this->setAction('throwBadRequest');
     }
     // ブロック編集許可(編集長以上)持っていないなら403
     if (!Current::permission('block_editable')) {
         throw new ForbiddenException();
     }
     // ここから元コンテンツを取得する処理
     //$this->_prepare();
     $key = $this->params['key'];
     $conditions = $this->Video->getConditions();
     $conditions['Video.key'] = $key;
     $query = array('conditions' => $conditions);
     $video = $this->Video->find('first', $query);
     // ここまで元コンテンツを取得する処理
     // ダウンロード実行
     if (!$video) {
         // 表示できない記事へのアクセスなら404
         throw new NotFoundException(__d('videos', 'Invalid video entry'));
     }
     // 圧縮用パスワードキーを求める
     if (!empty($this->request->data['AuthorizationKey']['authorization_key'])) {
         $zipPassword = $this->request->data['AuthorizationKey']['authorization_key'];
     } else {
         $this->_setFlashMessageAndRedirect($key, __d('authorization_keys', 'please input compression password'));
         return;
     }
     // ダウンロードファイル名はタイトルにする
     $fileName = $video['Video']['title'];
     $zipFileName = $fileName . '.zip';
     $videoFileName = $fileName . '.mp4';
     $realFilePath = APP . WEBROOT_DIR . DS . $video['UploadFile'][Video::VIDEO_FILE_FIELD]['path'] . $video['UploadFile'][Video::VIDEO_FILE_FIELD]['id'] . DS . $video['UploadFile'][Video::VIDEO_FILE_FIELD]['real_file_name'];
     $zip = new ZipDownloader();
     $zip->addFile($realFilePath, $videoFileName);
     $zip->setPassword($zipPassword);
     $zip->close();
     return $zip->download($zipFileName);
 }
Ejemplo n.º 16
0
 /**
  * 権限の取得
  *
  * @return array
  */
 protected function _getPermission()
 {
     $permissionNames = array('content_readable', 'content_creatable', 'content_editable', 'content_publishable');
     $permission = array();
     foreach ($permissionNames as $key) {
         $permission[$key] = Current::permission($key);
     }
     return $permission;
 }
Ejemplo n.º 17
0
 /**
  * 新着に表示するブロックデータ取得
  *
  * @param array $pluginKeys plugin_keyリスト
  * @param array $roomIds room_idリスト
  * @return array ブロックデータ
  */
 public function getBlocks($pluginKeys, $roomIds)
 {
     $this->loadModels(['Block' => 'Blocks.Block']);
     //除外するプラグイン
     $pluginKeys = array_diff($pluginKeys, self::$outPlugins);
     $conditions = array('Block.room_id' => $roomIds, 'BlocksLanguage.language_id' => Current::read('Language.id'), 'Block.plugin_key' => $pluginKeys);
     if (!Current::permission('block_editable')) {
         $now = gmdate('Y-m-d H:i:s');
         //ブロック公開設定の条件生成
         $conditions['OR'] = array($this->Block->alias . '.public_type' => self::TYPE_PUBLIC, array($this->Block->alias . '.public_type' => self::TYPE_LIMITED, $this->Block->alias . '.publish_start <=' => $now, $this->Block->alias . '.publish_end >=' => $now));
     }
     $result = $this->Block->find('all', array('recursive' => 0, 'fields' => array('Block.id', 'Block.plugin_key', 'Block.room_id', 'Block.key', 'BlocksLanguage.name'), 'conditions' => $conditions));
     $blocks = array();
     foreach ($result as $block) {
         $key = $block['Block']['plugin_key'] . $block['Block']['room_id'];
         $blocks[$key][$block['Block']['key']] = $block['Block'];
         $blocks[$key][$block['Block']['key']]['name'] = $block['BlocksLanguage']['name'];
     }
     return $blocks;
 }
Ejemplo n.º 18
0
 /**
  * ダウンロード処理
  *
  * @param array $file UploadFile data
  * @param string $size サムネイル名
  * @param array $options オプション
  * @return CakeResponse|null
  * @throws ForbiddenException
  * @throws BadRequestException
  * @throws NotFoundException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _downloadUploadFile($file, $size, $options)
 {
     $UploadFile = ClassRegistry::init('Files.UploadFile');
     // ルームチェック
     if ($file['UploadFile']['room_id']) {
         $roomId = Current::read('Room.id');
         if ($file['UploadFile']['room_id'] != $roomId) {
             throw new ForbiddenException('Not found file');
         }
     }
     if ($file['UploadFile']['block_key']) {
         // block_keyによるガード
         $Block = ClassRegistry::init('Blocks.Block');
         $uploadFileBlock = $Block->findByKey($file['UploadFile']['block_key']);
         // ブロック見えない & ブロック編集できないのは 403
         if ($Block->isVisible($uploadFileBlock) === false && Current::permission('block_editable') === false) {
             throw new ForbiddenException('Not found file');
         }
     }
     // size対応
     $filename = $file['UploadFile']['real_file_name'];
     if ($size !== null) {
         // $size = '../../'とかを排除するため!
         if (strpos($size, '..') !== false) {
             throw new BadRequestException();
         }
         $filename = $size . '_' . $filename;
     }
     $filePath = WWW_ROOT . $file['UploadFile']['path'] . $file['UploadFile']['id'] . DS . $filename;
     $options = Hash::merge(array('name' => $file['UploadFile']['original_name']), $options);
     try {
         $this->_controller->response->file($filePath, $options);
     } catch (NotFoundException $ex) {
         //データがない=リンク切れ。リンク切れの場合、ログアウトしないようにする
         CakeLog::error($ex);
         throw new NotFoundException('Not found file');
     } catch (Exception $ex) {
         CakeLog::error($ex);
         throw $ex;
     }
     // Download カウントアップ
     $UploadFile->countUp($file);
     return $this->_controller->response;
 }
Ejemplo n.º 19
0
 /**
  * <li>の出力
  *
  * @param string $activeTab アクティブタブ
  * @param string $key タブキー
  * @param array $tab タブデータ
  * @return string <li>タグの出力
  */
 private function __listTag($activeTab, $key, $tab)
 {
     $html = '';
     if ($activeTab === $key) {
         $activeTabCss = 'active';
     } else {
         $activeTabCss = '';
     }
     if (Current::permission(Hash::get($tab, 'permission', 'block_editable'))) {
         $html .= '<li class="' . $activeTabCss . '">';
         $html .= $this->NetCommonsHtml->link(__d($tab['label'][0], $tab['label'][1]), $tab['url']);
         $html .= '</li>';
     }
     return $html;
 }
Ejemplo n.º 20
0
 /**
  * Output workflow input comment
  *
  * @param string $statusFieldName This should be "Modelname.fieldname"
  * @return string Cancel url
  */
 public function inputComment($statusFieldName)
 {
     $status = Hash::get($this->_View->data, $statusFieldName);
     return $this->_View->element('Comments.form', array('contentPublishable' => Current::permission('content_publishable'), 'contentStatus' => $status));
 }
Ejemplo n.º 21
0
 /**
  * 時限公開のconditionsを返す
  *
  * @return array
  */
 protected function _getPeriodConditions()
 {
     if (Current::permission('content_editable')) {
         return array();
     }
     $netCommonsTime = new NetCommonsTime();
     $nowTime = $netCommonsTime->getNowDatetime();
     $limitedConditions[] = array('OR' => array('Registration.answer_start_period <=' => $nowTime, 'Registration.answer_start_period' => null));
     $limitedConditions[] = array('OR' => array('Registration.answer_end_period >=' => $nowTime, 'Registration.answer_end_period' => null));
     $timingConditions = array('OR' => array('Registration.answer_timing' => RegistrationsComponent::USES_NOT_USE, 'AND' => array('Registration.answer_timing' => RegistrationsComponent::USES_USE, $limitedConditions)));
     // 集計結果の表示は登録フォーム登録が始まっていることが前提
     $totalLimitPreCond = array('OR' => array('Registration.answer_timing' => RegistrationsComponent::USES_NOT_USE, 'AND' => array('Registration.answer_timing' => RegistrationsComponent::USES_USE, 'OR' => array('Registration.answer_start_period <=' => $nowTime, 'Registration.answer_start_period' => null))));
     $totalLimitCond[] = array('OR' => array('Registration.total_show_start_period <=' => $nowTime, 'Registration.total_show_start_period' => null));
     $totalTimingCond = array('Registration.is_total_show' => RegistrationsComponent::USES_USE, $totalLimitPreCond, 'OR' => array('Registration.total_show_timing' => RegistrationsComponent::USES_NOT_USE, $totalLimitCond));
     $timingConditions['OR'][] = $totalTimingCond;
     if (Current::permission('content_creatable')) {
         $timingConditions['OR']['Registration.created_user'] = Current::read('User.id');
     }
     return $timingConditions;
 }
 /**
  * _decideSettingLayout
  *
  * セッティング系の画面からの流れなのかどうかを判断し、レイアウトを決める
  *
  * @return void
  */
 protected function _decideSettingLayout()
 {
     $isSetting = Hash::get($this->request->params, 'named.q_mode');
     if ($isSetting == 'setting') {
         if (Current::permission('block_editable')) {
             $this->layout = 'NetCommons.setting';
         }
         return;
     }
 }