Commit 15f515e2 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files

Self search work, and fixes to Solr

parent 78c7af77
......@@ -37,21 +37,11 @@ catch (ParameterException $e) {
json_reply('missingparameter','Missing parameter \'query\'');
}
$type = param_variable('type', 'user');
$type = param_variable('type', 'all');
$limit = param_integer('limit', 20);
$offset = param_integer('offset', 0);
switch($type) {
case 'community':
$data = search_community($query, $limit, $offset, true);
$data['type'] = 'community';
break;
default:
$data = search_user($query, $limit, $offset);
$data['type'] = 'user';
break;
}
$data = search_selfsearch($query, $limit, $offset, $type);
json_headers();
$data['error'] = false;
......
......@@ -60,6 +60,8 @@ $string['select'] = 'Select';
$string['tags'] = 'Tags';
$string['tagsdesc'] = 'Enter comma separated tags for this item';
$string['selfsearch'] = 'Search My Portfolio';
// Quota strings
$string['quota'] = 'Quota';
$string['quotausage'] = 'You have used <span id="quota_used">%s</span> of your <span id="quota_total">%s</span> quota.';
......
......@@ -190,4 +190,11 @@ function search_community($query_string, $limit, $offset = 0, $all = false) {
return call_static_method(generate_class_name('search', $plugin), 'search_community', $query_string, $limit, $offset, $all);
}
function search_selfsearch($query_string, $limit, $offset, $type = 'all') {
$plugin = get_config('searchplugin');
safe_require('search', $plugin);
return call_static_method(generate_class_name('search', $plugin), 'self_search', $query_string, $limit, $offset, $type);
}
?>
......@@ -260,7 +260,14 @@ EOF;
);
}
if (!$USER->is_logged_in()) {
if ($USER->is_logged_in()) {
$SIDEBLOCKS[] = array(
'name' => 'selfsearch',
'weight' => 0,
'data' => array(),
);
}
else {
$SIDEBLOCKS[] = array(
'name' => 'login',
'weight' => -10,
......@@ -271,6 +278,7 @@ EOF;
);
}
if (isset($extraconfig['sideblocks']) && is_array($extraconfig['sideblocks'])) {
foreach ($extraconfig['sideblocks'] as $sideblock) {
$SIDEBLOCKS[] = $sideblock;
......
......@@ -62,14 +62,23 @@ class PluginSearchSolr extends PluginSearchInternal {
}
public static function event_reindex_user($event, $user) {
if (get_config('searchplugin') != 'solr') {
return;
}
self::index_user($user);
self::commit();
}
public static function event_saveartefact($event, $artefact) {
if (get_config('searchplugin') != 'solr') {
return;
}
self::index_artefact($artefact);
self::commit();
}
public static function event_deleteartefact($event, $artefact) {
if (get_config('searchplugin') != 'solr') {
return;
}
self::delete_byidtype($artefact->get('id'), 'artefact');
self::commit();
}
......@@ -193,10 +202,15 @@ END;
$result = $new_result;
}
}
return $results;
}
// This function will rebuild the solr indexes
public static function rebuild_all() {
if (get_config('searchplugin') != 'solr') {
return;
}
self::rebuild_users();
self::rebuild_artefacts();
self::commit();
......@@ -373,7 +387,7 @@ END;
if(is_array($value)) {
$value = implode('" OR "', $value);
}
array_push($q,$key . ':("' . $value . '")');
array_push($q,$key . ':(' . $value . ')');
}
require_once('snoopy/Snoopy.class.php');
......
......@@ -2,6 +2,7 @@
<html>
<head>
<title>{$PAGETITLE|escape}</title>
<script type="text/javascript" src="{$WWWROOT}js/firebug/firebug.js"></script>
<script type="text/javascript">
var config = {literal}{{/literal}
'theme': {$THEMELIST},
......
Supports Markdown
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