original_string: public function AddCategory() {
        // Check permission
        $this->Permission('Garden.Settings.Manage');
        
        // Set up head
        $this->AddJsFile('jquery.alphanumeric.js');
        $this->AddJsFile('categories.js');
        $this->AddJsFile('jquery.gardencheckboxgrid.js');
        $this->Title(T('Add Category'));
        $this->AddSideMenu('vanilla/settings/managecategories');
        
        // Prep models
        $RoleModel = new RoleModel();
        $PermissionModel = Gdn::PermissionModel();
        $this->Form->SetModel($this->CategoryModel);
        
        // Load all roles with editable permissions.
        $this->RoleArray = $RoleModel->GetArray();
        
        $this->FireEvent('AddEditCategory');
        
        if ($this->Form->IsPostBack() == FALSE) {
           $this->Form->AddHidden('CodeIsDefined', '0');
        } else {
           // Form was validly submitted
           $IsParent = $this->Form->GetFormValue('IsParent', '0');
           $this->Form->SetFormValue('AllowDiscussions', $IsParent == '1' ? '0' : '1');
           $this->Form->SetFormValue('CustomPoints', (bool)$this->Form->GetFormValue('CustomPoints'));
           $CategoryID = $this->Form->Save();
           if ($CategoryID) {
              $Category = CategoryModel::Categories($CategoryID);
              $this->SetData('Category', $Category);
              
              if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
                 Redirect('vanilla/settings/managecategories');
           } else {
              unset($CategoryID);
           }
        }
        // Get all of the currently selected role/permission combinations for this junction.
        $Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => isset($CategoryID) ? $CategoryID : 0), 'Category');
        $Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
     
        if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
           $this->SetData('PermissionData', $Permissions, TRUE);
        }
        
        // Render default view
        $this->Render();      
     }
code: public function AddCategory() {
        // Check permission
        $this->Permission('Garden.Settings.Manage');
        
        // Set up head
        $this->AddJsFile('jquery.alphanumeric.js');
        $this->AddJsFile('categories.js');
        $this->AddJsFile('jquery.gardencheckboxgrid.js');
        $this->Title(T('Add Category'));
        $this->AddSideMenu('vanilla/settings/managecategories');
        
        // Prep models
        $RoleModel = new RoleModel();
        $PermissionModel = Gdn::PermissionModel();
        $this->Form->SetModel($this->CategoryModel);
        
        // Load all roles with editable permissions.
        $this->RoleArray = $RoleModel->GetArray();
        
        $this->FireEvent('AddEditCategory');
        
        if ($this->Form->IsPostBack() == FALSE) {
           $this->Form->AddHidden('CodeIsDefined', '0');
        } else {
           // Form was validly submitted
           $IsParent = $this->Form->GetFormValue('IsParent', '0');
           $this->Form->SetFormValue('AllowDiscussions', $IsParent == '1' ? '0' : '1');
           $this->Form->SetFormValue('CustomPoints', (bool)$this->Form->GetFormValue('CustomPoints'));
           $CategoryID = $this->Form->Save();
           if ($CategoryID) {
              $Category = CategoryModel::Categories($CategoryID);
              $this->SetData('Category', $Category);
              
              if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
                 Redirect('vanilla/settings/managecategories');
           } else {
              unset($CategoryID);
           }
        }
        // Get all of the currently selected role/permission combinations for this junction.
        $Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => isset($CategoryID) ? $CategoryID : 0), 'Category');
        $Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
     
        if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
           $this->SetData('PermissionData', $Permissions, TRUE);
        }
        
        // Render default view
        $this->Render();      
     }
code_tokens: public function AddCategory ( ) { // Check permission $ this -> Permission ( 'Garden.Settings.Manage' ) ; // Set up head $ this -> AddJsFile ( 'jquery.alphanumeric.js' ) ; $ this -> AddJsFile ( 'categories.js' ) ; $ this -> AddJsFile ( 'jquery.gardencheckboxgrid.js' ) ; $ this -> Title ( T ( 'Add Category' ) ) ; $ this -> AddSideMenu ( 'vanilla/settings/managecategories' ) ; // Prep models $ RoleModel = new RoleModel ( ) ; $ PermissionModel = Gdn :: PermissionModel ( ) ; $ this -> Form -> SetModel ( $ this -> CategoryModel ) ; // Load all roles with editable permissions. $ this -> RoleArray = $ RoleModel -> GetArray ( ) ; $ this -> FireEvent ( 'AddEditCategory' ) ; if ( $ this -> Form -> IsPostBack ( ) == FALSE ) { $ this -> Form -> AddHidden ( 'CodeIsDefined' , '0' ) ; } else { // Form was validly submitted $ IsParent = $ this -> Form -> GetFormValue ( 'IsParent' , '0' ) ; $ this -> Form -> SetFormValue ( 'AllowDiscussions' , $ IsParent == '1' ? '0' : '1' ) ; $ this -> Form -> SetFormValue ( 'CustomPoints' , ( bool ) $ this -> Form -> GetFormValue ( 'CustomPoints' ) ) ; $ CategoryID = $ this -> Form -> Save ( ) ; if ( $ CategoryID ) { $ Category = CategoryModel :: Categories ( $ CategoryID ) ; $ this -> SetData ( 'Category' , $ Category ) ; if ( $ this -> DeliveryType ( ) == DELIVERY_TYPE_ALL ) Redirect ( 'vanilla/settings/managecategories' ) ; } else { unset ( $ CategoryID ) ; } } // Get all of the currently selected role/permission combinations for this junction. $ Permissions = $ PermissionModel -> GetJunctionPermissions ( array ( 'JunctionID' => isset ( $ CategoryID ) ? $ CategoryID : 0 ) , 'Category' ) ; $ Permissions = $ PermissionModel -> UnpivotPermissions ( $ Permissions , TRUE ) ; if ( $ this -> DeliveryType ( ) == DELIVERY_TYPE_ALL ) { $ this -> SetData ( 'PermissionData' , $ Permissions , TRUE ) ; } // Render default view $ this -> Render ( ) ; }
docstring: Adding a new category.
  
  @since 2.0.0
  @access public
docstring_tokens: Adding a new category .