diff options
| author | Andy Staudacher <andy.st@gmail.com> | 2009-11-15 19:44:47 -0800 |
|---|---|---|
| committer | Andy Staudacher <andy.st@gmail.com> | 2009-11-15 19:44:47 -0800 |
| commit | 0733dc37fda27a5ba35f9020edf3c66aa41a95a0 (patch) | |
| tree | 6877946232f1b01b1c8709054c689f6658cef34f /modules/search/helpers/search.php | |
| parent | 218493c50be9362d4abed6900a816308fee5d978 (diff) | |
| parent | 9379308f91a476f790fb8d444536719535c584e4 (diff) | |
Merge commit 'upstream/master'
Conflicts:
modules/gallery/tests/xss_data.txt
Diffstat (limited to 'modules/search/helpers/search.php')
| -rw-r--r-- | modules/search/helpers/search.php | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 0080b4ce..8c3bd3ab 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -22,30 +22,25 @@ class search_Core { $db = Database::instance(); $q = $db->escape_str($q); - if (!user::active()->admin) { - foreach (user::group_ids() as $id) { + if (!identity::active_user()->admin) { + foreach (identity::group_ids_for_active_user() as $id) { $fields[] = "`view_$id` = TRUE"; // access::ALLOW } - $access_sql = "AND (" . join(" AND ", $fields) . ")"; + $access_sql = "AND (" . join(" OR ", $fields) . ")"; } else { $access_sql = ""; } - // Count the total number of rows. We can't do this with our regular query because of the - // limit statement. It's possible that if we get rid of the limit (but keep the offset) on - // the 2nd query and combine the two, it might be faster than making 2 separate queries. - $count_query = "SELECT COUNT(*) AS c " . - "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " . - "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . - $access_sql; - $count = $db->query($count_query)->current()->c; - - $query = "SELECT {items}.*, MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " . + $query = + "SELECT SQL_CALC_FOUND_ROWS {items}.*, " . + " MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " . "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " . "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . $access_sql . "ORDER BY `score` DESC " . "LIMIT $limit OFFSET $offset"; + $data = $db->query($query); + $count = $db->query("SELECT FOUND_ROWS() as c")->current()->c; return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } @@ -57,7 +52,7 @@ class search_Core { list ($remaining) = search::stats(); if ($remaining) { site_status::warning( - t('Your search index needs to be updated. <a href="%url" class="gDialogLink">Fix this now</a>', + t('Your search index needs to be updated. <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__")))), "search_index_out_of_date"); } |
