Navigation Menu

Skip to content

Commit

Permalink
Printing json and stopping the framework when use Post::success with …
Browse files Browse the repository at this point in the history
…ajax requests whitout the redirect parameter
  • Loading branch information
Carlos André Ferrari committed Dec 8, 2009
1 parent 6e9fc8a commit 23d7541
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions core/classes/Post.php
Expand Up @@ -144,10 +144,9 @@ public static function getVal($c){
*/
public static function toObject($class = 'DTO')
{
global $_POST, $_PAR;
$obj = new $class();
if (isset($_PAR) && is_array($_PAR)) foreach ($_PAR as $k => $v) $obj->$k = $_PAR[$k];
if (isset($_POST) && is_array($_POST)) foreach ($_POST as $k => $v) $obj->$k = $_POST[$k];
if (!is_array($_POST)) return false;
foreach ($_POST as $k => $v) $obj->$k = p($k);
return $obj;
}

Expand Down Expand Up @@ -272,6 +271,7 @@ public static function setSucesso($mensagem, $redirect=false){
foreach(DAO::getAll() as $k => $d)
$json->addPackage($k, $d);
$json->set(1, $mensagem);
if (!$redirect) exit($json->render());
}else{
Session::set('form_tipo', POST_OK);
Session::set('form_mensagem' , $mensagem);
Expand All @@ -290,16 +290,6 @@ public static function success($mensagem, $redirect=false){
self::setSucesso($mensagem, $redirect);
}

/**
* Set in what comment the message will be renderized
*
* @param string $comment Comment name
* @return void
*/
public function autoRender($comment = 'message'){
Template::setVar($comment, Post::renderMsg());
}

/**
* Create a object based on the posted data and the current controller
*
Expand Down

0 comments on commit 23d7541

Please sign in to comment.