Commit a288042e authored by metzlerd's avatar metzlerd
Browse files

Worked on replacing code for searching... broken search right now.

parent 9d42c567
......@@ -34,17 +34,22 @@ class FrxDataFile extends FrxFile {
* List all the reports for a language.
* @return unknown
*/
public function allBlocks() {
public function userBlocks($search = '*') {
$blocks = array();
$sql = array_values($this->validateAllCache('sql'));
$inc = array_values($this->validateAllCache('inc'));
$xml = array_values($this->validateAllCache('xml'));
$data =$sql + $inc + $xml;
if ($data) foreach ($data as $base_name => $obj) {
if ($obj->cache) {
$obj->name = $base_name;
$blocks[$obj->cache['name']] = $obj;
}
if ($search == '*' || drupal_match_path($base_name, $search)) {
if ($obj->cache) {
$r = Frx::RepoMan()->repository($provider);
if ($r && $r->access($obj->access)) {
$obj->name = $base_name;
$blocks[$obj->cache['name']] = $obj;
}
}
}
}
uasort($blocks, 'FrxDataFile::blockCompare');
return $blocks;
......
......@@ -190,9 +190,7 @@ class FrxDataSource{
* @return unknown
*/
public function list_blocks($search, &$block_list, $subdir='') {
static $count=0;
// First find files that match the search string
if ($count > 100) return;
$path = $this->block_path . '/';
if ($subdir) $path .= $subdir . '/';
$block_path = $path . '*' . $search . '*';
......
......@@ -2116,37 +2116,6 @@ function forena_clean_xhtml($xhtml) {
return $ret;
}
/**
* Provides list of blocks that a user has access to that are in any repository matching
* a specified search string
*
* @param string $search block to search for.
* @return array list of blocks the user has access to.
*/
function forena_user_data_blocks($search) {
$repos = Frx::RepoMan()->repositories;
$blocks= array();
$user_blocks = array();
foreach ($repos as $name => $r) {
// Make really sure the data provider objects have been instantiated
$o = Frx::RepoMan()->repository($name);
if (method_exists($o, 'list_blocks')) {
$blocks = array();
$o->list_blocks($search, $blocks);
foreach ($blocks as $block) {
$block_info = $o->loadBlock($block);
if (method_exists($o, 'access')) {
$allow = $o->access(@$block_info['access']);
if ($allow) $user_blocks[] = $name . '/' . $block;
}
}
}
}
if ($user_blocks) asort($user_blocks);
return $user_blocks;
}
/**
* Prettifies an XML string into a human-readable and indented work of art
* @param string $xml The XML as a string
......
......@@ -353,8 +353,7 @@ function forena_categories_autocomplete($string='') {
*/
function forena_data_block_autocomplete($string='') {
require_once('forena.admin.inc');
$data_blocks = forena_user_data_blocks($string);
$data_blocks = Frx::DataFile()->userBlocks($string);
if ($data_blocks) {
$temp = array_values($data_blocks);
$data_blocks = array_combine($temp, $temp);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment