Пример #1
0
 public static function run()
 {
     global $rea_route, $config, $rea_controller;
     //rea_app::on("rea_end", array("rea_app_controller", "commit"));
     if (function_exists('app_start')) {
         app_start($rea_route->details['values']);
     }
     $rea_controller->dispatchEvent('app_start', array($rea_route->details['values']));
     global $app_extended_view_helpers;
     if (count($app_extended_view_helpers) > 0) {
         foreach ($app_extended_view_helpers as $a) {
             $a = '' . $a . '_extended_view_start';
             if (function_exists($a)) {
                 $a($rea_route->details['values']);
             }
         }
     }
     $fn = 'app_event_' . $rea_route->details['action'];
     if (function_exists($fn)) {
         $data = $fn($rea_route->details['values']);
     }
     $rea_controller->dispatchEvent($fn, array($rea_route->details['values']));
     if (function_exists('app_end')) {
         app_end($rea_route->details['values']);
     }
     $rea_controller->dispatchEvent('app_end', array($rea_route->details['values']));
     self::commit();
 }
Пример #2
0
function rea_app_model_run()
{
    global $page, $config;
    global $rea_app_route;
    global $auth_user, $rea_controller;
    $method = null;
    $page->name = $config->application['name'];
    $page->title = $config->application['name'];
    $page->uid = 'nkdfg';
    $values = array();
    if (function_exists('rea_ui_event_view_show')) {
        rea_app::registerForEvent('rea_view_show', 'rea_ui_event_view_show');
    }
    rea_app::registerForEvent('rea_view_show', 'rea_app_model_page_before_display');
    $rea_app_route = rea_app_route::loadRoute();
    $cfg_auth_actions = array('rea_login', 'rea_logout', 'rea_login_do', 'rea_login_ingest', 'ras_psr_start', 'ras_psr_show', 'ras_psr_do');
    $flg_is_auth_action = in_array($rea_app_route['action'], $cfg_auth_actions);
    if ($config->application['attributes']['opt_use_auth'] == 1 && !$config->application['attributes']['op_run_without_auth']) {
        //var_dump($config);
        if ($rea_app_route['action'] == 'rea_login_do' && !function_exists('app_event_rea_login_do')) {
            //handle it ourselves...
            rea_authorization::login_authorize($rea_app_route['values']);
            if (isset($_SESSION['REA_REENTRY_URL'])) {
                $url = $_SESSION['REA_REENTRY_URL'];
                unset($_SESSION['REA_REENTRY_URL']);
                rea_response::location($url);
                exit;
            }
        }
        if (!$flg_is_auth_action) {
            if (isset($config->application['attributes']['REA_REENTRY_URL'])) {
                $_SESSION['REA_REENTRY_URL'] = $config->application['attributes']['REA_REENTRY_URL'];
            } else {
                $_SESSION['REA_REENTRY_URL'] = REA_SELF_URL;
                //$config->application['attributes']['url'];
            }
        }
        if ($rea_app_route['action'] == 'rea_logout' && !function_exists('app_event_rea_logout')) {
            //handle it ourselves...
            rea_authorization::user_logout();
        }
        if (!$flg_is_auth_action) {
            /// REquire an authenticated session, reload session user
            $rea_controller->raiseEvent("auth_validate", array());
            if (!rea_authorization::user_validate()) {
                $url = rea_authorization::login_redirect();
                rea_response::location($url);
                exit;
            }
            if (isset($config->real_user)) {
                $config->alias_user = $config->real_user;
                if (isset($config->application['attributes']['authorization']['allow_subject_alias']) and $config->application['attributes']['authorization']['allow_subject_alias'] == 1 and isset($_SESSION['ras_alias'])) {
                    $alias_attributes = $config->real_user->getRoleAttribute('rea_sis_alias');
                    if (is_string($alias_attributes['appuid_allowed'])) {
                        $apps_allowed = array($alias_attributes['appuid_allowed']);
                    } else {
                        $apps_allowed = $alias_attributes['appuid_allowed']->getArray();
                    }
                    if ($apps_allowed[0] == '*' or in_array($config->application['uid'], $apps_allowed)) {
                        $u = ras::loadFromUID($_SESSION['ras_alias']);
                        $item = new ctrl_alert("Using alias for user: {$u->name_display} [{$u->email}] <a href='/" . strtolower(REA_LOCATIONID) . "/profile/scr_alias.php?a=remove'>Remove</a>", 'alert-success', false);
                        $page->write($item);
                        $config->alias_user = $u;
                        $config->alias_user->roles['rea_sis_alias'] = $config->real_user->roles['rea_sis_alias'];
                    }
                }
            }
            $rea_controller->raiseEvent('rea_app_model_user_available', array($config, $rea_app_route));
        }
        //rea_authorization::login_validate();
    }
    if (isset($config->application['attributes']['model_access'])) {
        $roles = '';
        if (isset($config->application['authorization']['roles']) && strlen($config->application['authorization']['roles']) > 0) {
            $roles = $config->application['authorization']['roles'];
        } elseif (isset($config->application['acl']) && strlen($config->application['acl']) > 0) {
            $roles = $config->application['acl'];
        }
        $ma = $config->application['attributes']['model_access'];
        $me = '';
        if (array_key_exists($rea_app_route['action'], $ma)) {
            $me = $ma[$rea_app_route['action']];
            if (!$config->alias_user->canAccess($me)) {
                $page->showError("Unable to continue", "You are not allowed to perform this operation. [ERR:APPMODELSEC01][" . htmlentities($rea_app_route['action']) . "]");
            }
        }
    }
    $rea_controller->raiseEvent('rea_app_model_app_start', array($config, $rea_app_route));
    //print "here1<br>";
    if (isset($_GET['a']) and $_GET['a'] == 'rea_logout') {
        unset($alias_check);
    } else {
        $alias_check = true;
    }
    if (function_exists('app_start')) {
        app_start($page, $rea_app_route['values']);
    }
    global $app_extended_view_helpers;
    if (count($app_extended_view_helpers) > 0) {
        foreach ($app_extended_view_helpers as $a) {
            $a = '' . $a . '_extended_view_start';
            if (function_exists($a)) {
                $a($page, $rea_app_route['values']);
            }
        }
    }
    $panel = '__';
    if (isset($_GET['rea_spawn_status'])) {
        $rea_app_route['method'] = 'get';
        $rea_app_route['action'] = 'spawn_' . $rea_app_route['values']['rea_spawn_status'];
    }
    if (isset($rea_app_route['values']['ui_form_persistant'])) {
        $panel = $rea_app_route['values']['ui_form_persistant'];
        $frm = new rea_values($rea_app_route['values']);
        $rea_app_route['values'] = $frm->load_persistant();
    }
    $fn = 'app_' . $rea_app_route['method'] . '_start';
    if (function_exists($fn)) {
        $data = $fn($page, $rea_app_route['values']);
    }
    $fn = 'app_event_' . $rea_app_route['action'];
    $pn = "process_{$panel}";
    if (function_exists($pn)) {
        $data = $pn($page, $rea_app_route['values']);
    } elseif (function_exists($fn)) {
        $data = $fn($page, $rea_app_route['values']);
    } elseif (strpos($rea_app_route['action'], 'spawn_') === 0) {
        $fn = 'app_event_' . $rea_app_route['action'];
        if (function_exists($fn)) {
            $fn($page, $rea_app_route['values']);
        } else {
            $fn = "rea_spawn_default_" . str_replace('spawn_', '', $rea_app_route['action']);
            if (function_exists($fn)) {
                $fn($page, $rea_app_route['values']);
            } else {
                $page->showError("Unable to continue", "Invalid request to application model. [2]");
            }
        }
    } else {
        $fn = "app_event_unhandled";
        if (function_exists($fn)) {
            $fn($page, $rea_app_route['values']);
        } else {
            $page->showError("Unable to continue", "Invalid request to application model." . $rea_app_route['action']);
        }
    }
    $fn = 'app_' . $rea_app_route['method'] . '_end';
    if (function_exists($fn)) {
        $data = $fn($page, $rea_app_route['values']);
    }
    if (function_exists('app_end')) {
        app_end($page, $rea_app_route['values']);
    }
    rea_app_model_show();
}