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


PHP CategoryModel::GetFull方法代码示例

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


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

示例1: discussions

 /**
  * Show all categories and few discussions from each.
  *
  * @param string $Category The url code of the parent category.
  * @since 2.0.0
  * @access public
  */
 public function discussions($Category = '')
 {
     // Setup head
     $this->addJsFile('discussions.js');
     $this->Menu->highlightRoute('/discussions');
     if (!$this->title()) {
         $Title = c('Garden.HomepageTitle');
         if ($Title) {
             $this->title($Title, '');
         } else {
             $this->title(t('All Categories'));
         }
     }
     if (!$Category) {
         $this->Description(c('Garden.Description', null));
     }
     Gdn_Theme::section('CategoryDiscussionList');
     // Set the category follow toggle before we load category data so that it affects the category query appropriately.
     $CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
     $CategoryFollowToggleModule->SetToggle();
     $this->CategoryModel->Watching = !Gdn::session()->GetPreference('ShowAllCategories');
     if ($Category) {
         $Subtree = CategoryModel::GetSubtree($Category, false);
         $CategoryIDs = consolidateArrayValuesByKey($Subtree, 'CategoryID');
         $Categories = $this->CategoryModel->GetFull($CategoryIDs)->resultArray();
     } else {
         $Categories = $this->CategoryModel->GetFull()->resultArray();
     }
     $this->setData('Categories', $Categories);
     // Get category data and discussions
     $this->DiscussionsPerCategory = c('Vanilla.Discussions.PerCategory', 5);
     $DiscussionModel = new DiscussionModel();
     $this->CategoryDiscussionData = array();
     foreach ($this->CategoryData->result() as $Category) {
         if ($Category->CategoryID > 0) {
             $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'Announce' => 'all'));
         }
     }
     // Add modules
     $this->addModule('NewDiscussionModule');
     $this->addModule('DiscussionFilterModule');
     $this->addModule('CategoriesModule');
     $this->addModule('BookmarkedModule');
     $this->addModule($CategoryFollowToggleModule);
     // Set view and render
     $this->View = 'discussions';
     $this->canonicalUrl(url('/categories', true));
     $Path = $this->fetchViewLocation('helper_functions', 'discussions', false, false);
     if ($Path) {
         include_once $Path;
     }
     // For GetOptions function
     $Path2 = $this->fetchViewLocation('helper_functions', 'categories', false, false);
     if ($Path2) {
         include_once $Path2;
     }
     $this->render();
 }
开发者ID:dimassrio,项目名称:vanilla,代码行数:65,代码来源:class.categoriescontroller.php

示例2: Base_Render_Before

    /**
     * Hack the Base Render in order to achieve our goal
     * 
     * @since 1.0
     * @version 1.7.2
     */
    public function Base_Render_Before(&$Sender)
    {
        // Attach the Plugin's CSS to the site
        $Sender->AddCssFile($this->GetResource('categories2menu.css', FALSE, FALSE));
        $Cat2MenuJQuerySource = '<script type="text/javascript">
var ddmenuitem = 0;
var menustyles = { "visibility":"visible", "display":"block", "z-index":"9"}

function Menu_close()
{  if(ddmenuitem) { ddmenuitem.css("visibility", "hidden"); } }

function Menu_open()
{  Menu_close();
   ddmenuitem = $(this).find("ul").css(menustyles);
}

jQuery(document).ready(function()
{  $("ul#Menu > li").bind("mouseover", Menu_open);
   $("ul#Menu > li").bind("mouseout", Menu_close);
});

document.onclick = Menu_close;</script>
';
        // Add the jQuery JavaScript to the page
        $Sender->Head->AddString($Cat2MenuJQuerySource);
        if ($Sender->Menu) {
            // Set this to FALSE|TRUE whether you want to display the Discussion-Counter next to each Category or not
            $DisplayCounter = TRUE;
            // Build the Categories Model & load Categories Data
            $CategoryModel = new CategoryModel();
            $_CategoryData = $CategoryModel->GetFull();
            // If there are any Categories...
            if ($_CategoryData != FALSE) {
                // Add a link to the Category overview as first menuitem
                $Sender->Menu->AddLink('Discussions', T('→ All Categories'), '/categories/all');
                // If $DisplayCounter is set to TRUE, get Count discussions per Category separately
                $CountDiscussions = 0;
                foreach ($_CategoryData->Result() as $Category) {
                    // (will ignore root node)
                    if ($Category->Name != 'Root') {
                        $CountDiscussions = $CountDiscussions + $Category->CountDiscussions;
                    }
                }
                // Fetch every single Category...
                foreach ($_CategoryData->Result() as $Category) {
                    if ($Category->Name != 'Root') {
                        if ($DisplayCounter == TRUE) {
                            // Build the Categories-Menu with Discussions-Counter
                            $Sender->Menu->AddLink('Discussions', $Category->Name . ' <span>' . $Category->CountDiscussions . '</span>', '/categories/' . $Category->UrlCode, FALSE);
                        } else {
                            // Build the Categories-Menu
                            $Sender->Menu->AddLink('Discussions', $Category->Name, '/categories/' . $Category->UrlCode, FALSE);
                        }
                    }
                }
            }
        }
    }
