<?php

	/**
	 * Simple Security class to check user role permissions.
	 * 
	 * @link http://www.oldauntie.org
	 * @author Maggie Marple <oldauntie@oldauntie.org>
	 * @version 1.0
	 */
    class Security {
        const ROLE_ADMIN	= '1';
        const ROLE_USER		= '2';
        const ROLE_VIEWER	= '3';
        
        /**
         * Creates a new Security object.
         *
         */
        public function __construct() {
			
        }
        
        /**
         * Sets a value for replacing a specific tag.
         *
         * @param int $permission_rid the requested/needed role to access a certain function
         * @param int $uid the value to replace
         * 
         * @return boolean
         */
        public static function checkByUid($permission_rid, $uid) {
            
            $bRV = false;
            $con = new Connection();
            
            $sql = "SELECT uid FROM users WHERE rid <= " . $permission_rid . " AND uid = " . $uid;;
            
            $rv = $con->selectOneValue($sql);
            
            if( isset( $rv ) == true && empty( $rv ) == false && $rv != false ){
				$bRV = true;
			}
            
            return $bRV;
        }
        
        
    }

?>
