Esempio n. 1
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 ESecurityException($msg);
         }
     } else {
         if ($deny) {
             $currentUrl = urlencode(Manager::getCurrentURL());
             $module = Manager::getConf('login.module');
             $url = Manager::getURL("{$module}/main.login", array('return_to' => $currentUrl));
             Manager::getPage()->redirect($url);
         }
     }
     return $ok;
 }
Esempio n. 2
0
 public function addEvent($event, $handler, $preventDefault = true, $dijit = false)
 {
     if ($handler[0] == ':') {
         $url = Manager::getCurrentURL() . '?event=' . substr($handler, 1);
         $handler = MUI::doAjaxText($url, $this->id);
     }
     $isDijit = false;
     //$this->getIsDijit() || $dijit;
     if ($event == 'onClick') {
         $event = 'click';
     } elseif ($event == 'onChange') {
         $event = 'change';
     }
     $this->event[$event][] = array('handler' => $handler, 'prevent' => $preventDefault, 'dijit' => $isDijit);
 }
Esempio n. 3
0
 public function generate()
 {
     // panel
     $panel = new MBaseControl('mpanel');
     $panel->property->title = $this->property->title;
     $panel->style->width = $this->style->width;
     $panel->property->close = $this->property->close;
     $panel->property->class = $this->property->class;
     //mdump('--');
     //mdump($this->style->border);
     $panel->options->border = isset($this->style->border) ? $this->style->border : false;
     $panel->generate();
     //gera o panel para obter todos os atributos
     // propriedades
     $this->property->action = $this->property->action ?: Manager::getCurrentURL();
     \Maestro\Utils\MUtil::setIfNull($this->property->method, 'POST');
     \Maestro\Utils\MUtil::setIfNull($this->style->width, "100%");
     $this->property->role = "form";
     // define o layout com base na classe bootstrap do form
     \Maestro\Utils\MUtil::setIfNull($this->property->layout, "horizontal");
     $this->setClass("form-{$this->property->layout}");
     // neste tema o mform é constituído de 3 blocos principais: fields, buttons e help
     $fields = $buttons = $help = "";
     if ($this->fields != NULL) {
         $fields = $this->generateFields();
     }
     if ($this->buttons != NULL) {
         $buttons = $this->generateButtons();
     }
     if ($this->help != NULL) {
         $help = $this->generateHelp();
     }
     // toolbar
     if ($this->toolbar) {
         $this->toolbar->tag = 'header';
         $this->toolbar->setClass('datagrid-toolbar');
         $toolbar = $this->toolbar->generate();
     }
     // menubar
     if ($this->property->menubar) {
         $menubar = $this->property->menubar->generate();
     }
     // por default, o método de submissão é POST
     \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST");
     if ($this->property->onsubmit) {
         $this->page->onSubmit($this->property->onsubmit, $this->property->id);
     }
     // se o form tem fields com validators, define onSubmit
     $validators = '';
     if (count($this->property->toValidate)) {
         $this->page->onSubmit("\$('#{$this->property->id}').form('validate')", $this->id);
         $validators = implode(',', $this->property->bsValidator);
     }
     // obtem o codigo html via template
     $result = $this->painter->fetch('mform', $this, ['panel' => $panel, 'fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'validators' => $validators, 'menubar' => $menubar, 'toolbar' => $toolbar]);
     return $result;
 }
Esempio n. 4
0
 public function invokeHandler($m, $handler)
 {
     global $context, $module, $action, $item, $session, $page, $auth, $perms, $navbar, $theme, $history, $self, $url;
     if ($handler == '') {
         return false;
     }
     //$this->data = $data;
     $this->action = $handler;
     $app = Manager::getApp();
     if ($m == '' || $m == $app) {
         $module = $app;
         $path = Manager::getAppPath() . '/controllers/';
     } else {
         $module = $m;
         $path = Manager::getModulePath($module, 'controllers/');
     }
     //mdump("Handler:invokeHandler: [$module][$handler]");
     $context = Manager::getContext();
     $action = $context->getAction();
     $self = $context->getAction();
     $item = mrequest('item');
     $session = Manager::getSession();
     $navbar = new MNavigationBar();
     //$view = Manager::getView($module, 'handler', $action);
     $page = $this->theme;
     $url = Manager::getCurrentURL();
     $auth = Manager::getAuth();
     $perms = Manager::getPerms();
     $theme = $this->theme;
     $file = $path . $handler . '.inc.php';
     //mdump('Handler:invokeHandler: file : ' . $file);
     if ($return = file_exists($file)) {
         include $file;
     }
     return $return;
 }
Esempio n. 5
0
 /**
  * Brief Description.
  * Complete Description.
  *
  * @returns (tipo) desc
  *
  */
 public function generateBody()
 {
     $array = array();
     // optionally generate errors
     if ($this->hasErrors()) {
         $array[] = new MDiv('', $this->generateErrors());
     }
     if ($this->hasInfos()) {
         $array[] = new MDiv('', $this->generateInfos());
     }
     if ($this->action == '') {
         $this->action = Manager::getCurrentURL();
     }
     $array[] = $this->generateLayout();
     $array[] = $this->generateScript();
     $body = new MDiv('', $array, 'mFormBody');
     return $body;
 }