You are here

class AuthcachePollFragment in Authenticated User Page Caching (Authcache) 7.2

Personalized fragment handler for polls.

Hierarchy

Expanded class hierarchy of AuthcachePollFragment

1 string reference to 'AuthcachePollFragment'
authcache_poll_authcache_p13n_fragment in modules/authcache_poll/authcache_poll.module
Implements hook_authcache_p13n_fragment().

File

modules/authcache_poll/includes/AuthcachePollFragment.inc, line 10
Defines personalized fragment for polls.

View source
class AuthcachePollFragment implements AuthcacheP13nFragmentInterface, AuthcacheP13nFragmentLoaderInterface, AuthcacheP13nFragmentAccessInterface {
  protected $forceResults;

  /**
   * Construct new poll fragment.
   *
   * @param bool $force_results
   *   Specify true if the result graph should be returned regardless of
   *   whether the user has voted or not.
   */
  public function __construct($force_results = FALSE) {
    $this->forceResults = $force_results;
  }

  /**
   * Load requested nodes.
   */
  public function load($nids, $context) {
    return node_load_multiple($nids);
  }

  /**
   * Check whether the user has access to the given fragment.
   */
  public function check($account, $key, $subject, $context) {
    return user_access('access content', $account);
  }

  /**
   * Get poll results/form for user.
   *
   * @see poll.module
   */
  public function render($nid, $node, $context) {
    if ($this->forceResults) {
      $node->show_results = TRUE;
    }
    $build = node_view($node);
    if (isset($build['poll_view_voting'])) {
      return render($build['poll_view_voting']);
    }
    elseif (isset($build['poll_view_results'])) {
      return render($build['poll_view_results']);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AuthcachePollFragment::$forceResults protected property
AuthcachePollFragment::check public function Check whether the user has access to the given fragment. Overrides AuthcacheP13nFragmentAccessInterface::check
AuthcachePollFragment::load public function Load requested nodes. Overrides AuthcacheP13nFragmentLoaderInterface::load
AuthcachePollFragment::render public function Get poll results/form for user. Overrides AuthcacheP13nFragmentInterface::render
AuthcachePollFragment::__construct public function Construct new poll fragment.