예제 #1
0
    }
    foreach (Rule::getAllSigRules() as $rule) {
        foreach ($rule->getViolations() as $violation) {
            Notifications::addSignal($violation);
        }
    }
    $content = Notifications::getAll();
    // Return all notifications
    print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
});
$app->get('/admin/export/all', function () use($app) {
    if (Config::get('productionEnv')) {
        throw new Exception("Export not allowed in production environment", 403);
    }
    $allAtoms = array();
    foreach (Concept::getAllConcepts() as $concept) {
        $allAtoms[$concept->name] = $concept->getAllAtomIds();
    }
    $allLinks = array();
    foreach (Relation::getAllRelations() as $rel) {
        $allLinks[$rel->signature] = $rel->getAllLinks();
    }
    $strFileContent = '<?php' . PHP_EOL . '$allAtoms = ' . var_export($allAtoms, true) . ';' . PHP_EOL . '$allLinks = ' . var_export($allLinks, true) . ';' . PHP_EOL . '?>';
    file_put_contents(Config::get('absolutePath') . Config::get('logPath') . "export-" . date('Y-m-d_H-i-s') . ".php", $strFileContent);
});
$app->get('/admin/import', function () use($app) {
    if (Config::get('productionEnv')) {
        throw new Exception("Import not allowed in production environment", 403);
    }
    $file = $app->request->params('file');
    if (is_null($file)) {
예제 #2
0
use Ampersand\Session;
use Ampersand\Core\Atom;
use Ampersand\Log\Notifications;
use Ampersand\Interfacing\InterfaceObject;
use function Ampersand\Helper\isAssoc;
global $app;
/**************************************************************************************************
 *
 * resource calls WITHOUT interfaces
 *
 *************************************************************************************************/
$app->get('/resources', function () use($app) {
    if (Config::get('productionEnv')) {
        throw new Exception("List of all resource types is not available in production environment", 403);
    }
    $content = array_keys(Concept::getAllConcepts());
    // Return list of all concepts
    print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
});
$app->get('/resources/:resourceType', function ($resourceType) use($app) {
    $session = Session::singleton();
    $roleIds = $app->request->params('roleIds');
    $session->activateRoles($roleIds);
    $concept = Concept::getConcept($resourceType);
    // Checks
    if (!$session->isEditableConcept($concept)) {
        throw new Exception("You do not have access for this call", 403);
    }
    // Get list of all atoms for $resourceType (i.e. concept)
    $content = $concept->getAllAtomObjects();
    print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);