Welcome Guest, Not a member yet? Register   Sign In
Implementing MM_USERGROUP in codeIgniter
#4

[eluser]osci[/eluser]
array("1","2","3","4") creates keys as of 0,1,2,3 respectively.
if something is not found in array_search it returns false otherwise it returns that key.
I don't understand why the minus is used in the comparisons.
based on your code and taking into consideration the false occasion

Code:
$accessLevels = array("1","2","3","4");
$validLevel = $_SESSION['MM_UserGroup'];

$search_result = array_search($validLevel, $accessLevels);

if ($search_result === FALSE)
{
   // code for access denied  
} else {
   if ($search_result < 1)
   {
      $this->load->view('systemadmin');
   }
   if ($search_result < 2)
   {
      $this->load->view('administration');
   }
   if ($search_result < 3)
   {
      $this->load->view('helpdesk');
   }
   if ($search_result < 4)
   {
      $this->load->view('ceo');
   }
}

The way your code is structured if you are a sysadmin you see all views.
Should sysadmin see all views or only his?


Messages In This Thread
Implementing MM_USERGROUP in codeIgniter - by El Forum - 02-10-2011, 03:03 AM
Implementing MM_USERGROUP in codeIgniter - by El Forum - 02-10-2011, 03:53 AM
Implementing MM_USERGROUP in codeIgniter - by El Forum - 02-10-2011, 04:03 AM
Implementing MM_USERGROUP in codeIgniter - by El Forum - 02-10-2011, 04:39 AM
Implementing MM_USERGROUP in codeIgniter - by El Forum - 02-10-2011, 05:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB