Skip to content

Commit

Permalink
Fixed issues with role names not showing properly on the users displa…
Browse files Browse the repository at this point in the history
…y page.
  • Loading branch information
eyedol committed Oct 7, 2008
1 parent 2093551 commit e12c771
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
RewriteEngine On

# Installation directory
RewriteBase /
RewriteBase /ushahidi

# Protect application and system files from being viewed
# RewriteRule ^(application|modules|system) - [F,L]
Expand Down
2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* then a full URL will be used, eg: http://localhost/ushahidi/. If it only includes
* the path, and a site_protocol is specified, the domain will be auto-detected.
*/
$config['site_domain'] = '/';
$config['site_domain'] = '/ushahidi/';

/**
* Force a default protocol to be used by the site. If no site_protocol is
Expand Down
1 change: 1 addition & 0 deletions application/controllers/admin/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function index()
$this->template->content->total_items = $pagination->total_items;
$this->template->content->users = $users;
$this->template->content->roles = $roles;
$this->template->content->roles_users = $this->roles_users;


// Javascript Header
Expand Down
4 changes: 3 additions & 1 deletion application/models/roles_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public function __construct($id = NULL)
*/
public function get_role_id( $user_id ){
//TODO write necessary code to fetch role id specific to a user id.

$this->db->where('user_id', $user_id );
$query = $this->db->select('role_id')->from('roles_users')->get();
return $query->current();
}

/**
Expand Down
23 changes: 15 additions & 8 deletions application/views/admin/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,19 @@
$name = $user->name;
$email = $user->email;

// Get Roles
foreach(ORM::factory('role')->find_all() as $role)
{
if ($user->has(new Role_Model($role->name)))
$role = $role->name;
}
//ORM can do much better, will look
// into it more.
//get role ids
$role_id =
$roles_users->get_role_id($user_id );

$roles =
ORM::factory('role')->where('id',
$role_id->role_id )->find();

//get role names
$role = $roles->name;

?>
<tr>

Expand All @@ -142,13 +149,13 @@
'<?php echo(rawurlencode($user_id)); ?>',
'<?php echo(rawurlencode($username)); ?>',
'<?php echo(rawurlencode($name)); ?>',
'<?php echo(rawurlencode($role));?>',
'<?php echo(rawurlencode($role_id->role_id));?>',
'<?php echo(rawurlencode($email)); ?>')">Edit</a></li>
<li><a href="#" onclick="userAction('d',
'<?php echo(rawurlencode($user_id)); ?>',
'<?php echo(rawurlencode($username)); ?>',
'<?php echo(rawurlencode($name)); ?>',
'<?php echo(rawurlencode($role));?>',
'<?php echo(rawurlencode($role_id->role_id));?>',
'<?php echo(rawurlencode($email)); ?>',
'DELETE');" class="del">Delete</a></li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions application/views/admin/users_js.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function fillFields(id, username, name, role, email)
$("#user_id").attr("value", unescape(id));
$("#username").attr("value", unescape(username));
$("#name").attr("value", unescape(name));
$('#role').attr("value",unescape( $('#role').val() ) );
$('#role').attr("value",unescape( role ) );
$('#email').attr("value",unescape( email ) );

}
Expand All @@ -26,7 +26,7 @@ function userAction ( action, user_id,username,
$("#user_id").attr("value",user_id);
$("#username").attr("value", unescape(username));
$("#name").attr("value", unescape(name));
$('#role').attr("value",unescape( $('#role').val() ) );
$('#role').attr("value",unescape( role ) );
$('#email').attr("value",unescape( email ) );

// Submit Form
Expand Down

0 comments on commit e12c771

Please sign in to comment.