Changeset 2697
- Timestamp:
- 05/28/2008 04:31:04 PM (6 months ago)
- Files:
-
- 1 modified
-
releases/2.1.2/system/core/Event.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
releases/2.1.2/system/core/Event.php
r1932 r2697 41 41 self::$events[$name] = array(); 42 42 } 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; 49 51 50 52 return TRUE; … … 67 69 { 68 70 // Just add the event if there are no events 69 self::add($name, $callback);71 return self::add($name, $callback); 70 72 } 71 73 else 72 74 { 73 75 // 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 } 78 78 } 79 79 … … 94 94 { 95 95 // Just add the event if there are no events 96 self::add($name, $callback);96 return self::add($name, $callback); 97 97 } 98 98 else 99 99 { 100 100 // 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 } 105 103 } 106 104 … … 115 113 private static function insert_event($name, $key, $callback) 116 114 { 115 if (in_array($callback, self::$events[$name], TRUE)) 116 return FALSE; 117 117 118 // Add the new event at the given key location 118 119 self::$events[$name] = array_merge … … 125 126 array_slice(self::$events[$name], $key) 126 127 ); 128 129 return TRUE; 127 130 } 128 131
