Skip to content

Commit

Permalink
Modified keep_infos() and keep_errors() with options
Browse files Browse the repository at this point in the history
Modified keep_infos() and keep_errors() to include non-flash data values on optional boolean parameter.
  • Loading branch information
tswagger committed May 7, 2015
1 parent 5ff1af1 commit bae4b0c
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1690,13 +1690,24 @@ public function error($message = '', $flashdata = false){

/**
* Keep Errors
* keeps the flash data flash data
* Benefitial by using Ajax Requests
* more info about flash data
* http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
*
* Keeps the flashdata errors for one more page refresh. Optionally adds the default errors into the
* flashdata list. This should be called last in your controller, and with care as it could continue
* to revive all errors and not let them expire as intended.
* Benefitial when using Ajax Requests
* @see http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
* @param boolean $include_non_flash true if it should stow basic errors as flashdata (default = false)
*/
public function keep_errors(){
$this->CI->session->keep_flashdata('errors');
public function keep_errors($include_non_flash = FALSE)
{
// NOTE: keep_flashdata() overwrites anything new that has been added to flashdata so we are manually reviving flash data
// $this->CI->session->keep_flashdata('errors');

if($include_non_flash) {
$this->flash_errors = array_merge($this->flash_errors, $this->errors);
}
$this->flash_errors = array_merge($this->flash_errors, (array)$this->CI->session->flashdata('errors'));
$this->CI->session->set_flashdata('errors', $this->flash_errors);
}

//tested
Expand Down Expand Up @@ -1766,16 +1777,26 @@ public function info($message = '', $flashdata = false){

/**
* Keep Infos
* keeps the flash data
*
* Keeps the flashdata infos for one more page refresh. Optionally adds the default infos into the
* flashdata list. This should be called last in your controller, and with care as it could continue
* to revive all infos and not let them expire as intended.
* Benefitial by using Ajax Requests
* more info about flash data
* http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
* @see http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
* @param boolean $include_non_flash true if it should stow basic infos as flashdata (default = false)
*/
public function keep_infos(){
$this->CI->session->keep_flashdata('infos');
public function keep_infos($include_non_flash = FALSE)
{
// NOTE: keep_flashdata() overwrites anything new that has been added to flashdata so we are manually reviving flash data
// $this->CI->session->keep_flashdata('infos');

if($include_non_flash) {
$this->flash_infos = array_merge($this->flash_infos, $this->infos);
}
$this->flash_infos = array_merge($this->flash_infos, (array)$this->CI->session->flashdata('infos'));
$this->CI->session->set_flashdata('infos', $this->flash_infos);
}

//tested
/**
* Get Info Array
* Return array of info
Expand Down

0 comments on commit bae4b0c

Please sign in to comment.