function CompTariffedCharge($relation, $srcConcept, $srcAtom, $tgtConcept, $ctcNrOfDays, $ctcDailyAmount)
{
    emitLog("CompTariffedCharge({$relation},{$srcConcept},{$srcAtom},{$tgtConcept},{$ctcNrOfDays},{$ctcDailyAmount})");
    $result = intval($ctcNrOfDays) * intval($ctcDailyAmount);
    $result = strval($result);
    // Writing a '0' (integer) results in an empty string.
    InsPair($relation, $srcConcept, $srcAtom, $tgtConcept, $result);
    return;
}
function SetPeriod($relation, $DateConcept, $srcAtom, $Period)
{
    emitLog("SetPeriod({$relation},{$DateConcept},{$srcAtom},{$Period})");
    // Insert the pair ($srcAtom,$srcAtom + $period) into $relation
    if (($dt1 = strtotime($srcAtom)) === false) {
        ExecEngineSHOUTS("SetPeriod: Illegal date {$dt1} specified in srcAtom (3rd arg): {$srcAtom}");
    }
    if (($dt3 = strtotime($srcAtom . $Period)) === false) {
        ExecEngineSHOUTS("SetPeriod: Illegal period {$dt3} specified as period (4th arg): {$Period}");
    }
    $tgtAtom = date('d-m-Y', $dt3);
    global $execEngineWhispers;
    // Defined in 'pluginsettings.php'
    $execEngineWhispers = false;
    // ExecEngineWhispers("SetPeriod: InsPair($relation,$DateConcept,$srcAtom,$DateConcept,$tgtAtom)");
    // Als '$tgtAtom' nog niet in de database bestaat als een instantie van $DateConcept, dan moet die nog wel worden toegevoegd:
    if (!isAtomInConcept($tgtAtom, $DateConcept)) {
        addAtomToConcept($tgtAtom, $DateConcept);
    }
    InsPair($relation, $DateConcept, $srcAtom, $DateConcept, $tgtAtom);
    return;
}
Ejemplo n.º 3
0
function timeofdayGT($relation, $TimeofdayConcept, $srcAtom, $tgtAtom)
{
    emitLog("timeofdayGT({$relation},{$TimeofdayConcept},{$srcAtom},{$tgtAtom})");
    if (($dt1 = strtotime($srcAtom)) === false) {
        ExecEngineSHOUTS("timeofdayGT: Illegal timeofday {$dt1} specified in srcAtom (3rd arg): {$srcAtom}");
    }
    if (($dt2 = strtotime($tgtAtom)) === false) {
        ExecEngineSHOUTS("timeofdayGT: Illegal timeofday {$dt2} specified in tgtAtom (4th arg): {$tgtAtom}");
    }
    global $execEngineWhispers;
    // Defined in 'pluginsettings.php'
    $execEngineWhispers = false;
    if ($dt1 > $dt2) {
        InsPair($relation, $TimeofdayConcept, $srcAtom, $TimeofdayConcept, $tgtAtom);
    }
    return;
}
function DelAtom($concept, $atom)
{
    // call function from DatabaseUtils.php
    deleteAtom($atom, $concept);
    // delete atom + all relations with other atoms
    // log
    ExecEngineWhispers("Atom {$atom} ({$concept}) deleted");
    emitLog("deleteAtom({$atom}, {$concept})");
}
Ejemplo n.º 5
0
function ExecuteAllMappingRules()
{
    global $allRulesSql;
    // for every rule, (almost) all relevant info
    global $allRoles;
    // for every role, a list of all rules that the role must maintain
    global $execEningeIsVerySilent;
    // set in 'pluginsettings.php'
    global $MappingEngineRules;
    // array met alle ruleNames van de MappingEngine
    if (!isset($MappingEngineRules)) {
        foreach ($allRoles as $role) {
            if ($role['name'] == 'MappingEngine') {
                $MappingEngineRules = $role['ruleNames'];
            }
        }
    }
    $error = '';
    foreach ($MappingEngineRules as $ruleName) {
        // Check if Ampersand wants to change something:
        while (GetSMF('pause')) {
            echo "Value of semaphore: " . json_encode(GetPauseSMF()) . ".\n";
            echo "Interupted by high priority process, backing off for 1 second...\n";
            sleep(1);
        }
        $ruleSql = $allRulesSql[$ruleName];
        // Get (almost) all relevant info about the rule
        $rows = DB_doquerErr($ruleSql['violationsSQL'], $error);
        // execute violationsSQL to check for violations
        if ($error) {
            error("While evaluating rule '{$ruleName}': " . $error);
        }
        // if there are rows (i.e. violations)
        if (count($rows) != 0) {
            emitLog('Rule ' . $ruleSql['name'] . ' is repaired');
            $pairView = $ruleSql['pairView'];
            // pairView contains an array with the fragments of the violations message (if specified)
            foreach ($rows as $violation) {
                if ($pairView[0]['segmentType'] == 'Text' && strpos($pairView[0]['Text'], '{EX}') === 0) {
                    $theMessage = execPair($violation['src'], $ruleSql['srcConcept'], $violation['tgt'], $ruleSql['tgtConcept'], $pairView);
                    $theCleanMessage = strip_tags($theMessage);
                    $theCleanMessage = substr($theCleanMessage, 4);
                    // Strip {EX} tag
                    $functionsToBeCalled = explode('{EX}', $theCleanMessage);
                    // Split off subsequent function calls
                    if (count($functionsToBeCalled) > 1) {
                        ExecEngineWhispers("[[START]]");
                    }
                    foreach ($functionsToBeCalled as $functionToBeCalled) {
                        $params = explode(';', $functionToBeCalled);
                        // Split off variables
                        $cleanparams = array();
                        foreach ($params as $param) {
                            $cleanparams[] = trim($param);
                        }
                        $params = $cleanparams;
                        unset($cleanparams);
                        ExecEngineWhispers($functionToBeCalled);
                        $func = array_shift($params);
                        // First parameter is function name
                        if (function_exists($func)) {
                            call_user_func_array($func, $params);
                        } else {
                            ExecEngineSHOUTS("TODO: Create function {$func} with " . count($params) . " parameters.");
                        }
                    }
                    if (count($functionsToBeCalled) > 1) {
                        ExecEngineWhispers("[[DONE]]");
                    }
                }
            }
        }
    }
    return;
}