You are here

pages_restriction.cache.inc in Pages Restriction Access 7

Pages Restrictions cache related functions.

File

includes/pages_restriction.cache.inc
View source
<?php

/**
 * @file
 * Pages Restrictions cache related functions.
 */

/**
 * Function to flush everything from the cache table.
 */
function _pages_restriction_flush_cache() {
  db_delete('cache_pages_restriction')
    ->execute();
}

/**
 * Get all the cached data.
 *
 * @return array
 *   Array where the key is the id_session and the value is the next page.
 */
function _pages_restriction_get_cached_data() {
  $caches =& drupal_static(__FUNCTION__);
  if (empty($caches)) {

    // Retrieve all the cached data.
    $cache_raw = db_select('cache_pages_restriction', 'c')
      ->fields('c')
      ->execute()
      ->fetchAll(PDO::FETCH_ASSOC);

    // Define array containing cached data.
    foreach ($cache_raw as $cache) {
      $caches[$cache['id_session']][$cache['restrict_rules']] = $cache['next_page_path'];
    }
  }
  return $caches;
}
function _pages_restriction_delete_cached_data($session_id, $rule_id) {
  return db_delete('cache_pages_restriction')
    ->condition('id_session', $session_id)
    ->condition('restrict_rules', $rule_id)
    ->execute();
}

Functions

Namesort descending Description
_pages_restriction_delete_cached_data
_pages_restriction_flush_cache Function to flush everything from the cache table.
_pages_restriction_get_cached_data Get all the cached data.