當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DiscussionModel::setUserBookmarkCount方法代碼示例

本文整理匯總了PHP中DiscussionModel::setUserBookmarkCount方法的典型用法代碼示例。如果您正苦於以下問題:PHP DiscussionModel::setUserBookmarkCount方法的具體用法?PHP DiscussionModel::setUserBookmarkCount怎麽用?PHP DiscussionModel::setUserBookmarkCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DiscussionModel的用法示例。


在下文中一共展示了DiscussionModel::setUserBookmarkCount方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: bookmark

 /**
  * Allows user to bookmark or unbookmark a discussion.
  *
  * If the discussion isn't bookmarked by the user, this bookmarks it.
  * If it is already bookmarked, this unbookmarks it.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DiscussionID Unique discussion ID.
  */
 public function bookmark($DiscussionID = null)
 {
     // Make sure we are posting back.
     if (!$this->Request->isAuthenticatedPostBack()) {
         throw permissionException('Javascript');
     }
     $Session = Gdn::session();
     if (!$Session->UserID) {
         throw permissionException('SignedIn');
     }
     // Check the form to see if the data was posted.
     $Form = new Gdn_Form();
     $DiscussionID = $Form->getFormValue('DiscussionID', $DiscussionID);
     $Bookmark = $Form->getFormValue('Bookmark', null);
     $UserID = $Form->getFormValue('UserID', $Session->UserID);
     // Check the permission on the user.
     if ($UserID != $Session->UserID) {
         $this->permission('Garden.Moderation.Manage');
     }
     $Discussion = $this->DiscussionModel->getID($DiscussionID);
     if (!$Discussion) {
         throw notFoundException('Discussion');
     }
     $Bookmark = $this->DiscussionModel->bookmark($DiscussionID, $UserID, $Bookmark);
     // Set the new value for api calls and json targets.
     $this->setData(array('UserID' => $UserID, 'DiscussionID' => $DiscussionID, 'Bookmarked' => (bool) $Bookmark));
     setValue('Bookmarked', $Discussion, (int) $Bookmark);
     // Update the user's bookmark count
     $CountBookmarks = $this->DiscussionModel->setUserBookmarkCount($UserID);
     $this->jsonTarget('.User-CountBookmarks', (string) $CountBookmarks);
     //  Short circuit if this is an api call.
     if ($this->deliveryType() === DELIVERY_TYPE_DATA) {
         $this->render('Blank', 'Utility', 'Dashboard');
         return;
     }
     // Return the appropriate bookmark.
     require_once $this->fetchViewLocation('helper_functions', 'Discussions');
     $Html = bookmarkButton($Discussion);
     //      $this->jsonTarget(".Section-DiscussionList #Discussion_$DiscussionID .Bookmark,.Section-Discussion .PageTitle .Bookmark", $Html, 'ReplaceWith');
     $this->jsonTarget("!element", $Html, 'ReplaceWith');
     // Add the bookmark to the bookmarks module.
     if ($Bookmark) {
         // Grab the individual bookmark and send it to the client.
         $Bookmarks = new BookmarkedModule($this);
         if ($CountBookmarks == 1) {
             // When there is only one bookmark we have to get the whole module.
             $Target = '#Panel';
             $Type = 'Append';
             $Bookmarks->getData();
             $Data = $Bookmarks->toString();
         } else {
             $Target = '#Bookmark_List';
             $Type = 'Prepend';
             $Loc = $Bookmarks->fetchViewLocation('discussion');
             ob_start();
             include $Loc;
             $Data = ob_get_clean();
         }
         $this->jsonTarget($Target, $Data, $Type);
     } else {
         // Send command to remove bookmark html.
         if ($CountBookmarks == 0) {
             $this->jsonTarget('#Bookmarks', null, 'Remove');
         } else {
             $this->jsonTarget('#Bookmark_' . $DiscussionID, null, 'Remove');
         }
     }
     $this->render('Blank', 'Utility', 'Dashboard');
 }
開發者ID:caidongyun,項目名稱:vanilla,代碼行數:80,代碼來源:class.discussioncontroller.php


注:本文中的DiscussionModel::setUserBookmarkCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。