Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 /**
  * ワークフローのボタン表示
  *
  * @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;
 }
Пример #3
0
 /**
  * メール設定 登録,編集
  *
  * @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');
     }
 }
 /**
  * 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');
 }
 /**
  * 権限設定 編集
  *
  * @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');
     }
 }
 /**
  * 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
  *
  * @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');
 }
 /**
  * フォルダ選択画面
  *
  * @return void
  */
 public function select_folder()
 {
     // 移動するファイル・フォルダを取得
     $key = isset($this->request->params['key']) ? $this->request->params['key'] : null;
     $conditions = ['CabinetFile.key' => $key, 'CabinetFile.cabinet_id' => $this->_cabinet['Cabinet']['id']];
     $conditions = $this->CabinetFile->getWorkflowConditions($conditions);
     $cabinetFile = $this->CabinetFile->find('first', ['conditions' => $conditions]);
     if ($cabinetFile) {
         $currentTreeId = $cabinetFile['CabinetFileTree']['parent_id'];
     } else {
         // 新規フォルダ作成時はkeyが拾えないのでparent_idで現在位置を特定
         $currentTreeId = Hash::get($this->request->named, 'parent_id', null);
     }
     $this->set('currentTreeId', $currentTreeId);
     //レイアウトの設定
     $this->viewClass = 'View';
     $this->layout = 'NetCommons.modal';
     // 全フォルダツリーを得る
     $conditions = ['is_folder' => 1, 'cabinet_key' => $this->_cabinet['Cabinet']['key']];
     // 移動するのがフォルダだったら、下位フォルダを除外する
     if (isset($cabinetFile) && Hash::get($cabinetFile, 'CabinetFile.is_folder')) {
         $conditions['NOT'] = array('AND' => array('CabinetFileTree.lft >=' => $cabinetFile['CabinetFileTree']['lft'], 'CabinetFileTree.rght <=' => $cabinetFile['CabinetFileTree']['rght']));
     }
     $folders = $this->CabinetFileTree->find('threaded', ['conditions' => $conditions, 'recursive' => 0, 'order' => 'CabinetFile.filename ASC']);
     $this->set('folders', $folders);
     // カレントフォルダのツリーパスを得る
     if ($currentTreeId > 0) {
         $folderPath = $this->CabinetFileTree->getPath($currentTreeId, null, 0);
         $this->set('folderPath', $folderPath);
         $nestCount = count($folderPath);
         if ($nestCount > 1) {
             // 親フォルダあり
             $url = NetCommonsUrl::actionUrl(['key' => $folderPath[$nestCount - 2]['CabinetFile']['key'], 'block_id' => Current::read('Block.id'), 'frame_id' => Current::read('Frame.id')]);
         } else {
             // 親はキャビネット
             $url = NetCommonsUrl::backToIndexUrl();
         }
         $this->set('parentUrl', $url);
     } else {
         // ルート
         $this->set('folderPath', array());
         $this->set('parentUrl', false);
     }
 }
Пример #10
0
 /**
  * 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');
 }
Пример #11
0
 /**
  * ブロック設定 削除
  *
  * @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->is('delete')) {
         return $this->throwBadRequest();
     }
     //削除できるかチェック
     $user = $this->User->getUser($this->data['User']['id']);
     if (!$this->User->canUserDelete($user)) {
         return $this->throwBadRequest();
     }
     $this->User->deleteUser($user);
     $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully deleted.'), array('class' => 'success'));
     $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
 }
 /**
  * delete
  *
  * @throws BadRequestException
  * @return void
  */
 public function delete()
 {
     if (!$this->request->isDelete()) {
         $this->throwBadRequest();
         return;
     }
     $this->Announcement->deleteAnnouncement($this->data);
     $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
 }
 /**
  * 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);
     }
 }
Пример #15
0
 /**
  * delete
  *
  * @return void
  */
 public function delete()
 {
     if ($this->request->isDelete()) {
         if ($this->Faq->deleteFaq($this->data)) {
             $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
             return;
         }
     }
     $this->throwBadRequest();
 }
 /**
  * __setupViewParameters method
  *
  * @param array $registration 登録フォームデータ
  * @param string $backUrl BACKボタン押下時の戻るパス
  * @return void
  */
 private function __setupViewParameters($registration, $backUrl)
 {
     //$isPublished = $this->Registration->hasPublished($registration);
     // エラーメッセージはページ、項目、選択肢要素のそれぞれの場所に割り当てる
     $this->NetCommons->handleValidationError($this->Registration->validationErrors);
     $flatError = Hash::flatten($this->Registration->validationErrors);
     $newFlatError = array();
     foreach ($flatError as $key => $val) {
         if (preg_match('/^(.*)\\.(.*)\\.(.*)$/', $key, $matches)) {
             $newFlatError[$matches[1] . '.error_messages.' . $matches[2] . '.' . $matches[3]] = $val;
         }
     }
     $registration = Hash::merge($registration, Hash::expand($newFlatError));
     $registration = $this->NetCommonsTime->toUserDatetimeArray($registration, array('Registration.answer_start_period', 'Registration.answer_end_period', 'Registration.total_show_start_period'));
     $this->set('postUrl', array('url' => $this->_getActionUrl($this->action)));
     if ($this->layout == 'NetCommons.setting') {
         $this->set('cancelUrl', array('url' => NetCommonsUrl::backToIndexUrl('default_setting_action')));
     } else {
         $this->set('cancelUrl', array('url' => NetCommonsUrl::backToPageUrl()));
     }
     $this->set('deleteUrl', array('url' => $this->_getActionUrl('delete')));
     $this->set('questionTypeOptions', $this->Registrations->getQuestionTypeOptionsWithLabel());
     $this->set('newPageLabel', __d('registrations', 'page'));
     $this->set('newQuestionLabel', __d('registrations', 'New Question'));
     $this->set('newChoiceLabel', __d('registrations', 'new choice'));
     $this->set('newChoiceColumnLabel', __d('registrations', 'new column choice'));
     $this->set('newChoiceOtherLabel', __d('registrations', 'other choice'));
     // 都道府県データ
     $prefectures = $this->_getPrefectures();
     $this->set('prefectures', $prefectures);
     //$this->set('isPublished', $isPublished);
     $this->set('isPublished', false);
     $this->request->data = $registration;
     $this->request->data['Frame'] = Current::read('Frame');
     $this->request->data['Block'] = Current::read('Block');
     // メール通知設定
     $conditions = ['plugin_key' => 'registrations', 'block_key' => Current::read('Block.key')];
     $mailSetting = $this->MailSetting->find('first', ['conditions' => $conditions]);
     $this->set('mailSetting', $mailSetting);
 }