Ignore:
Timestamp:
Mar 9, 2006, 11:46:28 PM (18 years ago)
Author:
rub
Message:

Step 2 improvement issue 0000301:

o Add and use Functions Check of status
o Restricted Access for user generic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_user.inc.php

    r1070 r1072  
    538538
    539539/*
    540  * Return if current is an administrator
     540 * Return if current user have access to access_type definition
     541 * Test does with user status
     542 * @return bool
     543*/
     544function is_autorize_status($access_type)
     545{
     546  global $user;
     547
     548  $access_type_status = ACCESS_NONE;
     549  if (isset($user['status']))
     550  {
     551    switch ($user['status'])
     552    {
     553      case 'guest':
     554      case 'generic':
     555      {
     556        $access_type_status = ACCESS_GUEST;
     557        break;
     558      }
     559      case 'normal':
     560      {
     561        $access_type_status = ACCESS_CLASSIC;
     562        break;
     563      }
     564      case 'admin':
     565      {
     566        $access_type_status = ACCESS_ADMINISTRATOR;
     567        break;
     568      }
     569      case 'webmaster':
     570      {
     571        $access_type_status = ACCESS_WEBMASTER;
     572        break;
     573      }
     574    }
     575  }
     576
     577  return ($access_type_status >= $access_type);
     578}
     579
     580/*
     581 * Check if current user have access to access_type definition
     582 * Stop action if there are not access
     583 * Test does with user status
     584 * @return none
     585*/
     586function check_status($access_type)
     587{
     588  global $lang;
     589
     590  if (!is_autorize_status($access_type))
     591  {
     592    echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />';
     593    echo '<a href="'.PHPWG_ROOT_PATH.'identification.php">'.$lang['identification'].'</a></div>';
     594    exit();
     595  }
     596}
     597
     598/*
     599 * Return if current user is an administrator
    541600 * @return bool
    542601*/
    543602function is_admin()
    544603{
    545   global $user;
    546  
    547   return ($user['status'] == 'webmaster' or $user['status'] == 'admin') ? true : false;
     604  return is_autorize_status(ACCESS_ADMINISTRATOR);
    548605}
    549606
Note: See TracChangeset for help on using the changeset viewer.