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


PHP CategoryModel::AllowedDiscussionTypes方法代码示例

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


在下文中一共展示了CategoryModel::AllowedDiscussionTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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', GetValue('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;
         }
         // If user !$HasPermission, they are $PrivilegedGuest so redirect to $GuestUrl.
         $Url = $HasPermission ? GetValue('AddUrl', $Type) : $this->GuestUrl;
         if (!$Url) {
             continue;
         }
         if (isset($Category) && $HasPermission) {
             $Url .= '/' . rawurlencode(GetValue('UrlCode', $Category));
         }
         $this->AddButton(T(GetValue('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:3marproof,项目名称:vanilla,代码行数:53,代码来源:class.newdiscussionmodule.php

示例2: ToString

 public function ToString()
 {
     if ($this->CategoryID === NULL) {
         $this->CategoryID = Gdn::Controller()->Data('Category.CategoryID', FALSE);
     }
     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', GetValue('CategoryID', $PermissionCategory));
     } else {
         $HasPermission = Gdn::Session()->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', 'any');
     }
     if (!$HasPermission) {
         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 = GetValue('AddUrl', $Type);
         if (!$Url) {
             continue;
         }
         if (isset($Category)) {
             $Url .= '/' . rawurlencode(GetValue('UrlCode', $Category));
         }
         $this->AddButton(T(GetValue('AddText', $Type)), $Url);
     }
     if ($this->QueryString) {
         foreach ($this->Buttons as &$Row) {
             $Row['Url'] .= (strpos($Row['Url'], '?') !== FALSE ? '&' : '?') . $this->QueryString;
         }
     }
     return parent::ToString();
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:41,代码来源:class.newdiscussionmodule.php


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