开发者ID:ru4,项目名称:arabbnota,代码行数:64,代码来源:class.categories2menu.plugin.php

示例3: Discussions

 /**
  * Create a discussion.
  * @param int The category id to add the discussion to.
  */
 public function Discussions()
 {
     $CategoryID = 1;
     $Session = Gdn::Session();
     $DiscussionID = isset($this->Discussion) ? $this->Discussion->DiscussionID : '';
     $this->CategoryID = isset($this->Discussion) ? $this->Discussion->CategoryID : $CategoryID;
     if (Gdn::Config('Vanilla.Categories.Use') === TRUE) {
         $CategoryModel = new CategoryModel();
         // Filter to categories that this user can add to
         $CategoryModel->SQL->Distinct()->Join('Permission _p2', '_p2.JunctionID = c.CategoryID', 'inner')->Join('UserRole _ur2', '_p2.RoleID = _ur2.RoleID', 'inner')->BeginWhereGroup()->Where('_ur2.UserID', $Session->UserID)->Where('_p2.`Vanilla.Discussions.Add`', 1)->EndWhereGroup();
         $this->CategoryData = $CategoryModel->GetFull();
     }
     if (isset($this->Discussion)) {
         if ($this->Discussion->InsertUserID != $Session->UserID) {
             $this->Permission('Vanilla.Discussions.Edit', $this->Discussion->CategoryID);
         }
     } else {
         $this->Permission('Vanilla.Discussions.Add');
     }
     // Set the model on the form.
     $this->Form->SetModel($this->DiscussionModel);
     if ($this->Form->AuthenticatedPostBack() === TRUE) {
         $FormValues = $this->Form->FormValues();
         // Check category permissions
         if ($this->Form->GetFormValue('Announce', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Announce', $this->CategoryID)) {
             $this->Form->AddError('You do not have permission to announce in this category', 'Announce');
         }
         if ($this->Form->GetFormValue('Close', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Close', $this->CategoryID)) {
             $this->Form->AddError('You do not have permission to close in this category', 'Close');
         }
         if ($this->Form->GetFormValue('Sink', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Sink', $this->CategoryID)) {
             $this->Form->AddError('You do not have permission to sink in this category', 'Sink');
         }
         if (!$Session->CheckPermission('Vanilla.Discussions.Add', $this->CategoryID)) {
             $this->Form->AddError('You do not have permission to start discussions in this category', 'CategoryID');
         }
         if ($this->Form->ErrorCount() == 0) {
             $DiscussionID = $this->DiscussionModel->Save($FormValues, $this->CommentModel);
             $this->Form->SetValidationResults($this->DiscussionModel->ValidationResults());
         }
     }
     if ($this->Form->ErrorCount() > 0) {
         // Return the form errors
         $this->SetJSON("errors", $this->Form->Errors());
     }
     $this->Render();
 }
开发者ID:gregroiusairlangga,项目名称:vanilla-api-addon,代码行数:51,代码来源:class.categorycontroller.php

示例4: Discussions

 /**
  * Show all categories and few discussions from each.
  * 
  * @since 2.0.0
  * @access public
  */
 public function Discussions()
 {
     // Setup head
     $this->AddCssFile('vanilla.css');
     $this->Menu->HighlightRoute('/discussions');
     $this->AddJsFile('discussions.js');
     $Title = C('Garden.HomepageTitle');
     if ($Title) {
         $this->Title($Title, '');
     } else {
         $this->Title(T('All Categories'));
     }
     $this->Description(C('Garden.Description', NULL));
     Gdn_Theme::Section('CategoryDiscussionList');
     // Set the category follow toggle before we load category data so that it affects the category query appropriately.
     $CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
     $CategoryFollowToggleModule->SetToggle();
     // Get category data and discussions
     $this->DiscussionsPerCategory = C('Vanilla.Discussions.PerCategory', 5);
     $DiscussionModel = new DiscussionModel();
     $this->CategoryModel->Watching = !Gdn::Session()->GetPreference('ShowAllCategories');
     $this->CategoryData = $this->CategoryModel->GetFull();
     $this->SetData('Categories', $this->CategoryData);
     $this->CategoryDiscussionData = array();
     foreach ($this->CategoryData->Result() as $Category) {
         if ($Category->CategoryID > 0) {
             $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'Announce' => 'all'));
         }
     }
     // Add modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('DiscussionFilterModule');
     $this->AddModule('CategoriesModule');
     $this->AddModule('BookmarkedModule');
     $this->AddModule($CategoryFollowToggleModule);
     // Set view and render
     $this->View = 'discussions';
     $this->CanonicalUrl(Url('/categories', TRUE));
     $Path = $this->FetchViewLocation('helper_functions', 'discussions', FALSE, FALSE);
     if ($Path) {
         include_once $Path;
     }
     $this->Render();
 }
开发者ID:bishopb,项目名称:vanilla,代码行数:50,代码来源:class.categoriescontroller.php

示例5: PostController_Render_Before

 public function PostController_Render_Before($Sender)
 {
     if (Gdn::Session()->CheckPermission('Vanilla.Discussions.Close')) {
         $CategoryModel = new CategoryModel();
         $CategoryFull = $CategoryModel->GetFull();
         $CatsExpire = array();
         foreach ($CategoryFull as $Category) {
             $CatsExpire[$Category->CategoryID] = Gdn::Session()->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $Category->PermissionCategoryID) && $Category->AutoExpirePeriod;
         }
         $Sender->AddDefinition('CatsExpire', json_encode($CatsExpire));
         $Sender->AddJsFile('autoexpirecheck.js', 'plugins/AutoExpireDiscussions');
     }
 }
