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

Fixed MANTIS-4321 (side_tag_cloud block doesn't check permissions to content...

Fixed MANTIS-4321 (side_tag_cloud block doesn't check permissions to content behind tags (keywords))
parent 32b6e6ed
Loading
Loading
Loading
Loading
+0 −0

File changed.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

+2 −0
Original line number Diff line number Diff line
@@ -4,11 +4,13 @@ BLOCK_side_tag_cloud_USE=This is a common Web 2.0 feature, designed to provide a
BLOCK_side_tag_cloud_PARAM_param_TITLE=Content type
BLOCK_side_tag_cloud_PARAM_title_TITLE=Title
BLOCK_side_tag_cloud_PARAM_zone_TITLE=Zone
BLOCK_side_tag_cloud_PARAM_apply_permissions_TITLE=Apply permissions
BLOCK_side_tag_cloud_PARAM_max_TITLE=Maximum to show
BLOCK_side_tag_cloud_PARAM_param=You may use this parameter to limit the cloud to a specific content type (hook-type: 'systems/meta'). Default: ''.
BLOCK_side_tag_cloud_PARAM_zone=Advanced feature. The zone to look for the search module in. Default: search for it.
BLOCK_side_tag_cloud_PARAM_max=The maximum number of tags to show (the most frequent of all will be shown with priority). Default: '30'.
BLOCK_side_tag_cloud_PARAM_title=The title for the box. Default: 'Tag cloud'.
BLOCK_side_tag_cloud_PARAM_apply_permissions=Whether to omit keywords from non-accessible content. This will impact performance significantly. Default: '0'.
TAG_CLOUD=Tag cloud
TAGS=Tags
BLOCK_main_search_DESCRIPTION=Place a search box.
+15 −22
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class Block_side_tag_cloud
        $info['hack_version'] = null;
        $info['version'] = 3;
        $info['locked'] = false;
        $info['parameters'] = array('param', 'title', 'zone', 'max');
        $info['parameters'] = array('param', 'title', 'zone', 'max', 'apply_permissions');
        return $info;
    }

@@ -49,7 +49,8 @@ class Block_side_tag_cloud
    public function caching_environment()
    {
        $info = array();
        $info['cache_on'] = 'array(array_key_exists(\'title\',$map)?$map[\'title\']:do_lang(\'search:TAG_CLOUD\'),array_key_exists(\'max\',$map)?intval($map[\'max\']):30,array_key_exists(\'zone\',$map)?$map[\'zone\']:\'_SEARCH\',array_key_exists(\'param\',$map)?$map[\'param\']:\'\')';
        $info['cache_on'] = 'array(array_key_exists(\'title\',$map)?$map[\'title\']:do_lang(\'search:TAG_CLOUD\'),array_key_exists(\'max\',$map)?intval($map[\'max\']):30,array_key_exists(\'zone\',$map)?$map[\'zone\']:\'_SEARCH\',array_key_exists(\'param\',$map)?$map[\'param\']:\'\',((array_key_exists(\'apply_permissions\', $map) ? intval($map[\'apply_permissions\']) : 0) == 1))';
        $info['special_cache_flags'] = CACHE_AGAINST_DEFAULT | CACHE_AGAINST_PERMISSIVE_GROUPS;
        $info['ttl'] = (get_value('no_block_timeout') === '1') ? 60 * 60 * 24 * 365 * 5/*5 year timeout*/ : 60 * 1;
        return $info;
    }
@@ -65,9 +66,11 @@ class Block_side_tag_cloud
        require_lang('search');
        require_css('search');
        require_code('content');
        require_code('search');

        $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('search');
        $max_tags = array_key_exists('max', $map) ? intval($map['max']) : 30;
        $apply_permissions = ((array_key_exists('apply_permissions', $map) ? intval($map['apply_permissions']) : 0) == 1);

        $tags = array();
        $largest_num = 0;
@@ -78,37 +81,27 @@ class Block_side_tag_cloud
        // Find all keywords, hence all tags
        $limit_to = array_key_exists('param', $map) ? $map['param'] : '';
        if ($limit_to != '') {
            $where = '';
            $limit_to_arr = array();
            foreach (explode(',', $limit_to) as $l) {
                if ($where != '') {
                    $where .= ' OR ';
                }
                $where .= db_string_equal_to('meta_for_type', $l);
                $limit_to_arr[] = trim($l);

                $l2 = convert_composr_type_codes('seo_type_code', $l, 'search_hook');
                $search_limiter['search_' . $l2] = 1;
            }
            $search_limiter['all_defaults'] = '0';
        } else {
            $where = '1=1';
        }
        $sql = '
            SELECT
                ' . $GLOBALS['SITE_DB']->translate_field_ref('meta_keyword') . ' AS meta_keyword,
                COUNT(*) AS cnt
            FROM ' . get_table_prefix() . 'seo_meta_keywords m
            WHERE ' . $where . '
            GROUP BY ' . $GLOBALS['SITE_DB']->translate_field_ref('meta_keyword') . '
            ORDER BY COUNT(*) DESC';
        $meta_rows = $GLOBALS['SITE_DB']->query($sql, 300/*reasonable limit*/, null, false, false, array('meta_keyword' => 'SHORT_TRANS'));
        foreach ($meta_rows as $mr) {
            $keyword = $mr['meta_keyword'];
            $limit_to_arr = null;
        }
        $keywords = perform_keyword_search($limit_to_arr, null, $max_tags * 2, $apply_permissions);
        foreach ($keywords as $keyword => $cnt) {
            if (!is_string($keyword)) {
                $keyword = strval($keyword);
            }
            if (strlen(is_numeric($keyword) ? strval(intval($keyword)) : $keyword) < 4) {
                continue; // Won't be indexed, plus will uglify the tag list
            }
            $tags[$keyword] = $mr['cnt'];
            $tags[$keyword] = $cnt;
        }
        arsort($tags);
        $_tags = $tags;
        $tags = array();
        foreach ($_tags as $tag => $count) {
+2 −2
Original line number Diff line number Diff line
@@ -46,8 +46,8 @@ class Hook_content_meta_aware_banner_type
            'parent_category_meta_aware_type' => null,
            'is_category' => true,
            'is_entry' => false,
            'category_field' => null, // For category permissions
            'category_type' => null, // For category permissions
            'category_field' => 'id', // For category permissions
            'category_type' => 'banner_type', // For category permissions
            'parent_spec__table_name' => null,
            'parent_spec__parent_name' => null,
            'parent_spec__field_name' => null,
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ class Hook_content_meta_aware_news_category
            'parent_spec__table_name' => null,
            'parent_spec__parent_name' => null,
            'parent_spec__field_name' => null,
            'category_field' => null, // For category permissions
            'category_field' => 'id', // For category permissions
            'category_is_string' => false,

            'title_field' => 'nc_title',
Loading