Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add the snaapi codebase.

  • Loading branch information...
commit 26a1295fd7ed95e6edfd9aec46fafe4fec5a8bfb 0 parents
Jeff Verkoeyen authored
Showing with 32,940 additions and 0 deletions.
  1. 0  README
  2. +1 −0  application/.gitignore
  3. +86 −0 application/bootstrap.php
  4. +1 −0  application/bootstrapstrap.php.template
  5. +18 −0 application/config/app.ini
  6. +57 −0 application/controllers/ErrorController.php
  7. +8 −0 application/controllers/IndexController.php
  8. +12 −0 application/controllers/SnaapiController.php
  9. +49 −0 application/layouts/scripts/layout.phtml
  10. +19 −0 application/views/scripts/error/error.phtml
  11. 0  application/views/scripts/index/index.phtml
  12. +1,036 −0 library/Zend/Acl.php
  13. +64 −0 library/Zend/Acl/Assert/Interface.php
  14. +36 −0 library/Zend/Acl/Exception.php
  15. +65 −0 library/Zend/Acl/Resource.php
  16. +37 −0 library/Zend/Acl/Resource/Interface.php
  17. +65 −0 library/Zend/Acl/Role.php
  18. +37 −0 library/Zend/Acl/Role/Interface.php
  19. +266 −0 library/Zend/Acl/Role/Registry.php
  20. +36 −0 library/Zend/Acl/Role/Registry/Exception.php
  21. +79 −0 library/Zend/Amf/Constants.php
  22. +33 −0 library/Zend/Amf/Exception.php
  23. +321 −0 library/Zend/Amf/Parse/Amf0/Deserializer.php
  24. +289 −0 library/Zend/Amf/Parse/Amf0/Serializer.php
  25. +410 −0 library/Zend/Amf/Parse/Amf3/Deserializer.php
  26. +317 −0 library/Zend/Amf/Parse/Amf3/Serializer.php
  27. +64 −0 library/Zend/Amf/Parse/Deserializer.php
  28. +38 −0 library/Zend/Amf/Parse/InputStream.php
  29. +48 −0 library/Zend/Amf/Parse/OutputStream.php
  30. +58 −0 library/Zend/Amf/Parse/Serializer.php
  31. +133 −0 library/Zend/Amf/Parse/TypeLoader.php
  32. +249 −0 library/Zend/Amf/Request.php
  33. +79 −0 library/Zend/Amf/Request/Http.php
  34. +193 −0 library/Zend/Amf/Response.php
  35. +47 −0 library/Zend/Amf/Response/Http.php
  36. +627 −0 library/Zend/Amf/Server.php
  37. +35 −0 library/Zend/Amf/Server/Exception.php
  38. +278 −0 library/Zend/Amf/Util/BinaryStream.php
  39. +57 −0 library/Zend/Amf/Value/ByteArray.php
  40. +181 −0 library/Zend/Amf/Value/MessageBody.php
  41. +80 −0 library/Zend/Amf/Value/MessageHeader.php
  42. +91 −0 library/Zend/Amf/Value/Messaging/AbstractMessage.php
  43. +59 −0 library/Zend/Amf/Value/Messaging/AcknowledgeMessage.php
  44. +42 −0 library/Zend/Amf/Value/Messaging/AsyncMessage.php
  45. +127 −0 library/Zend/Amf/Value/Messaging/CommandMessage.php
  46. +66 −0 library/Zend/Amf/Value/Messaging/ErrorMessage.php
  47. +72 −0 library/Zend/Amf/Value/Messaging/RemotingMessage.php
  48. +153 −0 library/Zend/Amf/Value/TraitsInfo.php
  49. +161 −0 library/Zend/Auth.php
  50. +461 −0 library/Zend/Auth/Adapter/DbTable.php
  51. +230 −0 library/Zend/Auth/Adapter/Digest.php
  52. +38 −0 library/Zend/Auth/Adapter/Exception.php
  53. +847 −0 library/Zend/Auth/Adapter/Http.php
  54. +40 −0 library/Zend/Auth/Adapter/Http/Resolver/Exception.php
  55. +167 −0 library/Zend/Auth/Adapter/Http/Resolver/File.php
  56. +47 −0 library/Zend/Auth/Adapter/Http/Resolver/Interface.php
  57. +261 −0 library/Zend/Auth/Adapter/InfoCard.php
  58. +46 −0 library/Zend/Auth/Adapter/Interface.php
  59. +329 −0 library/Zend/Auth/Adapter/Ldap.php
  60. +284 −0 library/Zend/Auth/Adapter/OpenId.php
  61. +36 −0 library/Zend/Auth/Exception.php
  62. +148 −0 library/Zend/Auth/Result.php
  63. +38 −0 library/Zend/Auth/Storage/Exception.php
  64. +67 −0 library/Zend/Auth/Storage/Interface.php
  65. +96 −0 library/Zend/Auth/Storage/NonPersistent.php
  66. +150 −0 library/Zend/Auth/Storage/Session.php
  67. +245 −0 library/Zend/Cache.php
  68. +221 −0 library/Zend/Cache/Backend.php
  69. +354 −0 library/Zend/Cache/Backend/Apc.php
  70. +125 −0 library/Zend/Cache/Backend/ExtendedInterface.php
  71. +1,003 −0 library/Zend/Cache/Backend/File.php
  72. +98 −0 library/Zend/Cache/Backend/Interface.php
  73. +463 −0 library/Zend/Cache/Backend/Memcached.php
  74. +678 −0 library/Zend/Cache/Backend/Sqlite.php
  75. +269 −0 library/Zend/Cache/Backend/Test.php
  76. +501 −0 library/Zend/Cache/Backend/TwoLevels.php
  77. +215 −0 library/Zend/Cache/Backend/Xcache.php
  78. +316 −0 library/Zend/Cache/Backend/ZendPlatform.php
  79. +628 −0 library/Zend/Cache/Core.php
  80. +31 −0 library/Zend/Cache/Exception.php
  81. +242 −0 library/Zend/Cache/Frontend/Class.php
  82. +145 −0 library/Zend/Cache/Frontend/File.php
  83. +130 −0 library/Zend/Cache/Frontend/Function.php
  84. +105 −0 library/Zend/Cache/Frontend/Output.php
  85. +399 −0 library/Zend/Cache/Frontend/Page.php
  86. +76 −0 library/Zend/Captcha/Adapter.php
  87. +176 −0 library/Zend/Captcha/Base.php
  88. +52 −0 library/Zend/Captcha/Dumb.php
  89. +34 −0 library/Zend/Captcha/Exception.php
  90. +85 −0 library/Zend/Captcha/Figlet.php
  91. +589 −0 library/Zend/Captcha/Image.php
  92. +267 −0 library/Zend/Captcha/ReCaptcha.php
  93. +369 −0 library/Zend/Captcha/Word.php
  94. +433 −0 library/Zend/Config.php
  95. +32 −0 library/Zend/Config/Exception.php
  96. +254 −0 library/Zend/Config/Ini.php
  97. +101 −0 library/Zend/Config/Writer.php
  98. +101 −0 library/Zend/Config/Writer/Array.php
  99. +174 −0 library/Zend/Config/Writer/Ini.php
  100. +140 −0 library/Zend/Config/Writer/Xml.php
  101. +230 −0 library/Zend/Config/Xml.php
  102. +954 −0 library/Zend/Console/Getopt.php
  103. +65 −0 library/Zend/Console/Getopt/Exception.php
  104. +678 −0 library/Zend/Controller/Action.php
  105. +37 −0 library/Zend/Controller/Action/Exception.php
  106. +164 −0 library/Zend/Controller/Action/Helper/Abstract.php
  107. +138 −0 library/Zend/Controller/Action/Helper/ActionStack.php
  108. +77 −0 library/Zend/Controller/Action/Helper/AjaxContext.php
  109. +149 −0 library/Zend/Controller/Action/Helper/AutoComplete/Abstract.php
  110. +87 −0 library/Zend/Controller/Action/Helper/AutoCompleteDojo.php
  111. +82 −0 library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php
  112. +1,394 −0 library/Zend/Controller/Action/Helper/ContextSwitch.php
  113. +266 −0 library/Zend/Controller/Action/Helper/FlashMessenger.php
  114. +117 −0 library/Zend/Controller/Action/Helper/Json.php
  115. +510 −0 library/Zend/Controller/Action/Helper/Redirector.php
  116. +117 −0 library/Zend/Controller/Action/Helper/Url.php
  117. +994 −0 library/Zend/Controller/Action/Helper/ViewRenderer.php
  118. +380 −0 library/Zend/Controller/Action/HelperBroker.php
  119. +280 −0 library/Zend/Controller/Action/HelperBroker/PriorityStack.php
  120. +439 −0 library/Zend/Controller/Dispatcher/Abstract.php
  121. +36 −0 library/Zend/Controller/Dispatcher/Exception.php
  122. +204 −0 library/Zend/Controller/Dispatcher/Interface.php
  123. +488 −0 library/Zend/Controller/Dispatcher/Standard.php
  124. +34 −0 library/Zend/Controller/Exception.php
  125. +974 −0 library/Zend/Controller/Front.php
  126. +150 −0 library/Zend/Controller/Plugin/Abstract.php
  127. +245 −0 library/Zend/Controller/Plugin/ActionStack.php
  128. +363 −0 library/Zend/Controller/Plugin/Broker.php
  129. +257 −0 library/Zend/Controller/Plugin/ErrorHandler.php
  130. +344 −0 library/Zend/Controller/Request/Abstract.php
  131. +84 −0 library/Zend/Controller/Request/Apache404.php
  132. +36 −0 library/Zend/Controller/Request/Exception.php
  133. +998 −0 library/Zend/Controller/Request/Http.php
  134. +275 −0 library/Zend/Controller/Request/HttpTestCase.php
  135. +54 −0 library/Zend/Controller/Request/Simple.php
  136. +755 −0 library/Zend/Controller/Response/Abstract.php
  137. +67 −0 library/Zend/Controller/Response/Cli.php
  138. +34 −0 library/Zend/Controller/Response/Exception.php
  139. +37 −0 library/Zend/Controller/Response/Http.php
  140. +129 −0 library/Zend/Controller/Response/HttpTestCase.php
  141. +169 −0 library/Zend/Controller/Router/Abstract.php
  142. +35 −0 library/Zend/Controller/Router/Exception.php
  143. +122 −0 library/Zend/Controller/Router/Interface.php
  144. +399 −0 library/Zend/Controller/Router/Rewrite.php
  145. +313 −0 library/Zend/Controller/Router/Route.php
  146. +52 −0 library/Zend/Controller/Router/Route/Abstract.php
  147. +135 −0 library/Zend/Controller/Router/Route/Chain.php
  148. +341 −0 library/Zend/Controller/Router/Route/Hostname.php
  149. +36 −0 library/Zend/Controller/Router/Route/Interface.php
