예제 #1
0
function gotClearanceForTagChain($const_base)
{
    global $rackCode, $expl_tags, $impl_tags;
    $context = array_merge($const_base, $expl_tags, $impl_tags);
    $context = reindexById($context, 'tag', TRUE);
    foreach ($rackCode as $sentence) {
        switch ($sentence['type']) {
            case 'SYNT_GRANT':
                if (eval_expression($sentence['condition'], $context)) {
                    return $sentence['decision'];
                }
                break;
            case 'SYNT_ADJUSTMENT':
                if (eval_expression($sentence['condition'], $context) and processAdjustmentSentence($sentence['modlist'], $expl_tags)) {
                    $impl_tags = getImplicitTags($expl_tags);
                    // recalculate
                    $context = array_merge($const_base, $expl_tags, $impl_tags);
                    $context = reindexById($context, 'tag', TRUE);
                }
                break;
            default:
                throw new RackTablesError("Can't process sentence of unknown type '{$sentence['type']}'", RackTablesError::INTERNAL);
        }
    }
    return FALSE;
}
예제 #2
0
function gotClearanceForTagChain($const_base)
{
    global $rackCode, $expl_tags, $impl_tags;
    $ptable = array();
    foreach ($rackCode as $sentence) {
        switch ($sentence['type']) {
            case 'SYNT_DEFINITION':
                $ptable[$sentence['term']] = $sentence['definition'];
                break;
            case 'SYNT_GRANT':
                if (eval_expression($sentence['condition'], array_merge($const_base, $expl_tags, $impl_tags), $ptable)) {
                    switch ($sentence['decision']) {
                        case 'LEX_ALLOW':
                            return TRUE;
                        case 'LEX_DENY':
                            return FALSE;
                        default:
                            throw new RackTablesError("Condition match for unknown grant decision '{$sentence['decision']}'", RackTablesError::INTERNAL);
                    }
                }
                break;
            case 'SYNT_ADJUSTMENT':
                if (eval_expression($sentence['condition'], array_merge($const_base, $expl_tags, $impl_tags), $ptable) and processAdjustmentSentence($sentence['modlist'], $expl_tags)) {
                    // recalculate implicit chain only after actual change, not just on matched condition
                    $impl_tags = getImplicitTags($expl_tags);
                }
                // recalculate
                break;
            default:
                throw new RackTablesError("Can't process sentence of unknown type '{$sentence['type']}'", RackTablesError::INTERNAL);
        }
    }
    return FALSE;
}
예제 #3
0
function judgeContext($expression)
{
    global $pTable, $expl_tags, $impl_tags, $auto_tags;
    return eval_expression($expression, array_merge($expl_tags, $impl_tags, $auto_tags), $pTable, TRUE);
}