Skip to content

Commit

Permalink
Base - 0.0.0-DEV.3.4
Browse files Browse the repository at this point in the history
Correção no SendMail
  • Loading branch information
KaduAmaral committed May 23, 2016
1 parent 7389bf0 commit 1f07d8a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Base – 0.0.0-DEV.3.3
# Base – 0.0.0-DEV.3.4
>>>>>>> origin/master
Base é uma "base" para construção de soluções em MVC com PHP.
Expand Down
9 changes: 7 additions & 2 deletions base/core/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ class Config {
public $device;

public static $config;
public static $email;
public static $email = NULL;

function __construct() {

$this->apps = (require APPS . 'appsconfig.php');
$app = APP;
$this->app = $this->apps->$app;

if (!empty($this->app->email))
self::$email = $this->app->email;

$this->setDefaults();

$this->device = New MobileDetect();
Expand All @@ -36,13 +39,15 @@ function __construct() {


self::setLanguage();

}

private function setDefaults(){
if (empty($this->app->view))
$this->app->view = APPS . APP . DS . 'view' . DS;

if (empty($this->app->emails))
$this->app->emails = $this->app->view . 'emails' . DS;

if (!defined('URL') && !empty($this->app->url))
define('URL', $this->app->url);

Expand Down
7 changes: 5 additions & 2 deletions base/core/controller.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function execute($param = NULL){

}

public function controller($controller, $action = 'index'){
public function controller($controller, $action = 'index', $args = NULL){


$class = "\\Controller\\{$controller}Controller";
Expand All @@ -72,7 +72,10 @@ public function controller($controller, $action = 'index'){
$app = New $class($request);

if (method_exists($app, $action)) {
return $app->$action();
if (is_array($args) && count($args) > 0)
return call_user_func_array([$app, $action], $args);
else
return $app->$action();
} else {
throw new \Exception('Requisição inválida.');
}
Expand Down
48 changes: 24 additions & 24 deletions base/core/sendmail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,47 @@ class SendMail extends PHPMailer {
private $debug = FALSE;
private $config;

function __construct($config = NULL) {
function __construct() {

if (!defined('EMAIL_CONFIG')){
if (is_null($config))
throw new \Exception('Configurações de e-mail não informada', 14);
else
$this->config = $config;
} else
$this->config = EMAIL_CONFIG;
if (empty(Config::$email))
throw new \Exception('Configurações de e-mail não informada', 14);
else
$this->config = Config::$email;

if ($this->config['debug'])
if (!empty($this->config->debug) && $this->config->debug)
$this->SMTPDebug = 2;

if ($this->config['smtp'])
if (!empty($this->config->smtp) && $this->config->smtp)
$this->IsSMTP(); // telling the class to use SMTP

if ($this->config['auth'])
if (!empty($this->config->auth) && $this->config->auth)
$this->SMTPAuth = TRUE; // enable SMTP authentication


$this->SMTPSecure = $this->config['secure']; // sets the prefix to the servier
if (!empty($this->config->secure))
$this->SMTPSecure = $this->config->secure; // sets the prefix to the servier

$this->Host = $this->config['host'];
if (!empty($this->config->host))
$this->Host = $this->config->host;

$this->Port = 465; // set the SMTP port
$this->Username = '[email protected]';
$this->Password = 'iL]4*-64^$Ew';
if (!empty($this->config->port))
$this->Port = $this->config->port; // set the SMTP port || 465

$this->Username = $this->config->user;
$this->Password = $this->config->pass;

$this->isHTML(true);

$this->setLanguage('pt');

$this->CharSet = 'utf-8';
$this->SetFrom($this->config['from']['email'], $this->config['from']['name']);

}
if (!empty($this->config->from))
$this->SetFrom($this->config->from->email, !empty($this->config->from->name) ? $this->config->from->name : $this->config->from->email);

function Debug(){
$this->debug = !$this->debug;
}

function load($file, $vars = []){
return Load::EMAIL($file, $vars);
function Debug() {
$this->debug = !$this->debug;
}

}
}

0 comments on commit 1f07d8a

Please sign in to comment.