Commit a0551b34 authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4431 (Various minor search bugs (internal issues / issues in...

Fixed MANTIS-4431 (Various minor search bugs (internal issues / issues in unsupported configurations))
parent d4d7f68f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -120,15 +120,17 @@ class Hook_search_catalogue_categories extends FieldsSearchHook
        }
        $this->_handle_date_check($cutoff, 'cc_add_date', $where_clause);
        if (!$GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
            if (get_value('disable_cat_cat_perms') !== '1') {
                $where_clause .= ' AND ';
                $where_clause .= 'z.category_name IS NOT NULL';
            }
            $where_clause .= ' AND ';
            $where_clause .= 'p.category_name IS NOT NULL';
        }

        $table = 'catalogue_categories r';
        $g_or = _get_where_clause_groups(get_member());
        if ($g_or != '') {
        if ($g_or !== null) {
            $table .= ((get_value('disable_cat_cat_perms') === '1') ? '' : (' JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access z ON (' . db_string_equal_to('z.module_the_name', 'catalogues_category') . ' AND z.category_name=r.id AND ' . str_replace('group_id', 'z.group_id', $g_or) . ')')) . ' JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access p ON (' . db_string_equal_to('p.module_the_name', 'catalogues_catalogue') . ' AND p.category_name=r.c_name AND ' . str_replace('group_id', 'p.group_id', $g_or) . ')';
        }

+4 −2
Original line number Diff line number Diff line
@@ -192,8 +192,10 @@ class Hook_search_catalogue_entries extends FieldsSearchHook
        }
        $this->_handle_date_check($cutoff, 'r.ce_add_date', $where_clause);
        if (!$GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
            if (get_value('disable_cat_cat_perms') !== '1') {
                $where_clause .= ' AND ';
                $where_clause .= 'z.category_name IS NOT NULL';
            }
            $where_clause .= ' AND ';
            $where_clause .= 'p.category_name IS NOT NULL';
        }
@@ -225,7 +227,7 @@ class Hook_search_catalogue_entries extends FieldsSearchHook
            if (is_null($title_field)) {
                return array(); // No fields in catalogue -- very odd
            }
            if ($g_or == '') {
            if ($g_or === null) {
                $rows = get_search_rows('catalogue_entry', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, $table, $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*,r.id AS id,r.cc_id AS r_cc_id,' . $title_field . ' AS b_cv_value' . $extra_select, $nontrans_fields);
            } else {
                $rows = get_search_rows('catalogue_entry', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, $table . ' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access z ON (' . db_string_equal_to('z.module_the_name', 'catalogues_category') . ' AND z.category_name=r.cc_id AND ' . str_replace('group_id', 'z.group_id', $g_or) . ') LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access p ON (' . db_string_equal_to('p.module_the_name', 'catalogues_catalogue') . ' AND p.category_name=r.c_name AND ' . str_replace('group_id', 'p.group_id', $g_or) . ')', $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*,r.id AS id,r.cc_id AS r_cc_id,' . $title_field . ' AS b_cv_value' . $extra_select, $nontrans_fields);
@@ -249,7 +251,7 @@ class Hook_search_catalogue_entries extends FieldsSearchHook

            $join .= $privacy_join;

            if ($g_or == '') {
            if ($g_or === null) {
                $rows = get_search_rows('catalogue_entry', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'catalogue_fields f LEFT JOIN ' . get_table_prefix() . 'catalogue_entries r ON (r.c_name=f.c_name)' . $join, $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*,r.id AS id,r.cc_id AS r_cc_id' . $extra_select, $non_trans_fields);
            } else {
                $rows = get_search_rows('catalogue_entry', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'catalogue_fields f LEFT JOIN ' . get_table_prefix() . 'catalogue_entries r ON (r.c_name=f.c_name)' . $join . ((get_value('disable_cat_cat_perms') === '1') ? '' : (' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access z ON (' . db_string_equal_to('z.module_the_name', 'catalogues_category') . ' AND z.category_name=r.cc_id AND ' . str_replace('group_id', 'z.group_id', $g_or) . ')')) . ' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access p ON (' . db_string_equal_to('p.module_the_name', 'catalogues_catalogue') . ' AND p.category_name=r.c_name AND ' . str_replace('group_id', 'p.group_id', $g_or) . ')', $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*,r.id AS id,r.cc_id AS r_cc_id' . $extra_select, $non_trans_fields);
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ class Hook_search_comcode_pages extends FieldsSearchHook
        $this->_get_search_parameterisation_advanced_for_content_type('_comcode_page', $table, $where_clause, $trans_fields, $nontrans_fields, db_function('CONCAT', array('r.the_zone', 'r.the_page')));

        // Calculate and perform query
        if ($g_or == '') {
        if ($g_or === null) {
            $rows = get_search_rows('comcode_page', 'the_zone:the_page', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, $table, $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.the_zone,r.the_page', $nontrans_fields);
        } else {
            $rows = get_search_rows('comcode_page', 'the_zone:the_page', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, $table . ' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_zone_access z ON (z.zone_name=r.the_zone AND (' . str_replace('group_id', 'z.group_id', $g_or) . '))', $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*', $nontrans_fields);
+15 −5
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ class Hook_search_catalogue_entries extends FieldsSearchHook
            }

            $g_or = _get_where_clause_groups(get_member());
            if ($g_or != '') {
            if ($g_or !== null) {
                if (get_value('disable_cat_cat_perms') !== '1') {
                    $where_clause .= ' AND EXISTS(SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access z WHERE ' . db_string_equal_to('z.module_the_name', 'catalogues_category') . ' AND z.category_name=i_category_id AND ' . str_replace('group_id', 'z.group_id', $g_or) . ')';
                }
@@ -363,8 +363,10 @@ class Hook_search_catalogue_entries extends FieldsSearchHook
            }
            $this->_handle_date_check($cutoff, 'r.ce_add_date', $where_clause);
            if (!$GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
                if (get_value('disable_cat_cat_perms') !== '1') {
                    $where_clause .= ' AND ';
                    $where_clause .= 'z.category_name IS NOT NULL';
                }
                $where_clause .= ' AND ';
                $where_clause .= 'p.category_name IS NOT NULL';
            }
@@ -374,9 +376,6 @@ class Hook_search_catalogue_entries extends FieldsSearchHook
            }

            $g_or = _get_where_clause_groups(get_member());
            if ($g_or != '') {
                $table .= ((get_value('disable_cat_cat_perms') === '1') ? '' : (' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access z ON (' . db_string_equal_to('z.module_the_name', 'catalogues_category') . ' AND z.category_name=r.cc_id AND ' . str_replace('group_id', 'z.group_id', $g_or) . ')')) . ' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access p ON (' . db_string_equal_to('p.module_the_name', 'catalogues_catalogue') . ' AND p.category_name=r.c_name AND ' . str_replace('group_id', 'p.group_id', $g_or) . ')';
            }

            $privacy_join = '';
            if (addon_installed('content_privacy')) {
@@ -388,6 +387,11 @@ class Hook_search_catalogue_entries extends FieldsSearchHook
            $catalogue_name = get_param_string('catalogue_name', '');
            if ($catalogue_name != '') {
                $table = 'catalogue_entries r';

                if ($g_or !== null) {
                    $table .= ((get_value('disable_cat_cat_perms') === '1') ? '' : (' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access z ON (' . db_string_equal_to('z.module_the_name', 'catalogues_category') . ' AND z.category_name=r.cc_id AND ' . str_replace('group_id', 'z.group_id', $g_or) . ')')) . ' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access p ON (' . db_string_equal_to('p.module_the_name', 'catalogues_catalogue') . ' AND p.category_name=r.c_name AND ' . str_replace('group_id', 'p.group_id', $g_or) . ')';
                }

                list($sup_table, $where_clause, $trans_fields, $nontrans_fields, $title_field) = $this->_get_search_parameterisation_advanced($catalogue_name);
                $table .= $sup_table;
                $table .= $privacy_join;
@@ -400,6 +404,12 @@ class Hook_search_catalogue_entries extends FieldsSearchHook

                $rows = get_search_rows('catalogue_entry', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, $table, $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*,' . $title_field . ' AS b_cv_value' . $extra_select, $nontrans_fields);
            } else {
                $table = 'catalogue_fields f LEFT JOIN ' . get_table_prefix() . 'catalogue_entries r ON (r.c_name=f.c_name)';

                if ($g_or !== null) {
                    $table .= ((get_value('disable_cat_cat_perms') === '1') ? '' : (' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access z ON (' . db_string_equal_to('z.module_the_name', 'catalogues_category') . ' AND z.category_name=r.cc_id AND ' . str_replace('group_id', 'z.group_id', $g_or) . ')')) . ' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access p ON (' . db_string_equal_to('p.module_the_name', 'catalogues_catalogue') . ' AND p.category_name=r.c_name AND ' . str_replace('group_id', 'p.group_id', $g_or) . ')';
                }

                if (multi_lang_content() && $GLOBALS['SITE_DB']->query_select_value('translate', 'COUNT(*)') > 10000) { // Big sites can't do indiscriminate catalogue translatable searches for performance reasons
                    $trans_fields = array();
                    $join = ' JOIN ' . get_table_prefix() . 'catalogue_efv_short c ON (r.id=c.ce_id AND f.id=c.cf_id) LEFT JOIN ' . get_table_prefix() . 'catalogue_efv_long d ON (r.id=d.ce_id AND f.id=d.cf_id)';
@@ -418,7 +428,7 @@ class Hook_search_catalogue_entries extends FieldsSearchHook

                $join .= $privacy_join;

                $rows = get_search_rows('catalogue_entry', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'catalogue_fields f LEFT JOIN ' . get_table_prefix() . 'catalogue_entries r ON (r.c_name=f.c_name)' . $join, $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*' . $extra_select, $non_trans_fields);
                $rows = get_search_rows('catalogue_entry', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, $table . $join, $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*' . $extra_select, $non_trans_fields);
            }
        }

+1 −0
Original line number Diff line number Diff line
@@ -268,6 +268,7 @@ class Hook_search_cns_own_pt extends FieldsSearchHook
            if (!is_guest()) {
                $where_clause .= ' OR r.p_intended_solely_for=' . strval(get_member()) . ' OR r.p_poster=' . strval(get_member());
            }
            $where_clause .= ')';
            $sq = build_search_submitter_clauses('p_poster', $author_id, $author);
            if (is_null($sq)) {
                return array();
Loading