Hi Apple,
I just made some modified lines in these files. Just add the modified lines into yours.
Just see the comment "MY CUSTOM CODE FOR ROLE NAME"
I couldn't share whole file because too long and it will make you confuse to read those a lot of lines
For current_user.inc (location at includes/current_user.inc)
class current_user
{
var $user;
var $loginname;
var $username;
var $name;
var $company; // user's company
var $pos;
var $access;
var $timeout;
var $last_act;
var $role_set = false;
var $old_db;
var $logged;
var $ui_mode = 0;
var $prefs;
var $cur_con; // current db connection (can be different from $company for superuser)
/* custom */
var $rolename; // MY CUSTOM CODE FOR ROLE NAME
var $org_id;
function current_user()
{
global $def_coy;
$this->loginname = $this->username = $this->name = "";
$this->company = isset($def_coy)? $def_coy : 0;
$this->logged = false;
$this->prefs = new user_prefs();
}
function logged_in()
{
return $this->logged;
}
function set_company($company)
{
$this->company = $company;
}
function login($company, $loginname, $password)
{
global $security_areas, $security_groups, $security_headings, $path_to_root;
$this->set_company($company);
$this->logged = false;
$Auth_Result = get_user_for_login($loginname, $password);
if (db_num_rows($Auth_Result) > 0)
{
$myrow = db_fetch($Auth_Result);
$this->old_db = isset($myrow["full_access"]);
if (! @$myrow["inactive"]) {
if ($this->old_db) {
// Transition code:
// db was not yet upgraded after source update to v.2.2
// give enough access for admin user to continue upgrade
if (!isset($security_groups) || !isset($security_headings)) {
echo "<center><br><br><font size='5' color='red'><b>";
echo _('Before software upgrade you have to include old $security_groups and $security_headings arrays from old config.php file to the new one.');
echo '<br>'."<a href=$path_to_root/index.php>"._("Back")."</a>";
echo "</b></font><br><br></center>";
exit;
}
$this->access = $myrow["full_access"];
if (in_array(20, $security_groups[$this->access]))
// temporary access for admin users
$this->role_set[] = $security_areas['SA_SOFTWAREUPGRADE'][0];
else {
echo "<center><br><br><font size='5' color='red'><b>";
echo _('System is available for site admin only until full database upgrade');
echo "</b></font><br><br></center>";
exit;
}
} else {
$this->role_set = array();
$this->access = $myrow["role_id"];
// store area codes available for current user role
$role = get_security_role($this->access);
if (!$role)
return false;
foreach( $role['areas'] as $code )
// filter only area codes for enabled security sections
if (in_array($code&~0xff, $role['sections']))
$this->role_set[] = $code;
$this->rolename = $role['role']; // MY CUSTOM CODE FOR ROLE NAME
}
$this->name = $myrow["real_name"];
$this->pos = $myrow["pos"];
$this->org_id = $myrow["org_id"];
$this->loginname = $loginname;
$this->username = $this->loginname;
$this->prefs = new user_prefs($myrow);
$this->user = @$myrow["id"];
update_user_visitdate($this->username);
$this->logged = true;
$this->last_act = time();
$this->timeout = session_timeout();
}
}
return $this->logged;
}
.....
.....
For security_db.inc (location at admin/db/security_db.inc)
..........
function get_security_role($id)
{
$sql = "SELECT * FROM ".TB_PREF."security_roles WHERE id=".(int)$id;
$ret = db_query($sql, "could not retrieve security roles");
$row = db_fetch($ret);
if ($row != false) {
$row['role'] = $row['role']; // MY CUSTOM CODE FOR ROLE NAME
$row['areas'] = explode(';', $row['areas']);
$row['sections'] = explode(';', $row['sections']);
}
return $row;
}
...................
renderer.php (location at themes/default/renderer.php)
..............
echo "<p id='user-info'>" . _("Welcome") . ", " . $_SESSION["wa_current_user"]->name .
" (" . $_SESSION["wa_current_user"]->rolename . ")</p>";
..............
now I can access rolename via $_SESSION['wa_current_user']->rolename
Good luck brother
Feel free to ask me if you still need help