Config::set('ignoreInvariantViolations', 'transactions', false); // for debugging can be set to true (transactions will be committed regardless off invariant violations) Config::set('interfaceAutoCommitChanges', 'transactions', true); // specifies whether changes in an interface are automatically commited when allowed (all invariants hold) Config::set('interfaceAutoSaveChanges', 'transactions', true); // specifies whether changes in interface are directly communicated (saved) to server Config::set('interfaceCacheGetCalls', 'transactions', false); // specifies whether GET calls should be cached by the frontend (e.g. angular) application // Default CRUD rights for interfaces Config::set('defaultCrudC', 'transactions', true); Config::set('defaultCrudR', 'transactions', true); Config::set('defaultCrudU', 'transactions', true); Config::set('defaultCrudD', 'transactions', true); // Default notification settings Config::set('defaultShowSignals', 'notifications', true); Config::set('defaultShowInfos', 'notifications', true); Config::set('defaultShowWarnings', 'notifications', true); Config::set('defaultShowSuccesses', 'notifications', true); Config::set('defaultAutoHideSuccesses', 'notifications', true); Config::set('defaultShowErrors', 'notifications', true); Config::set('defaultShowInvariants', 'notifications', true); // Navigation menu settings AngularApp::addMenuItem('refresh', 'app/views/menu/installer.html', function ($session) { return !Config::get('productionEnv'); }); AngularApp::addMenuItem('refresh', 'app/views/menu/checkAllRules.html', function ($session) { return !Config::get('productionEnv'); }); } catch (Exception $e) { throw $e; }
use Ampersand\Core\Concept; use Ampersand\Config; use Ampersand\Interfacing\InterfaceObject; use Ampersand\Core\Relation; use Ampersand\Log\Logger; use PHPExcel_Cell; use PHPExcel_Shared_Date; use PHPExcel_IOFactory; require_once __DIR__ . '/lib/Classes/PHPExcel.php'; // UI AngularApp::addMenuItem('ext', 'extensions/ExcelImport/ui/views/MenuItem.html', function ($session) { $roles = Config::get('allowedRolesForExcelImport', 'excelImport'); return !empty(array_intersect($session->getActiveRoles(), (array) $roles)) || is_null($roles); }); AngularApp::addCSS('extensions/ExcelImport/ui/css/style.css'); AngularApp::addJS('extensions/ExcelImport/ui/js/ExcelImport.js'); // API $GLOBALS['api']['files'][] = __DIR__ . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . 'import.php'; // Config Config::set('allowedMimeTypes', 'excelImport', array('application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/excel')); class ExcelImport { /** * * @var string */ public $file; /** * * @var \Psr\Log\LoggerInterface */
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; public static $doRun = true; public static $autoRerun; public static $runCount; public static function run($allRules = false) { $database = Database::singleton();
namespace Ampersand\Extension\OAuthLogin; use Exception; use Ampersand\AngularApp; use Ampersand\Config; use Ampersand\Session; use Ampersand\Database\Database; use Ampersand\Core\Atom; use Ampersand\Core\Concept; use Ampersand\Core\Relation; // UI AngularApp::addMenuItem('role', 'extensions/OAuthLogin/ui/views/MenuItem.html', function ($session) { return true; }); AngularApp::addJS('extensions/OAuthLogin/ui/js/LoginModule.js'); // API $GLOBALS['api']['files'][] = __DIR__ . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . 'oauthlogin.php'; class OAuthLoginController { private $token_url; private $client_id; private $client_secret; private $redirect_uri; private $tokenObj; private $dataObj; function __construct($client_id, $client_secret, $redirect_uri, $token_url) { $this->client_id = $client_id; $this->client_secret = $client_secret; $this->redirect_uri = $redirect_uri;
<?php use Ampersand\Session; use Ampersand\AngularApp; use Ampersand\Log\Notifications; use Ampersand\Config; use Ampersand\Rule\RuleEngine; global $app; $app->get('/sessions/:sessionId/navbar', function ($sessionId) use($app) { $session = Session::singleton(); $roleIds = $app->request->params('roleIds'); $session->activateRoles($roleIds); foreach (RuleEngine::getSignalViolationsFromDB() as $violation) { Notifications::addSignal($violation); } $content = array('top' => AngularApp::getNavBarIfcs('top'), 'new' => AngularApp::getNavBarIfcs('new'), 'refreshMenu' => AngularApp::getMenuItems('refresh'), 'extMenu' => AngularApp::getMenuItems('ext'), 'roleMenu' => AngularApp::getMenuItems('role'), 'defaultSettings' => array('notifications' => Notifications::getDefaultSettings(), 'switchAutoCommit' => Config::get('interfaceAutoCommitChanges', 'transactions'), 'cacheGetCalls' => Config::get('interfaceCacheGetCalls', 'transactions'), 'switchAutoSave' => Config::get('interfaceAutoSaveChanges', 'transactions')), 'notifications' => Notifications::getAll(), 'session' => array('id' => $session->id, 'loggedIn' => $session->sessionUserLoggedIn()), 'sessionRoles' => array_values($session->getSessionRoles()), 'sessionVars' => $session->getSessionVars()); print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); }); $app->get('/sessions/:sessionId/notifications', function ($sessionId) use($app) { $session = Session::singleton(); $roleIds = $app->request->params('roleIds'); $session->activateRoles($roleIds); foreach (RuleEngine::getSignalViolationsFromDB() as $violation) { Notifications::addSignal($violation); } $content = Notifications::getAll(); print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); }); $app->delete('/sessions/:sessionId', function ($sessionId) use($app) { $session = Session::singleton(); // Checks