/** * index()のテスト * * @return void */ public function testIndex() { //ログイン TestAuthGeneral::login($this); //テスト実施 $frameId = '6'; $url = array('plugin' => $this->plugin, 'controller' => $this->_controller, 'action' => 'index', 'frame_id' => $frameId); $result = $this->_testNcAction($url, array('method' => 'get')); //チェック //--追加ボタンチェック $addLink = $url; $addLink['controller'] = $this->_editController; $addLink['action'] = 'add'; $this->assertRegExp('/<a href=".*?' . preg_quote(NetCommonsUrl::actionUrl($addLink), '/') . '.*?".*?>/', $result); //--編集ボタンチェック $blockId = '2'; $editLink = $url; $editLink['controller'] = $this->_editController; $editLink['action'] = 'edit'; $editLink['block_id'] = $blockId; $this->assertRegExp('/<a href=".*?' . preg_quote(NetCommonsUrl::actionUrl($editLink), '/') . '.*?".*?>/', $result); //--カレントブロックラジオボタン $this->assertInput('input', 'data[Frame][block_id]', null, $result); //ログアウト TestAuthGeneral::logout($this); }
/** * 埋め込みタグ{X-URL}にセットする値 を取得 * * @param string $contentKey コンテンツキー * @param array $urlParams X-URLのurlパラメータ * @return array */ public function getXUrl($contentKey, $urlParams = array()) { // fullpassのURL if (is_array($urlParams)) { $url = NetCommonsUrl::actionUrl(Hash::merge(array('controller' => Current::read('Plugin.key'), 'action' => 'view', 'block_id' => Current::read('Block.id'), 'frame_id' => Current::read('Frame.id'), 'key' => $contentKey), $urlParams)); $url = NetCommonsUrl::url($url, true); } else { $url = $urlParams; } return array('X-URL', $url); }
/** * add registration display method * * @return void */ public function add() { // NetCommonsお約束:投稿権限のある人物しかこのアクションにアクセスできない // それは$componentsの組み込みでallow => add => content_creatableで担保される // アクション処理内でチェックする必要はない unset($this->helpers['Blocks.BlockTabs']['blockTabs']['role_permissions']); unset($this->helpers['Blocks.BlockTabs']['blockTabs']['mail_settings']); unset($this->helpers['Blocks.BlockTabs']['blockTabs']['answer_list']); // POSTされたデータを読み取り if ($this->request->is('post')) { // Postデータをもとにした新登録フォームデータの取得をModelに依頼する $actionModel = ClassRegistry::init('Registrations.ActionRegistrationAdd', 'true'); if ($registration = $actionModel->createRegistration($this->request->data)) { $tm = $this->_getRegistrationEditSessionIndex(); // 作成中登録フォームデータをセッションキャッシュに書く $this->Session->write('Registrations.registrationEdit.' . $tm, $registration); // 次の画面へリダイレクト $urlArray = array('controller' => 'registration_edit', 'action' => 'edit_question', Current::read('Block.id'), 'frame_id' => Current::read('Frame.id'), 's_id' => $tm); if ($this->layout == 'NetCommons.setting') { $urlArray['q_mode'] = 'setting'; } $this->redirect(NetCommonsUrl::actionUrl($urlArray)); return; } else { // データに不備があった場合 $this->NetCommons->handleValidationError($actionModel->validationErrors); } } else { // 新規に登録フォームを作成するときは最初にブロックをつくっておく $frame['Frame'] = Current::read('Frame'); $this->Registration->createBlock($frame); } // 過去データ 取り出し $conditions = Hash::remove($this->Registration->getBaseCondition(), 'block_id'); $conditions['Block.room_id'] = Current::read('Room.id'); $pastRegistrations = $this->Registration->find('all', array('fields' => array('id', 'title', 'status', 'answer_timing', 'answer_start_period', 'answer_end_period'), 'conditions' => $conditions, 'offset' => 0, 'limit' => 1000, 'recursive' => 0, 'order' => array('Registration.modified DESC'))); $this->set('pastRegistrations', $pastRegistrations); if ($this->layout == 'NetCommons.setting') { $this->set('cancelUrl', NetCommonsUrl::backToIndexUrl('default_setting_action')); } else { $this->set('cancelUrl', NetCommonsUrl::backToPageUrl()); } // // NetCommonsお約束:投稿のデータはrequest dataに設定する // $this->request->data['Frame'] = Current::read('Frame'); $this->request->data['Block'] = Current::read('Block'); // create_optionが未設定のときは初期値として「NEW」を設定する if (!$this->request->data('ActionRegistrationAdd.create_option')) { $this->request->data('ActionRegistrationAdd.create_option', RegistrationsComponent::REGISTRATION_CREATE_OPT_NEW); } }
/** * ブロック削除のForm出力 * * @param array $options オプション * - `model` モデル名 * - `callback` コールバックするelement * - `callbackOptions` コールバックのオプション * - `url` 削除アクション(省略可) * - `options` Form->create()のオプション * @return string HTML */ public function displayDeleteForm($options = array()) { $html = ''; if ($this->_View->request->params['action'] === 'edit') { if (Hash::get($options, 'url')) { $options['options']['url'] = Hash::get($options, 'url'); $options = Hash::remove($options, 'url'); } if (!Hash::get($options, 'options.url')) { $options['options']['url'] = NetCommonsUrl::actionUrl(array('controller' => $this->_View->request->params['controller'], 'action' => 'delete', 'block_id' => Current::read('Block.id'), 'frame_id' => Current::read('Frame.id'))); } if (!Hash::get($options, 'model')) { $options['model'] = 'BlockDelete'; } $html .= $this->_View->element('Blocks.delete_form', $options); } return $html; }
/** * upload action * * file: data[Wysiwyg][file] * block_key: data[Block][key] * としてそれぞれ POSTされるものとして作成。 * * @return void */ public function upload() { // 初期処理 $uploadFileModel = $this->_getUploadFileModel(); // Wysiwyg.file 情報が与えられていない時はエラーを返す。 $uploadFile = false; if ($this->_isUploadedFile($this->data['Wysiwyg'])) { // FileUploadコンポーネントからアップロードファイル情報の取得 $file = $this->FileUpload->getTemporaryUploadFile('Wysiwyg.file'); // uploadFile登録に必要な data(block_key)を作成する。 $data = ['UploadFile' => ['block_key' => $this->data['Block']['key'], 'room_id' => $this->data['Block']['room_id']]]; $uploadFile = $uploadFileModel->registByFile($file, 'wysiwyg', null, 'Wysiwyg.file', $data); } // 戻り値として生成する値を返す // $file: ファイル情報 // $message: エラーメッセージ // $result: 結果の OK/NG // $statusCode: responseとしても返す // $file = []; $message = ''; if ($uploadFile) { $statusCode = 200; // Status 200(OK) $result = true; // アップロードしたファイルのパスを作成 $url = NetCommonsUrl::actionUrl(array('plugin' => 'wysiwyg', 'controller' => strtolower($this->name), 'action' => 'download', $uploadFile['UploadFile']['room_id'], $uploadFile['UploadFile']['id']), true); $file = ['id' => $uploadFile['UploadFile']['id'], 'original_name' => $uploadFile['UploadFile']['original_name'], 'path' => $url]; } else { $statusCode = 400; // Status 400(Bad request) $result = false; if ($uploadFileModel->validationErrors) { $message = $uploadFileModel->validationErrors['real_file_name']; } else { $message = 'File is required.'; } } // JSONを返す $this->viewClass = 'Json'; $this->response->statusCode($statusCode); $this->set(compact('statusCode', 'result', 'message', 'file')); $this->set('_serialize', ['statusCode', 'result', 'message', 'file']); }
/** * 親フォルダのURLを返す * * @param array $currentFolder 現在位置のCabinetFileデータ(フォルダ) * @param array $folderPath 現在位置までのTreeパス * @return null|string 親フォルダのURL */ protected function _getParentFolderUrl($currentFolder, $folderPath) { // 親フォルダのTreeIDがルートフォルダのTreeIDと違うなら親フォルダは通常フォルダ $isRootFolder = $currentFolder['CabinetFileTree']['parent_id'] === null; $hasParentFolder = $currentFolder['CabinetFileTree']['parent_id'] != $folderPath[0]['CabinetFileTree']['id']; if ($isRootFolder) { // root folder $url = null; } elseif ($hasParentFolder) { // 親フォルダあり $nestCount = count($folderPath); $url = NetCommonsUrl::actionUrl(['key' => $folderPath[$nestCount - 2]['CabinetFile']['key'], 'block_id' => Current::read('Block.id'), 'frame_id' => Current::read('Frame.id')]); } else { // 親はキャビネット(ルートフォルダ) $url = NetCommonsUrl::backToPageUrl(); } return $url; }
/** * getAggregateButtons 集計のボタン表示 * * @param array $registration 登録データ * @param array $options option * @return string */ public function getAggregateButtons($registration, $options = array()) { // // 集計ボタン // 集計表示しない=ボタン自体ださない // 集計表示する=登録すみ、または登録期間終了 集計ボタン // 登録フォーム自体が公開状態にない(not editor) // 未登録&登録期間内 集計ボタン(disabled) $key = $registration['Registration']['key']; if ($registration['Registration']['is_total_show'] == RegistrationsComponent::EXPRESSION_NOT_SHOW) { return ''; } $disabled = ''; // 登録フォーム本体が始まってない if ($registration['Registration']['period_range_stat'] == RegistrationsComponent::REGISTRATION_PERIOD_STAT_BEFORE) { $disabled = 'disabled'; } else { // 始まっている // 集計結果公開期間外である $nowTime = (new NetCommonsTime())->getNowDatetime(); if ($registration['Registration']['total_show_timing'] == RegistrationsComponent::USES_USE && strtotime($nowTime) < strtotime($registration['Registration']['total_show_start_period'])) { $disabled = 'disabled'; } else { // 集計結果公開期間内である // 一つでも登録している if (!in_array($key, $this->_View->viewVars['ownAnsweredKeys'])) { // 未登録 $disabled = 'disabled'; } } } list($title, $icon, $btnClass) = $this->_getBtnAttributes($options); $url = NetCommonsUrl::actionUrl(array('controller' => 'registration_answer_summaries', 'action' => 'view', Current::read('Block.id'), $key, 'frame_id' => Current::read('Frame.id'))); // この登録フォームの編集権限を持っているなら無条件で集計表示ボタン操作できる if ($this->_View->Workflow->canEdit('Registration', $registration)) { $disabled = ''; } $html = $this->NetCommonsHtml->link($icon . $title, $url, array('class' => $btnClass . ' ' . $disabled, 'escape' => false)); return $html; }
/** * Get compress password * * @return mixed */ private function __getCompressPassword() { if (isset($this->request->data['AuthorizationKey']) && $this->request->data['AuthorizationKey']['authorization_key'] !== '') { return $this->request->data['AuthorizationKey']['authorization_key']; } // エラー $this->NetCommons->setFlashNotification(__d('circular_notices', 'Setting of password is required always to download answers.'), array('interval' => NetCommonsComponent::ALERT_VALIDATE_ERROR_INTERVAL)); $this->redirect(NetCommonsUrl::actionUrl(array('controller' => 'circular_notices', 'action' => 'view', 'block_id' => Current::read('Block.id'), 'key' => $this->request->params['key'], 'frame_id' => Current::read('Frame.id')))); return false; }
/** * _setFlashMessageAndRedirect * * @param string $contentKey コンテンツキー * @param string $message flash error message * * @return void */ protected function _setFlashMessageAndRedirect($contentKey, $message) { $this->NetCommons->setFlashNotification($message, array('interval' => NetCommonsComponent::ALERT_VALIDATE_ERROR_INTERVAL)); $url = NetCommonsUrl::actionUrl(array('controller' => 'videos', 'action' => 'view', 'block_id' => Current::read('Block.id'), 'key' => $contentKey), true); // 暫定対応:どうゆう訳だか、ここだと?frame_idが上記でセットされないので直書き $url .= '?frame_id=' . Current::read('Frame.id'); $this->redirect($url); }
/** * editアクションのGETテスト * * @param array $approvalFields コンテンツ承認の利用有無のフィールド * @param string|null $exception Exception * @param string $return testActionの実行後の結果 * @dataProvider dataProviderEditGet * @return string Viewの内容 */ public function testEditGet($approvalFields, $exception = null, $return = 'view') { //ログイン TestAuthGeneral::login($this); $frameId = '6'; $blockId = '4'; //テスト実施 $url = array('plugin' => $this->plugin, 'controller' => $this->_controller, 'action' => 'edit', 'frame_id' => $frameId, 'block_id' => $blockId); $params = array('method' => 'get', 'return' => 'view'); $result = $this->_testNcAction($url, $params, $exception, $return); if (!$exception) { //チェック $assert = array('method' => 'assertInput', 'type' => 'form', 'name' => null, 'value' => NetCommonsUrl::actionUrl($url)); $this->asserts(array($assert), $result); $assert = array('method' => 'assertInput', 'type' => 'input', 'name' => 'data[Block][id]', 'value' => $blockId); $this->asserts(array($assert), $result); $this->_assertEditGetPermission($approvalFields, $result); } //ログアウト TestAuthGeneral::logout($this); return $result; }
/** * 投稿者(TrackableCreator)や最終更新者(TrackableUpdater)などのアバターの表示 * * @param array $user ユーザデータ * @param array $attributes imgタグの属性 * @param string $modelId モデル名+id(TrackableCreator.idやTrackableUpdater.idなど) * @param bool $imgTag imgタグとするかのフラグ * @return string HTMLタグ * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function avatar($user, $attributes = [], $modelId = 'TrackableCreator.id', $imgTag = true) { $html = ''; if ($this->_View->request->params['plugin'] === 'user_manager' && $this->_View->request->params['controller'] === 'user_manager') { $url = NetCommonsUrl::actionUrl(array('plugin' => 'user_manager', 'controller' => 'user_manager', 'action' => 'download', 'key' => Hash::get($user, $modelId), 'key2' => UserAttribute::AVATAR_FIELD, 'thumb')); } else { $url = NetCommonsUrl::actionUrl(array('plugin' => 'users', 'controller' => 'users', 'action' => 'download', 'key' => Hash::get($user, $modelId), 'key2' => UserAttribute::AVATAR_FIELD, 'thumb')); } if ($imgTag) { $html .= $this->NetCommonsHtml->image($url, Hash::merge(['class' => 'user-avatar-xs', 'alt' => '', 'hasBlock' => false], $attributes)); } else { $html .= Router::url($url); } return $html; }
/** * approve * * @return void */ public function approve() { if (!$this->request->isPut()) { $this->throwBadRequest(); return; } $data = $this->data; $data['BbsArticle']['status'] = $this->Workflow->parseStatus(); if (!$data['BbsArticle']['status']) { $this->throwBadRequest(); return; } if ($this->BbsArticle->saveCommentAsPublish($data)) { $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success')); $url = NetCommonsUrl::actionUrl(array('controller' => $this->params['controller'], 'action' => 'view', 'frame_id' => $this->data['Frame']['id'], 'key' => $this->data['BbsArticle']['key'])); $this->redirect($url); return; } $this->NetCommons->handleValidationError($this->BbsArticle->validationErrors); $this->throwBadRequest(); }
/** * 削除 * * @return CakeResponse */ public function delete() { if (!$this->request->is('delete')) { return $this->throwBadRequest(); } $video = $this->Video->getWorkflowContents('first', array('recursive' => 1, 'conditions' => array($this->Video->alias . '.key' => $this->data['Video']['key']))); //削除権限チェック if (!$this->Video->canDeleteWorkflowContent($video)) { return $this->throwBadRequest(); } // 削除 if (!$this->Video->deleteVideo($this->data)) { return $this->throwBadRequest(); } // 一覧へ $url = NetCommonsUrl::actionUrl(array('controller' => 'videos', 'action' => 'index', 'block_id' => $this->data['Block']['id'], 'frame_id' => $this->data['Frame']['id'])); $this->redirect($url); }
/** * ユーザ属性の表示 * * @param string $fieldName モデルのフィールド名 * @param array $userAttribute ユーザ属性データ * @return string HTMLタグ */ public function userElement($fieldName, $userAttribute) { $element = ''; $userAttributeKey = $userAttribute['UserAttribute']['key']; if ($userAttribute['UserAttributeSetting']['data_type_key'] === DataType::DATA_TYPE_IMG) { $imageUrl = NetCommonsUrl::actionUrl(array('plugin' => 'users', 'controller' => 'users', 'action' => 'download', 'key' => Hash::get($this->_View->viewVars['user'], 'User.id'), 'key2' => $userAttributeKey, 'medium')); $element .= '<div class="thumbnail user-thumbnail">'; $element .= $this->NetCommonsHtml->image($imageUrl, array('class' => 'img-responsive img-rounded')); $element .= '</div>'; } elseif (isset($userAttribute['UserAttributeChoice'])) { if ($userAttributeKey === 'role_key') { $keyPath = '{n}[key=' . Hash::get($this->_View->viewVars['user'], $fieldName) . ']'; } else { $keyPath = '{n}[code=' . Hash::get($this->_View->viewVars['user'], $fieldName) . ']'; } $option = Hash::extract($userAttribute['UserAttributeChoice'], $keyPath); $element .= h($option[0]['name']); } elseif ($this->UsersLanguage->hasField($userAttributeKey)) { $element .= $this->__displayLanguageField($fieldName); } elseif (in_array($userAttributeKey, UserAttribute::$typeDatetime, true)) { $element .= $this->Date->dateFormat(h(Hash::get($this->_View->viewVars['user'], $fieldName)), UserAttribute::DISPLAY_DATETIME_FORMAT); } elseif (isset($fieldName)) { $element .= h(Hash::get($this->_View->viewVars['user'], $fieldName)); } else { $element .= ''; } return $element; }
/** * Called after the Controller::beforeFilter() and before the controller action * * @param Controller $controller Controller with components to startup * @return void * @throws ForbiddenException */ public function startup(Controller $controller) { // 何もしないでと指示されている場合 if ($this->operationType == VisualCaptchaComponent::OPERATION_NONE) { return; } // 埋め込み型の時 if ($this->operationType == VisualCaptchaComponent::OPERATION_EMBEDDING) { // 埋め込み型のときは判断・処理は利用側のプラグインに移譲する return; } // 切り替え型のとき // リダイレクトURL準備 $this->visualCaptchaAction['frame_id'] = Current::read('Frame.id'); $this->visualCaptchaAction['block_id'] = Current::read('Block.id'); // リファラが自分自身でないことが必須(無限ループになる if ($this->operationType == VisualCaptchaComponent::OPERATION_REDIRECT) { if ($controller->action == $this->targetAction) { // OK判定が出ているか出てないならばリダイレクト if (!$controller->Session->check('VisualCaptcha.judgement')) { // 切り替え後、認証成功時のURLを取り出す $returnUrl = $controller->request->here(false); $controller->Session->write('VisualCaptcha.returnUrl', $returnUrl); $controller->redirect(NetCommonsUrl::actionUrl($this->visualCaptchaAction)); } else { // 出ているときはリダイレクトない // そのままガード外して目的の画面へ行かせるので、ここでOK判定を消しておく $controller->Session->delete('VisualCaptcha.judgement'); } } } }
/** * _getActionUrl method * * @param string $method 遷移先アクション名 * @return void */ protected function _getActionUrl($method) { $urlArray = array('controller' => Inflector::underscore($this->name), 'action' => $method, Current::read('Block.id'), $this->_getRegistrationKey($this->_registration), 'frame_id' => Current::read('Frame.id'), 's_id' => $this->_getRegistrationEditSessionIndex()); if ($this->layout == 'NetCommons.setting') { $urlArray['q_mode'] = 'setting'; } return NetCommonsUrl::actionUrl($urlArray); }
/** * saveAnswerStatus * 登録状態を書き換える * * @param array $summary summary data * @param int $status status * @throws InternalErrorException * @return bool */ public function saveAnswerStatus($summary, $status) { $summary['RegistrationAnswerSummary']['answer_status'] = $status; if ($status == RegistrationsComponent::ACTION_ACT) { // サマリの状態を完了にして確定する $summary['RegistrationAnswerSummary']['answer_time'] = (new NetCommonsTime())->getNowDatetime(); // メールのembed のURL設定を行っておく $url = NetCommonsUrl::actionUrl(array('controller' => 'registration_blocks', 'action' => 'index', Current::read('Block.id'), 'frame_id' => Current::read('Frame.id')), true); $this->setAddEmbedTagValue('X-URL', $url); // 本人にもメールする設定でメールアドレス欄があったら、一番最初のメールアドレス宛にメールする $condition = $this->Registration->getBaseCondition(); $registration = $this->Registration->find('first', ['conditions' => $condition]); // X-SUBJECT設定 $this->setAddEmbedTagValue('X-SUBJECT', $registration['Registration']['title']); // 登録された項目の取得 // RegistrationAnswerに登録データの取り扱いしやすい形への整備機能を組み込んであるので、それを利用したかった // AnswerとQuestionがJOINされた形でFindしないと整備機能が発動しない // そうするためにはrecursive=2でないといけないわけだが、recursive=2にするとRoleのFindでSQLエラーになる // 仕方ないのでこの形式で処理を行う // 単純にRegistrationAnswerSummary.idでFindすると、LEFT JOIN の関係で同じ項目が複数でてきてしまう。 $questionIds = Hash::extract($registration['RegistrationPage'], '{n}.RegistrationQuestion.{n}.id'); $answers = $this->RegistrationAnswer->find('all', array('fields' => array('RegistrationAnswer.*', 'RegistrationQuestion.*'), 'conditions' => array('registration_answer_summary_id' => $summary[$this->alias]['id'], 'RegistrationQuestion.id' => $questionIds), 'recursive' => -1, 'joins' => array(array('table' => 'registration_questions', 'alias' => 'RegistrationQuestion', 'type' => 'LEFT', 'conditions' => array('RegistrationAnswer.registration_question_key = RegistrationQuestion.key'))))); // X-DATA展開 $xData = $this->_makeXData($summary, $answers); $this->setAddEmbedTagValue('X-DATA', $xData); // TO_ADDRESSESには表示しない(ルーム配信のみ表示)末尾定型文を追加(登録フォーム回答) $this->setSetting(MailQueueBehavior::MAIL_QUEUE_SETTING_MAIL_BODY_AFTER, __d('registrations', 'Registration.mail.after.body')); if ($registration['Registration']['is_regist_user_send']) { // 本人にもメールする foreach ($registration['RegistrationPage'][0]['RegistrationQuestion'] as $index => $question) { if ($question['question_type'] == RegistrationsComponent::TYPE_EMAIL) { // メール項目あり // メアドをregistration_answersから取得 $registUserMail = $answers[$index]['RegistrationAnswer']['answer_value']; // 送信先にset $this->setSetting(MailQueueBehavior::MAIL_QUEUE_SETTING_TO_ADDRESSES, [$registUserMail]); // ループから抜ける break; } } } } else { // 完了時以外はメールBehaviorを外す $this->Behaviors->unload('Mails.MailQueue'); } $this->begin(); try { $this->set($summary); if (!$this->validates()) { $this->rollback(); return false; } if (!$this->save($summary, false)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } $this->commit(); } catch (Exception $ex) { $this->rollback(); CakeLog::error($ex); throw $ex; } return true; }
/** * _setFlashMessageAndRedirect * * @param string $message flash error message * * @return void */ protected function _setFlashMessageAndRedirect($message) { $this->NetCommons->setFlashNotification($message, array('interval' => NetCommonsComponent::ALERT_VALIDATE_ERROR_INTERVAL)); $this->redirect(NetCommonsUrl::actionUrl(array('controller' => 'registration_blocks', 'action' => 'index', 'frame_id' => Current::read('Frame.id')))); }
/** * Set block tabs * * @param Controller $controller Controller with components to beforeRender * @return void */ private function __setBlockTabs(Controller $controller) { //ブロック設定のタブ $defaultUrls = array(self::BLOCK_TAB_SETTING => array('plugin' => $controller->params['plugin'], 'controller' => Inflector::singularize($controller->params['plugin']) . '_blocks', 'action' => $controller->params['action'], 'frame_id' => Current::read('Frame.id'), 'block_id' => Current::read('Block.id')), self::BLOCK_TAB_PERMISSION => array('plugin' => $controller->params['plugin'], 'controller' => Inflector::singularize($controller->params['plugin']) . '_block_role_permissions', 'action' => 'edit', 'frame_id' => Current::read('Frame.id'), 'block_id' => Current::read('Block.id'))); $settings = array(); foreach ($this->settings['blockTabs'] as $key => $tab) { if (!is_array($tab) && in_array($tab, $this->settings['blockTabs'], true)) { $this->settings['blockTabs'][$tab] = array(); $key = $tab; } $settings[$key] = $this->settings['blockTabs'][$key]; if (!isset($defaultUrls[$key])) { continue; } if (isset($this->settings['blockTabs'][$key]['url']['plugin'])) { $defaultUrls[$key]['plugin'] = $this->settings['blockTabs'][$key]['url']['plugin']; } if (isset($this->settings['blockTabs'][$key]['url']['controller'])) { $defaultUrls[$key]['controller'] = $this->settings['blockTabs'][$key]['url']['controller']; } if (isset($this->settings['blockTabs'][$key]['url']['action'])) { $defaultUrls[$key]['action'] = $this->settings['blockTabs'][$key]['url']['action']; } $settings[$key]['url'] = NetCommonsUrl::actionUrl($defaultUrls[$key]); } $controller->set('blockSettingTabs', $settings); }
/** * _redirectAnswerPage * * @return void */ protected function _redirectAnswerPage() { $this->redirect(NetCommonsUrl::actionUrl(array('controller' => 'registration_answers', 'action' => 'view', Current::read('Block.id'), $this->_getRegistrationKey($this->__registration), 'frame_id' => Current::read('Frame.id')))); }
/** * delete()のテスト * * @param array $data 削除データ * @dataProvider dataProviderDelete * @return void */ public function testDelete($data) { //ログイン TestAuthGeneral::login($this); $frameId = '6'; $blockId = '4'; //アクション実行 $url = NetCommonsUrl::actionUrl(array('plugin' => $this->plugin, 'controller' => $this->_controller, 'action' => 'delete', 'frame_id' => $frameId, 'block_id' => $blockId)); $params = array('method' => 'delete', 'return' => 'view', 'data' => $data); $this->testAction($url, $params); //チェック $header = $this->controller->response->header(); $asserts = array(array('method' => 'assertNotEmpty', 'value' => $header['Location'])); $this->asserts($asserts, $this->contents); //ログアウト TestAuthGeneral::logout($this); }
/** * 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')))); }
/** * _redirectStartup * 認証に成功したあとの戻りURLをセッションに保存して * 切り替え型の画面を呼び出す * * @param Controller $controller Controller with components to startup * @return void */ protected function _redirectStartup(Controller $controller) { // リダイレクトURL準備 $this->AuthorizeKeyAction[] = $this->_hashKey; $this->AuthorizeKeyAction['block_id'] = Current::read('Block.id'); $this->AuthorizeKeyAction['frame_id'] = Current::read('Frame.id'); // 現在の稼働アクションがターゲットであること if ($controller->action == $this->targetAction) { // OK判定が出ているか出てないならばリダイレクト if (!$controller->Session->check('AuthorizationKey.judgement.' . $this->_hashKey)) { // 切り替え後、認証成功時のURLを取り出す $returnUrl = $controller->request->here(false); $controller->Session->write('AuthorizationKey.returnUrl.' . $this->_hashKey, $returnUrl); $controller->redirect(NetCommonsUrl::actionUrl($this->AuthorizeKeyAction)); } else { // 出ているときはリダイレクトない // そのままガード外して目的の画面へ行かせるので、ここでOK判定を消しておく $controller->Session->delete('AuthorizationKey.judgement.' . $this->_hashKey); } } }