本文整理汇总了PHP中Current::permission方法的典型用法代码示例。如果您正苦于以下问题:PHP Current::permission方法的具体用法?PHP Current::permission怎么用?PHP Current::permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Current
的用法示例。
在下文中一共展示了Current::permission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: 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;
}
示例3: index
/**
* index method
*
* @return void
*/
public function index()
{
// 作成権限なければ emptyRender
if (Current::permission('content_creatable')) {
// 追加ボタン表示
$this->view = 'Registrations/noRegistration';
} else {
$this->setAction('emptyRender');
}
}
示例4: getAnnouncement
/**
* Get announcement data
*
* @return array
*/
public function getAnnouncement()
{
if (Current::permission('content_editable')) {
$conditions[$this->alias . '.is_latest'] = true;
} else {
$conditions[$this->alias . '.is_active'] = true;
}
$announcement = $this->find('first', array('recursive' => 0, 'conditions' => $this->getBlockConditionById($conditions)));
return $announcement;
}
示例5: getEdumap
/**
* 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;
}
示例6: view
/**
* view method
*
* @return void
*/
public function view()
{
$announcement = $this->Announcement->getAnnouncement();
if (!$announcement) {
if (Current::permission('content_editable')) {
$announcement = $this->Announcement->createAll();
} else {
$this->setAction('emptyRender');
return;
}
}
$this->set('announcement', $announcement['Announcement']);
}
示例7: setup
/**
* SetUp Attachment behavior
*
* @param Model $model instance of model
* @param array $config array of configuration settings.
* @throws CakeException 先にOriginalKeyが登録されてないと例外
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function setup(Model $model, $config = array())
{
$this->__commonConfig = array('Attr' => array('AllowedFrameTargets' => array('_blank', '_self', '_parent', '_top'), 'AllowedRel' => array('alternate', 'author', 'bookmark', 'help', 'icon', 'license', 'next', 'nofollow', 'noreferrer', 'prefetch', 'prev', 'search', 'stylesheet', 'tag'), 'EnableID' => true), 'Cache' => array('SerializerPath' => $this->__cachePath), 'CSS' => array('AllowDuplicates' => true, 'AllowImportant' => true, 'AllowTricky' => true, 'DefinitionRev' => 1, 'Proprietary' => true, 'Trusted' => true), 'Core' => array('AllowHostnameUnderscore' => true, 'ConvertDocumentToFragment' => false, 'DisableExcludes' => true, 'Encoding' => 'UTF-8', 'MaintainLineNumbers' => false), 'HTML' => array('Doctype' => 'XHTML 1.0 Transitional', 'SafeIframe' => true, 'FlashAllowFullScreen' => true, 'TargetNoreferrer' => false, 'Trusted' => true), 'URI' => array('SafeIframeRegexp' => '%^(https?:)?//(www\\.youtube(?:-nocookie)?\\.com/)%'), 'Output' => array('FlashCompat' => true));
$this->__htmlNotLimitedConfig = array('Core' => array('HiddenElements' => array()), 'HTML' => array('Proprietary' => true, 'SafeEmbed' => true), 'URI' => array('SafeIframeRegexp' => '%^(https?:)?%'));
$this->__htmlLimitedConfig = array('CSS' => array('AllowedProperties' => array('color' => true, 'background-color' => true, 'margin' => true, 'text-align' => true, 'margin-left' => true, 'margin-right' => true, 'margin-top' => true, 'margin-bottom' => true, 'padding' => true, 'padding-left' => true, 'padding-right' => true, 'padding-top' => true, 'padding-bottom' => true, 'border' => true, 'border-left' => true, 'border-right' => true, 'border-top' => true, 'border-bottom' => true, 'border-width' => true, 'border-left-width' => true, 'border-right-width' => true, 'border-top-width' => true, 'border-bottom-width' => true, 'border-style' => true, 'border-left-style' => true, 'border-right-style' => true, 'border-top-style' => true, 'border-bottom-style' => true, 'border-color' => true, 'border-left-color' => true, 'border-right-color' => true, 'border-top-color' => true, 'border-bottom-color' => true, 'display' => true, 'float' => true, 'clear' => true, 'width' => true, 'height' => true, 'vertical-align' => true, 'overflow' => true, 'visibility' => true, 'background' => true, 'background-image' => true, 'background-repeat' => true, 'background-attachment' => true, 'background-position' => true, 'font' => true, 'font-style' => true, 'font-variant' => true, 'font-weight' => true, 'font-size' => true, 'line-height' => true, 'font-family' => true, 'text-indent' => true, 'text-decoration' => true, 'letter-spacing' => true, 'text-transform' => true, 'white-space' => true, 'table-layout' => true, 'border-spacing' => true, 'border-collapse' => true)), 'HTML' => array('Allowed' => 'div,' . 'span,' . 'h1[align],' . 'h2[align],' . 'h3[align],' . 'h4[align],' . 'h5[align],' . 'h6[align],' . 'br[clear],' . 'img[src|vspace|hspace|border|alt|height|width],' . 'ol[compact|start|type],' . 'ul[compact|type],' . 'li[type|value],' . 'a[href|target],' . 'hr[align|color|noshade|size|width],' . 'table[cellspacing|cellpadding|border|align],' . 'tbody[align|bgcolor|char|charoff|valign],' . 'tr[colspan|rowspan],' . 'td[colspan|rowspan|bgcolor|align|valign|height|width|nowrap|char|charoff' . '|abbr|axis|headers|scope],' . 'blockquote[cite],' . 'p[align],' . 'th[colspan|rowspan|bgcolor|align|valign|height|width|nowrap|char|charoff' . '|abbr|axis|headers|scope],' . 'strong,' . 'caption[align|valign],' . 'cite,' . 'code,' . 'kbd,' . 'pre[cols|width|wrap],' . 'q,' . 'small,' . 'sub,' . 'sup,' . 'object[archive|border|classid|code|codebase|codetype|data|declare|name' . '|standby|tabindex|type|usemap|align|width|height|hspace|vspace],' . 'param[name|value],' . 'em,' . 'i,' . 'iframe[src|height|width|hspace|vspace|marginheight|marginwidth' . '|allowtransparency|frameborder|border|bordercolor|allowfullscreen],' . 'col[span],' . 'colgroup[span],' . 'rb,' . 'ruby,' . 'rp,' . 'rt,' . 'wbr,' . 'embed[src|height|width|hspace|vspace|units|border|frameborder|play|loop' . '|quality|pluginspage|type|allowscriptaccess|allowfullscreen|flashvars],' . 'font[size|color|face],' . 'big,' . 'center,' . 'tt,' . 'u,' . 's,' . 'strike,' . 'noembed,' . '*[class|id|title|cite|background|style|align|dir|lang|language]'), 'URI' => array('AllowedSchemes' => array('http' => true, 'https' => true, 'mailto' => true, 'ftp' => true)));
if (Current::permission('html_not_limited')) {
// HTMLタグ使用権限がある場合
$purifyConfig = $this->__htmlNotLimitedConfig;
$customFilters = array();
} else {
$purifyConfig = $this->__htmlLimitedConfig;
$customFilters = array('HTMLPurifier_Filter_Comment');
}
$this->__settings = Hash::merge($this->__settings, array('fields' => $config['fields'], 'config' => Hash::merge($this->__commonConfig, $purifyConfig), 'customFilters' => $customFilters));
}
示例8: getBlockStatus
/**
* ブロックのステータスラベルを表示
*
* @param null|bool $isSetting 強制的にセッティングモード
* @return string HTML
*/
public function getBlockStatus($isSetting = null)
{
if (!Current::permission('block_editable')) {
return '';
}
if (!isset($isSetting)) {
$isSetting = Current::isSettingMode();
}
if (!$isSetting || !Current::read('Block.id')) {
return '';
}
$block = Current::read('Block', array());
$publicType = Hash::get($block, 'public_type');
if ($publicType === Block::TYPE_PUBLIC) {
return '';
}
$html = $this->__getBlockStatus();
return $html;
}
示例9: index
/**
* index method
*
* @throws NotFoundException
* @return void
*/
public function index()
{
if (Current::isSettingMode() && !Current::permission('page_editable')) {
$paths = func_get_args();
$path = implode('/', $paths);
$this->redirect('/' . $path);
return;
}
$paths = func_get_args();
$path = implode('/', $paths);
$page = $this->Page->getPageWithFrame($path);
if (empty($page)) {
throw new NotFoundException();
}
$this->set('page', $page);
$page['Container'] = Hash::combine($page['Container'], '{n}.type', '{n}');
$page['Box'] = Hash::combine($page['Box'], '{n}.id', '{n}', '{n}.container_id');
$page['Container'] = array(Container::TYPE_MAIN => $page['Container'][Container::TYPE_MAIN]);
$this->set('pageMainContainer', $page);
}
示例10: isPublishableEdit
/**
* 公開許可あり(承認者、承認OFF時の一般)の編集か ゲット
*
* @param Model $model モデル
* @param string $contentKey コンテンツキー
* @return bool
*/
public function isPublishableEdit(Model $model, $contentKey)
{
$workflowType = Hash::get($this->settings, $model->alias . '.workflowType');
// --- コンテンツコメント
if ($workflowType == MailQueueBehavior::MAIL_QUEUE_WORKFLOW_TYPE_COMMENT) {
if (!Current::permission('content_comment_publishable')) {
// 公開権限なし
return false;
}
// 登録日時
$created = Hash::get($model->data, $model->alias . '.created');
$isApproveAction = Hash::get($this->settings, $model->alias . '.isCommentApproveAction');
if (isset($created)) {
// 新規登録
return false;
}
if ($isApproveAction) {
// 承認時
return false;
}
return true;
}
// --- 通常
if (!Current::permission('content_publishable')) {
// 公開権限なし
return false;
}
//$contentKey = $this->__getContentKey($model);
$keyField = $this->settings[$model->alias]['keyField'];
$conditions = array($model->alias . '.' . $keyField => $contentKey);
$result = $model->find('all', array('recursive' => -1, 'conditions' => $conditions, 'order' => array($model->alias . '.modified DESC'), 'callbacks' => false));
if (count($result) <= 1) {
// 新規登録
return false;
}
// keyに対して2件以上記事がある = 編集
// 1つ前のコンテンツのステータス
$beforeStatus = $result[1][$model->alias]['status'];
$status = $result[0][$model->alias]['status'];
// 承認ONでもOFFでも、公開中の記事を編集して、公開だったら、公開の編集
// ・承認ONで、承認者が公開中の記事を編集しても、公開許可ありの編集で、メール送らない
// ・承認OFFで、公開中の記事を編集しても、公開許可ありの編集で、メール送らない
// ・・公開中の記事(1つ前の記事のstatus=1)
// ・・編集した記事が公開(status=1)
// ※承認ONで公開中の記事を編集して、編集した記事が公開なのは、承認者だけ
if ($beforeStatus == WorkflowComponent::STATUS_PUBLISHED && $status == WorkflowComponent::STATUS_PUBLISHED) {
// 公開の編集
return true;
}
// 公開以外の編集
return false;
}
示例11: delete
/**
* 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'))));
}
示例12: getConditions
/**
* UserIdと権限から参照可能なEntryを取得するCondition配列を返す
*
* @return array condition
*/
public function getConditions()
{
// contentReadable falseなら何も見えない
if (!Current::permission('content_readable')) {
$conditions = array('Video.id' => 0);
// ありえない条件でヒット0にしてる
return $conditions;
}
// デフォルト絞り込み条件
$conditions = array('Video.block_id' => Current::read('Block.id'));
$conditions = $this->getWorkflowConditions($conditions);
return $conditions;
}
示例13: canDeleteWorkflowContent
/**
* コンテンツの公開権限があるかどうかのチェック
* - 公開権限あり(content_publishable) and 編集権限あり(content_editable)
* - 自分自身のコンテンツ+一度も公開されていない
*
* @param Model $model Model using this behavior
* @param array $data コンテンツデータ
* @return bool true:削除可、false:削除不可
*/
public function canDeleteWorkflowContent(Model $model, $data)
{
if (Current::permission('content_publishable')) {
return true;
}
if (!$this->canEditWorkflowContent($model, $data)) {
return false;
}
if (!isset($data[$model->alias])) {
$data[$model->alias] = $data;
}
$conditions = array('is_active' => true);
if ($model->hasField('key') && isset($data[$model->alias]['key'])) {
$conditions['key'] = $data[$model->alias]['key'];
} else {
return false;
}
$count = $model->find('count', array('recursive' => -1, 'conditions' => $conditions));
return (int) $count === 0;
}
示例14: addLinkButton
/**
* Creates a `<a>` tag for add link. The type attribute defaults
*
* @param string $title The button's caption. Not automatically HTML encoded
* @param mixed $url Link url
* @param array $options Array of options and HTML attributes.
* @return string A HTML button tag.
*/
public function addLinkButton($title = '', $url = null, $options = array())
{
$output = '';
if (!Current::permission('content_creatable')) {
return $output;
}
//URLの設定
$defaultUrl = array('plugin' => $this->_View->request->params['plugin'], 'controller' => $this->_View->request->params['controller']);
if (!isset($url)) {
$url = array('action' => 'add', 'block_id' => Current::read('Block.id'), 'frame_id' => Current::read('Frame.id'));
if (isset($this->_View->viewVars['addActionController'])) {
$url['controller'] = $this->_View->viewVars['addActionController'];
}
}
$url = Hash::merge($defaultUrl, $url);
$output = $this->LinkButton->add($title, $url, $options);
return $output;
}
示例15: download
/**
* 動画のzipダウンロード
*
* @return CakeResponse
* @throws NotFoundException 表示できない記事へのアクセス
* @throws ForbiddenException アクセス権なし
* @see DownloadComponent::doDownload()
*/
public function download()
{
// ダウンロードリンク使わないなら、400
if (!$this->useDownloadLink) {
return $this->setAction('throwBadRequest');
}
// ブロック編集許可(編集長以上)持っていないなら403
if (!Current::permission('block_editable')) {
throw new ForbiddenException();
}
// ここから元コンテンツを取得する処理
//$this->_prepare();
$key = $this->params['key'];
$conditions = $this->Video->getConditions();
$conditions['Video.key'] = $key;
$query = array('conditions' => $conditions);
$video = $this->Video->find('first', $query);
// ここまで元コンテンツを取得する処理
// ダウンロード実行
if (!$video) {
// 表示できない記事へのアクセスなら404
throw new NotFoundException(__d('videos', 'Invalid video entry'));
}
// 圧縮用パスワードキーを求める
if (!empty($this->request->data['AuthorizationKey']['authorization_key'])) {
$zipPassword = $this->request->data['AuthorizationKey']['authorization_key'];
} else {
$this->_setFlashMessageAndRedirect($key, __d('authorization_keys', 'please input compression password'));
return;
}
// ダウンロードファイル名はタイトルにする
$fileName = $video['Video']['title'];
$zipFileName = $fileName . '.zip';
$videoFileName = $fileName . '.mp4';
$realFilePath = APP . WEBROOT_DIR . DS . $video['UploadFile'][Video::VIDEO_FILE_FIELD]['path'] . $video['UploadFile'][Video::VIDEO_FILE_FIELD]['id'] . DS . $video['UploadFile'][Video::VIDEO_FILE_FIELD]['real_file_name'];
$zip = new ZipDownloader();
$zip->addFile($realFilePath, $videoFileName);
$zip->setPassword($zipPassword);
$zip->close();
return $zip->download($zipFileName);
}