Changeset 2697

Show
Ignore:
Timestamp:
05/28/2008 04:31:04 PM (6 months ago)
Author:
Shadowhand
Message:

Merging r2696 into 2.1.2

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • releases/2.1.2/system/core/Event.php

    r1932 r2697  
    4141                        self::$events[$name] = array(); 
    4242                } 
    43  
    44                 if ( ! in_array($callback, self::$events[$name], TRUE)) 
    45                 { 
    46                         // Add the event if it does not already exist in the queue 
    47                         self::$events[$name][] = $callback; 
    48                 } 
     43                elseif (in_array($callback, self::$events[$name], TRUE)) 
     44                { 
     45                        // The event already exists 
     46                        return FALSE; 
     47                } 
     48 
     49                // Add the event 
     50                self::$events[$name][] = $callback; 
    4951 
    5052                return TRUE; 
     
    6769                { 
    6870                        // Just add the event if there are no events 
    69                         self::add($name, $callback); 
     71                        return self::add($name, $callback); 
    7072                } 
    7173                else 
    7274                { 
    7375                        // Insert the event immediately before the existing event 
    74                         self::insert_event($name, $key, $callback); 
    75                 } 
    76  
    77                 return TRUE; 
     76                        return self::insert_event($name, $key, $callback); 
     77                } 
    7878        } 
    7979 
     
    9494                { 
    9595                        // Just add the event if there are no events 
    96                         self::add($name, $callback); 
     96                        return self::add($name, $callback); 
    9797                } 
    9898                else 
    9999                { 
    100100                        // Insert the event immediately after the existing event 
    101                         self::insert_event($name, $key + 1, $callback); 
    102                 } 
    103  
    104                 return TRUE; 
     101                        return self::insert_event($name, $key + 1, $callback); 
     102                } 
    105103        } 
    106104 
     
    115113        private static function insert_event($name, $key, $callback) 
    116114        { 
     115                if (in_array($callback, self::$events[$name], TRUE)) 
     116                        return FALSE; 
     117 
    117118                // Add the new event at the given key location 
    118119                self::$events[$name] = array_merge 
     
    125126                        array_slice(self::$events[$name], $key) 
    126127                ); 
     128 
     129                return TRUE; 
    127130        } 
    128131