开发者ID:x00,项目名称:AutoExpireDiscussions-Vanilla-Plugin,代码行数:13,代码来源:default.php

示例6: Discussion

 /**
  * Create a discussion.
  *
  * @param int The CategoryID to add the discussion to.
  */
 public function Discussion($CategoryID = '')
 {
     $UseCategories = C('Vanilla.Categories.Use');
     if (!$UseCategories) {
         $CategoryID = 0;
     }
     $Session = Gdn::Session();
     $DiscussionID = isset($this->Discussion) ? $this->Discussion->DiscussionID : '';
     $DraftID = isset($this->Draft) ? $this->Draft->DraftID : 0;
     $this->CategoryID = isset($this->Discussion) ? $this->Discussion->CategoryID : $CategoryID;
     if ($UseCategories) {
         $CategoryModel = new CategoryModel();
         $this->CategoryData = $CategoryModel->GetFull('', 'Vanilla.Discussions.Add');
     }
     $this->AddJsFile('jquery.autogrow.js');
     $this->AddJsFile('post.js');
     $this->AddJsFile('autosave.js');
     $this->Title(T('Start a New Discussion'));
     if (isset($this->Discussion)) {
         if ($this->Discussion->InsertUserID != $Session->UserID) {
             $this->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $this->Discussion->CategoryID);
         }
         // Make sure that content can (still) be edited.
         $EditContentTimeout = C('Garden.EditContentTimeout', -1);
         $CanEdit = $EditContentTimeout == -1 || strtotime($this->Discussion->DateInserted) + $EditContentTimeout > time();
         if (!$CanEdit) {
             $this->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $this->Discussion->CategoryID);
         }
     } else {
         $this->Permission('Vanilla.Discussions.Add');
     }
     // Set the model on the form.
     $this->Form->SetModel($this->DiscussionModel);
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         if (isset($this->Discussion)) {
             $this->Form->SetData($this->Discussion);
         } else {
             if (isset($this->Draft)) {
                 $this->Form->SetData($this->Draft);
             } else {
                 $this->Form->SetData(array('CategoryID' => $CategoryID));
             }
         }
     } else {
         // Save as a draft?
         $FormValues = $this->Form->FormValues();
         if ($DraftID == 0) {
             $DraftID = $this->Form->GetFormValue('DraftID', 0);
         }
         $Draft = $this->Form->ButtonExists('Save Draft') ? TRUE : FALSE;
         $Preview = $this->Form->ButtonExists('Preview') ? TRUE : FALSE;
         if (!$Preview) {
             // Check category permissions
             if ($this->Form->GetFormValue('Announce', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Announce', TRUE, 'Category', $this->CategoryID)) {
                 $this->Form->AddError('You do not have permission to announce in this category', 'Announce');
             }
             if ($this->Form->GetFormValue('Close', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $this->CategoryID)) {
                 $this->Form->AddError('You do not have permission to close in this category', 'Close');
             }
             if ($this->Form->GetFormValue('Sink', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Sink', TRUE, 'Category', $this->CategoryID)) {
                 $this->Form->AddError('You do not have permission to sink in this category', 'Sink');
             }
             if (!$Session->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', $this->CategoryID)) {
                 $this->Form->AddError('You do not have permission to start discussions in this category', 'CategoryID');
             }
             // Make sure that the title will not be invisible after rendering
             $Name = $this->Form->GetFormValue('Name', '');
             if ($Name != '' && Gdn_Format::Text($Name) == '') {
                 $this->Form->AddError(T('You have entered an invalid discussion title'), 'Name');
             }
             if ($this->Form->ErrorCount() == 0) {
                 if ($Draft) {
                     $DraftID = $this->DraftModel->Save($FormValues);
                     $this->Form->SetValidationResults($this->DraftModel->ValidationResults());
                 } else {
                     $DiscussionID = $this->DiscussionModel->Save($FormValues, $this->CommentModel);
                     $this->Form->SetValidationResults($this->DiscussionModel->ValidationResults());
                     if ($DiscussionID > 0 && $DraftID > 0) {
                         $this->DraftModel->Delete($DraftID);
                     }
                 }
             }
         } else {
             // If this was a preview click, create a discussion/comment shell with the values for this comment
             $this->Discussion = new stdClass();
             $this->Discussion->Name = $this->Form->GetValue('Name', '');
             $this->Comment = new stdClass();
             $this->Comment->InsertUserID = $Session->User->UserID;
             $this->Comment->InsertName = $Session->User->Name;
             $this->Comment->InsertPhoto = $Session->User->Photo;
             $this->Comment->DateInserted = Gdn_Format::Date();
             $this->Comment->Body = ArrayValue('Body', $FormValues, '');
             if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
                 $this->AddAsset('Content', $this->FetchView('preview'));
             } else {
//.........这里部分代码省略.........
开发者ID:TiGR,项目名称:Garden,代码行数:101,代码来源:class.postcontroller.php

示例7: ModerationController_SplitComments_Create

   /**
    * Add a method to the ModerationController to handle splitting comments out to a new discussion.
    */
   public function ModerationController_SplitComments_Create($Sender) {
      $Session = Gdn::Session();
      $Sender->Form = new Gdn_Form();
      $Sender->Title(T('Split Comments'));
      $Sender->Category = FALSE;

      $DiscussionID = GetValue('0', $Sender->RequestArgs, '');
      if (!is_numeric($DiscussionID))
         return;
      
      $DiscussionModel = new DiscussionModel();
      $Discussion = $DiscussionModel->GetID($DiscussionID);
      if (!$Discussion)
         return;
      
      // Verify that the user has permission to perform the split
      $Sender->Permission('Vanilla.Discussion.Edit', TRUE, 'Category', $Discussion->CategoryID);
      
      $CheckedComments = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedComments', array());
      if (!is_array($CheckedComments))
         $CheckedComments = array();
       
      $CommentIDs = array();
      foreach ($CheckedComments as $DiscID => $Comments) {
         foreach ($Comments as $Comment) {
            if (substr($Comment, 0, 8) == 'Comment_' && $DiscID == $DiscussionID)
               $CommentIDs[] = str_replace('Comment_', '', $Comment);
         }
      }
      // Load category data
      $Sender->ShowCategorySelector = (bool)C('Vanilla.Categories.Use');
      if ($Sender->ShowCategorySelector) {
         $CategoryModel = new CategoryModel();
         $CategoryData = $CategoryModel->GetFull('', 'Vanilla.Discussions.Add');
         $aCategoryData = array();
         foreach ($CategoryData->Result() as $Category) {
            if ($Category->CategoryID <= 0)
               continue;
            
            if ($Discussion->CategoryID == $Category->CategoryID)
               $Sender->Category = $Category;
            
            $CategoryName = $Category->Name;   
            if ($Category->Depth > 1) {
               $CategoryName = '↳ '.$CategoryName;
               $CategoryName = str_pad($CategoryName, strlen($CategoryName) + $Category->Depth - 2, ' ', STR_PAD_LEFT);
               $CategoryName = str_replace(' ', '&#160;', $CategoryName);
            }
            $aCategoryData[$Category->CategoryID] = $CategoryName;
            $Sender->EventArguments['aCategoryData'] = &$aCategoryData;
				$Sender->EventArguments['Category'] = &$Category;
				$Sender->FireEvent('AfterCategoryItem');
         }
         $Sender->CategoryData = $aCategoryData;
      }
      
      $CountCheckedComments = count($CommentIDs);
      $Sender->SetData('CountCheckedComments', $CountCheckedComments);
      // Perform the split
      if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $Data = $Sender->Form->FormValues();
         $Data['Body'] = sprintf(T('This discussion was created from comments split from: %s.'), Anchor(Gdn_Format::Text($Discussion->Name), 'discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).'/'));
         $NewDiscussionID = $DiscussionModel->Save($Data);
         $Sender->Form->SetValidationResults($DiscussionModel->ValidationResults());
         
         if ($Sender->Form->ErrorCount() == 0 && $NewDiscussionID > 0) {
            // Re-assign the comments to the new discussion record
            $DiscussionModel->SQL
               ->Update('Comment')
               ->Set('DiscussionID', $NewDiscussionID)
               ->WhereIn('CommentID', $CommentIDs)
               ->Put();
            
            // Update counts on both discussions
            $CommentModel = new CommentModel();
            $CommentModel->UpdateCommentCount($DiscussionID);
            $CommentModel->UpdateUserCommentCounts($DiscussionID);
            $CommentModel->UpdateCommentCount($NewDiscussionID);
   
            // Clear selections
            unset($CheckedComments[$DiscussionID]);
            Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedComments', $CheckedComments);
            ModerationController::InformCheckedComments($Sender);
            $Sender->RedirectUrl = Url('discussion/'.$NewDiscussionID.'/'.Gdn_Format::Url($Data['Name']));
         }
      }
      
      $Sender->Render($this->GetView('splitcomments.php'));
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:93,代码来源:class.splitmerge.plugin.php

示例8: Discussion

   /**
    * Create or update a discussion.
    *
    * @since 2.0.0
    * @access public
    * 
    * @param int $CategoryID Unique ID of the category to add the discussion to.
    */
   public function Discussion($CategoryID = '') {
      // Override CategoryID if categories are disabled
      $UseCategories = $this->ShowCategorySelector = (bool)C('Vanilla.Categories.Use');
      if (!$UseCategories) 
         $CategoryID = 0;
         
      // Setup head
      $this->AddJsFile('jquery.autogrow.js');
      $this->AddJsFile('post.js');
      $this->AddJsFile('autosave.js');
      
      $Session = Gdn::Session();
      
      // Set discussion, draft, and category data
      $DiscussionID = isset($this->Discussion) ? $this->Discussion->DiscussionID : '';
      $DraftID = isset($this->Draft) ? $this->Draft->DraftID : 0;
      $this->CategoryID = isset($this->Discussion) ? $this->Discussion->CategoryID : $CategoryID;
      $this->Category = FALSE;
      if ($UseCategories) {
         $CategoryModel = new CategoryModel();
         $CategoryData = $CategoryModel->GetFull('', 'Vanilla.Discussions.Add');
         $aCategoryData = array();
         foreach ($CategoryData->Result() as $Category) {
            if ($Category->CategoryID <= 0)
               continue;
            
            if ($this->CategoryID == $Category->CategoryID)
               $this->Category = $Category;
            
            $CategoryName = $Category->Name;   
            if ($Category->Depth > 1) {
               $CategoryName = '↳ '.$CategoryName;
               $CategoryName = str_pad($CategoryName, strlen($CategoryName) + $Category->Depth - 2, ' ', STR_PAD_LEFT);
               $CategoryName = str_replace(' ', '&#160;', $CategoryName);
            }
            $aCategoryData[$Category->CategoryID] = $CategoryName;
            $this->EventArguments['aCategoryData'] = &$aCategoryData;
				$this->EventArguments['Category'] = &$Category;
				$this->FireEvent('AfterCategoryItem');
         }
         $this->CategoryData = $aCategoryData;
      }
      
      // Check permission 
      if (isset($this->Discussion)) {
         // Permission to edit
         if ($this->Discussion->InsertUserID != $Session->UserID)
            $this->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $this->Category->PermissionCategoryID);

         // Make sure that content can (still) be edited.
         $EditContentTimeout = C('Garden.EditContentTimeout', -1);
         $CanEdit = $EditContentTimeout == -1 || strtotime($this->Discussion->DateInserted) + $EditContentTimeout > time();
         if (!$CanEdit)
            $this->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $this->Category->PermissionCategoryID);

         $this->Title(T('Edit Discussion'));
      } else {
         // Permission to add
         $this->Permission('Vanilla.Discussions.Add');
         $this->Title(T('Start a New Discussion'));
      }
      
      // Set the model on the form
      $this->Form->SetModel($this->DiscussionModel);
      if ($this->Form->AuthenticatedPostBack() === FALSE) {
         // Prep form with current data for editing
         if (isset($this->Discussion)) {
            $this->Form->SetData($this->Discussion);
         } else if (isset($this->Draft))
            $this->Form->SetData($this->Draft);
         else
            $this->Form->SetData(array('CategoryID' => $CategoryID));
            
      } else { // Form was submitted
         // Save as a draft?
         $FormValues = $this->Form->FormValues();
         $this->DeliveryType(GetIncomingValue('DeliveryType', $this->_DeliveryType));
         if ($DraftID == 0)
            $DraftID = $this->Form->GetFormValue('DraftID', 0);
            
         $Draft = $this->Form->ButtonExists('Save Draft') ? TRUE : FALSE;
         $Preview = $this->Form->ButtonExists('Preview') ? TRUE : FALSE;
         if (!$Preview) {
            if (!is_object($this->Category) && isset($FormValues['CategoryID']))
               $this->Category = $aCategoryData[$FormValues['CategoryID']];

            if (is_object($this->Category)) {
               // Check category permissions.
               if ($this->Form->GetFormValue('Announce', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Announce', TRUE, 'Category', $this->Category->PermissionCategoryID))
                  $this->Form->AddError('You do not have permission to announce in this category', 'Announce');

               if ($this->Form->GetFormValue('Close', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $this->Category->PermissionCategoryID))
//.........这里部分代码省略.........
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:101,代码来源:class.postcontroller.php

示例9: Discussion

 /**
  * Create a discussion.
  *
  * @param int The CategoryID to add the discussion to.
  */
 public function Discussion($CategoryID = '')
 {
     $Session = Gdn::Session();
     $DiscussionID = isset($this->Discussion) ? $this->Discussion->DiscussionID : '';
     $DraftID = isset($this->Draft) ? $this->Draft->DraftID : 0;
     $this->CategoryID = isset($this->Discussion) ? $this->Discussion->CategoryID : $CategoryID;
     if (Gdn::Config('Vanilla.Categories.Use') === TRUE) {
         $CategoryModel = new CategoryModel();
         // Filter to categories that this user can add to
         $CategoryModel->SQL->Distinct()->Join('Permission _p2', '_p2.JunctionID = c.CategoryID', 'inner')->Join('UserRole _ur2', '_p2.RoleID = _ur2.RoleID', 'inner')->BeginWhereGroup()->Where('_ur2.UserID', $Session->UserID)->Where('_p2.`Vanilla.Discussions.Add`', 1)->EndWhereGroup();
         $this->CategoryData = $CategoryModel->GetFull();
     }
     $this->AddJsFile('js/library/jquery.autogrow.js');
     $this->AddJsFile('post.js');
     $this->AddJsFile('autosave.js');
     $this->Title(T('Start a New Discussion'));
     if (isset($this->Discussion)) {
         if ($this->Discussion->InsertUserID != $Session->UserID) {
             $this->Permission('Vanilla.Discussions.Edit', $this->Discussion->CategoryID);
         }
     } else {
         $this->Permission('Vanilla.Discussions.Add');
     }
     // Set the model on the form.
     $this->Form->SetModel($this->DiscussionModel);
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         if (isset($this->Discussion)) {
             $this->Form->SetData($this->Discussion);
         } else {
             if (isset($this->Draft)) {
                 $this->Form->SetData($this->Draft);
             } else {
                 $this->Form->SetData(array('CategoryID' => $CategoryID));
             }
         }
     } else {
         // Save as a draft?
         $FormValues = $this->Form->FormValues();
         if ($DraftID == 0) {
             $DraftID = $this->Form->GetFormValue('DraftID', 0);
         }
         $Draft = $this->Form->ButtonExists('Save Draft') ? TRUE : FALSE;
         $Preview = $this->Form->ButtonExists('Preview') ? TRUE : FALSE;
         if (!$Preview) {
             // Check category permissions
             if ($this->Form->GetFormValue('Announce', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Announce', $this->CategoryID)) {
                 $this->Form->AddError('You do not have permission to announce in this category', 'Announce');
             }
             if ($this->Form->GetFormValue('Close', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Close', $this->CategoryID)) {
                 $this->Form->AddError('You do not have permission to close in this category', 'Close');
             }
             if ($this->Form->GetFormValue('Sink', '') != '' && !$Session->CheckPermission('Vanilla.Discussions.Sink', $this->CategoryID)) {
                 $this->Form->AddError('You do not have permission to sink in this category', 'Sink');
             }
             if (!$Session->CheckPermission('Vanilla.Discussions.Add', $this->CategoryID)) {
                 $this->Form->AddError('You do not have permission to start discussions in this category', 'CategoryID');
             }
             if ($this->Form->ErrorCount() == 0) {
                 if ($Draft) {
                     $DraftID = $this->DraftModel->Save($FormValues);
                     $this->Form->SetValidationResults($this->DraftModel->ValidationResults());
                 } else {
                     $DiscussionID = $this->DiscussionModel->Save($FormValues, $this->CommentModel);
                     $this->Form->SetValidationResults($this->DiscussionModel->ValidationResults());
                     if ($DiscussionID > 0 && $DraftID > 0) {
                         $this->DraftModel->Delete($DraftID);
                     }
                 }
             }
         } else {
             // If this was a preview click, create a discussion/comment shell with the values for this comment
             $this->Discussion = new stdClass();
             $this->Discussion->Name = $this->Form->GetValue('Name', '');
             $this->Comment = new stdClass();
             $this->Comment->InsertUserID = $Session->User->UserID;
             $this->Comment->InsertName = $Session->User->Name;
             $this->Comment->InsertPhoto = $Session->User->Photo;
             $this->Comment->DateInserted = Gdn_Format::Date();
             $this->Comment->Body = ArrayValue('Body', $FormValues, '');
             if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
                 $this->AddAsset('Content', $this->FetchView('preview'));
             } else {
                 $this->View = 'preview';
             }
         }
         if ($this->Form->ErrorCount() > 0) {
             // Return the form errors
             $this->StatusMessage = $this->Form->Errors();
         } else {
             if ($DiscussionID > 0 || $DraftID > 0) {
                 // Make sure that the ajax request form knows about the newly created discussion or draft id
                 $this->SetJson('DiscussionID', $DiscussionID);
                 $this->SetJson('DraftID', $DraftID);
                 if (!$Preview) {
                     // If the discussion was not a draft
//.........这里部分代码省略.........
开发者ID:sheldon,项目名称:Garden,代码行数:101,代码来源:class.postcontroller.php

示例10: Controller_Index

 /**
  * Get flagged content & show settings.
  *
  * Default method of virtual Flagging controller.
  */
 public function Controller_Index($Sender) {
    $Sender->AddCssFile('admin.css');
    $Sender->AddCssFile($this->GetResource('design/flagging.css', FALSE, FALSE));
    
    $Validation = new Gdn_Validation();
    $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
    $ConfigurationModel->SetField(array(
       'Plugins.Flagging.UseDiscussions',
       'Plugins.Flagging.CategoryID'
    ));
    
    // Set the model on the form.
    $Sender->Form->SetModel($ConfigurationModel);
    
    $CategoryModel = new CategoryModel();
    $Sender->CategoryData = $CategoryModel->GetFull('', 'Vanilla.Discussions.Add');
    
    // If seeing the form for the first time...
    if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
       // Apply the config settings to the form.
       $Sender->Form->SetData($ConfigurationModel->Data);
    } else {
       $Saved = $Sender->Form->Save();
       if($Saved) {
          $Sender->InformMessage(T("Your changes have been saved."));
       }
    }
    
    $FlaggedItems = Gdn::SQL()->Select('*')
       ->From('Flag fl')
       ->OrderBy('DateInserted', 'DESC')
       ->Get();
    
    $Sender->FlaggedItems = array();
    while ($Flagged = $FlaggedItems->NextRow(DATASET_TYPE_ARRAY)) {
       $URL = $Flagged['ForeignURL'];
       $Index = $Flagged['DateInserted'].'-'.$Flagged['InsertUserID'];
       $Flagged['EncodedURL'] = str_replace('=','-',base64_encode($Flagged['ForeignURL']));
       $Sender->FlaggedItems[$URL][$Index] = $Flagged;
    }
    unset($FlaggedItems);
    
    $Sender->Render($this->GetView('flagging.php'));
 }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:49,代码来源:class.flagging.plugin.php


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