Esempio n. 1
0
<?php

namespace Ampersand\Extension\Messaging;

use Exception;
use Ampersand\Hooks;
use Ampersand\Config;
use Ampersand\Log\Logger;
use Pushalot;
require_once __DIR__ . '/lib/pushalot_api.php';
// Define hooks
$hook = array('class' => '\\Ampersand\\Extension\\Messaging\\PushalotNotifications', 'function' => 'pushNotificationCache', 'filename' => 'Pushalot.php', 'filepath' => 'extensions/Messaging', 'params' => array());
Hooks::addHook('postDatabaseCommitTransaction', $hook);
$hook = array('class' => '\\Ampersand\\Extension\\Messaging\\PushalotNotifications', 'function' => 'clearNotificationCache', 'filename' => 'Pushalot.php', 'filepath' => 'extensions/Messaging', 'params' => array());
Hooks::addHook('postDatabaseRollbackTransaction', $hook);
class PushalotNotifications
{
    private static $notifications = array();
    public static function execEnginePushNotificationOnCommit($userKeys, $message, $title = null, $url = null, $urltitle = null)
    {
        Logger::getLogger('MESSAGING')->debug('Pushalot[execEnginePushNotificationOnCommit' . ']; $userKeys=[' . $userKeys . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']');
        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)
    {
        Logger::getLogger('MESSAGING')->debug('Pushalot[pushNotificationOnCommit' . ']; $userKeys=[' . $userKeys . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']');
Esempio n. 2
0
use Exception;
use Ampersand\Hooks;
use Ampersand\Database\Database;
use Ampersand\AngularApp;
use Ampersand\Config;
use Ampersand\Role;
use Ampersand\Log\Logger;
use Ampersand\Rule\Rule;
use Ampersand\Rule\RuleEngine;
use Ampersand\Rule\Violation;
use function Ampersand\Helper\getDirectoryList;
// Define hooks
$hook1 = array('class' => '\\Ampersand\\Extension\\ExecEngine\\ExecEngine', 'function' => 'run', 'filename' => 'ExecEngine.php', 'filepath' => 'extensions/ExecEngine', 'params' => array());
Hooks::addHook('preDatabaseCloseTransaction', $hook1);
$hook2 = array('class' => '\\Ampersand\\Extension\\ExecEngine\\ExecEngine', 'function' => 'run', 'filename' => 'ExecEngine.php', 'filepath' => 'extensions/ExecEngine', 'params' => array(true));
Hooks::addHook('postDatabaseReinstallDB', $hook2);
// UI
AngularApp::addMenuItem('ext', 'extensions/ExecEngine/ui/views/MenuItem.html', function ($session) {
    $roles = Config::get('allowedRolesForRunFunction', 'execEngine');
    return !empty(array_intersect($session->getActiveRoles(), (array) $roles)) || is_null($roles);
});
AngularApp::addJS('extensions/ExecEngine/ui/js/ExecEngine.js');
// API
$GLOBALS['api']['files'][] = __DIR__ . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . 'run.php';
// 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;