Airship\Cabin\Bridge\Blueprint\Blog::getNextVersionUniqueId PHP Method

getNextVersionUniqueId() public method

Get the next version's unique ID
public getNextVersionUniqueId ( integer $postId, integer $currentVersionId ) : string
$postId integer
$currentVersionId integer
return string
    public function getNextVersionUniqueId(int $postId, int $currentVersionId) : string
    {
        $latest = $this->db->cell('SELECT
                uniqueid
            FROM
                hull_blog_post_versions
            WHERE
                    post = ?
                AND versionid > ?
                ORDER BY versionid DESC
                LIMIT 1
            ', $postId, $currentVersionId);
        if (empty($latest)) {
            return '';
        }
        return $latest;
    }

Usage Example

Example #1
0
 /**
  * View a version of a blog post.
  *
  * @param string $postID
  * @param string $uniqueID
  *
  * @route blog/post/history/{id}/view/{string}
  */
 public function postHistoryView(string $postID = '', string $uniqueID = '')
 {
     $postID = (int) $postID;
     $blog = $this->blog->getBlogPostById($postID);
     if (!$blog || !$this->can('read')) {
         \Airship\redirect($this->airship_cabin_prefix . '/blog/post');
     }
     $blog['tags'] = $this->blog->getTagsForPost($postID);
     $version = $this->blog->getBlogPostVersionByUniqueId($uniqueID);
     if ((int) $version['postid'] !== $postID || empty($version)) {
         \Airship\redirect($this->airship_cabin_prefix . '/blog/post/history/' . $postID);
     }
     if ($this->isSuperUser()) {
         $authors = $this->author->getAll();
     } else {
         $authors = $this->author->getForUser($this->getActiveUserId());
     }
     $categories = $this->blog->getCategoryTree();
     $tags = $this->blog->getTags();
     $this->lens('blog/post_history_view', ['active_link' => 'bridge-link-blog-posts', 'authors' => $authors, 'blogpost' => $blog, 'categories' => $categories, 'tags' => $tags, 'title' => \__('Revision for  Blog Post "%s"', 'default', Util::noHTML($blog['title'])), 'prev_uniqueid' => $this->blog->getPrevVersionUniqueId($postID, (int) $version['versionid']), 'next_uniqueid' => $this->blog->getNextVersionUniqueId($postID, (int) $version['versionid']), 'version' => $version]);
 }