4 * Determines if a block wil be visible or not
6 * A pointer to the $block array
8 * Fix/Create def_view and everything else, there is a lot to be done here
10 function block_visibility(&$block) {
12 global $user, $x, $xx;
14 //By default it will not be displayed
15 $by_view = $by_role = $by_page = FALSE;
17 //This is not complete
19 if($block['def_view'] == 'av'){
22 elseif($block['def_view'] == ''){
29 //Determine if this role will see it
30 if($block['roles'] != ''){
31 $block['roles'] = explode(',', $block['roles']);
32 foreach($user['roles'] as $userrole => $role){
33 if(in_array($userrole, $block['roles'])){
42 //Determine if this page will see it
43 if($block['pages'] != ''){
44 if($block['pages_type'] < 2){
45 $page_match = path_match_path($x, $block['pages']);
46 //In all pages except the following ones
47 if($block['pages_type'] == 0 && $page_match == 0){
50 //Only in the following pages
51 elseif($block['pages_type'] == 1 && $page_match){
57 $by_page = eval($block['pages']);
60 //If nothing came will make it true by default
65 if($by_role && $by_page){
72 * Implementation of hook_ini
73 * Setup all blocks for the current page
77 global $db, $skin, $block_display, $block_settings, $redirect;
84 $blocks = db_query("SELECT b.*, br.* FROM {PRE_}blocks b INNER JOIN {PRE_}blocks_regions br on b.bid = br.bid WHERE skin = '".$skin['name']."' AND status = 1 ORDER BY pos ASC", TRUE);
90 foreach($blocks as $block){
92 //Lets see if it will be displayed
93 if(block_visibility($block)){
98 if($block['settings'] != ''){
99 $block_settings['settings'] = unserialize($block['settings']);
100 foreach($block_settings['settings'] as $conf => $details){
101 $block_settings[$conf] = $details;
103 unset($block_settings['settings']);
106 $block['body'] = text_process($block['body'], $block['format']);
109 $block['title'] = ($block['title_ov'] != '' ? ($block['title_ov'] == '<none>' ? '' : $block['title_ov']) : $block['title']);
112 $contents = array('module' => $block['module'],'blockid' => $block['bid'], 'title' => ($block['title_ov'] != '' ? ($block['title_ov'] == '<none>' ? '' : $block['title_ov']) : $block['title']), 'body' => $block['body']);
113 $skin['regions'][$block['region']] .= skin_dressme_tpl('block', 'block_VAR_', $contents, $block['bid']);