本文整理汇总了PHP中CategoryModel::PermissionCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::PermissionCategory方法的具体用法?PHP CategoryModel::PermissionCategory怎么用?PHP CategoryModel::PermissionCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel::PermissionCategory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Permission checks & property prep.
*/
public function __construct()
{
parent::__construct();
$this->_MediaCache = NULL;
$this->CanUpload = Gdn::Session()->CheckPermission('Plugins.Attachments.Upload.Allow', FALSE);
$this->CanDownload = Gdn::Session()->CheckPermission('Plugins.Attachments.Download.Allow', FALSE);
if ($this->CanUpload) {
$PermissionCategory = CategoryModel::PermissionCategory(Gdn::Controller()->Data('Category'));
if (!GetValue('AllowFileUploads', $PermissionCategory, TRUE)) {
$this->CanUpload = FALSE;
}
}
}
示例2: 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;
}
// If user !$HasPermission, they are $PrivilegedGuest so redirect to $GuestUrl.
$Url = $HasPermission ? val('AddUrl', $Type) : $this->GuestUrl;
if (!$Url) {
continue;
}
if (isset($Category) && $HasPermission) {
$Url .= '/' . rawurlencode(val('UrlCode', $Category));
}
$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();
}
示例3: 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();
}