4 * \defgroup Block Block Module
9 * Determines if a block wil be visible or not
11 * A pointer to the $block array
13 * Fix/Create def_view and everything else, there is a lot to be done here
15 function block_visibility(&$block) {
17 global $user, $x, $xx;
19 //By default it will not be displayed
20 $by_view = $by_role = $by_page = FALSE;
22 //This is not complete
24 if($block['def_view'] == 'av'){
27 elseif($block['def_view'] == ''){
34 //Determine if this role will see it
35 if($block['roles'] != ''){
36 $block['roles'] = explode(',', $block['roles']);
37 foreach($user['roles'] as $userrole => $role){
38 if(in_array($userrole, $block['roles'])){
47 //Determine if this page will see it
48 if($block['pages'] != ''){
49 if($block['pages_type'] < 2){
50 $page_match = path_match_path($x, $block['pages']);
51 //In all pages except the following ones
52 if($block['pages_type'] == 0 && $page_match == 0){
55 //Only in the following pages
56 elseif($block['pages_type'] == 1 && $page_match){
62 $by_page = eval($block['pages']);
65 //If nothing came will make it true by default
70 if($by_role && $by_page){
77 * Implementation of hook_ini
78 * Setup all blocks for the current page
82 global $db, $skin, $block_display, $block_settings, $redirect;
89 $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);
95 foreach($blocks as $block){
97 //Lets see if it will be displayed
98 if(block_visibility($block)){
103 if($block['settings'] != ''){
104 $block_settings['settings'] = unserialize($block['settings']);
105 foreach($block_settings['settings'] as $conf => $details){
106 $block_settings[$conf] = $details;
108 unset($block_settings['settings']);
111 $block['body'] = text_process($block['body'], $block['format']);
114 $block['title'] = ($block['title_ov'] != '' ? ($block['title_ov'] == '<none>' ? '' : $block['title_ov']) : $block['title']);
117 $contents = array('module' => $block['module'],'blockid' => $block['bid'], 'title' => ($block['title_ov'] != '' ? ($block['title_ov'] == '<none>' ? '' : $block['title_ov']) : $block['title']), 'body' => $block['body']);
118 $skin['regions'][$block['region']] .= skin_dressme_tpl('block', 'block_VAR_', $contents, $block['bid']);