Sorry, we could not display the entire diff because too many files (1,885) changed.
0  README
No changes.
1  application/.gitignore
@@ -0,0 +1 @@
+bootstrapstrap.php
86 application/bootstrap.php
@@ -0,0 +1,86 @@
+<?php
+require_once "bootstrapstrap.php";
+
+// application/bootstrap.php
+//
+// APPLICATION CONSTANTS - Set the constants to use in this application.
+// These constants are accessible throughout the application, even in ini
+// files. We optionally set APPLICATION_PATH here in case our entry point
+// isn't index.php (e.g., if required from our test suite or a script).
+defined('APPLICATION_PATH')
+ or define('APPLICATION_PATH', dirname(__FILE__));
+
+defined('APPLICATION_ENVIRONMENT')
+ or define('APPLICATION_ENVIRONMENT', 'development');
+
+function msg_dev_only($msg) {
+ return APPLICATION_ENVIRONMENT == 'development' ? '<span class="devonly">' . $msg . '</span>' : '';
+}
+
+// FRONT CONTROLLER - Get the front controller.
+// The Zend_Front_Controller class implements the Singleton pattern, which is a
+// design pattern used to ensure there is only one instance of
+// Zend_Front_Controller created on each request.
+$frontController = Zend_Controller_Front::getInstance();
+
+// CONTROLLER DIRECTORY SETUP - Point the front controller to your action
+// controller directory.
+$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');
+
+// APPLICATION ENVIRONMENT - Set the current environment.
+// Set a variable in the front controller indicating the current environment --
+// commonly one of development, staging, testing, production, but wholly
+// dependent on your organization's and/or site's needs.
+$frontController->setParam('env', APPLICATION_ENVIRONMENT);
+
+// LAYOUT SETUP - Setup the layout component
+// The Zend_Layout component implements a composite (or two-step-view) pattern
+// In this call we are telling the component where to find the layouts scripts.
+Zend_Layout::startMvc(APPLICATION_PATH . '/layouts/scripts');
+
+// CONFIGURATION - Setup the configuration object
+// The Zend_Config_Ini component will parse the ini file, and resolve all of
+// the values for the given section. Here we will be using the section name
+// that corresponds to the APP's Environment
+$configuration = new Zend_Config_Ini(
+ APPLICATION_PATH . '/config/app.ini',
+ APPLICATION_ENVIRONMENT
+);
+
+// DATABASE ADAPTER - Setup the database adapter
+// Zend_Db implements a factory interface that allows developers to pass in an
+// adapter name and some parameters that will create an appropriate database
+// adapter object. In this instance, we will be using the values found in the
+// "database" section of the configuration obj.
+$dbAdapter = Zend_Db::factory($configuration->database);
+
+// DATABASE TABLE SETUP - Setup the Database Table Adapter
+// Since our application will be utilizing the Zend_Db_Table component, we need
+// to give it a default adapter that all table objects will be able to utilize
+// when sending queries to the db.
+Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
+
+// REGISTRY - setup the application registry
+// An application registry allows the application to store application
+// necessary objects into a safe and consistent (non global) place for future
+// retrieval. This allows the application to ensure that regardless of what
+// happends in the global scope, the registry will contain the objects it
+// needs.
+$registry = Zend_Registry::getInstance();
+$registry->configuration = $configuration;
+$registry->dbAdapter = $dbAdapter;
+$registry->staticSalt = 'Fv2mJlk4mfF45jfld';
+
+// VIEW SETUP - Initialize properties of the view object
+// The Zend_View component is used for rendering views. Here, we grab a "global"
+// view instance from the layout object, and specify the doctype we wish to
+// use -- in this case, XHTML1 Strict.
+$view = Zend_Layout::getMvcInstance()->getView();
+$view->doctype('XHTML1_STRICT');
+$view->setHelperPath(APPLICATION_PATH . '/helpers', 'Fur_View_Helper');
+
+// CLEANUP - Remove items from global scope.
+// This will clear all our local boostrap variables from the global scope of
+// this script (and any scripts that called bootstrap). This will enforce
+// object retrieval through the applications's registry.
+unset($view, $frontController, $configuration, $dbAdapter, $registry);
1  application/bootstrapstrap.php.template
@@ -0,0 +1 @@
+<?php
18 application/config/app.ini
@@ -0,0 +1,18 @@
+
+[development]
+database.adapter = "PDO_MYSQL"
+database.params.host = "localhost"
+database.params.username = "snaapi_admin"
+database.params.password = "Sn4ap1H0st!"
+database.params.dbname = "snaapi"
+
+google_api_key = ABQIAAAATnDX7Vje0TwQ5gRCsLmjAxQQGzvfRfte0t1k3BwzMpMLXsETZxSgeRonkoVe3Rx3LLTU8tnFE9FOCA
+
+[testing : development]
+
+[production : development]
+
+database.params.host = "localhost"
+database.params.username = "jverkoey_cartfur"
+database.params.password = "R4lz0th123!"
+database.params.dbname = "jverkoey_cartografur"
57 application/controllers/ErrorController.php
@@ -0,0 +1,57 @@
+<?php
+
+include_once APPLICATION_PATH . '/controllers/SnaapiController.php';
+
+/**
+ * ErrorController
+ */
+class ErrorController extends SnaapiController
+{
+ /**
+ * errorAction() is the action that will be called by the "ErrorHandler"
+ * plugin. When an error/exception has been encountered
+ * in a ZF MVC application (assuming the ErrorHandler has not been disabled
+ * in your bootstrap) - the Errorhandler will set the next dispatchable
+ * action to come here. This is the "default" module, "error" controller,
+ * specifically, the "error" action. These options are configurable.
+ *
+ * @see http://framework.zend.com/manual/en/zend.controller.plugins.html
+ *
+ * @return void
+ */
+ public function errorAction() {
+ // Ensure the default view suffix is used so we always return good
+ // content
+ $this->_helper->viewRenderer->setViewSuffix('phtml');
+
+ // Grab the error object from the request
+ $errors = $this->_getParam('error_handler');
+
+ // $errors will be an object set as a parameter of the request object,
+ // type is a property
+ switch ($errors->type) {
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
+
+ // 404 error -- controller or action not found
+ $this->getResponse()->setHttpResponseCode(404);
+ $this->view->message = 'Page not found';
+ break;
+ default:
+ // application error
+ $this->getResponse()->setHttpResponseCode(500);
+ $this->view->message = 'Application error';
+ break;
+ }
+
+ // pass the environment to the view script so we can conditionally
+ // display more/less information
+ $this->view->env = $this->getInvokeArg('env');
+
+ // pass the actual exception object to the view
+ $this->view->exception = $errors->exception;
+
+ // pass the request to the view
+ $this->view->request = $errors->request;
+ }
+}
8 application/controllers/IndexController.php
@@ -0,0 +1,8 @@
+<?php
+
+include_once APPLICATION_PATH . '/controllers/SnaapiController.php';
+
+class IndexController extends SnaapiController {
+ public function indexAction() {
+ }
+}
12 application/controllers/SnaapiController.php
@@ -0,0 +1,12 @@
+<?php
+// application/controllers/SnaapiController.php
+
+class SnaapiController extends Zend_Controller_Action {
+
+ public function init() {
+ $this->view->headTitle('snaapi');
+ $this->view->headTitle()->setSeparator(' | ');
+ $this->view->env = $this->getInvokeArg('env');
+ }
+
+}
49 application/layouts/scripts/layout.phtml
@@ -0,0 +1,49 @@
+<?= $this->doctype() ?>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <link rel="shortcut icon" href="/favicon.ico" mce_href="/favicon.ico" />
+ <?= $this->headTitle() ?>
+ <? if( APPLICATION_ENVIRONMENT == 'development' ) { ?>
+ <style type="text/css">
+ .devonly {
+ border: 1px solid #ccc;
+ background-color: #ff0;
+ padding: 0.2em;
+ }
+ </style>
+ <? } ?>
+<?php // These are in a reverse order of importance because we're prepending.
+ $this->headLink()->prependStylesheet('/css/common.css');
+ $this->headLink()->prependStylesheet('/css/global.css'); ?>
+<?= $this->headLink() ?>
+<?= $this->headScript() ?>
+</head>
+<body>
+
+<div id="content">
+<?= $this->layout()->content ?>
+</div>
+
+<div class="spacer"></div>
+
+<div id="footer">
+ <div class="wrapper">
+ <div class="links">
+ <ul>
+ <li><a href="/">Home</a></li>
+ <li><a href="/contact">Contact</a></li>
+ <li><a href="/about">About</a></li>
+ </ul>
+ </div>
+ <div class="copyright">©2009 snaapi</div>
+ </div>
+</div>
+
+<?php // These are in a reverse order of importance because we're prepending.
+ $this->inlineScript()->prependFile('/js/jquery.js');
+?>
+<?= $this->inlineScript() ?>
+
+</body>
+</html>
19 application/views/scripts/error/error.phtml
@@ -0,0 +1,19 @@
+<?php $this->headLink()->appendStylesheet('/css/server_error.css') ?>
+
+<div class="server_error">
+<h1>Pardon our dust! Here's what we know about what happened:</h1>
+<h2><?= $this->message ?></h2>
+
+<? if ('development' == $this->env): ?>
+ <h3>Exception information:</h3>
+ <p>
+ <b>Message:</b> <?= $this->exception->getMessage() ?>
+ </p>
+
+ <h3>Stack trace:</h3>
+ <pre><?= $this->exception->getTraceAsString() ?></pre>
+
+ <h3>Request Parameters:</h3>
+ <pre><? var_dump($this->request->getParams()) ?></pre>
+<? endif ?>
+</div>
0  application/views/scripts/index/index.phtml
No changes.
1,036 library/Zend/Acl.php
@@ -0,0 +1,1036 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Acl.php 9417 2008-05-08 16:28:31Z darby $
+ */
+
+
+/**
+ * @see Zend_Acl_Resource_Interface
+ */
+require_once 'Zend/Acl/Resource/Interface.php';
+
+
+/**
+ * @see Zend_Acl_Role_Registry
+ */
+require_once 'Zend/Acl/Role/Registry.php';
+
+
+/**
+ * @see Zend_Acl_Assert_Interface
+ */
+require_once 'Zend/Acl/Assert/Interface.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Acl
+{
+ /**
+ * Rule type: allow
+ */
+ const TYPE_ALLOW = 'TYPE_ALLOW';
+
+ /**
+ * Rule type: deny
+ */
+ const TYPE_DENY = 'TYPE_DENY';
+
+ /**
+ * Rule operation: add
+ */
+ const OP_ADD = 'OP_ADD';
+
+ /**
+ * Rule operation: remove
+ */
+ const OP_REMOVE = 'OP_REMOVE';
+
+ /**
+ * Role registry
+ *
+ * @var Zend_Acl_Role_Registry
+ */
+ protected $_roleRegistry = null;
+
+ /**
+ * Resource tree
+ *
+ * @var array
+ */
+ protected $_resources = array();
+
+ /**
+ * ACL rules; whitelist (deny everything to all) by default
+ *
+ * @var array
+ */
+ protected $_rules = array(
+ 'allResources' => array(
+ 'allRoles' => array(
+ 'allPrivileges' => array(
+ 'type' => self::TYPE_DENY,
+ 'assert' => null
+ ),
+ 'byPrivilegeId' => array()
+ ),
+ 'byRoleId' => array()
+ ),
+ 'byResourceId' => array()
+ );
+
+ /**
+ * Adds a Role having an identifier unique to the registry
+ *
+ * The $parents parameter may be a reference to, or the string identifier for,
+ * a Role existing in the registry, or $parents may be passed as an array of
+ * these - mixing string identifiers and objects is ok - to indicate the Roles
+ * from which the newly added Role will directly inherit.
+ *
+ * In order to resolve potential ambiguities with conflicting rules inherited
+ * from different parents, the most recently added parent takes precedence over
+ * parents that were previously added. In other words, the first parent added
+ * will have the least priority, and the last parent added will have the
+ * highest priority.
+ *
+ * @param Zend_Acl_Role_Interface $role
+ * @param Zend_Acl_Role_Interface|string|array $parents
+ * @uses Zend_Acl_Role_Registry::add()
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function addRole(Zend_Acl_Role_Interface $role, $parents = null)
+ {
+ $this->_getRoleRegistry()->add($role, $parents);
+
+ return $this;
+ }
+
+ /**
+ * Returns the identified Role
+ *
+ * The $role parameter can either be a Role or Role identifier.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @uses Zend_Acl_Role_Registry::get()
+ * @return Zend_Acl_Role_Interface
+ */
+ public function getRole($role)
+ {
+ return $this->_getRoleRegistry()->get($role);
+ }
+
+ /**
+ * Returns true if and only if the Role exists in the registry
+ *
+ * The $role parameter can either be a Role or a Role identifier.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @uses Zend_Acl_Role_Registry::has()
+ * @return boolean
+ */
+ public function hasRole($role)
+ {
+ return $this->_getRoleRegistry()->has($role);
+ }
+
+ /**
+ * Returns true if and only if $role inherits from $inherit
+ *
+ * Both parameters may be either a Role or a Role identifier. If
+ * $onlyParents is true, then $role must inherit directly from
+ * $inherit in order to return true. By default, this method looks
+ * through the entire inheritance DAG to determine whether $role
+ * inherits from $inherit through its ancestor Roles.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @param Zend_Acl_Role_Interface|string $inherit
+ * @param boolean $onlyParents
+ * @uses Zend_Acl_Role_Registry::inherits()
+ * @return boolean
+ */
+ public function inheritsRole($role, $inherit, $onlyParents = false)
+ {
+ return $this->_getRoleRegistry()->inherits($role, $inherit, $onlyParents);
+ }
+
+ /**
+ * Removes the Role from the registry
+ *
+ * The $role parameter can either be a Role or a Role identifier.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @uses Zend_Acl_Role_Registry::remove()
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function removeRole($role)
+ {
+ $this->_getRoleRegistry()->remove($role);
+
+ if ($role instanceof Zend_Acl_Role_Interface) {
+ $roleId = $role->getRoleId();
+ } else {
+ $roleId = $role;
+ }
+
+ foreach ($this->_rules['allResources']['byRoleId'] as $roleIdCurrent => $rules) {
+ if ($roleId === $roleIdCurrent) {
+ unset($this->_rules['allResources']['byRoleId'][$roleIdCurrent]);
+ }
+ }
+ foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
+ foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
+ if ($roleId === $roleIdCurrent) {
+ unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Removes all Roles from the registry
+ *
+ * @uses Zend_Acl_Role_Registry::removeAll()
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function removeRoleAll()
+ {
+ $this->_getRoleRegistry()->removeAll();
+
+ foreach ($this->_rules['allResources']['byRoleId'] as $roleIdCurrent => $rules) {
+ unset($this->_rules['allResources']['byRoleId'][$roleIdCurrent]);
+ }
+ foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
+ foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
+ unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds a Resource having an identifier unique to the ACL
+ *
+ * The $parent parameter may be a reference to, or the string identifier for,
+ * the existing Resource from which the newly added Resource will inherit.
+ *
+ * @param Zend_Acl_Resource_Interface $resource
+ * @param Zend_Acl_Resource_Interface|string $parent
+ * @throws Zend_Acl_Exception
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function add(Zend_Acl_Resource_Interface $resource, $parent = null)
+ {
+ $resourceId = $resource->getResourceId();
+
+ if ($this->has($resourceId)) {
+ require_once 'Zend/Acl/Exception.php';
+ throw new Zend_Acl_Exception("Resource id '$resourceId' already exists in the ACL");
+ }
+
+ $resourceParent = null;
+
+ if (null !== $parent) {
+ try {
+ if ($parent instanceof Zend_Acl_Resource_Interface) {
+ $resourceParentId = $parent->getResourceId();
+ } else {
+ $resourceParentId = $parent;
+ }
+ $resourceParent = $this->get($resourceParentId);
+ } catch (Zend_Acl_Exception $e) {
+ throw new Zend_Acl_Exception("Parent Resource id '$resourceParentId' does not exist");
+ }
+ $this->_resources[$resourceParentId]['children'][$resourceId] = $resource;
+ }
+
+ $this->_resources[$resourceId] = array(
+ 'instance' => $resource,
+ 'parent' => $resourceParent,
+ 'children' => array()
+ );
+
+ return $this;
+ }
+
+ /**
+ * Returns the identified Resource
+ *
+ * The $resource parameter can either be a Resource or a Resource identifier.
+ *
+ * @param Zend_Acl_Resource_Interface|string $resource
+ * @throws Zend_Acl_Exception
+ * @return Zend_Acl_Resource_Interface
+ */
+ public function get($resource)
+ {
+ if ($resource instanceof Zend_Acl_Resource_Interface) {
+ $resourceId = $resource->getResourceId();
+ } else {
+ $resourceId = (string) $resource;
+ }
+
+ if (!$this->has($resource)) {
+ require_once 'Zend/Acl/Exception.php';
+ throw new Zend_Acl_Exception("Resource '$resourceId' not found");
+ }
+
+ return $this->_resources[$resourceId]['instance'];
+ }
+
+ /**
+ * Returns true if and only if the Resource exists in the ACL
+ *
+ * The $resource parameter can either be a Resource or a Resource identifier.
+ *
+ * @param Zend_Acl_Resource_Interface|string $resource
+ * @return boolean
+ */
+ public function has($resource)
+ {
+ if ($resource instanceof Zend_Acl_Resource_Interface) {
+ $resourceId = $resource->getResourceId();
+ } else {
+ $resourceId = (string) $resource;
+ }
+
+ return isset($this->_resources[$resourceId]);
+ }
+
+ /**
+ * Returns true if and only if $resource inherits from $inherit
+ *
+ * Both parameters may be either a Resource or a Resource identifier. If
+ * $onlyParent is true, then $resource must inherit directly from
+ * $inherit in order to return true. By default, this method looks
+ * through the entire inheritance tree to determine whether $resource
+ * inherits from $inherit through its ancestor Resources.
+ *
+ * @param Zend_Acl_Resource_Interface|string $resource
+ * @param Zend_Acl_Resource_Interface|string $inherit
+ * @param boolean $onlyParent
+ * @throws Zend_Acl_Resource_Registry_Exception
+ * @return boolean
+ */
+ public function inherits($resource, $inherit, $onlyParent = false)
+ {
+ try {
+ $resourceId = $this->get($resource)->getResourceId();
+ $inheritId = $this->get($inherit)->getResourceId();
+ } catch (Zend_Acl_Exception $e) {
+ throw $e;
+ }
+
+ if (null !== $this->_resources[$resourceId]['parent']) {
+ $parentId = $this->_resources[$resourceId]['parent']->getResourceId();
+ if ($inheritId === $parentId) {
+ return true;
+ } else if ($onlyParent) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ while (null !== $this->_resources[$parentId]['parent']) {
+ $parentId = $this->_resources[$parentId]['parent']->getResourceId();
+ if ($inheritId === $parentId) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Removes a Resource and all of its children
+ *
+ * The $resource parameter can either be a Resource or a Resource identifier.
+ *
+ * @param Zend_Acl_Resource_Interface|string $resource
+ * @throws Zend_Acl_Exception
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function remove($resource)
+ {
+ try {
+ $resourceId = $this->get($resource)->getResourceId();
+ } catch (Zend_Acl_Exception $e) {
+ throw $e;
+ }
+
+ $resourcesRemoved = array($resourceId);
+ if (null !== ($resourceParent = $this->_resources[$resourceId]['parent'])) {
+ unset($this->_resources[$resourceParent->getResourceId()]['children'][$resourceId]);
+ }
+ foreach ($this->_resources[$resourceId]['children'] as $childId => $child) {
+ $this->remove($childId);
+ $resourcesRemoved[] = $childId;
+ }
+
+ foreach ($resourcesRemoved as $resourceIdRemoved) {
+ foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $rules) {
+ if ($resourceIdRemoved === $resourceIdCurrent) {
+ unset($this->_rules['byResourceId'][$resourceIdCurrent]);
+ }
+ }
+ }
+
+ unset($this->_resources[$resourceId]);
+
+ return $this;
+ }
+
+ /**
+ * Removes all Resources
+ *
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function removeAll()
+ {
+ foreach ($this->_resources as $resourceId => $resource) {
+ foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $rules) {
+ if ($resourceId === $resourceIdCurrent) {
+ unset($this->_rules['byResourceId'][$resourceIdCurrent]);
+ }
+ }
+ }
+
+ $this->_resources = array();
+
+ return $this;
+ }
+
+ /**
+ * Adds an "allow" rule to the ACL
+ *
+ * @param Zend_Acl_Role_Interface|string|array $roles
+ * @param Zend_Acl_Resource_Interface|string|array $resources
+ * @param string|array $privileges
+ * @param Zend_Acl_Assert_Interface $assert
+ * @uses Zend_Acl::setRule()
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function allow($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)
+ {
+ return $this->setRule(self::OP_ADD, self::TYPE_ALLOW, $roles, $resources, $privileges, $assert);
+ }
+
+ /**
+ * Adds a "deny" rule to the ACL
+ *
+ * @param Zend_Acl_Role_Interface|string|array $roles
+ * @param Zend_Acl_Resource_Interface|string|array $resources
+ * @param string|array $privileges
+ * @param Zend_Acl_Assert_Interface $assert
+ * @uses Zend_Acl::setRule()
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function deny($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)
+ {
+ return $this->setRule(self::OP_ADD, self::TYPE_DENY, $roles, $resources, $privileges, $assert);
+ }
+
+ /**
+ * Removes "allow" permissions from the ACL
+ *
+ * @param Zend_Acl_Role_Interface|string|array $roles
+ * @param Zend_Acl_Resource_Interface|string|array $resources
+ * @param string|array $privileges
+ * @uses Zend_Acl::setRule()
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function removeAllow($roles = null, $resources = null, $privileges = null)
+ {
+ return $this->setRule(self::OP_REMOVE, self::TYPE_ALLOW, $roles, $resources, $privileges);
+ }
+
+ /**
+ * Removes "deny" restrictions from the ACL
+ *
+ * @param Zend_Acl_Role_Interface|string|array $roles
+ * @param Zend_Acl_Resource_Interface|string|array $resources
+ * @param string|array $privileges
+ * @uses Zend_Acl::setRule()
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function removeDeny($roles = null, $resources = null, $privileges = null)
+ {
+ return $this->setRule(self::OP_REMOVE, self::TYPE_DENY, $roles, $resources, $privileges);
+ }
+
+ /**
+ * Performs operations on ACL rules
+ *
+ * The $operation parameter may be either OP_ADD or OP_REMOVE, depending on whether the
+ * user wants to add or remove a rule, respectively:
+ *
+ * OP_ADD specifics:
+ *
+ * A rule is added that would allow one or more Roles access to [certain $privileges
+ * upon] the specified Resource(s).
+ *
+ * OP_REMOVE specifics:
+ *
+ * The rule is removed only in the context of the given Roles, Resources, and privileges.
+ * Existing rules to which the remove operation does not apply would remain in the
+ * ACL.
+ *
+ * The $type parameter may be either TYPE_ALLOW or TYPE_DENY, depending on whether the
+ * rule is intended to allow or deny permission, respectively.
+ *
+ * The $roles and $resources parameters may be references to, or the string identifiers for,
+ * existing Resources/Roles, or they may be passed as arrays of these - mixing string identifiers
+ * and objects is ok - to indicate the Resources and Roles to which the rule applies. If either
+ * $roles or $resources is null, then the rule applies to all Roles or all Resources, respectively.
+ * Both may be null in order to work with the default rule of the ACL.
+ *
+ * The $privileges parameter may be used to further specify that the rule applies only
+ * to certain privileges upon the Resource(s) in question. This may be specified to be a single
+ * privilege with a string, and multiple privileges may be specified as an array of strings.
+ *
+ * If $assert is provided, then its assert() method must return true in order for
+ * the rule to apply. If $assert is provided with $roles, $resources, and $privileges all
+ * equal to null, then a rule having a type of:
+ *
+ * TYPE_ALLOW will imply a type of TYPE_DENY, and
+ *
+ * TYPE_DENY will imply a type of TYPE_ALLOW
+ *
+ * when the rule's assertion fails. This is because the ACL needs to provide expected
+ * behavior when an assertion upon the default ACL rule fails.
+ *
+ * @param string $operation
+ * @param string $type
+ * @param Zend_Acl_Role_Interface|string|array $roles
+ * @param Zend_Acl_Resource_Interface|string|array $resources
+ * @param string|array $privileges
+ * @param Zend_Acl_Assert_Interface $assert
+ * @throws Zend_Acl_Exception
+ * @uses Zend_Acl_Role_Registry::get()
+ * @uses Zend_Acl::get()
+ * @return Zend_Acl Provides a fluent interface
+ */
+ public function setRule($operation, $type, $roles = null, $resources = null, $privileges = null,
+ Zend_Acl_Assert_Interface $assert = null)
+ {
+ // ensure that the rule type is valid; normalize input to uppercase
+ $type = strtoupper($type);
+ if (self::TYPE_ALLOW !== $type && self::TYPE_DENY !== $type) {
+ require_once 'Zend/Acl/Exception.php';
+ throw new Zend_Acl_Exception("Unsupported rule type; must be either '" . self::TYPE_ALLOW . "' or '"
+ . self::TYPE_DENY . "'");
+ }
+
+ // ensure that all specified Roles exist; normalize input to array of Role objects or null
+ if (!is_array($roles)) {
+ $roles = array($roles);
+ } else if (0 === count($roles)) {
+ $roles = array(null);
+ }
+ $rolesTemp = $roles;
+ $roles = array();
+ foreach ($rolesTemp as $role) {
+ if (null !== $role) {
+ $roles[] = $this->_getRoleRegistry()->get($role);
+ } else {
+ $roles[] = null;
+ }
+ }
+ unset($rolesTemp);
+
+ // ensure that all specified Resources exist; normalize input to array of Resource objects or null
+ if (!is_array($resources)) {
+ $resources = array($resources);
+ } else if (0 === count($resources)) {
+ $resources = array(null);
+ }
+ $resourcesTemp = $resources;
+ $resources = array();
+ foreach ($resourcesTemp as $resource) {
+ if (null !== $resource) {
+ $resources[] = $this->get($resource);
+ } else {
+ $resources[] = null;
+ }
+ }
+ unset($resourcesTemp);
+
+ // normalize privileges to array
+ if (null === $privileges) {
+ $privileges = array();
+ } else if (!is_array($privileges)) {
+ $privileges = array($privileges);
+ }
+
+ switch ($operation) {
+
+ // add to the rules
+ case self::OP_ADD:
+ foreach ($resources as $resource) {
+ foreach ($roles as $role) {
+ $rules =& $this->_getRules($resource, $role, true);
+ if (0 === count($privileges)) {
+ $rules['allPrivileges']['type'] = $type;
+ $rules['allPrivileges']['assert'] = $assert;
+ if (!isset($rules['byPrivilegeId'])) {
+ $rules['byPrivilegeId'] = array();
+ }
+ } else {
+ foreach ($privileges as $privilege) {
+ $rules['byPrivilegeId'][$privilege]['type'] = $type;
+ $rules['byPrivilegeId'][$privilege]['assert'] = $assert;
+ }
+ }
+ }
+ }
+ break;
+
+ // remove from the rules
+ case self::OP_REMOVE:
+ foreach ($resources as $resource) {
+ foreach ($roles as $role) {
+ $rules =& $this->_getRules($resource, $role);
+ if (null === $rules) {
+ continue;
+ }
+ if (0 === count($privileges)) {
+ if (null === $resource && null === $role) {
+ if ($type === $rules['allPrivileges']['type']) {
+ $rules = array(
+ 'allPrivileges' => array(
+ 'type' => self::TYPE_DENY,
+ 'assert' => null
+ ),
+ 'byPrivilegeId' => array()
+ );
+ }
+ continue;
+ }
+ if ($type === $rules['allPrivileges']['type']) {
+ unset($rules['allPrivileges']);
+ }
+ } else {
+ foreach ($privileges as $privilege) {
+ if (isset($rules['byPrivilegeId'][$privilege]) &&
+ $type === $rules['byPrivilegeId'][$privilege]['type']) {
+ unset($rules['byPrivilegeId'][$privilege]);
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ require_once 'Zend/Acl/Exception.php';
+ throw new Zend_Acl_Exception("Unsupported operation; must be either '" . self::OP_ADD . "' or '"
+ . self::OP_REMOVE . "'");
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns true if and only if the Role has access to the Resource
+ *
+ * The $role and $resource parameters may be references to, or the string identifiers for,
+ * an existing Resource and Role combination.
+ *
+ * If either $role or $resource is null, then the query applies to all Roles or all Resources,
+ * respectively. Both may be null to query whether the ACL has a "blacklist" rule
+ * (allow everything to all). By default, Zend_Acl creates a "whitelist" rule (deny
+ * everything to all), and this method would return false unless this default has
+ * been overridden (i.e., by executing $acl->allow()).
+ *
+ * If a $privilege is not provided, then this method returns false if and only if the
+ * Role is denied access to at least one privilege upon the Resource. In other words, this
+ * method returns true if and only if the Role is allowed all privileges on the Resource.
+ *
+ * This method checks Role inheritance using a depth-first traversal of the Role registry.
+ * The highest priority parent (i.e., the parent most recently added) is checked first,
+ * and its respective parents are checked similarly before the lower-priority parents of
+ * the Role are checked.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @param Zend_Acl_Resource_Interface|string $resource
+ * @param string $privilege
+ * @uses Zend_Acl::get()
+ * @uses Zend_Acl_Role_Registry::get()
+ * @return boolean
+ */
+ public function isAllowed($role = null, $resource = null, $privilege = null)
+ {
+ if (null !== $role) {
+ $role = $this->_getRoleRegistry()->get($role);
+ }
+
+ if (null !== $resource) {
+ $resource = $this->get($resource);
+ }
+
+ if (null === $privilege) {
+ // query on all privileges
+ do {
+ // depth-first search on $role if it is not 'allRoles' pseudo-parent
+ if (null !== $role && null !== ($result = $this->_roleDFSAllPrivileges($role, $resource, $privilege))) {
+ return $result;
+ }
+
+ // look for rule on 'allRoles' psuedo-parent
+ if (null !== ($rules = $this->_getRules($resource, null))) {
+ foreach ($rules['byPrivilegeId'] as $privilege => $rule) {
+ if (self::TYPE_DENY === ($ruleTypeOnePrivilege = $this->_getRuleType($resource, null, $privilege))) {
+ return false;
+ }
+ }
+ if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, null, null))) {
+ return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
+ }
+ }
+
+ // try next Resource
+ $resource = $this->_resources[$resource->getResourceId()]['parent'];
+
+ } while (true); // loop terminates at 'allResources' pseudo-parent
+ } else {
+ // query on one privilege
+ do {
+ // depth-first search on $role if it is not 'allRoles' pseudo-parent
+ if (null !== $role && null !== ($result = $this->_roleDFSOnePrivilege($role, $resource, $privilege))) {
+ return $result;
+ }
+
+ // look for rule on 'allRoles' pseudo-parent
+ if (null !== ($ruleType = $this->_getRuleType($resource, null, $privilege))) {
+ return self::TYPE_ALLOW === $ruleType;
+ } else if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, null, null))) {
+ return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
+ }
+
+ // try next Resource
+ $resource = $this->_resources[$resource->getResourceId()]['parent'];
+
+ } while (true); // loop terminates at 'allResources' pseudo-parent
+ }
+ }
+
+ /**
+ * Returns the Role registry for this ACL
+ *
+ * If no Role registry has been created yet, a new default Role registry
+ * is created and returned.
+ *
+ * @return Zend_Acl_Role_Registry
+ */
+ protected function _getRoleRegistry()
+ {
+ if (null === $this->_roleRegistry) {
+ $this->_roleRegistry = new Zend_Acl_Role_Registry();
+ }
+ return $this->_roleRegistry;
+ }
+
+ /**
+ * Performs a depth-first search of the Role DAG, starting at $role, in order to find a rule
+ * allowing/denying $role access to all privileges upon $resource
+ *
+ * This method returns true if a rule is found and allows access. If a rule exists and denies access,
+ * then this method returns false. If no applicable rule is found, then this method returns null.
+ *
+ * @param Zend_Acl_Role_Interface $role
+ * @param Zend_Acl_Resource_Interface $resource
+ * @return boolean|null
+ */
+ protected function _roleDFSAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null)
+ {
+ $dfs = array(
+ 'visited' => array(),
+ 'stack' => array()
+ );
+
+ if (null !== ($result = $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs))) {
+ return $result;
+ }
+
+ while (null !== ($role = array_pop($dfs['stack']))) {
+ if (!isset($dfs['visited'][$role->getRoleId()])) {
+ if (null !== ($result = $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs))) {
+ return $result;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Visits an $role in order to look for a rule allowing/denying $role access to all privileges upon $resource
+ *
+ * This method returns true if a rule is found and allows access. If a rule exists and denies access,
+ * then this method returns false. If no applicable rule is found, then this method returns null.
+ *
+ * This method is used by the internal depth-first search algorithm and may modify the DFS data structure.
+ *
+ * @param Zend_Acl_Role_Interface $role
+ * @param Zend_Acl_Resource_Interface $resource
+ * @param array $dfs
+ * @return boolean|null
+ * @throws Zend_Acl_Exception
+ */
+ protected function _roleDFSVisitAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
+ &$dfs = null)
+ {
+ if (null === $dfs) {
+ /**
+ * @see Zend_Acl_Exception
+ */
+ require_once 'Zend/Acl/Exception.php';
+ throw new Zend_Acl_Exception('$dfs parameter may not be null');
+ }
+
+ if (null !== ($rules = $this->_getRules($resource, $role))) {
+ foreach ($rules['byPrivilegeId'] as $privilege => $rule) {
+ if (self::TYPE_DENY === ($ruleTypeOnePrivilege = $this->_getRuleType($resource, $role, $privilege))) {
+ return false;
+ }
+ }
+ if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, $role, null))) {
+ return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
+ }
+ }
+
+ $dfs['visited'][$role->getRoleId()] = true;
+ foreach ($this->_getRoleRegistry()->getParents($role) as $roleParentId => $roleParent) {
+ $dfs['stack'][] = $roleParent;
+ }
+
+ return null;
+ }
+
+ /**
+ * Performs a depth-first search of the Role DAG, starting at $role, in order to find a rule
+ * allowing/denying $role access to a $privilege upon $resource
+ *
+ * This method returns true if a rule is found and allows access. If a rule exists and denies access,
+ * then this method returns false. If no applicable rule is found, then this method returns null.
+ *
+ * @param Zend_Acl_Role_Interface $role
+ * @param Zend_Acl_Resource_Interface $resource
+ * @param string $privilege
+ * @return boolean|null
+ * @throws Zend_Acl_Exception
+ */
+ protected function _roleDFSOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
+ $privilege = null)
+ {
+ if (null === $privilege) {
+ /**
+ * @see Zend_Acl_Exception
+ */
+ require_once 'Zend/Acl/Exception.php';
+ throw new Zend_Acl_Exception('$privilege parameter may not be null');
+ }
+
+ $dfs = array(
+ 'visited' => array(),
+ 'stack' => array()
+ );
+
+ if (null !== ($result = $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs))) {
+ return $result;
+ }
+
+ while (null !== ($role = array_pop($dfs['stack']))) {
+ if (!isset($dfs['visited'][$role->getRoleId()])) {
+ if (null !== ($result = $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs))) {
+ return $result;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Visits an $role in order to look for a rule allowing/denying $role access to a $privilege upon $resource
+ *
+ * This method returns true if a rule is found and allows access. If a rule exists and denies access,
+ * then this method returns false. If no applicable rule is found, then this method returns null.
+ *
+ * This method is used by the internal depth-first search algorithm and may modify the DFS data structure.
+ *
+ * @param Zend_Acl_Role_Interface $role
+ * @param Zend_Acl_Resource_Interface $resource
+ * @param string $privilege
+ * @param array $dfs
+ * @return boolean|null
+ * @throws Zend_Acl_Exception
+ */
+ protected function _roleDFSVisitOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
+ $privilege = null, &$dfs = null)
+ {
+ if (null === $privilege) {
+ /**
+ * @see Zend_Acl_Exception
+ */
+ require_once 'Zend/Acl/Exception.php';
+ throw new Zend_Acl_Exception('$privilege parameter may not be null');
+ }
+
+ if (null === $dfs) {
+ /**
+ * @see Zend_Acl_Exception
+ */
+ require_once 'Zend/Acl/Exception.php';
+ throw new Zend_Acl_Exception('$dfs parameter may not be null');
+ }
+
+ if (null !== ($ruleTypeOnePrivilege = $this->_getRuleType($resource, $role, $privilege))) {
+ return self::TYPE_ALLOW === $ruleTypeOnePrivilege;
+ } else if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, $role, null))) {
+ return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
+ }
+
+ $dfs['visited'][$role->getRoleId()] = true;
+ foreach ($this->_getRoleRegistry()->getParents($role) as $roleParentId => $roleParent) {
+ $dfs['stack'][] = $roleParent;
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the rule type associated with the specified Resource, Role, and privilege
+ * combination.
+ *
+ * If a rule does not exist or its attached assertion fails, which means that
+ * the rule is not applicable, then this method returns null. Otherwise, the
+ * rule type applies and is returned as either TYPE_ALLOW or TYPE_DENY.
+ *
+ * If $resource or $role is null, then this means that the rule must apply to
+ * all Resources or Roles, respectively.
+ *
+ * If $privilege is null, then the rule must apply to all privileges.
+ *
+ * If all three parameters are null, then the default ACL rule type is returned,
+ * based on whether its assertion method passes.
+ *
+ * @param Zend_Acl_Resource_Interface $resource
+ * @param Zend_Acl_Role_Interface $role
+ * @param string $privilege
+ * @return string|null
+ */
+ protected function _getRuleType(Zend_Acl_Resource_Interface $resource = null, Zend_Acl_Role_Interface $role = null,
+ $privilege = null)
+ {
+ // get the rules for the $resource and $role
+ if (null === ($rules = $this->_getRules($resource, $role))) {
+ return null;
+ }
+
+ // follow $privilege
+ if (null === $privilege) {
+ if (isset($rules['allPrivileges'])) {
+ $rule = $rules['allPrivileges'];
+ } else {
+ return null;
+ }
+ } else if (!isset($rules['byPrivilegeId'][$privilege])) {
+ return null;
+ } else {
+ $rule = $rules['byPrivilegeId'][$privilege];
+ }
+
+ // check assertion if necessary
+ if (null === $rule['assert'] || $rule['assert']->assert($this, $role, $resource, $privilege)) {
+ return $rule['type'];
+ } else if (null !== $resource || null !== $role || null !== $privilege) {
+ return null;
+ } else if (self::TYPE_ALLOW === $rule['type']) {
+ return self::TYPE_DENY;
+ } else {
+ return self::TYPE_ALLOW;
+ }
+ }
+
+ /**
+ * Returns the rules associated with a Resource and a Role, or null if no such rules exist
+ *
+ * If either $resource or $role is null, this means that the rules returned are for all Resources or all Roles,
+ * respectively. Both can be null to return the default rule set for all Resources and all Roles.
+ *
+ * If the $create parameter is true, then a rule set is first created and then returned to the caller.
+ *
+ * @param Zend_Acl_Resource_Interface $resource
+ * @param Zend_Acl_Role_Interface $role
+ * @param boolean $create
+ * @return array|null
+ */
+ protected function &_getRules(Zend_Acl_Resource_Interface $resource = null, Zend_Acl_Role_Interface $role = null,
+ $create = false)
+ {
+ // create a reference to null
+ $null = null;
+ $nullRef =& $null;
+
+ // follow $resource
+ do {
+ if (null === $resource) {
+ $visitor =& $this->_rules['allResources'];
+ break;
+ }
+ $resourceId = $resource->getResourceId();
+ if (!isset($this->_rules['byResourceId'][$resourceId])) {
+ if (!$create) {
+ return $nullRef;
+ }
+ $this->_rules['byResourceId'][$resourceId] = array();
+ }
+ $visitor =& $this->_rules['byResourceId'][$resourceId];
+ } while (false);
+
+
+ // follow $role
+ if (null === $role) {
+ if (!isset($visitor['allRoles'])) {
+ if (!$create) {
+ return $nullRef;
+ }
+ $visitor['allRoles']['byPrivilegeId'] = array();
+ }
+ return $visitor['allRoles'];
+ }
+ $roleId = $role->getRoleId();
+ if (!isset($visitor['byRoleId'][$roleId])) {
+ if (!$create) {
+ return $nullRef;
+ }
+ $visitor['byRoleId'][$roleId]['byPrivilegeId'] = array();
+ }
+ return $visitor['byRoleId'][$roleId];
+ }
+
+}
64 library/Zend/Acl/Assert/Interface.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Interface.php 8861 2008-03-16 14:30:18Z thomas $
+ */
+
+
+/**
+ * @see Zend_Acl
+ */
+require_once 'Zend/Acl.php';
+
+
+/**
+ * @see Zend_Acl_Role_Interface
+ */
+require_once 'Zend/Acl/Role/Interface.php';
+
+
+/**
+ * @see Zend_Acl_Resource_Interface
+ */
+require_once 'Zend/Acl/Resource/Interface.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+interface Zend_Acl_Assert_Interface
+{
+ /**
+ * Returns true if and only if the assertion conditions are met
+ *
+ * This method is passed the ACL, Role, Resource, and privilege to which the authorization query applies. If the
+ * $role, $resource, or $privilege parameters are null, it means that the query applies to all Roles, Resources, or
+ * privileges, respectively.
+ *
+ * @param Zend_Acl $acl
+ * @param Zend_Acl_Role_Interface $role
+ * @param Zend_Acl_Resource_Interface $resource
+ * @param string $privilege
+ * @return boolean
+ */
+ public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null,
+ $privilege = null);
+}
36 library/Zend/Acl/Exception.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 8861 2008-03-16 14:30:18Z thomas $
+ */
+
+
+/**
+ * @see Zend_Exception
+ */
+require_once 'Zend/Exception.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Acl_Exception extends Zend_Exception
+{}
65 library/Zend/Acl/Resource.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Resource.php 8861 2008-03-16 14:30:18Z thomas $
+ */
+
+
+/**
+ * @see Zend_Acl_Resource_Interface
+ */
+require_once 'Zend/Acl/Resource/Interface.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Acl_Resource implements Zend_Acl_Resource_Interface
+{
+ /**
+ * Unique id of Resource
+ *
+ * @var string
+ */
+ protected $_resourceId;
+
+ /**
+ * Sets the Resource identifier
+ *
+ * @param string $resourceId
+ * @return void
+ */
+ public function __construct($resourceId)
+ {
+ $this->_resourceId = (string) $resourceId;
+ }
+
+ /**
+ * Defined by Zend_Acl_Resource_Interface; returns the Resource identifier
+ *
+ * @return string
+ */
+ public function getResourceId()
+ {
+ return $this->_resourceId;
+ }
+
+}
37 library/Zend/Acl/Resource/Interface.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Interface.php 8861 2008-03-16 14:30:18Z thomas $
+ */
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+interface Zend_Acl_Resource_Interface
+{
+ /**
+ * Returns the string identifier of the Resource
+ *
+ * @return string
+ */
+ public function getResourceId();
+}
65 library/Zend/Acl/Role.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Role.php 8861 2008-03-16 14:30:18Z thomas $
+ */
+
+
+/**
+ * @see Zend_Acl_Role_Interface
+ */
+require_once 'Zend/Acl/Role/Interface.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Acl_Role implements Zend_Acl_Role_Interface
+{
+ /**
+ * Unique id of Role
+ *
+ * @var string
+ */
+ protected $_roleId;
+
+ /**
+ * Sets the Role identifier
+ *
+ * @param string $id
+ * @return void
+ */
+ public function __construct($roleId)
+ {
+ $this->_roleId = (string) $roleId;
+ }
+
+ /**
+ * Defined by Zend_Acl_Role_Interface; returns the Role identifier
+ *
+ * @return string
+ */
+ public function getRoleId()
+ {
+ return $this->_roleId;
+ }
+
+}
37 library/Zend/Acl/Role/Interface.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Interface.php 8861 2008-03-16 14:30:18Z thomas $
+ */
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+interface Zend_Acl_Role_Interface
+{
+ /**
+ * Returns the string identifier of the Role
+ *
+ * @return string
+ */
+ public function getRoleId();
+}
266 library/Zend/Acl/Role/Registry.php
@@ -0,0 +1,266 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Registry.php 8861 2008-03-16 14:30:18Z thomas $
+ */
+
+
+/**
+ * @see Zend_Acl_Role_Interface
+ */
+require_once 'Zend/Acl/Role/Interface.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Acl_Role_Registry
+{
+ /**
+ * Internal Role registry data storage
+ *
+ * @var array
+ */
+ protected $_roles = array();
+
+ /**
+ * Adds a Role having an identifier unique to the registry
+ *
+ * The $parents parameter may be a reference to, or the string identifier for,
+ * a Role existing in the registry, or $parents may be passed as an array of
+ * these - mixing string identifiers and objects is ok - to indicate the Roles
+ * from which the newly added Role will directly inherit.
+ *
+ * In order to resolve potential ambiguities with conflicting rules inherited
+ * from different parents, the most recently added parent takes precedence over
+ * parents that were previously added. In other words, the first parent added
+ * will have the least priority, and the last parent added will have the
+ * highest priority.
+ *
+ * @param Zend_Acl_Role_Interface $role
+ * @param Zend_Acl_Role_Interface|string|array $parents
+ * @throws Zend_Acl_Role_Registry_Exception
+ * @return Zend_Acl_Role_Registry Provides a fluent interface
+ */
+ public function add(Zend_Acl_Role_Interface $role, $parents = null)
+ {
+ $roleId = $role->getRoleId();
+
+ if ($this->has($roleId)) {
+ /**
+ * @see Zend_Acl_Role_Registry_Exception
+ */
+ require_once 'Zend/Acl/Role/Registry/Exception.php';
+ throw new Zend_Acl_Role_Registry_Exception("Role id '$roleId' already exists in the registry");
+ }
+
+ $roleParents = array();
+
+ if (null !== $parents) {
+ if (!is_array($parents)) {
+ $parents = array($parents);
+ }
+ /**
+ * @see Zend_Acl_Role_Registry_Exception
+ */
+ require_once 'Zend/Acl/Role/Registry/Exception.php';
+ foreach ($parents as $parent) {
+ try {
+ if ($parent instanceof Zend_Acl_Role_Interface) {
+ $roleParentId = $parent->getRoleId();
+ } else {
+ $roleParentId = $parent;
+ }
+ $roleParent = $this->get($roleParentId);
+ } catch (Zend_Acl_Role_Registry_Exception $e) {
+ throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist");
+ }
+ $roleParents[$roleParentId] = $roleParent;
+ $this->_roles[$roleParentId]['children'][$roleId] = $role;
+ }
+ }
+
+ $this->_roles[$roleId] = array(
+ 'instance' => $role,
+ 'parents' => $roleParents,
+ 'children' => array()
+ );
+
+ return $this;
+ }
+
+ /**
+ * Returns the identified Role
+ *
+ * The $role parameter can either be a Role or a Role identifier.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @throws Zend_Acl_Role_Registry_Exception
+ * @return Zend_Acl_Role_Interface
+ */
+ public function get($role)
+ {
+ if ($role instanceof Zend_Acl_Role_Interface) {
+ $roleId = $role->getRoleId();
+ } else {
+ $roleId = (string) $role;
+ }
+
+ if (!$this->has($role)) {
+ /**
+ * @see Zend_Acl_Role_Registry_Exception
+ */
+ require_once 'Zend/Acl/Role/Registry/Exception.php';
+ throw new Zend_Acl_Role_Registry_Exception("Role '$roleId' not found");
+ }
+
+ return $this->_roles[$roleId]['instance'];
+ }
+
+ /**
+ * Returns true if and only if the Role exists in the registry
+ *
+ * The $role parameter can either be a Role or a Role identifier.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @return boolean
+ */
+ public function has($role)
+ {
+ if ($role instanceof Zend_Acl_Role_Interface) {
+ $roleId = $role->getRoleId();
+ } else {
+ $roleId = (string) $role;
+ }
+
+ return isset($this->_roles[$roleId]);
+ }
+
+ /**
+ * Returns an array of an existing Role's parents
+ *
+ * The array keys are the identifiers of the parent Roles, and the values are
+ * the parent Role instances. The parent Roles are ordered in this array by
+ * ascending priority. The highest priority parent Role, last in the array,
+ * corresponds with the parent Role most recently added.
+ *
+ * If the Role does not have any parents, then an empty array is returned.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @uses Zend_Acl_Role_Registry::get()
+ * @return array
+ */
+ public function getParents($role)
+ {
+ $roleId = $this->get($role)->getRoleId();
+
+ return $this->_roles[$roleId]['parents'];
+ }
+
+ /**
+ * Returns true if and only if $role inherits from $inherit
+ *
+ * Both parameters may be either a Role or a Role identifier. If
+ * $onlyParents is true, then $role must inherit directly from
+ * $inherit in order to return true. By default, this method looks
+ * through the entire inheritance DAG to determine whether $role
+ * inherits from $inherit through its ancestor Roles.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @param Zend_Acl_Role_Interface|string $inherit
+ * @param boolean $onlyParents
+ * @throws Zend_Acl_Role_Registry_Exception
+ * @return boolean
+ */
+ public function inherits($role, $inherit, $onlyParents = false)
+ {
+ /**
+ * @see Zend_Acl_Role_Registry_Exception
+ */
+ require_once 'Zend/Acl/Role/Registry/Exception.php';
+ try {
+ $roleId = $this->get($role)->getRoleId();
+ $inheritId = $this->get($inherit)->getRoleId();
+ } catch (Zend_Acl_Role_Registry_Exception $e) {
+ throw $e;
+ }
+
+ $inherits = isset($this->_roles[$roleId]['parents'][$inheritId]);
+
+ if ($inherits || $onlyParents) {
+ return $inherits;
+ }
+
+ foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
+ if ($this->inherits($parentId, $inheritId)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Removes the Role from the registry
+ *
+ * The $role parameter can either be a Role or a Role identifier.
+ *
+ * @param Zend_Acl_Role_Interface|string $role
+ * @throws Zend_Acl_Role_Registry_Exception
+ * @return Zend_Acl_Role_Registry Provides a fluent interface
+ */
+ public function remove($role)
+ {
+ /**
+ * @see Zend_Acl_Role_Registry_Exception
+ */
+ require_once 'Zend/Acl/Role/Registry/Exception.php';
+ try {
+ $roleId = $this->get($role)->getRoleId();
+ } catch (Zend_Acl_Role_Registry_Exception $e) {
+ throw $e;
+ }
+
+ foreach ($this->_roles[$roleId]['children'] as $childId => $child) {
+ unset($this->_roles[$childId]['parents'][$roleId]);
+ }
+ foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
+ unset($this->_roles[$parentId]['children'][$roleId]);
+ }
+
+ unset($this->_roles[$roleId]);
+
+ return $this;
+ }
+
+ /**
+ * Removes all Roles from the registry
+ *
+ * @return Zend_Acl_Role_Registry Provides a fluent interface
+ */
+ public function removeAll()
+ {
+ $this->_roles = array();
+
+ return $this;
+ }
+
+}
36 library/Zend/Acl/Role/Registry/Exception.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 8861 2008-03-16 14:30:18Z thomas $
+ */
+
+
+/**
+ * @see Zend_Acl_Exception
+ */
+require_once 'Zend/Acl/Exception.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Acl
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Acl_Role_Registry_Exception extends Zend_Acl_Exception
+{}
79 library/Zend/Amf/Constants.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Amf
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * The following constants are used throughout serialization and
+ * deserialization to detect the AMF marker and encoding types.
+ *
+ * @package Zend_Amf
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+final class Zend_Amf_Constants
+{
+ const AMF0_NUMBER = 0x00;
+ const AMF0_BOOLEAN = 0x01;
+ const AMF0_STRING = 0x02;
+ const AMF0_OBJECT = 0x03;
+ const AMF0_MOVIECLIP = 0x04;
+ const AMF0_NULL = 0x05;
+ const AMF0_UNDEFINED = 0x06;
+ const AMF0_REFERENCE = 0x07;
+ const AMF0_MIXEDARRAY = 0x08;
+ const AMF0_OBJECTTERM = 0x09;
+ const AMF0_ARRAY = 0x0a;
+ const AMF0_DATE = 0x0b;
+ const AMF0_LONGSTRING = 0x0c;
+ const AMF0_UNSUPPORTED = 0x0e;
+ const AMF0_XML = 0x0f;
+ const AMF0_TYPEDOBJECT = 0x10;
+ const AMF0_AMF3 = 0x11;
+ const AMF0_OBJECT_ENCODING = 0x00;
+
+ const AMF3_UNDEFINED = 0x00;
+ const AMF3_NULL = 0x01;
+ const AMF3_BOOLEAN_FALSE = 0x02;
+ const AMF3_BOOLEAN_TRUE = 0x03;
+ const AMF3_INTEGER = 0x04;
+ const AMF3_NUMBER = 0x05;
+ const AMF3_STRING = 0x06;
+ const AMF3_XML = 0x07;
+ const AMF3_DATE = 0x08;
+ const AMF3_ARRAY = 0x09;
+ const AMF3_OBJECT = 0x0A;
+ const AMF3_XMLSTRING = 0x0B;
+ const AMF3_BYTEARRAY = 0x0C;
+ const AMF3_OBJECT_ENCODING = 0x03;
+
+ // Object encodings for AMF3 object types
+ const ET_PROPLIST = 0x00;
+ const ET_EXTERNAL = 0x01;
+ const ET_DYNAMIC = 0x02;
+ const ET_PROXY = 0x03;
+
+ /**
+ * Special content length value that indicates "unknown" content length
+ * per AMF Specification
+ */
+ const UNKNOWN_CONTENT_LENGTH = -1;
+ const URL_APPEND_HEADER = 'AppendToGatewayUrl';
+ const RESULT_METHOD = '/onResult';
+ const STATUS_METHOD = '/onStatus';
+}
33 library/Zend/Amf/Exception.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Amf
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * Zend_Exception
+ */
+require_once 'Zend/Exception.php';
+
+/**
+ * @package Zend_Amf
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Amf_Exception extends Zend_Exception
+{
+}
321 library/Zend/Amf/Parse/Amf0/Deserializer.php
@@ -0,0 +1,321 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Amf
+ * @subpackage Parse_Amf0
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/** Zend_Amf_Parse_Deserializer */
+require_once 'Zend/Amf/Parse/Deserializer.php';
+
+/**
+ * Read an AMF0 input stream and convert it into PHP data types
+ *
+ * @todo Implement Typed Object Class Mapping
+ * @todo Class could be implmented as Factory Class with each data type it's own class
+ * @package Zend_Amf
+ * @subpackage Parse_Amf0
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Amf_Parse_Amf0_Deserializer extends Zend_Amf_Parse_Deserializer
+{
+ /**
+ * An array of objects used for recursivly deserializing an object.
+ * @var array
+ */
+ protected $_reference = array();
+
+ /**
+ * If AMF3 serialization occurs, update to AMF0 0x03
+ *
+ * @var int
+ */
+ protected $_objectEncoding = Zend_Amf_Constants::AMF0_OBJECT_ENCODING;
+
+ /**
+ * refrence to AMF3 deserializer
+ *
+ * @var Zend_Amf_Parse_Amf3_Deserializer
+ */
+ protected $_deserializer = null;
+
+ /**
+ * Read AMF markers and dispatch for deserialization
+ *
+ * Checks for AMF marker types and calls the appropriate methods
+ * for deserializing those marker types. Markers are the data type of
+ * the following value.
+ *
+ * @param integer $typeMarker
+ * @return mixed whatever the data type is of the marker in php
+ * @return mixed
+ * @throws Zend_Amf_Exception for invalid type
+ */
+ public function readTypeMarker($typeMarker