You are here

function sbp_paths_sbp_paths in Search by Page 6

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

Implementation of 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=%d', $environment);
  $ret = array();
  while ($item = db_fetch_object($res)) {

    // This comes from checkboxes, so it looks like 'en' => 1, '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;
}