/**
  * Output workflow buttons
  *
  * @param string $statusFieldName This should be "Modelname.fieldname"
  * @param string|null $cancelUrl Cancel url
  * @param bool $panel If true is add to panel footer div, then false is not div.
  * @return string Cancel url
  * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
  */
 public function buttons($statusFieldName, $cancelUrl = null, $panel = true)
 {
     $status = Hash::get($this->data, $statusFieldName);
     $output = '';
     if ($panel) {
         $output .= '<div class="panel-footer text-center">';
     }
     if (!isset($cancelUrl)) {
         $cancelUrl = NetCommonsUrl::backToIndexUrl();
     }
     $output .= $this->Html->link('<span class="glyphicon glyphicon-remove"></span> ' . __d('net_commons', 'Cancel'), $cancelUrl, array('class' => 'btn btn-default btn-workflow', 'escape' => false));
     if (Current::permission('content_publishable') && $status === WorkflowComponent::STATUS_APPROVED) {
         $output .= $this->Form->button(__d('net_commons', 'Disapproval'), array('class' => 'btn btn-warning btn-workflow', 'name' => 'save_' . WorkflowComponent::STATUS_DISAPPROVED));
     } else {
         $output .= $this->Form->button(__d('net_commons', 'Save temporally'), array('class' => 'btn btn-info btn-workflow', 'name' => 'save_' . WorkflowComponent::STATUS_IN_DRAFT));
     }
     if (Current::permission('content_publishable')) {
         $output .= $this->Form->button(__d('net_commons', 'OK'), array('class' => 'btn btn-primary btn-workflow', 'name' => 'save_' . WorkflowComponent::STATUS_PUBLISHED));
     } else {
         $output .= $this->Form->button(__d('net_commons', 'OK'), array('class' => 'btn btn-primary btn-workflow', 'name' => 'save_' . WorkflowComponent::STATUS_APPROVED));
     }
     if ($panel) {
         $output .= '</div>';
     }
     return $output;
 }
 /**
  * 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);
 }
 /**
  * アクションが/frames/frames/editで、NetCommonsForm->create()の結果を出力する
  *
  * ##### return サンプル
  * ```
  * <form method="post" novalidate="novalidate" ng-submit="submit($event)" action="/frames/frames/edit">
  * ```
  *
  * @param mixed $model モデル名
  * @param array $options オプション
  * @return string
  */
 public function create($model = null, $options = array())
 {
     $options['url'] = NetCommonsUrl::blockUrl(array('plugin' => 'frames', 'controller' => 'frames', 'action' => 'edit'));
     $output = $this->NetCommonsForm->create('', $options);
     $output .= $this->NetCommonsForm->hidden('Frame.id');
     return $output;
 }
 /**
  * ワークフローのボタン表示
  *
  * @param string $statusFieldName ステータスのフィールド名("Modelname.fieldname")
  * @param string|null $cancelUrl キャンセルURL
  * @param bool $panel panel-footerを表示するかどうか
  * @param string|null $backUrl 前へのURL
  * @return string ボタンHTML
  * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
  */
 public function buttons($statusFieldName, $cancelUrl = null, $panel = true, $backUrl = null)
 {
     $output = '';
     if ($panel) {
         $output .= '<div class="panel-footer text-center">';
     }
     $status = Hash::get($this->_View->request->data, $statusFieldName . '_');
     if (!$status) {
         $status = Hash::get($this->_View->request->data, $statusFieldName);
     }
     //変更前のstatusを保持する
     $output .= $this->NetCommonsForm->hidden('status_', array('value' => $status));
     if (!isset($cancelUrl)) {
         $cancelUrl = NetCommonsUrl::backToIndexUrl();
     }
     $cancelOptions = array('ng-class' => '{disabled: sending}', 'ng-click' => 'sending=true');
     if (Current::permission('content_publishable') && $status === WorkflowComponent::STATUS_APPROVED) {
         $saveTempOptions = array('label' => __d('net_commons', 'Disapproval'), 'class' => 'btn btn-warning' . $this->Button->getButtonSize() . ' btn-workflow', 'name' => 'save_' . WorkflowComponent::STATUS_DISAPPROVED, 'ng-class' => '{disabled: sending}');
     } else {
         $saveTempOptions = array('label' => __d('net_commons', 'Save temporally'), 'class' => 'btn btn-info' . $this->Button->getButtonSize() . ' btn-workflow', 'name' => 'save_' . WorkflowComponent::STATUS_IN_DRAFT, 'ng-class' => '{disabled: sending}');
     }
     if (Current::permission('content_publishable')) {
         $saveOptions = array('label' => __d('net_commons', 'OK'), 'class' => 'btn btn-primary' . $this->Button->getButtonSize() . ' btn-workflow', 'name' => 'save_' . WorkflowComponent::STATUS_PUBLISHED, 'ng-class' => '{disabled: sending}');
     } else {
         $saveOptions = array('label' => __d('net_commons', 'OK'), 'class' => 'btn btn-primary' . $this->Button->getButtonSize() . ' btn-workflow', 'name' => 'save_' . WorkflowComponent::STATUS_APPROVED, 'ng-class' => '{disabled: sending}');
     }
     $output .= $this->Button->cancelAndSaveAndSaveTemp($cancelUrl, $cancelOptions, $saveTempOptions, $saveOptions, $backUrl);
     if ($panel) {
         $output .= '</div>';
     }
     return $output;
 }
 /**
  * メール設定 登録,編集
  *
  * @return mixed
  */
 public function edit()
 {
     if ($this->request->is('post') || $this->request->is('put')) {
         $result = $this->MailSetting->saveMailSettingAndFixedPhrase($this->request->data);
         if ($result) {
             $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success', 'interval' => NetCommonsComponent::ALERT_SUCCESS_INTERVAL));
             if (!$this->backUrl) {
                 return $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
             } else {
                 return $this->redirect($this->backUrl);
             }
         }
         $this->NetCommons->handleValidationError($this->MailSetting->validationErrors);
         $this->NetCommons->handleValidationError($this->MailSettingFixedPhrase->validationErrors);
         if (isset($this->request->data['BlockRolePermission'])) {
             $this->request->data['BlockRolePermission'] = Hash::merge($this->viewVars['permissions']['BlockRolePermissions'], $this->request->data['BlockRolePermission']);
         }
     } else {
         $mailSettingPlugin = $this->viewVars['mailSettingPlugin'];
         $this->request->data['MailSetting'] = $mailSettingPlugin['MailSetting'];
         $this->request->data['MailSettingFixedPhrase'] = $mailSettingPlugin['MailSettingFixedPhrase'];
         $this->request->data['BlockRolePermission'] = $this->viewVars['permissions']['BlockRolePermissions'];
         $this->request->data['Frame'] = Current::read('Frame');
     }
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     if (!$this->initLink()) {
         return;
     }
     $this->Categories->initCategories(true);
     $this->Paginator->settings = array('Link' => array('order' => array('LinkOrder.weight' => 'asc'), 'conditions' => array('Link.block_id' => $this->viewVars['blockId'], 'Link.is_latest' => true), 'limit' => -1));
     $links = $this->Paginator->paginate('Link');
     $links = Hash::combine($links, '{n}.LinkOrder.weight', '{n}', '{n}.Category.id');
     //POST処理
     $data = array();
     if ($this->request->isPost()) {
         //登録処理
         $data = $this->data;
         $this->LinkOrder->saveLinkOrders($data);
         //validationError
         if ($this->NetCommons->handleValidationError($this->LinkOrder->validationErrors)) {
             //リダイレクト
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
     }
     $data = Hash::merge(array('links' => $links), $data);
     $results = $this->camelizeKeyRecursive($data);
     $this->set($results);
 }
 /**
  * edit
  *
  * @throws BadRequestException
  * @return void
  */
 public function edit()
 {
     //Edumapデータを取得
     $this->__initEdumap();
     //コメントデータ取得
     $comments = $this->Comment->getComments(array('plugin_key' => $this->params['plugin'], 'content_key' => $this->viewVars['edumap']['key']));
     $data = array();
     if ($this->request->isPost()) {
         if (!($status = $this->NetCommonsWorkflow->parseStatus())) {
             return;
         }
         $data = $this->__parseRequestData();
         $data = Hash::merge($data, array('Edumap' => array('status' => $status)));
         unset($data['Edumap']['id']);
         if (!$this->viewVars['blockId']) {
             $visibilitySetting = $this->EdumapVisibilitySetting->create();
             $data = Hash::merge($data, $visibilitySetting);
         }
         //登録処理
         $this->Edumap->saveEdumap($data);
         if ($this->NetCommons->handleValidationError($this->Edumap->validationErrors)) {
             //正常の場合
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
         $data['Edumap']['foundation_date'] = $this->data['Edumap']['foundation_date'];
         $data['Edumap']['closed_date'] = $this->data['Edumap']['closed_date'];
         $data['contentStatus'] = null;
         $data['comments'] = null;
         unset($data['Edumap']['status']);
     }
     $data = $this->camelizeKeyRecursive(Hash::merge($data, array('comments' => $comments, 'contentStatus' => $this->viewVars['edumap']['status'])));
     $results = Hash::merge($this->viewVars, $data);
     $this->set($results);
 }
 /**
  * beforeFilter
  *
  * @return void
  * @see NetCommonsAppController::beforeFilter()
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     // 親クラスが独自コントローラのためcomponentsがマージされないので自分で読みこむ。
     $this->RegistrationBlockTabs = $this->Components->load('Registrations.RegistrationBlockTabs');
     // メール設定 多段の場合にセット
     $this->MailSettings->permission = array('mail_content_receivable', 'mail_answer_receivable');
     $this->MailSettings->typeKeys = array(MailSettingFixedPhrase::DEFAULT_TYPE, MailSettingFixedPhrase::ANSWER_TYPE);
     $this->backUrl = NetCommonsUrl::backToIndexUrl('default_setting_action');
 }
 /**
  * 埋め込みタグ{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);
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     if ($this->request->isPut() || $this->request->isPost()) {
         if ($this->BbsFrameSetting->saveBbsFrameSetting($this->data)) {
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
         $this->NetCommons->handleValidationError($this->BbsFrameSetting->validationErrors);
     } else {
         $this->request->data = $this->BbsFrameSetting->getBbsFrameSetting(true);
         $this->request->data['Frame'] = Current::read('Frame');
     }
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     if ($this->request->isPost()) {
         if ($this->FaqQuestionOrder->saveFaqQuestionOrders($this->data)) {
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
         $this->NetCommons->handleValidationError($this->FaqQuestionOrder->validationErrors);
     } else {
         $this->Paginator->settings = array('FaqQuestion' => array('recursive' => 0, 'order' => array('FaqQuestionOrder.weight' => 'asc'), 'conditions' => $this->FaqQuestion->getWorkflowConditions(array('FaqQuestion.faq_id' => $this->viewVars['faq']['id'])), 'limit' => PHP_INT_MAX));
         $this->request->data['FaqQuestions'] = $this->Paginator->paginate('FaqQuestion');
         $this->request->data['Frame'] = Current::read('Frame');
         $this->request->data['Faq'] = $this->viewVars['faq'];
     }
 }
 /**
  * edit action
  *
  * @return void
  */
 public function edit()
 {
     if ($this->request->is(array('post', 'put'))) {
         $data = $this->request->data;
         if ($this->CircularNoticeFrameSetting->saveCircularNoticeFrameSetting($data)) {
             $this->redirect(NetCommonsUrl::backToPageUrl(true));
             return;
         }
         $this->NetCommons->handleValidationError($this->CircularNoticeFrameSetting->validationErrors);
     } else {
         $this->request->data = $this->CircularNoticeFrameSetting->getCircularNoticeFrameSetting(true);
         $this->request->data['Frame'] = Current::read('Frame');
     }
     $this->set('circularNoticeFrameSetting', $this->request->data['CircularNoticeFrameSetting']);
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     if ($this->request->isPut() || $this->request->isPost()) {
         //登録(PUT)処理
         $data = $this->data;
         $data['AccessCounterFrameSetting']['display_type'] = (int) $data['AccessCounterFrameSetting']['display_type'];
         if ($this->AccessCounterFrameSetting->saveAccessCounterFrameSetting($data)) {
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
         $this->NetCommons->handleValidationError($this->AccessCounterFrameSetting->validationErrors);
     } else {
         //初期データセット
         $this->request->data = $this->AccessCounterFrameSetting->getAccessCounterFrameSetting(true);
         $this->request->data['Frame'] = Current::read('Frame');
     }
 }
Exemple #14
0
 /**
  * ブロック削除の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;
 }
 /**
  * 権限設定 編集
  *
  * @return CakeResponse
  */
 public function edit()
 {
     $permissions = $this->Workflow->getBlockRolePermissions(array('content_creatable', 'content_publishable', 'content_comment_creatable', 'content_comment_publishable'));
     $this->set('roles', $permissions['Roles']);
     if ($this->request->is('post')) {
         if ($this->VideoSetting->saveVideoSetting($this->request->data)) {
             $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
             return;
         }
         $this->NetCommons->handleValidationError($this->VideoSetting->validationErrors);
         $this->request->data['BlockRolePermission'] = Hash::merge($permissions['BlockRolePermissions'], $this->request->data['BlockRolePermission']);
     } else {
         $videoSetting = $this->VideoSetting->getVideoSetting();
         $this->request->data = Hash::merge($this->request->data, $videoSetting);
         $this->request->data['BlockRolePermission'] = $permissions['BlockRolePermissions'];
         $this->request->data['Frame'] = Current::read('Frame');
     }
 }
 /**
  * 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']);
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     $this->RoomsForm->setRoomsForCheckbox();
     $this->PluginsForm->setPluginsRoomForCheckbox($this, $this->PluginsForm->findOptions);
     $options = Hash::extract($this->viewVars['pluginsRoom'], '{n}.Plugin.key');
     $blocks = $this->TopicFrameSetting->getBlocks($options, array_keys($this->viewVars['rooms']));
     $this->set('selectBlocks', $blocks);
     if ($this->request->is('put') || $this->request->is('post')) {
         //登録処理
         $data = $this->data;
         $data['TopicFramesRoom']['room_id'] = Hash::get($data, 'TopicFramesRoom.room_id');
         if (!$data['TopicFramesRoom']['room_id']) {
             $data['TopicFramesRoom']['room_id'] = array();
         }
         $data['TopicFramesPlugin']['plugin_key'] = Hash::get($data, 'TopicFramesPlugin.plugin_key');
         if (!$data['TopicFramesPlugin']['plugin_key']) {
             $data['TopicFramesPlugin']['plugin_key'] = array();
         }
         $data['TopicFramesBlock'] = Hash::get($data, 'TopicFramesBlock');
         if ($this->TopicFrameSetting->saveTopicFrameSetting($data)) {
             $this->redirect(NetCommonsUrl::backToPageUrl(true));
             return;
         }
         $this->NetCommons->handleValidationError($this->TopicFrameSetting->validationErrors);
     } else {
         //新着設定を取得
         $this->request->data = $this->TopicFrameSetting->getTopicFrameSetting();
         $this->request->data['Frame'] = Current::read('Frame');
         //表示するルームを取得
         $result = $this->TopicFramesRoom->find('list', array('recursive' => -1, 'fields' => array('id', 'room_id'), 'conditions' => ['frame_key' => Current::read('Frame.key')]));
         $this->request->data['TopicFramesRoom']['room_id'] = array_unique(array_values($result));
         //表示するプラグインを取得
         $result = $this->TopicFramesPlugin->find('list', array('recursive' => -1, 'fields' => array('id', 'plugin_key'), 'conditions' => ['frame_key' => Current::read('Frame.key')]));
         $this->request->data['TopicFramesPlugin']['plugin_key'] = array_unique(array_values($result));
         //表示するブロックを取得
         $result = $this->TopicFramesBlock->find('first', array('recursive' => -1, 'fields' => array('id', 'block_key', 'plugin_key', 'room_id'), 'conditions' => ['frame_key' => Current::read('Frame.key')]));
         $this->request->data['TopicFramesBlock'] = Hash::get($result, 'TopicFramesBlock', array());
         if (!$this->request->data['TopicFramesBlock']) {
             $block = Hash::extract($blocks, '{s}.{s}');
             $this->request->data['TopicFramesBlock'] = array('block_key' => Hash::get($block, '0.key'), 'plugin_key' => Hash::get($block, '0.plugin_key'), 'room_id' => Hash::get($block, '0.room_id'));
         }
     }
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     if (!($cabinet = $this->Cabinet->getCabinet())) {
         return $this->setAction('throwBadRequest');
     }
     $permissions = $this->Workflow->getBlockRolePermissions(array('content_creatable', 'content_publishable', 'content_comment_creatable', 'content_comment_publishable'));
     $this->set('roles', $permissions['Roles']);
     if ($this->request->is('post')) {
         if ($this->CabinetSetting->saveCabinetSetting($this->request->data)) {
             return $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
         }
         $this->NetCommons->handleValidationError($this->CabinetSetting->validationErrors);
         $this->request->data['BlockRolePermission'] = Hash::merge($permissions['BlockRolePermissions'], $this->request->data['BlockRolePermission']);
     } else {
         $this->request->data['CabinetSetting'] = $cabinet['CabinetSetting'];
         $this->request->data['Block'] = $cabinet['Block'];
         $this->request->data['BlockRolePermission'] = $permissions['BlockRolePermissions'];
         $this->request->data['Frame'] = Current::read('Frame');
     }
 }
 /**
  * edit method
  *
  * @return void
  */
 public function edit()
 {
     if ($this->request->isPost() || $this->request->isPut()) {
         $data = $this->data;
         $data['Announcement']['status'] = $this->Workflow->parseStatus();
         unset($data['Announcement']['id']);
         if ($this->Announcement->saveAnnouncement($data)) {
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
         $this->NetCommons->handleValidationError($this->Announcement->validationErrors);
     } else {
         //初期データセット
         if (!($this->request->data = $this->Announcement->getAnnouncement())) {
             $this->request->data = $this->Announcement->createAll();
         }
         $this->request->data['Frame'] = Current::read('Frame');
     }
     $comments = $this->Announcement->getCommentsByContentKey($this->request->data['Announcement']['key']);
     $this->set('comments', $comments);
 }
 /**
  * edit action
  *
  * @return void
  */
 public function edit()
 {
     if (!$this->NetCommonsFrame->validateFrameId()) {
         $this->throwBadRequest();
         return false;
     }
     $data = array();
     if ($this->request->isPost()) {
         $data = $this->data;
         $this->RssReaderFrameSetting->saveRssReaderFrameSetting($this->data);
         if ($this->NetCommons->handleValidationError($this->RssReaderFrameSetting->validationErrors)) {
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
         unset($data['Frame']);
     }
     if (!($rssFrameSetting = $this->RssReaderFrameSetting->getRssReaderFrameSetting($this->viewVars['frameKey']))) {
         $rssFrameSetting = $this->RssReaderFrameSetting->create(['frame_key' => $this->viewVars['frameKey']]);
     }
     $results = $this->camelizeKeyRecursive(Hash::merge($rssFrameSetting, $data));
     $this->set($results);
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     CurrentFrame::setBlock($this->request->params['pass'][1]);
     if (!($faq = $this->Faq->getFaq())) {
         $this->throwBadRequest();
         return false;
     }
     $permissions = $this->Workflow->getBlockRolePermissions(array('content_creatable', 'content_publishable'));
     $this->set('roles', $permissions['Roles']);
     if ($this->request->isPost()) {
         if ($this->FaqSetting->saveFaqSetting($this->request->data)) {
             $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
             return;
         }
         $this->NetCommons->handleValidationError($this->FaqSetting->validationErrors);
     } else {
         $this->request->data['FaqSetting'] = $faq['FaqSetting'];
         $this->request->data['Block'] = $faq['Block'];
         $this->request->data['BlockRolePermission'] = $permissions['BlockRolePermissions'];
         $this->request->data['Frame'] = Current::read('Frame');
     }
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     // この処理に来る前に必ずSettingレコードは作成される(beforeFilterで
     // (作成できてないときはExceptionエラーが発生して、ここにはこれない
     $registrationSetting = $this->RegistrationSetting->getSetting();
     $permissions = $this->Workflow->getBlockRolePermissions(array('content_creatable', 'content_publishable', 'content_comment_creatable', 'content_comment_publishable'));
     $this->set('roles', $permissions['Roles']);
     if ($this->request->is('post')) {
         if ($this->RegistrationSetting->saveRegistrationSetting($this->request->data)) {
             $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success'));
             $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
             return;
         }
         $this->NetCommons->handleValidationError($this->RegistrationSetting->validationErrors);
         $this->request->data['BlockRolePermission'] = Hash::merge($permissions['BlockRolePermissions'], $this->request->data['BlockRolePermission']);
         return;
     }
     $this->request->data['RegistrationSetting'] = $registrationSetting['RegistrationSetting'];
     $this->request->data['Block'] = $registrationSetting['Block'];
     $this->request->data['BlockRolePermission'] = $permissions['BlockRolePermissions'];
     $this->request->data['Frame'] = Current::read('Frame');
 }
 /**
  * edit action
  *
  * @return void
  */
 public function edit()
 {
     $frameId = Current::read('Frame.id');
     if (!$frameId || !($setting = $this->CircularNoticeSetting->getCircularNoticeSetting($frameId))) {
         $this->setAction('throwBadRequest');
         return false;
     }
     $permissions = $this->Workflow->getBlockRolePermissions(array('content_creatable', 'content_publishable'));
     $this->set('roles', $permissions['Roles']);
     if ($this->request->is(array('post', 'put'))) {
         $data = $this->data;
         if ($this->CircularNoticeSetting->saveCircularNoticeSetting($data)) {
             $this->redirect(NetCommonsUrl::backToPageUrl(true));
             return;
         }
         $this->NetCommons->handleValidationError($this->CircularNoticeSetting->validationErrors);
         $this->request->data['CircularNoticeRolePermission'] = Hash::merge($permissions['BlockRolePermissions'], $this->request->data['BlockRolePermission']);
     } else {
         $this->request->data['CircularNoticeSetting'] = $setting['CircularNoticeSetting'];
         $this->request->data['BlockRolePermission'] = $permissions['BlockRolePermissions'];
         $this->request->data['Frame'] = Current::read('Frame');
     }
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     //フレームなしの場合、
     if (!Current::read('Frame.id')) {
         $this->autoRender = false;
         return;
     }
     if ($this->request->is(array('post', 'put'))) {
         //不要パラメータ除去
         $data = $this->data;
         unset($data['save']);
         if ($this->MenuFrameSetting->saveMenuFrameSetting($data)) {
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
         $this->NetCommons->handleValidationError($this->MenuFrameSetting->validationErrors);
         $this->request->data = $data;
     } else {
         $this->request->data = Hash::merge($this->request->data, $this->MenuFrameSetting->find('first', array('recursive' => -1, 'conditions' => array('frame_key' => Current::read('Frame.key')))));
         $this->request->data['Frame'] = Current::read('Frame');
         $this->request->data['Menus'] = $this->MenuFramesPage->getMenuData();
     }
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     if (!$this->NetCommonsFrame->validateFrameId()) {
         $this->throwBadRequest();
         return false;
     }
     if (!($linkFrameSetting = $this->LinkFrameSetting->getLinkFrameSetting($this->viewVars['frameKey']))) {
         $linkFrameSetting = $this->LinkFrameSetting->create(array('id' => null, 'display_type' => LinkFrameSetting::TYPE_DROPDOWN, 'frame_key' => $this->viewVars['frameKey'], 'category_separator_line' => null, 'list_style' => null));
     }
     $linkFrameSetting = $this->camelizeKeyRecursive($linkFrameSetting);
     $data = array();
     if ($this->request->isPost()) {
         $data = $this->data;
         $this->LinkFrameSetting->saveLinkFrameSetting($data);
         if ($this->NetCommons->handleValidationError($this->LinkFrameSetting->validationErrors)) {
             $this->redirect(NetCommonsUrl::backToPageUrl());
             return;
         }
     }
     $data = Hash::merge($linkFrameSetting, $data);
     $results = $this->camelizeKeyRecursive($data);
     $this->set($results);
 }
 /**
  * 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'))));
 }
Exemple #27
0
 /**
  * link
  *
  * @return void
  */
 public function link()
 {
     $linkKey = null;
     if (isset($this->data['Link']['key'])) {
         $linkKey = $this->data['Link']['key'];
     }
     $this->set('linkKey', $linkKey);
     //データ取得
     if (!$this->__initLink()) {
         return;
     }
     if (!$this->request->isPost()) {
         $this->throwBadRequest();
         return;
     }
     if (!$this->Link->updateCount($this->data['Link']['id'], $this->viewVars['blockId'])) {
         $this->throwBadRequest();
         return;
     }
     $this->redirect(NetCommonsUrl::backToPageUrl());
 }
 /**
  * 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');
             }
         }
     }
 }
 /**
  * ブロック設定 削除
  *
  * @return CakeResponse
  */
 public function delete()
 {
     if ($this->request->is('delete')) {
         if ($this->VideoSetting->deleteVideoSetting($this->data)) {
             return $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
         }
     }
     $this->throwBadRequest();
 }
 /**
  * delete
  *
  * @return void
  */
 public function delete()
 {
     if ($this->request->isDelete()) {
         if ($this->Bbs->deleteBbs($this->data)) {
             $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
         }
     }
     $this->setAction('throwBadRequest');
 }