示例#1
0
<?php

// Define hooks
$updateHook = array('class' => 'Mutation', 'function' => 'mutUpdate', 'filename' => 'Mutation.php', 'filepath' => 'extensions/Mutation', 'params' => array('$fullRelationSignature', '$stableAtom', '$stableConcept', '$modifiedAtom', '$modifiedConcept', '$source'));
$insertHook = array('class' => 'Mutation', 'function' => 'mutInsert', 'filename' => 'Mutation.php', 'filepath' => 'extensions/Mutation', 'params' => array('$fullRelationSignature', '$stableAtom', '$stableConcept', '$modifiedAtom', '$modifiedConcept', '$source'));
$deleteHook = array('class' => 'Mutation', 'function' => 'mutDelete', 'filename' => 'Mutation.php', 'filepath' => 'extensions/Mutation', 'params' => array('$fullRelationSignature', '$stableAtom', '$stableConcept', '$modifiedAtom', '$modifiedConcept', '$source'));
Hooks::addHook('postDatabaseUpdate', $updateHook);
Hooks::addHook('postDatabaseInsert', $insertHook);
Hooks::addHook('postDatabaseDelete', $deleteHook);
class Mutation
{
    public static function mutUpdate($fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
    {
        $operation = 'Changed';
        Mutation::saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source);
    }
    public static function mutInsert($fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
    {
        $operation = 'Added';
        Mutation::saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source);
    }
    public static function mutDelete($fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
    {
        $operation = 'Removed';
        Mutation::saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source);
    }
    private static function saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
    {
        if (array_key_exists($fullRelationSignature, Config::get('mutationConcepts', 'MutationExtension'))) {
            Notifications::addLog("Save mutation on '{$fullRelationSignature}' (editUpdate)", 'Mutation');
            $mutConcept = Config::get('mutationConcepts', 'MutationExtension')[$fullRelationSignature];
<?php

require_once __DIR__ . '/lib/class.phpmailer.php';
// Define hooks
$hook = array('class' => 'EmailNotifications', 'function' => 'pushNotificationCache', 'filename' => 'Email.php', 'filepath' => 'extensions/Messaging', 'params' => array());
Hooks::addHook('postDatabaseCommitTransaction', $hook);
$hook = array('class' => 'EmailNotifications', 'function' => 'clearNotificationCache', 'filename' => 'Email.php', 'filepath' => 'extensions/Messaging', 'params' => array());
Hooks::addHook('postDatabaseRollbackTransaction', $hook);
class EmailNotifications
{
    private static $notifications = array();
    public static function execEnginePushNotificationOnCommit($userKeys, $message, $title = null, $url = null, $urltitle = null)
    {
        Notifications::addLog('Email[execEnginePushNotificationOnCommit' . ']; $userKeys=[' . $userKeys . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']', 'MESSAGING');
        if ($userKeys == '_NULL') {
            $userKeys = array(null);
        } else {
            $userKeys = explode('_AND', $userKeys);
        }
        self::pushNotificationOnCommit($userKeys, $message, $title, $url, $urltitle);
    }
    public static function pushNotificationOnCommit($userKeys, $message, $title = null, $url = null, $urltitle = null)
    {
        Notifications::addLog('Email[pushNotificationOnCommit' . ']; $userKeys=[' . $userKeys . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']', 'MESSAGING');
        foreach ($userKeys as $userKey) {
            if (!is_null($userKey)) {
                self::$notifications[] = array('userKey' => $userKey, 'message' => $message, 'title' => $title, 'url' => $url, 'urltitle' => $urltitle);
            }
        }
        // Send same notification to users in 'alwaysNotifyUsers' config
        foreach ((array) Config::get('alwaysNotifyUsers', 'msg_email') as $notifyUser) {
示例#3
0
<?php

// Define hooks
$hook1 = array('class' => 'ExecEngine', 'function' => 'run', 'filename' => 'ExecEngine.php', 'filepath' => 'extensions/ExecEngine', 'params' => array());
Hooks::addHook('preDatabaseCloseTransaction', $hook1);
$hook2 = array('class' => 'ExecEngine', 'function' => 'run', 'filename' => 'ExecEngine.php', 'filepath' => 'extensions/ExecEngine', 'params' => array(true));
Hooks::addHook('postDatabaseReinstallDB', $hook2);
// UI
$GLOBALS['navBar']['refreshMenu'][] = array('url' => 'extensions/ExecEngine/ui/views/MenuItem.html');
AngularApp::addJS('extensions/ExecEngine/ui/js/ExecEngine.js');
// Config (can be overwritten in localSettings.php)
Config::set('execEngineRoleName', 'execEngine', 'ExecEngine');
Config::set('autoRerun', 'execEngine', true);
Config::set('maxRunCount', 'execEngine', 10);
class ExecEngine
{
    private static $roleName;
    public static $doRun = true;
    public static $autoRerun;
    public static $runCount;
    public static function run($allRules = false)
    {
        $database = Database::singleton();
        Notifications::addLog('------------------------- EXEC ENGINE STARTED -------------------------', 'ExecEngine');
        // Load the execEngine functions (security hazard :P)
        $files = getDirectoryList(__DIR__ . '/functions');
        foreach ($files as $file) {
            if (substr($file, -3) !== 'php') {
                continue;
            }
            require_once __DIR__ . '/functions/' . $file;