Ignore:
Timestamp:
Feb 26, 2011, 4:28:24 PM (13 years ago)
Author:
patdenice
Message:

Add display option. Optimizations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PWG_Stuffs/include/class.inc.php

    r9369 r9383  
    99  var $blocks = array();
    1010  var $pos = 'begin';
     11  var $template_var = array();
    1112
    1213  function stuffs()
    1314  {
     15    global $page, $template;
     16
     17    if ($page['stuffs_section'] == 'on_picture')
     18    {
     19      $this->template_var['begin'] = 'PLUGIN_PICTURE_BEFORE';
     20      $this->template_var['end'] = 'PLUGIN_PICTURE_AFTER';
     21      $template->set_prefilter('header', array('stuffs', 'prefilter_picture_css'));
     22      pwgs_picture_special_sections();
     23    }
     24    else
     25    {
     26      $this->template_var['begin'] = 'PLUGIN_INDEX_CONTENT_BEFORE';
     27      $this->template_var['end'] = 'PLUGIN_INDEX_CONTENT_AFTER';
     28      $template->set_prefilter( 'header', array('stuffs', 'prefilter_index_css') );
     29    }
     30
    1431    $this->get_user_groups();
    1532    $this->get_modules();
     
    3552    global $page, $user;
    3653
     54    if (!isset($page['stuffs_section'])) return;
     55
    3756    $query = '
    38 SELECT id, name, path, parent, datas, groups, show_title, id_line, width
     57SELECT DISTINCT id, name, path, parent, datas, groups, show_title, id_line, width
    3958FROM ' . STUFFS_TABLE . '
    40 WHERE users LIKE "%' . $user['status'] . '%"
    41 ';
    42 
    43     $script = script_basename();
    44     if ($script == 'index')
    45     {
    46       $query .= !$page['is_homepage'] ?
    47         'AND on_cats = "true"' :
    48         'AND on_home = "true"' ;
    49     }
    50     elseif ($script == 'picture')
    51     {
    52       $query .= 'AND on_picture = "true"';
    53     }
    54     else return;
    55 
    56     $query .= '
    57 ORDER BY pos ASC;';
     59LEFT JOIN ' . USER_GROUP_TABLE . '
     60  ON user_id = '.$user['id'].'
     61WHERE (users IS NULL OR users LIKE "%' . $user['status'] . '%")
     62  AND (groups IS NULL OR groups REGEXP CONCAT("(^|,)",group_id,"(,|$)"))
     63  AND level <= '.$user['level'].'
     64  AND '.$page['stuffs_section'].' = "true"
     65ORDER BY pos ASC
     66;';
    5867
    5968    $result = pwg_query($query);
     
    8695      {
    8796        continue;
    88       }
    89       if (!empty($module['groups']))
    90       {
    91         $authorized_groups = explode(',', $module['groups']);
    92         if (array_intersect($this->user_groups, $authorized_groups) == array()) continue;
    9397      }
    9498
Note: See TracChangeset for help on using the changeset viewer.