You are here

function sbp_paths_sbp_paths in Search by Page 7

Same name and namespace in other branches
  1. 6 sbp_paths.module \sbp_paths_sbp_paths()

Implements Search by Page hook_sbp_paths().

Reads path information stored in the database, and returns it.

File

./sbp_paths.module, line 16
Module file for Search by Page Paths, a sub-module for Search by Page.

Code

function sbp_paths_sbp_paths($environment) {
  $min_time = search_by_page_setting_get('sbp_paths_min_time', $environment, 1);
  $max_time = search_by_page_setting_get('sbp_paths_max_time', $environment, 0);
  $res = db_query('SELECT * FROM {sbpp_path} p WHERE p.environment=:env', array(
    ':env' => $environment,
  ))
    ->fetchAll();
  $ret = array();
  foreach ($res as $item) {

    // This comes from checkboxes, so it looks like 'en' => 'en', 'es' => 0,
    // etc.
    $languages = @unserialize($item->languages);
    $langs = array();
    if (is_array($languages)) {
      foreach ($languages as $lang => $val) {
        if ($val) {
          $langs[] = $lang;
        }
      }
    }
    $ret[$item->page_path] = array(
      'id' => $item->pid,
      'role' => $item->role,
      'languages' => $langs,
      'min_time' => $min_time,
      'max_time' => $max_time,
    );
  }
  return $ret;
}