예제 #1
0
 public function checkLogin()
 {
     Manager::logMessage('[LOGIN] Running CheckLogin');
     // if not checking logins, we are done
     if (!MUtil::getBooleanValue(Manager::getConf('maestro.login.check'))) {
         Manager::logMessage('[LOGIN] I am not checking login today...');
         return true;
     }
     // we have a session login?
     $session = Manager::getSession();
     $login = $session->getValue('__sessionLogin');
     if ($login) {
         if ($login->getLogin()) {
             Manager::logMessage('[LOGIN] Using session login: '******'[LOGIN] Using existing login:'******'[LOGIN] No Login but Login required!');
     return false;
 }
예제 #2
0
 public function main()
 {
     if (Manager::isLogged()) {
         $this->render('formMain');
     } else {
         $this->data->datasources = Manager::getConf('fnbr.datasource');
         $this->render('formLogin');
     }
 }
예제 #3
0
 public function __construct()
 {
     $this->name = 'page' . uniqid();
     $this->scripts = new MScripts($this->name);
     $this->content = '';
     $template = Manager::getConf('ui.theme.template') ?: 'index';
     $this->setTemplateName($template);
     $this->setTemplate();
     $this->styleSheetCode = '';
 }
예제 #4
0
 public static function getInstance()
 {
     if (self::$instance == NULL) {
         $configLoader = Manager::getConf('maestro.db.configLoader') ?: 'PHP';
         $manager = self::$instance = new PersistentManager();
         self::$container = Manager::getInstance();
         $manager->setConfigLoader($configLoader);
     }
     return self::$instance;
 }
예제 #5
0
 public static function hasType($type)
 {
     if (Type::hasType($type)) {
         return true;
     } else {
         $className = Manager::getConf('maestro.types')[$type];
         if (isset($type)) {
             Type::addType($type, $className);
             return true;
         }
     }
     return false;
 }
예제 #6
0
 public function __construct()
 {
     parent::__construct("maestro");
     $conf = Manager::getConf('maestro.logs');
     $this->baseDir = $conf['path'];
     $this->level = $conf['level'];
     $this->handler = $conf['handler'];
     $this->port = $conf['port'];
     $this->peer = $conf['peer'];
     $this->strict = $conf['strict'];
     if (empty($this->host)) {
         $this->host = $_SERVER['REMOTE_ADDR'];
     }
 }
예제 #7
0
 public function preProcess()
 {
     $data = Manager::getData();
     if (Manager::isLogged()) {
         $login = Manager::getLogin();
         $userIdLanguage = $login->getUser()->getConfigData('fnbrIdLanguage');
     }
     $idLanguage = $data->lang;
     if ($idLanguage == '') {
         $idLanguage = Manager::getSession()->idLanguage;
         if ($idLanguage == '') {
             $idLanguage = $userIdLanguage;
             if ($idLanguage == '') {
                 $idLanguage = 1;
             }
         }
     }
     Manager::getSession()->idLanguage = $idLanguage;
     $db = $data->datasource ?: (Manager::getSession()->fnbrdb ?: Manager::getConf('db.active'));
     Manager::setConf('db.active', $db);
     //Manager::setConf('options.language', Base::languages()[$idLanguage]);
 }
예제 #8
0
 public function checkAccess($transaction, $access, $deny = false)
 {
     //mdump($transaction);
     //mdump('--------------------');
     //mdump($access);
     $module = Manager::getModule();
     $ok = false;
     if (!is_numeric($access)) {
         $access = $this->access[$access];
     }
     if ($this->auth->isLogged()) {
         $login = $this->auth->getLogin();
         // MLogin object
         $transaction = strtoupper($transaction);
         // Transaction name
         $isAdmin = $login->isAdmin();
         // Is administrator?
         $rights = (int) $login->getRights($transaction);
         // user rights
         $rightsInAll = (int) $login->getRights('ALL');
         // user rights in all transactions
         $ok = ($rights & $access) == $access || ($rightsInAll & $access) == $access || $isAdmin;
         if (!$ok && $deny) {
             $msg = _M('Acesso Negado') . "<br><br>\n" . "<center><big><i><font color=red>" . _M('Transação: ') . "{$transaction}</font></i></big></center><br><br>\n" . _M('Informe um login válido para acessar esta página.') . "<br>";
             //$go = Manager::getCurrentURL();
             //$error = MPrompt::error($msg, $go, $caption, '');
             //Manager::prompt($error, $deny);
             throw new \Maestro\Services\ESecurityException($msg);
         }
     } else {
         if ($deny) {
             $currentUrl = urlencode(\Manager::getCurrentURL());
             $module = Manager::getConf('maestro.login.module');
             $url = Manager::getURL("{$module}/main.login", array('return_to' => $currentUrl));
             Manager::getPage()->redirect($url);
         }
     }
     return $ok;
 }
예제 #9
0
 public function execute()
 {
     // registra, carrega e processa os filtros
     $filters = Manager::getConf('maestro.filters');
     if (is_array($filters)) {
         foreach ($filters as $filter) {
             $filterInstance = MApp::getFilter($this, $filter);
             $filterInstance->preProcess();
         }
     }
     // se a execução não foi cancelada pelos filtros
     if ($this->canCallHandler()) {
         $this->invoke();
     }
     // executa o pos-processamento dos filtros indicados em conf.php
     foreach (Manager::$filters as $filter) {
         $filter[1]->postProcess();
     }
 }
예제 #10
0
 /**
  *
  */
 public static function getTemplate($path)
 {
     $templateClass = '\\Maestro\\UI\\MTemplate' . Manager::getConf('maestro.ui.templateEngine');
     return new $templateClass($path);
 }
예제 #11
0
 public function __construct($request)
 {
     $loader = Manager::$container->get('loader');
     $this->app = strtolower(Manager::getConf('maestro.app'));
     $this->appName = Manager::getConf('maestro.apps.' . $this->app);
     $this->appPath = Manager::getAppPath();
     $part1 = strtolower($request->getAttribute('part1'));
     if ($part1 != '') {
         if ($part1 == 'api' || $part1 == 'service') {
             $this->type = 'service';
             $this->handler = strtolower($request->getAttribute('part2'));
             $this->action = strtolower($request->getAttribute('part3'));
             $this->id = $request->getAttribute('part4');
         } elseif (Manager::getConf('maestro.modules.' . $part1) != '') {
             $this->type = 'module';
             $this->module = $part1;
         } else {
             $this->type = 'controller';
             $class = $this->appName . "\\Infrastructure\\Maestro\\Controllers\\" . $part1 . "Controller";
             if ($loader->findFile($class)) {
                 $this->handler = $part1;
                 $this->action = strtolower($request->getAttribute('part2')) ?: 'main';
                 $this->id = $request->getAttribute('part3');
             } else {
                 $this->section = $part1;
                 $this->handler = strtolower($request->getAttribute('part2'));
                 $this->action = strtolower($request->getAttribute('part3')) ?: 'main';
                 $this->id = $request->getAttribute('part4');
             }
         }
     }
     if ($this->type == 'module') {
         $part2 = strtolower($request->getAttribute('part2'));
         if ($part2 == 'api' || $part2 == 'service') {
             $this->type = 'service';
             $this->handler = strtolower($request->getAttribute('part3'));
             $this->action = strtolower($request->getAttribute('part4'));
             $this->id = $request->getAttribute('part5');
         } else {
             $this->type = 'controller';
             $class = $this->app . "\\" . $this->module . "\\Infrastructure\\Maestro\\Controllers\\" . $part2 . "Controller";
             if ($loader->findFile($class)) {
                 $this->handler = $part2;
                 $this->action = strtolower($request->getAttribute('part3')) ?: 'main';
                 $this->id = $request->getAttribute('part4');
             } else {
                 $this->section = $part2;
                 $this->handler = strtolower($request->getAttribute('part3'));
                 $this->action = strtolower($request->getAttribute('part4')) ?: 'main';
                 $this->id = $request->getAttribute('part5');
             }
         }
         $this->app = $this->module;
         $this->appPath .= DIRECTORY_SEPARATOR . Manager::getConf('maestro.modules.' . $this->module);
     }
     if ($this->id != '') {
         $_REQUEST['id'] = $this->id;
     }
     mtrace('Context app: ' . $this->app);
     mtrace('Context module: ' . $this->module);
     mtrace('Context section: ' . $this->section);
     mtrace('Context type: ' . $this->type);
     mtrace('Context handler: ' . $this->handler);
     mtrace('Context action: ' . $this->action);
     mtrace('Context id: ' . $this->id);
 }
예제 #12
0
 public function __construct()
 {
     parent::__construct('page' . uniqid());
     $this->scripts = new MScripts($this->name);
     $this->fileUpload = mrequest('__ISFILEUPLOAD') == 'yes';
     $this->content = new MBaseControl();
     $template = mrequest('__TEMPLATE') ?: (Manager::getConf('theme.template') ?: 'index');
     $this->setTemplateName($template);
     $this->setTemplate();
     $this->styleSheetCode = '';
     $this->renderType = "page";
     $this->renderId = $this->name;
     ob_start();
 }
예제 #13
0
function shutdown()
{
    $error = error_get_last();
    /*
     * TODO: handler this error message
     */
    if ($error['type'] & Maestro\Manager::getConf('maestro.debug.severity')) {
        if (Maestro\Manager::isAjaxCall()) {
            $ajax = Maestro\Manager::getAjax();
            $ob = ob_get_clean();
            if ($ajax->isEmpty()) {
                $ajax->setType('page');
                $ajax->setData($ob);
            }
            $result = $ajax->returnData();
            echo $result;
        }
    }
}