Hi people,

I'm trying to set a Tabset of two tabs. The first with the Latest (unblocked) member and the second with a link to register or to get involved. Till now, I have this PHP code working :

<?php

$tabs = array();

  $tabs['example1'] = array(
    '#type' => 'tabset',
  );
  $tabs['example1']['tab1'] = array(
    '#type' => 'tabpage',
    '#title' => t('You?'),
    '#content' => l(t('Join the Intal community!'), "user/register"),
  );
$result = db_query_range('SELECT uid FROM {users} WHERE status != 0 ORDER BY uid DESC', 0, 1);
$items = array();
while ($row = db_fetch_object($result)) {
  $user = user_load(array('uid' => $row->uid));
 }

$pic = theme('user_picture', $user);

if ($user->picture) {
$sec_tab_content = l($pic, 'user/'.$user->uid, array(), NULL,NULL,FALSE,TRUE);
$sec_tab_content .= "<br class=\"clearit\"/>";
}

if (!$user->picture) {

$theme_path = path_to_theme();
$pic = "<img src=\"/".$theme_path."/images/profile.png\"  alt=\"profile\" class=\"profile-pic\" />";
$sec_tab_content = l($pic, 'user/'.$user->uid, array(), NULL,NULL,FALSE,TRUE);
$sec_tab_content .= "<br />";
$sec_tab_content .= " &raquo; ".l($user->name,'user/'.$user->uid);

}

$tabs['example1']['tab2'] = array(
    '#type' => 'tabpage',
    '#title' => t('Our latest member'),
    '#content' => $sec_tab_content
  );

  return tabs_render($tabs);
?>

But I want to have a different link for different roles. One link for Anonymous user, one for Authentificated user and an other one for the other roles. So i tries this code :

<?php
global $user;

if ($user->uid) {
  $allowed_roles = array('admin','member','staff');
  if (is_array($role = $user->roles)) {
    if(count(array_intersect($user->roles, $allowed_roles)) > 0) {
      $fst_tab_content = l(t('Go to the help page'), "node/5429"); 
    }
    else {
      $fst_tab_content = l(t('Become a Member'), "node/5428"); 
    }
  }
} 
else {
  $fst_tab_content = l(t('Join the Intal community!'), "user/register");
}

$tabs = array();

$tabs['example1'] = array(
   '#type' => 'tabset',
);

  $tabs['example1']['tab1'] = array(
    '#type' => 'tabpage',
    '#title' => t('You?'),
    '#content' => $fst_tab_content,
  );
$result = db_query_range('SELECT uid FROM {users} WHERE status != 0 ORDER BY uid DESC', 0, 1);
$row = array();
while ($row = db_fetch_object($result)) {
  $user = user_load(array('uid' => $row->uid));
 }

$pic = theme('user_picture', $user);

if ($user->picture) {
$sec_tab_content = l($pic, 'user/'.$user->uid);
$sec_tab_content .= "<br class=\"clearit\"/>";
}

if (!$user->picture) {

$theme_path = path_to_theme();
$pic = "<img src=\"/".$theme_path."/images/profile.png\"  alt=\"profile\" class=\"profile-pic\" />";
$sec_tab_content = l($pic, 'user/'.$user->uid);
$sec_tab_content .= "<br />";
$sec_tab_content .= " &raquo; ".l($user->name,'user/'.$user->uid);

}

$tabs['example1']['tab2'] = array(
    '#type' => 'tabpage',
    '#title' => t('Our latest member'),
    '#content' => $sec_tab_content,
  );

  return tabs_render($tabs);
?>

The problem with this code is that when I submit changes to the block, my session becomes the latest member session and I cannot logout no more. The solution, I found to restore sessions is modifying settings.php to disable all custom blocks.

I'm a php beginner so excuse me if my question seems stupid ;-)
Thank you for your help.

Rafik

Comments

d------’s picture