public function novoAluno() { $db = $this->getDatabase('exemplos'); try { $transaction = $db->beginTransaction(); $pessoa = new Pessoa(); $pessoa->setData($this->data); $pessoa->save(); $this->data->idPessoa = $pessoa->getId(); $aluno = new Aluno(); $aluno->setData($this->data); $aluno->save(); $mail = $this->getMail(); $mail->Subject = 'Novo registro de aluno - ' . $aluno->getMatricula(); $mail->Body = 'Criado novo registro de aluno - ' . $aluno->getMatricula() . ' em ' . Manager::getSysTime(); $mail->addAddress($this->data->email); $ok = $mail->send(); $mensagem = 'Aluno criado com sucesso.'; $transaction->commit(); } catch (\Exception $e) { // rollback da transação em caso de algum erro $transaction->rollback(); $this->data->error = true; $mensagem = $e->getMessage(); } return $mensagem; }
public function sendEmail() { try { $time = Manager::getSysTime(); $ipaddress = $_SERVER['REMOTE_ADDR']; $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = Manager::getConf('mailer.smtpServer'); // SMTP server $mail->From = Manager::getConf('mailer.smtpFrom'); $mail->FromName = Manager::getConf('mailer.smtpFromName'); $mail->Subject = $this->data->assunto; $mail->isHTML(false); $mail->CharSet = 'utf-8'; $body = 'Enviada de: ' . $ipaddress . ' em ' . $time; $mail->Body = $body . "\n" . $this->data->mensagem; $mail->WordWrap = 100; $mail->addAddress($this->data->email); $ok = $mail->send(); $mail->clearAllRecipients(); $this->renderPrompt('information', 'Mensagem enviada com sucesso!'); } catch (Exception $e) { $this->renderPrompt('error', $e->getMessage()); } }
public function newTimeLine($tl) { $timeline = 'tl_' . $tl; $result = $this->getCriteria()->select('max(numOrder) as max')->where("upper(timeline) = upper('{$timeline}')")->asQuery()->getResult(); $max = $result[0]['max']; $order = ($max ?: 0) + 1; $this->setPersistent(false); $this->setTimeLine($timeline); $this->setNumOrder($order); $this->setTlDateTime(\Manager::getSysTime()); $author = \Manager::getLogin()->getLogin(); $this->setAuthor($author); $this->save(); return $timeline; }
public function __construct() { $this->host = $_SERVER['SERVER_NAME']; $this->path = $this->getPathInfo(); mtrace('MRequest path = ' . $this->path); $this->querystring = $this->getQueryString(); $this->method = $this->getRequestType(); $this->domain = $this->getServerName(); $this->remoteAddress = $this->getUserHostAddress(); $this->contentType = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : ''; $this->port = $this->getPort(); $this->secure = $this->getIsSecureConnection(); $this->headers = $_SERVER; $this->cookies = isset($_COOKIES) ? $_COOKIES : ''; $dispatch = Manager::getOptions('dispatch'); /* $p = strpos($this->path,$dispatch); if ($p !== false) { $this->path = str_replace($dispatch, '', $this->path); } $this->baseUrl = Manager::getConf('url.base'); $p = ($this->path && $this->baseUrl) ? strpos($this->path,$this->baseUrl) : false; if (($this->baseUrl != '') && ($p !== false)) { $this->path = str_replace($this->baseUrl, '', $this->path); } * */ $this->baseUrl = $this->getBaseUrl(); $this->date = Manager::getSysTime(); $this->isNew = true; $this->user = ''; $this->password = ''; $this->isLoopback = $this->remoteAddress == '127.0.0.1'; $this->params = $_REQUEST; $this->url = $this->getUrl(); $this->dispatch = $this->getBase() . $dispatch; $this->resolveFormat(); $auth = isset($_SERVER['AUTH_TYPE']) ? $_SERVER['AUTH_TYPE'] : ''; if ($auth != '' && substr($auth, 0, 6) == "Basic ") { $this->user = $_SERVER['PHP_AUTH_USER']; $this->password = $_SERVER['PHP_AUTH_PW']; } //mtrace('MRequest path = ' . $this->path); //mtrace('MRequest base = ' . $this->getBase()); //mtrace('MRequest baseURL = ' . $this->getBaseURL()); //mtrace('MRequest url = ' . $this->url); }
/** * Brief Description. * Complete Description. * * @param $msg (tipo) desc * * @returns (tipo) desc * */ private function handlerDb($msg) { $login = Manager::getLogin(); $uid = $login ? $login->getLogin() : ''; $ts = Manager::getSysTime(); $db = Manager::getDatabase('manager'); $idLog = $db->getNewId('seq_manager_log'); $sql = new MSQL('idlog, timestamp, login, msg, host', 'manager_log'); $db->execute($sql->insert(array($idLog, $ts, $uid, $msg, $this->host))); }
public function formTextField() { $this->data->email = '*****@*****.**'; $this->data->nomeValidator = false; $this->data->currency = Manager::currency(1234.56); $this->data->dataNascimento = Manager::date(Manager::getSysDate()); $this->data->timestamp = Manager::timestamp(Manager::getSysTime()); $this->render(); }
public function applyClass() { $result = str_replace('$_classC', ucfirst($this->var['class']), $this->templateFile); $result = str_replace('$_class', $this->var['class'], $result); $result = str_replace('$_moduleC', ucfirst($this->var['module']), $result); $result = str_replace('$_module', $this->var['module'], $result); $result = str_replace('$_constants', $this->var['constants'], $result); $result = str_replace('$_properties', $this->var['properties'], $result); $result = str_replace('$_methods', $this->var['methods'], $result); $result = str_replace('$_comment', $this->var['comment'], $result); $result = str_replace('$_package', $this->var['package'], $result); $result = str_replace('$_ormmap', $this->var['ormmap'], $result); $result = str_replace('$_actions', $this->var['actions'], $result); $result = str_replace('$_descriptionC', ucfirst($this->var['description'] ?: 'id'), $result); $result = str_replace('$_description', $this->var['description'] ?: 'id', $result); $result = str_replace('$_configLog', $this->var['configLog'], $result); $result = str_replace('$_configValidators', $this->var['configValidators'], $result); $result = str_replace('$_configConverters', $this->var['configConverters'], $result); $result = str_replace('$_extends', $this->var['extends'] ?: '\\MBusinessModel', $result); $result = str_replace('$_time', Manager::getSysTime(), $result); $result = str_replace('$_default', $this->var['default'], $result); $this->resultFile = $result; }