Skip to content

Commit

Permalink
Modified error() and info() to NOT use flashdata by default
Browse files Browse the repository at this point in the history
After further analysis of how error and info messages were being used
and how they were likely to be implemented, I changed the default to
NOT use CI Flashdata by default.
  • Loading branch information
tswagger committed Feb 28, 2015
1 parent dd45503 commit 9daa4df
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,35 @@
* https://github.com/emreakay/CodeIgniter-Aauth
*
* @todo separate (on some level) the unvalidated users from the "banned" users
* @todo remove requirement for unique name/username (or default it to use email address, perhaps via config file)
* @todo remove requirement for unique name/username (or default it to use email address, perhaps via config file). OR remove altogether as login uses email address
* @todo add configuration to not use cookies if sessions are enabled.
*/
class Aauth {

/**
* The CodeIgniter object variable
* @access public
* @var object
*/
public $CI;

/**
* Variable for loading the config array into
* @access public
* @var array
*/
public $config_vars;

/**
* Array to store error messages
* @access public
* @var array
*/
public $errors = array();

/**
* Array to store info messages
* @access public
* @var array
*/
public $infos = array();
Expand Down Expand Up @@ -307,6 +312,7 @@ public function is_loggedin() {
* error message, unless 'no_permission' value is set in config. If 'no_permission' is
* set in config it redirects user to the set url and passes the 'no_access' error message.
* It also updates last activity every time function called.
*
* @param bool $perm_par If not given just control user logged in or not
*/
public function control( $perm_par = false ){
Expand Down Expand Up @@ -352,6 +358,7 @@ public function logout() {
* Fast login
* Login with just a user id
* @param int $user_id User id to log in
* @return bool true if login successful.
*/
public function login_fast($user_id){

Expand All @@ -373,7 +380,9 @@ public function login_fast($user_id){
);

$this->CI->session->set_userdata($data);
return true;
}
return false;
}

/**
Expand Down Expand Up @@ -754,6 +763,7 @@ public function verify_user($user_id, $ver_code){
* Send verification email
* Sends a verification email based on user id
* @param int $user_id User id to send verification email to
* @todo return success indicator
*/
public function send_verification($user_id){

Expand Down Expand Up @@ -1650,9 +1660,9 @@ public function set_as_read_pm($pm_id){
* Error
* Add message to error array and set flash data
* @param string $message Message to add to array
* @param boolean $flashdata if true add $message to CI flashdata (deflault: true)
* @param boolean $flashdata if true add $message to CI flashdata (deflault: false)
*/
public function error($message = '', $flashdata = true){
public function error($message = '', $flashdata = false){
$this->errors[] = $message;
if($flashdata) {
$this->CI->session->set_flashdata('errors', $this->errors);
Expand All @@ -1674,14 +1684,14 @@ public function keep_errors(){
/**
* Get Errors Array
* Return array of errors
* @return array|bool Array of messages or false if no errors
* @return array Array of messages, empty array if no errors
*/
public function get_errors_array(){

if (!count($this->errors)==0){
return $this->errors;
} else {
return false;
return array();
}
}

Expand Down Expand Up @@ -1724,9 +1734,9 @@ public function clear_errors() {
* Add message to info array and set flash data
*
* @param string $message Message to add to infos array
* @param boolean $flashdata if true add $message to CI flashdata (deflault: true)
* @param boolean $flashdata if true add $message to CI flashdata (deflault: false)
*/
public function info($message = '', $flashdata = true){
public function info($message = '', $flashdata = false){

$this->infos[] = $message;
if($flashdata) {
Expand All @@ -1749,14 +1759,14 @@ public function keep_infos(){
/**
* Get Info Array
* Return array of info
* @return array|bool Array of messages or false if no errors
* @return array Array of messages, empty array if no errors
*/
public function get_infos_array(){

if (!count($this->infos)==0){
return $this->infos;
} else {
return false;
return array();
}
}

Expand Down

0 comments on commit 9daa4df

Please sign in to comment.