本文整理汇总了PHP中Current::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Current::read方法的具体用法?PHP Current::read怎么用?PHP Current::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Current
的用法示例。
在下文中一共展示了Current::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRegistrationForAnswerCsv
/**
* 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;
}
示例2: dropDownToggle
/**
* 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));
}
示例3: canUserEdit
/**
* ユーザの編集出来るかどうか
*
* @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;
}
示例4: beforeRender
/**
* 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']);
}
}
示例5: edit
/**
* 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']);
}
}
示例6: wysiwygScript
/**
* 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');
}
示例7: sendMail
/**
* 新規登録のメール処理
*
* @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;
}
示例8: readToArticle
/**
* 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;
}
示例9: beforeValidate
/**
* 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);
}
示例10: beforeRender
/**
* 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;
}
示例11: edit
/**
* 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;
}
}
}
示例12: createMailSettingFixedPhrase
/**
* メール設定-定型文 データ新規作成
*
* @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;
}
示例13: getSetting
/**
* 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());
}
示例14: setUserRoleAdminOnBasic
/**
* システム管理者以外は、選択肢からシステム管理者を除外
*
* @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 . ']');
}
}
示例15: __prepare
/**
* 前準備
*
* @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);
}