function DatumDelta($dateRelation, $DateConcept, $srcAtom, $deltaperiod, $tgtAtom)
{
    emitLog("datumDelta({$dateRelation},{$DateConcept},{$srcAtom},{$deltaperiod},{$tgtAtom})");
    if (($dt1 = strtotime($srcAtom)) === false) {
        ExecEngineSHOUTS("DatumDelta: Illegal date {$dt1} specified in srcAtom (3rd arg): {$srcAtom}");
    }
    if (($dt2 = strtotime($tgtAtom)) === false) {
        ExecEngineSHOUTS("DatumDelta: Illegal date {$dt2} specified in tgtAtom (5th arg): {$tgtAtom}");
    }
    if ($dt1 >= $dt2) {
        ExecEngineSHOUTS("DatumDelta: srcAtom (3rd arg) {$srcAtom} must be smaller than tgtAtom (5th arg) {$tgtAtom}");
    }
    if (($dt3 = strtotime($srcAtom . $deltaperiod)) === false) {
        ExecEngineSHOUTS("DatumDelta: Illegal period {$dt3} specified as period (4th arg): {$deltaperiod}");
    }
    global $execEngineWhispers;
    // Defined in 'pluginsettings.php'
    $execEngineWhispers = false;
    // ExecEngineWhispers ("DatumDelta: dt1 = ".date('d-m-Y', $dt1)."; dt2 = ".date('d-m-Y', $dt2)."; dt3 = ".date('d-m-Y', $dt3));
    // ExecEngineWhispers ("DatumDelta: 'InsPair' mag alleen als ".date('d-m-Y', $dt3)." voor $tgtAtom ligt.");
    if ($dt3 < $dt2) {
        ExecEngineWhispers("DatumDelta: InsPair({$dateRelation},{$DateConcept},{$srcAtom},{$DateConcept},{$tgtAtom})");
        InsPair($dateRelation, $DateConcept, $srcAtom, $DateConcept, $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.º 3
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;
}