PHP Classes

File: usage.php

Recommend this page to a friend!
  Classes of Michael Ziegler   MyACL   usage.php   Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: Demo how to use this class
Class: MyACL
Control user access with Zend_ACL and a database
Author: By
Last change: doesnt include Zend/Db anymore, as acl.class.php does it already
Date: 16 years ago
Size: 727 bytes


Class file image Download

// Add the Zend Framework dir to our include_path
ini_set( "include_path", ini_get( "include_path" ).":/dir/to/zend/library" );

// We need the MyACL class
// it includes the Db adapter itself, so no need to do that here
require_once './acl.class.php';

// Connect to database
$db = Zend_Db::factory( 'mysqli', array(
'host' => 'localhost',
'username' => 'r00t',
'password' => 'w00t',
'dbname' => 't00t'

// Cre8 ACL reading from the database the adapter is connected to
$acl = new MyACL( $db );

// Now let's ask some questions, shall we?
var_dump( $acl->isAllowed( 'Editors', 'TextWritingProggie', null ) );
var_dump( $acl->isAllowed( 'Publishers', 'svn', 'commit' ) );