/**
  * getRegistrationForAnswerCsv
  *
  * @param int $registrationKey registration key
  * @return array registration data
  */
 public function getRegistrationForAnswerCsv($registrationKey)
 {
     // 指定の登録フォームデータを取得
     // CSVの取得は公開してちゃんとした登録を得ている登録フォームに限定である
     $registration = $this->Registration->find('first', array('conditions' => array('Registration.block_id' => Current::read('Block.id'), 'Registration.key' => $registrationKey, 'Registration.is_active' => true, 'Registration.language_id' => Current::read('Language.id')), 'recursive' => -1));
     return $registration;
 }
 /**
  * Output categories drop down toggle
  *
  * #### Options
  *
  *   - `empty`: String is empty label.
  *  - `header`: String is header label.
  *  - `divider`: True is divider.
  *   - `displayMenu`: True is display menu. False is <li> tag only.
  *   - `displayEmpty`: True is empty display. False is not display.
  *
  * @param array $options Array of options and HTML arguments.
  * @return string HTML tags
  */
 public function dropDownToggle($options = array())
 {
     //カレントCategoryId
     if (isset($this->_View->params['named']['category_id'])) {
         $currentCategoryId = $this->_View->params['named']['category_id'];
     } else {
         $currentCategoryId = '0';
     }
     //URLのセット
     if (!isset($options['url'])) {
         $options['url'] = array('plugin' => $this->_View->params['plugin'], 'controller' => $this->_View->params['controller'], 'action' => $this->_View->params['action'], Current::read('Frame.id'));
     }
     //オプションのセット
     if (isset($options['empty']) && $options['empty']) {
         if (is_string($options['empty'])) {
             $name = $options['empty'];
             //呼び出しもとでhtmlspecialcharsする
         } else {
             $name = __d('categories', 'Select Category');
         }
         $options['categories'] = array('0' => array('id' => null, 'name' => $name));
     } else {
         $options['categories'] = array();
     }
     $options['categories'] = Hash::merge($options['categories'], Hash::combine($this->_View->viewVars['categories'], '{n}.Category.id', '{n}.Category'));
     if (isset($options['header']) && $options['header']) {
         if (!is_string($options['header'])) {
             $options['header'] = __d('categories', 'Category');
         }
     }
     return $this->_View->element('Categories.dropdown_toggle_category', array('currentCategoryId' => $currentCategoryId, 'options' => $options));
 }
 /**
  * ユーザの編集出来るかどうか
  *
  * @param Model $model ビヘイビア呼び出し元モデル
  * @param array $user ユーザデータ
  * @return bool
  */
 public function canUserEdit(Model $model, $user)
 {
     if (!$user || Current::read('User.role_key') !== UserRole::USER_ROLE_KEY_SYSTEM_ADMINISTRATOR && $user['User']['role_key'] === UserRole::USER_ROLE_KEY_SYSTEM_ADMINISTRATOR) {
         return false;
     }
     return true;
 }
 /**
  * beforeRender
  *
  * @param Controller $controller Controller
  * @return void
  * @throws NotFoundException
  */
 public function beforeRender(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested']) || $controller->request->is('ajax')) {
         return;
     }
     //Pluginデータ取得
     $controller->Plugin = ClassRegistry::init('PluginManager.Plugin', true);
     $controller->PluginsRole = ClassRegistry::init('PluginManager.PluginsRole', true);
     $controlPanel = $controller->Plugin->create(array('key' => 'control_panel', 'name' => __d('control_panel', 'Control Panel Top'), 'default_action' => 'control_panel/index'));
     $this->plugins = $controller->PluginsRole->getPlugins(array(Plugin::PLUGIN_TYPE_FOR_SITE_MANAGER, Plugin::PLUGIN_TYPE_FOR_SYSTEM_MANGER), Current::read('User.role_key'), 'INNER');
     array_unshift($this->plugins, $controlPanel);
     //Layoutのセット
     $controller->layout = 'ControlPanel.default';
     //cancelUrlをセット
     $controller->set('cancelUrl', '/');
     $controller->set('isControlPanel', true);
     $controller->set('hasControlPanel', true);
     //ページHelperにセット
     $controller->set('pluginsMenu', $this->plugins);
     if (isset($this->settings['plugin'])) {
         $plugin = $this->settings['plugin'];
     } else {
         $plugin = $controller->params['plugin'];
     }
     $plugin = Hash::extract($this->plugins, '{n}.Plugin[key=' . $plugin . ']');
     if (isset($plugin[0]['name'])) {
         if (!isset($controller->viewVars['title'])) {
             $controller->set('title', $plugin[0]['name']);
         }
         $controller->set('pageTitle', $plugin[0]['name']);
     }
 }
 /**
  * edit
  *
  * @param string $roleKey user_roles.key
  * @return void
  */
 public function edit($roleKey = null)
 {
     //既存データ取得
     $userRole = $this->UserRole->find('first', array('recursive' => -1, 'conditions' => array('key' => $roleKey, 'language_id' => Current::read('Language.id'))));
     if (!$userRole) {
         return $this->throwBadRequest();
     }
     if ($this->request->is('put')) {
         //不要パラメータ除去
         unset($this->request->data['save']);
         //登録処理
         if ($this->UserRole->saveUserRolePlugins($this->request->data)) {
             //正常の場合
             $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success'));
             return $this->redirect('/user_roles/user_roles/index');
         } else {
             $this->NetCommons->handleValidationError($this->UserRoleSetting->validationErrors);
             $this->redirect('/user_roles/user_roles_plugins/edit/' . h($roleKey));
         }
     } else {
         $this->request->data = $this->UserRoleSetting->getUserRoleSetting(Plugin::PLUGIN_TYPE_FOR_SITE_MANAGER, $roleKey);
         $this->request->data = Hash::merge($userRole, $this->request->data);
         $this->set('roleKey', $roleKey);
         $this->set('subtitle', $this->request->data['UserRole']['name']);
     }
 }
 /**
  * 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');
 }
 /**
  * 新規登録のメール処理
  *
  * @param int $confirmation 完了確認ステータス
  * @param array $user ユーザ情報
  * @return bool
  */
 public function sendMail($confirmation, $user)
 {
     if ($confirmation === AutoUserRegist::CONFIRMATION_USER_OWN) {
         $data['subject'] = SiteSettingUtil::read('AutoRegist.approval_mail_subject');
         $data['body'] = SiteSettingUtil::read('AutoRegist.approval_mail_body');
         $data['email'] = array($user['User']['email']);
         $data['url'] = Router::url('/auth/auto_user_regist/approval', true) . $user['User']['activate_parameter'];
     } elseif ($confirmation === AutoUserRegist::CONFIRMATION_ADMIN_APPROVAL) {
         $data['subject'] = SiteSettingUtil::read('AutoRegist.acceptance_mail_subject');
         $data['body'] = SiteSettingUtil::read('AutoRegist.acceptance_mail_body');
         $data['email'] = $this->__getMailAddressForAdmin();
         $data['url'] = Router::url('/auth/auto_user_regist/acceptance', true) . $user['User']['activate_parameter'];
     } else {
         return true;
     }
     foreach ($data['email'] as $email) {
         $this->mail->mailAssignTag->setFixedPhraseSubject($data['subject']);
         $this->mail->mailAssignTag->setFixedPhraseBody($data['body']);
         $this->mail->mailAssignTag->assignTags(array('X-URL' => $data['url']));
         $this->mail->mailAssignTag->initPlugin(Current::read('Language.id'));
         $this->mail->initPlugin(Current::read('Language.id'));
         $this->mail->to($email);
         $this->mail->setFrom(Current::read('Language.id'));
         $this->mail->sendMailDirect();
     }
     return true;
 }
 /**
  * Save BbsArticlesUser
  *
  * @param object $model instance of model
  * @param array $bbsArticleKey received bbs_article_key
  * @return mixed On success Model::$data if its not empty or true, false on failure
  * @throws InternalErrorException
  */
 public function readToArticle(Model $model, $bbsArticleKey)
 {
     $model->loadModels(['BbsArticlesUser' => 'Bbses.BbsArticlesUser']);
     //既読チェック
     if (!Current::read('User.id')) {
         return true;
     }
     $count = $model->BbsArticlesUser->find('count', array('recursive' => -1, 'conditions' => array('bbs_article_key' => $bbsArticleKey, 'user_id' => Current::read('User.id'))));
     if ($count > 0) {
         return true;
     }
     //トランザクションBegin
     $model->BbsArticlesUser->begin();
     //バリデーション
     $data = $model->BbsArticlesUser->create(array('bbs_article_key' => $bbsArticleKey, 'user_id' => Current::read('User.id')));
     $model->BbsArticlesUser->set($data);
     if (!$model->BbsArticlesUser->validates()) {
         $model->BbsArticlesUser->rollback();
         return false;
     }
     try {
         if (!$model->BbsArticlesUser->save(null, false)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
         //トランザクションCommit
         $model->BbsArticlesUser->commit();
     } catch (Exception $ex) {
         //トランザクションRollback
         $model->BbsArticlesUser->rollback($ex);
     }
     return true;
 }
Exemple #9
0
 /**
  * beforeValidate is called before a model is validated, you can use this callback to
  * add behavior validation rules into a models validate array. Returning false
  * will allow you to make the validation fail.
  *
  * @param Model $model Model using this behavior
  * @param array $options Options passed from Model::save().
  * @return mixed False or null will abort the operation. Any other result will continue.
  * @see Model::save()
  */
 public function beforeValidate(Model $model, $options = array())
 {
     //ページデータをセット
     $referencePageId = $model->getReferencePageId($model->data);
     $fields = array('room_id', 'permalink');
     $targetPage = $model->findById($referencePageId, $fields);
     if (empty($targetPage)) {
         return false;
     }
     $model->data['Page']['room_id'] = Current::read('Room.id');
     $slug = $model->data['Page']['slug'];
     if (!isset($slug)) {
         $slug = '';
     }
     $model->data['Page']['slug'] = $slug;
     $permalink = '';
     if (strlen($targetPage['Page']['permalink']) !== 0) {
         $permalink = $targetPage['Page']['permalink'] . '/';
     }
     $permalink .= $slug;
     $model->data['Page']['permalink'] = $permalink;
     $model->data['Page']['is_published'] = true;
     $model->data['Page']['is_container_fluid'] = false;
     return parent::beforeValidate($model, $options);
 }
 /**
  * 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;
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     //会員権限リストを取得する
     $userRoles = $this->UserRole->find('list', array('recursive' => -1, 'fields' => array('key', 'name'), 'conditions' => array('language_id' => Current::read('Language.id')), 'order' => array('id' => 'asc')));
     $this->set('userRoles', $userRoles);
     //リクエストセット
     if ($this->request->is('post')) {
         $data = $this->request->data['SiteSetting'];
         $value = $data['Security.deny_ip_move']['0']['value'];
         if (is_array($value)) {
             $data['Security.deny_ip_move']['0']['value'] = implode('|', $value);
         }
         //登録処理
         $this->request->data['SiteSetting'] = $data;
         $this->SiteSetting->userRoles = $userRoles;
         $this->SiteManager->saveData();
     } else {
         $this->request->data['SiteSetting'] = $this->SiteSetting->getSiteSettingForEdit(array('SiteSetting.key' => array('Upload.allow_extension', 'Security.deny_ip_move', 'Security.enable_bad_ips', 'Security.bad_ips', 'Security.enable_allow_system_plugin_ips', 'Security.allow_system_plugin_ips')));
         $ips = $this->request->data['SiteSetting']['Security.allow_system_plugin_ips']['0']['value'];
         if (!$this->SiteSetting->hasCurrentIp($ips)) {
             $ips = Hash::get($_SERVER, 'REMOTE_ADDR');
             $this->request->data['SiteSetting']['Security.allow_system_plugin_ips']['0']['value'] = $ips;
         }
     }
 }
 /**
  * メール設定-定型文 データ新規作成
  *
  * @param int $languageId 言語ID
  * @param string $typeKey メール定型文の種類
  * @param string $pluginKey プラグインキー
  * @return array メール設定データ配列
  */
 public function createMailSettingFixedPhrase($languageId = null, $typeKey = self::DEFAULT_TYPE, $pluginKey = null)
 {
     if ($languageId === null) {
         $languageId = Current::read('Language.id');
     }
     if ($pluginKey === null) {
         $pluginKey = Current::read('Plugin.key');
     }
     //デフォルトデータ取得
     $conditions = array('language_id' => $languageId, 'plugin_key' => $pluginKey, 'block_key' => null, 'type_key' => $typeKey);
     $mailFixedPhrase = $this->getMailSettingFixedPhrase($conditions);
     if ($mailFixedPhrase) {
         $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.id');
     } else {
         $mailFixedPhrase = $this->create();
         $mailFixedPhrase[$this->alias]['type_key'] = $typeKey;
     }
     //初期データセット
     $this->__noSetData('mail_fixed_phrase_subject', $mailFixedPhrase, $typeKey);
     $this->__noSetData('mail_fixed_phrase_body', $mailFixedPhrase, $typeKey);
     $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.created');
     $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.created_user');
     $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.modified');
     $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.modified_user');
     return $mailFixedPhrase;
 }
 /**
  * getSetting
  *
  * @return array RegistrationBlockSetting data
  */
 public function getSetting()
 {
     $blockSetting = $this->Block->find('all', array('recursive' => -1, 'conditions' => array('Block.id' => Current::read('Block.id'))));
     if (!$blockSetting) {
         return $blockSetting;
     }
     return Hash::merge($blockSetting[0], $this->getBlockSetting());
 }
 /**
  * システム管理者以外は、選択肢からシステム管理者を除外
  *
  * @return void
  */
 public function setUserRoleAdminOnBasic()
 {
     $controller = $this->controller;
     //システム管理者以外は、選択肢からシステム管理者を除外
     if (UserRole::USER_ROLE_KEY_SYSTEM_ADMINISTRATOR !== Current::read('User.role_key')) {
         $controller->viewVars['userAttributes'] = Hash::remove($controller->viewVars['userAttributes'], '{n}.{n}.{n}.UserAttributeChoice.{n}[key=' . UserRole::USER_ROLE_KEY_SYSTEM_ADMINISTRATOR . ']');
     }
 }
 /**
  * 前準備
  *
  * @return void
  */
 private function __prepare()
 {
     //権限リスト取得
     $userRoles = $this->UserRole->find('list', array('recursive' => 0, 'fields' => array('UserRole.key', 'UserRole.name'), 'conditions' => array('UserRole.type' => UserRole::ROLE_TYPE_USER, 'UserRole.language_id' => Current::read('Language.id'), 'UserRoleSetting.is_site_plugins' => false), 'order' => array('UserRole.id' => 'asc')));
     $this->set('userRoles', $userRoles);
     //会員項目リスト取得
     $userAttributes = $this->UserAttribute->find('all', array('recursive' => 0, 'fields' => array('UserAttribute.name', 'UserAttributeSetting.id', 'UserAttributeSetting.required', 'UserAttributeSetting.auto_regist_display', 'UserAttributeSetting.auto_regist_weight'), 'conditions' => array('UserAttribute.language_id' => Current::read('Language.id'), 'UserAttributeSetting.data_type_key NOT' => array('img', 'label'), 'OR' => array('UserAttributeSetting.user_attribute_key' => 'username', 'UserAttributeSetting.only_administrator_editable' => false)), 'order' => array('UserAttributeSetting.auto_regist_weight' => 'asc', 'UserAttributeSetting.row' => 'asc', 'UserAttributeSetting.col' => 'asc', 'UserAttributeSetting.weight' => 'asc')));
     $this->set('userAttributes', $userAttributes);
 }
 /**
  * VideoFrameSettingデータ取得
  *
  * @param bool $created If True, the results of the Model::find() to create it if it was null
  * @return array
  */
 public function getVideoFrameSetting($created)
 {
     $conditions = array('frame_key' => Current::read('Frame.key'));
     $videoFrameSetting = $this->find('first', array('recursive' => -1, 'conditions' => $conditions));
     if ($created && !$videoFrameSetting) {
         $videoFrameSetting = $this->create(array('frame_key' => Current::read('Frame.key')));
     }
     return $videoFrameSetting;
 }
 /**
  * Get access counter setting data
  *
  * @param bool $created If True, the results of the Model::find() to create it if it was null
  * @return array
  */
 public function getAccessCounterFrameSetting($created)
 {
     $conditions = array('frame_key' => Current::read('Frame.key'));
     $counterFrameSetting = $this->find('first', array('recursive' => -1, 'conditions' => $conditions));
     if ($created && !$counterFrameSetting) {
         $counterFrameSetting = $this->create(array('id' => null, 'display_type' => self::DISPLAY_TYPE_VALUE_0));
     }
     return $counterFrameSetting;
 }
 /**
  * キャビネットファイルのUnzip
  *
  * @param Model $model CabinetFile
  * @param array $cabinetFile CabinetFileデータ
  * @return bool
  * @throws InternalErrorException
  */
 public function unzip(Model $model, $cabinetFile)
 {
     $model->begin();
     try {
         // テンポラリフォルダにunzip
         $zipPath = WWW_ROOT . $cabinetFile['UploadFile']['file']['path'] . $cabinetFile['UploadFile']['file']['id'] . DS . $cabinetFile['UploadFile']['file']['real_file_name'];
         //debug($zipPath);
         App::uses('UnZip', 'Files.Utility');
         $unzip = new UnZip($zipPath);
         $tmpFolder = $unzip->extract();
         if ($tmpFolder === false) {
             throw new InternalErrorException('UnZip Failed.');
         }
         $parentCabinetFolder = $model->find('first', ['conditions' => ['CabinetFileTree.id' => $cabinetFile['CabinetFileTree']['parent_id']]]);
         // unzipされたファイル拡張子のバリデーション
         // unzipされたファイルのファイルサイズバリデーション
         $files = $tmpFolder->findRecursive();
         $unzipTotalSize = 0;
         foreach ($files as $file) {
             //
             $unzipTotalSize += filesize($file);
             // ここでは拡張子だけチェックする
             $extension = pathinfo($file, PATHINFO_EXTENSION);
             if (!$model->isAllowUploadFileExtension($extension)) {
                 // NG
                 $model->validationErrors = [__d('cabinets', 'Unzip failed. Contains does not allow file format.')];
                 return false;
             }
         }
         // ルームファイルサイズ制限
         $maxRoomDiskSize = Current::read('Space.room_disk_size');
         if ($maxRoomDiskSize !== null) {
             // nullだったらディスクサイズ制限なし。null以外ならディスクサイズ制限あり
             // 解凍後の合計
             // 現在のルームファイルサイズ
             $roomId = Current::read('Room.id');
             $roomFileSize = $model->getTotalSizeByRoomId($roomId);
             if ($roomFileSize + $unzipTotalSize > $maxRoomDiskSize) {
                 $model->validationErrors[] = __d('cabinets', 'Failed to expand. The total size exceeds the limit.<br />' . 'The total size limit is %s (%s left).', CakeNumber::toReadableSize($roomFileSize + $unzipTotalSize), CakeNumber::toReadableSize($maxRoomDiskSize));
                 return false;
             }
         }
         // 再帰ループで登録処理
         list($folders, $files) = $tmpFolder->read(true, false, true);
         foreach ($files as $file) {
             $this->_addFileFromPath($model, $parentCabinetFolder, $file);
         }
         foreach ($folders as $folder) {
             $this->_addFolderFromPath($model, $parentCabinetFolder, $folder);
         }
     } catch (Exception $e) {
         return $model->rollback($e);
     }
     $model->commit();
     return true;
 }
Exemple #19
0
 /**
  * Get menu data
  *
  * @return array Menu data
  */
 public function getMenuData()
 {
     $this->LanguagesPage = ClassRegistry::init('Pages.LanguagesPage');
     //Menuデータ取得
     $menus = $this->Page->find('all', array('recursive' => -1, 'fields' => array($this->Page->alias . '.*', $this->LanguagesPage->alias . '.*', $this->alias . '.*'), 'conditions' => array($this->Page->alias . '.room_id' => Current::read('Room.id')), 'joins' => array(array('table' => $this->LanguagesPage->table, 'alias' => $this->LanguagesPage->alias, 'type' => 'INNER', 'conditions' => array($this->Page->alias . '.id' . ' = ' . $this->LanguagesPage->alias . ' .page_id', $this->LanguagesPage->alias . '.language_id' => Current::read('Language.id'))), array('table' => $this->table, 'alias' => $this->alias, 'type' => 'LEFT', 'conditions' => array($this->Page->alias . '.id' . ' = ' . $this->alias . ' .page_id', $this->alias . '.frame_key' => Current::read('Frame.key')))), 'order' => array($this->Page->alias . '.lft' => 'asc')));
     if (!$menus) {
         return null;
     }
     return $menus;
 }
 /**
  * Get AccessCounter
  *
  * @param bool $created If True, the results of the Model::find() to create it if it was null
  * @return array AccessCounter
  */
 public function getAccessCounter($created)
 {
     $conditions[$this->alias . '.block_key'] = Current::read('Block.key');
     $conditions['Block.room_id'] = Current::read('Block.room_id');
     $accessCounter = $this->find('first', array('recursive' => 0, 'conditions' => $conditions));
     if ($created && !$accessCounter) {
         $accessCounter = $this->create();
     }
     return $accessCounter;
 }
 /**
  * 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)
 {
     $this->controller = $controller;
     $this->controller->Category = ClassRegistry::init('Categories.Category');
     $result = $this->controller->Category->getCategories(Current::read('Block.id'), Current::read('Block.room_id'));
     $this->controller->set('categories', $result);
     if (!in_array('Categories.Category', $this->controller->helpers)) {
         $this->controller->helpers[] = 'Categories.Category';
     }
 }
Exemple #22
0
 /**
  * getMaxWeight
  *
  * @param int $boxId boxes.id
  * @return int $weight link_orders.weight
  */
 public function getMaxWeight($boxId)
 {
     $order = $this->find('first', array('recursive' => -1, 'fields' => array('weight'), 'conditions' => array('language_id' => Current::read('Language.id'), 'box_id' => $boxId), 'order' => array('weight' => 'DESC')));
     if (isset($order[$this->alias]['weight'])) {
         $weight = (int) $order[$this->alias]['weight'];
     } else {
         $weight = 0;
     }
     return $weight;
 }
 /**
  * Called after the Controller::beforeFilter() and before the controller action
  *
  * @param Controller $controller Controller with components to startup
  * @return void
  * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::startup
  */
 public function startup(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested'])) {
         return;
     }
     $controller->helpers[] = 'UserRoles.UserRoleForm';
     $this->Role = ClassRegistry::init('Roles.Role');
     $defaultRoles = $this->Role->find('list', array('recursive' => -1, 'fields' => array('key', 'name'), 'conditions' => array('is_system' => true, 'language_id' => Current::read('Language.id'), 'type' => Role::ROLE_TYPE_ROOM), 'order' => array('id' => 'asc')));
     $controller->set('defaultRoleOptions', $defaultRoles);
 }
