当前位置: 首页>>代码示例>>PHP>>正文


PHP CategoryModel::permissionCategory方法代码示例

本文整理汇总了PHP中CategoryModel::permissionCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::permissionCategory方法的具体用法?PHP CategoryModel::permissionCategory怎么用?PHP CategoryModel::permissionCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CategoryModel的用法示例。


在下文中一共展示了CategoryModel::permissionCategory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: toString

 /**
  * Render the module.
  *
  * @return string
  */
 public function toString()
 {
     // Set CategoryID if we have one.
     if ($this->CategoryID === null) {
         $this->CategoryID = Gdn::controller()->data('Category.CategoryID', false);
     }
     // Allow plugins and themes to modify parameters.
     Gdn::controller()->EventArguments['NewDiscussionModule'] =& $this;
     Gdn::controller()->fireEvent('BeforeNewDiscussionButton');
     // Make sure the user has the most basic of permissions first.
     $PermissionCategory = CategoryModel::permissionCategory($this->CategoryID);
     if ($this->CategoryID) {
         $Category = CategoryModel::categories($this->CategoryID);
         $HasPermission = Gdn::session()->checkPermission('Vanilla.Discussions.Add', true, 'Category', val('CategoryID', $PermissionCategory));
     } else {
         $HasPermission = Gdn::session()->checkPermission('Vanilla.Discussions.Add', true, 'Category', 'any');
     }
     // Determine if this is a guest & we're using "New Discussion" button as call to action.
     $PrivilegedGuest = $this->ShowGuests && !Gdn::session()->isValid();
     // No module for you!
     if (!$HasPermission && !$PrivilegedGuest) {
         return '';
     }
     // Grab the allowed discussion types.
     $DiscussionTypes = CategoryModel::allowedDiscussionTypes($PermissionCategory);
     foreach ($DiscussionTypes as $Key => $Type) {
         if (isset($Type['AddPermission']) && !Gdn::session()->checkPermission($Type['AddPermission'])) {
             unset($DiscussionTypes[$Key]);
             continue;
         }
         $Url = val('AddUrl', $Type);
         if (!$Url) {
             continue;
         }
         if (isset($Category)) {
             $Url .= '/' . rawurlencode(val('UrlCode', $Category));
         }
         // Present a signin redirect for a $PrivilegedGuest.
         if (!$HasPermission) {
             $Url = $this->GuestUrl . '?Target=' . $Url;
         }
         $this->addButton(t(val('AddText', $Type)), $Url);
     }
     // Add QueryString to URL if one is defined.
     if ($this->QueryString && $HasPermission) {
         foreach ($this->Buttons as &$Row) {
             $Row['Url'] .= (strpos($Row['Url'], '?') !== false ? '&' : '?') . $this->QueryString;
         }
     }
     return parent::toString();
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:56,代码来源:class.newdiscussionmodule.php

示例2: __construct

 /**
  * Permission checks & property prep.
  */
 public function __construct()
 {
     parent::__construct();
     if (!class_exists('MediaModel')) {
         require __DIR__ . '/class.mediamodel.php';
     }
     $this->_MediaCache = null;
     $this->CanUpload = checkPermission('Plugins.Attachments.Upload.Allow');
     $this->CanDownload = checkPermission('Plugins.Attachments.Download.Allow');
     if ($this->CanUpload) {
         $PermissionCategory = CategoryModel::permissionCategory(Gdn::controller()->data('Category'));
         if (!val('AllowFileUploads', $PermissionCategory, true)) {
             $this->CanUpload = false;
         }
     }
 }
开发者ID:vanilla,项目名称:addons,代码行数:19,代码来源:class.fileupload.plugin.php

示例3: __construct

 /**
  * Setup some variables for instance.
  */
 public function __construct()
 {
     parent::__construct();
     $this->mediaCache = null;
     $this->mediaCacheExpire = 60 * 60 * 6;
     $this->AssetPath = Asset('/plugins/editor');
     $this->pluginInfo = Gdn::pluginManager()->getPluginInfo('editor', Gdn_PluginManager::ACCESS_PLUGINNAME);
     $this->ForceWysiwyg = c('Plugins.editor.ForceWysiwyg', false);
     // Check upload permissions
     $this->canUpload = Gdn::session()->checkPermission('Plugins.Attachments.Upload.Allow', false);
     if ($this->canUpload) {
         $PermissionCategory = CategoryModel::permissionCategory(Gdn::controller()->data('Category'));
         if (!val('AllowFileUploads', $PermissionCategory, true)) {
             $this->canUpload = false;
         }
     }
     // Check against config, too
     if (!c('Garden.AllowFileUploads', false)) {
         $this->canUpload = false;
     }
 }
开发者ID:rbrahmson,项目名称:vanilla,代码行数:24,代码来源:class.editor.plugin.php

示例4: canUpload

 /**
  * Checks whether the canUpload property is set and if not, calculates it value.
  * The calculation is based on config, user permissions, and category permissions.
  *
  * @return bool Whether the session user is allowed to upload a file.
  */
 protected function canUpload()
 {
     // If the property has been set, return it
     if (isset($this->canUpload)) {
         return $this->canUpload;
     } else {
         // Check config and user role upload permission
         if (c('Garden.AllowFileUploads', true) && Gdn::session()->checkPermission('Plugins.Attachments.Upload.Allow', false)) {
             // Check category-specific permission
             $PermissionCategory = CategoryModel::permissionCategory(Gdn::controller()->data('Category'));
             $this->canUpload = val('AllowFileUploads', $PermissionCategory, true);
         } else {
             $this->canUpload = false;
         }
     }
     return $this->canUpload;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:23,代码来源:class.editor.plugin.php


注:本文中的CategoryModel::permissionCategory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。