Skip to content
This repository has been archived by the owner on Jan 18, 2018. It is now read-only.

Commit

Permalink
a few improvements to the acl translator, adding a @throws i forgot, …
Browse files Browse the repository at this point in the history
…some class constants, and an improvement to the blender (as suggested by SleePy in #linode)
  • Loading branch information
katanacrimson committed Dec 29, 2011
1 parent c603574 commit bba0b87
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ACL/Translator.php
Expand Up @@ -11,7 +11,7 @@
*/

namespace OpenFlame\Framework\ACL;
use \OpenFlame\Framework\Core;
use \OpenFlame\Framework\Core\Internal\RuntimeException;

/**
* OpenFlame Framework - ACL binary auth compiler object
Expand All @@ -23,6 +23,10 @@
*/
class Translator
{
const YES = 1;
const NO = 0;
const NEVER = -1;

/**
* @var array - Array containing the finished, processed group data after resolveAuths() is run
*/
Expand Down Expand Up @@ -85,6 +89,8 @@ public function setAuths(array $auth_flags)
* @return array - An array containing two entries, a "groups" subarray containing the "inherit" and "auths" strings, and potentially the unique identifiers of any child groups (under "children") and the unique identifier of the parent group (under "parent")
*
* @note if the group's data is not loaded with this->setGroup() the group's auth data will not be computed.
*
* @throws RuntimeException
*/
public function buildGroupAuths($group_id_set)
{
Expand Down Expand Up @@ -123,7 +129,7 @@ public function buildGroupAuths($group_id_set)
}
if(isset($inherit_tree[$inherit_id]))
{
throw new \RuntimeException('Recursive group inheritance detected, aborting');
throw new RuntimeException('Recursive group inheritance detected, aborting');
}

$inherit_tree[$inherit_id] = true;
Expand Down Expand Up @@ -173,6 +179,10 @@ public function getAuthID($auth_name)
*/
public function blender(&$item, $key, $merge)
{
// Typecast both to integer.
$item = (int) $item;
$merge[$key] = (int) $merge[$key];

/**
* assume:
* 1 = 'yes'
Expand Down Expand Up @@ -206,7 +216,7 @@ public function blender(&$item, $key, $merge)
*
* this structure allows "never" to always, ALWAYS work.
*/
if(isset($merge[$key]) && $merge[$key] != 0 && $item != -1)
if(empty($merge[$key]) && $item != -1)
{
$item = $merge[$key];
}
Expand Down

0 comments on commit bba0b87

Please sign in to comment.