Exemple #24
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
  * Display the VisualCaptcha auto redirect screen
  *
  * @return void
  */
 public function view()
 {
     if ($this->request->is('post')) {
         if ($this->VisualCaptcha->check()) {
             // リダイレクト先はセッションクリアか
             return $this->redirect($this->VisualCaptcha->getReturnUrl());
         }
     }
     $this->request->data['Frame'] = Current::read('Frame');
     $this->request->data['Block'] = Current::read('Block');
 }
 /**
  * アクセスチェック
  *
  * @param Controller $controller Controller with components to startup
  * @return bool
  */
 public function accessCheck(Controller $controller)
 {
     if (!Current::read('User.id')) {
         return true;
     }
     if (!$controller->Session->check('roomAccesse.' . Current::read('RolesRoomsUser.id'))) {
         $RolesRoomsUser = ClassRegistry::init('Rooms.RolesRoomsUser');
         $RolesRoomsUser->saveAccessed(Current::read('RolesRoomsUser.id'));
         $controller->Session->write('roomAccesse.' . Current::read('RolesRoomsUser.id'), true);
     }
     return true;
 }
 /**
  * Get button for popup dialog
  *
  * @param array $options option for input
  * @return string button tag
  */
 public function popupButton($options)
 {
     $defaults = array('class' => 'btn btn-success', 'icon' => 'glyphicon-download', 'label' => '', 'popup-title' => __d('authorization_keys', 'Authorization key confirm dialog'), 'popup-label' => __d('authorization_keys', 'Authorization key'), 'popup-placeholder' => __d('authorization_keys', 'Please input authorization key'));
     $options = Hash::merge($defaults, $options);
     if (!empty($options['icon'])) {
         $icon = '<span class="glyphicon ' . $options['icon'] . '" ></span>';
     } else {
         $icon = '';
     }
     $html = '<a  authorization-keys-popup-link frame-id="' . Current::read('Frame.id') . '" ' . 'class="' . $options['class'] . '" ' . 'url="' . $options['url'] . '" ' . 'popup-title="' . $options['popup-title'] . '" ' . 'popup-label="' . $options['popup-label'] . '" ' . 'popup-placeholder="' . $options['popup-placeholder'] . '">' . $icon . $options['label'] . '</a>';
     return $html;
 }
 /**
  * index
  *
  * @return void
  */
 public function index()
 {
     $this->set('addActionController', 'access_counters');
     $this->set('editActionController', 'access_counters');
     $this->Paginator->settings = array('AccessCounter' => array('order' => array('Block.id' => 'desc'), 'conditions' => $this->AccessCounter->getBlockConditions()));
     $accessCounters = $this->Paginator->paginate('AccessCounter');
     if (!$accessCounters) {
         $this->view = 'Blocks.Blocks/not_found';
         return;
     }
     $this->set('accessCounters', $accessCounters);
     $this->request->data['Frame'] = Current::read('Frame');
 }
 /**
  * beforeFilter
  *
  * @return void
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     $results = $this->current;
     $this->set($results);
     // フレームが新規配置された場合はブロック設定/フレーム設定を初期化
     $blockId = Current::read('Block.id');
     if (!$blockId) {
         $frameId = Current::read('Frame.id');
         $this->CircularNoticeSetting->setCircularNoticeSetting($frameId);
         $this->CircularNoticeFrameSetting->setCircularNoticeFrameSetting($frameId);
     }
 }
 /**
  * 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');
     }
 }