allowedDiscussionTypes() public static method

Checks the allowed discussion types on a category.
public static allowedDiscussionTypes ( array $PermissionCategory, array $category = [] ) : array
$PermissionCategory array The permission category of the category.
$category array The category we're checking the permission on.
return array The allowed discussion types on the category.
 /**
  * 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();
 }