All pastes #191922 Raw Edit

Mine

public text v1 · immutable
·published 2006-10-05 14:10 UTC
rendered paste body
<?php
/**
* Author  =  Ruud Alberts
* Date    =  2005-11-24
* Version =  1.0
* File    =  lib/authorization.php
*
* Description:
* Class Authorization registers permission in the session
* variable 'auth'. Must also be used to check if a certain
* user has a permission to do something
**/
class Authorization{

	/**
	* @desc register a session for a certain permission
	* @param array, array
	* @return void
	* @access public
	**/
  public function register($perm, $declined){
    foreach($perm AS $key => $val){
      if(!array_key_exists($key, $declined)){
        $_SESSION['perm'][$key] = true;
      }
    }
  }

	/**
	* @desc check if the user has a certain permission
	* @param integer
	* @return bool
	* @access public
	**/
  public function hasPermission($permid){
    if(isset($_SESSION['perm'][$permid])){
      return $_SESSION['perm'][$permid];
    }
    return false;
  }
}
?>