Example #1
0
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;
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
     */
Example #3
0
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();