Changeset 498

Show
Ignore:
Timestamp:
06/08/08 02:04:56 (7 months ago)
Author:
padams
Message:

- fixed bug were calling application config was not over writing user config values fetched from the db
- added several missing entity classes
- added check fro upgrades
- added upgrade call
- added several new DAO methods
- abstracted SQL into platfrom constants
- removed call to installer. Entities now create their own tables

Location:
trunk
Files:
10 added
53 modified

Legend:

Unmodified
Added
Removed
  • trunk/asyncEventProcessor.php

    r493 r498  
    7373         */ 
    7474        function asyncEventProcessor($config = null) { 
     75                 
    7576                $this->owa_caller($config); 
    76                                  
     77                 
    7778                if ($this->config['error_handler'] == 'development'): 
    78                         $this->config['error_handler'] = 'async_development'; 
    79                 endif; 
    80                  
    81                 //$this->e = &owa_error::get_instance(); 
    82  
     79                        //$this->config['error_handler'] = 'async_development'; 
     80                endif; 
     81                 
    8382                // Turns off async setting so that the proper event queue is created 
    8483                $this->config['async_db'] = false; 
     84                $this->c->set('base', 'async_db', false); 
     85                 
     86                // load event queue 
    8587                $this->eq = &eventQueue::get_instance(); 
     88                 
     89                // load DAO 
    8690                $this->db = &owa_coreAPI::dbSingleton(); 
    8791                 
     
    125129         */ 
    126130        function process_events($event_file) { 
    127                 $this->e->info(sprintf('Starting Async Event Processing Run for: %s', 
    128                                                                         $event_file)); 
    129                 //check for lock file 
    130                 if (file_exists($this->config['async_log_dir'].$this->config['async_lock_file'])): 
    131                         //read contents of lock file for last PID 
    132                         $lock_file = fopen($this->config['async_log_dir'].$this->config['async_lock_file'], "r") or die ("Could not create lock file"); 
    133                                 if ($lock_file): 
    134                                         while (!feof($lock_file)) { 
    135                                         $former_pid = fgets($lock_file, 4096); 
    136                                     } 
    137                                         fclose($lock_file); 
     131                 
     132                if (file_exists($event_file)): 
     133                        $this->e->info(sprintf('Starting Async Event Processing Run for: %s', $event_file)); 
     134                        //check for lock file 
     135                        if (file_exists($this->config['async_log_dir'].$this->config['async_lock_file'])): 
     136                                //read contents of lock file for last PID 
     137                                $lock_file = fopen($this->config['async_log_dir'].$this->config['async_lock_file'], "r") or die ("Could not create lock file"); 
     138                                        if ($lock_file): 
     139                                                while (!feof($lock_file)) { 
     140                                                        $former_pid = fgets($lock_file, 4096); 
     141                                                } 
     142                                                fclose($lock_file); 
     143                                        endif; 
     144                                //check to see if former PID is still running 
     145                                $ps_check = $this->is_running($former_pid); 
     146                                //if the process is still running, exit. 
     147                                if ($ps_check == true): 
     148                                        $this->e->info(sprintf('Previous Process (%d) still active. Terminating Run.', 
     149                                                                                $former_pid)); 
     150                                        exit; 
     151                                //if it's not running remove the lock file and proceead. 
     152                                else: 
     153                                        $this->e->info(sprintf('Process %d is not running. Continuing Run... \n', 
     154                                                                                $former_pid)); 
     155                                        unlink ($this->config['async_log_dir'].$this->config['async_lock_file']); 
     156                                        $this->process_event_log($event_file); 
    138157                                endif; 
    139                         //check to see if former PID is still running 
    140                         $ps_check = $this->is_running($former_pid); 
    141                         //if the process is still running, exit. 
    142                         if ($ps_check == true): 
    143                                 $this->e->info(sprintf('Previous Process (%d) still active. Terminating Run.', 
    144                                                                         $former_pid)); 
    145                                 exit; 
    146                         //if it's not running remove the lock file and proceead. 
     158         
    147159                        else: 
    148                                 $this->e->info(sprintf('Process %d is not running. Continuing Run... \n', 
    149                                                                         $former_pid)); 
    150                                 unlink ($this->config['async_log_dir'].$this->config['async_lock_file']); 
    151160                                $this->process_event_log($event_file); 
     161                                 
    152162                        endif; 
    153  
    154163                else: 
    155                         $this->process_event_log($event_file); 
    156                          
     164                        $this->e->debug("No event file found at: ".$event_file); 
    157165                endif; 
    158166                return; 
     
    176184                 
    177185                if (file_exists($file)): 
     186                        $this->db->connect(); 
    178187                        if($this->db->connection_status == true): 
    179188                                $this->create_lock_file(); 
  • trunk/conf/messages.php

    r452 r498  
    37372002 => array("<B>Login Failed</B>. Your user name or password did not match.",0), 
    38382003 => array("Your Account lacks the necessary priviledges to access the requested resource.",0), 
    39 2004 => array("You must login to access the requested resource."), 
     392004 => array("You must login to access the requested resource.",0), 
    40402010 => array("Sucess. Logout Complete.",0), 
    4141 
     
    6868//install 
    69693300 => array("Could not connect to the database. Please check the database connection settings in your configuration file and try again.",0), 
    70 3301 => array("The version of PHP installed on this server is too old. Please upgrade to at least PHP 4."), 
     703301 => array("The version of PHP installed on this server is too old. Please upgrade to at least PHP 4.",0), 
    71713302 => array("Database Schema Installation failed. Please check the error log file for more details.",0), 
    72723303 => array("Success. Default Site Added.",0), 
  • trunk/eventQueue.php

    r415 r498  
    1818 
    1919require_once(OWA_PEARLOG_DIR . DIRECTORY_SEPARATOR . 'Log.php'); 
    20 require_once(OWA_PLUGINS_DIR . DIRECTORY_SEPARATOR . 'log/queue.php'); 
    21 require_once(OWA_PLUGINS_DIR . DIRECTORY_SEPARATOR . 'log/async_queue.php'); 
     20require_once(OWA_PLUGIN_DIR . 'log/queue.php'); 
     21require_once(OWA_PLUGIN_DIR . 'log/async_queue.php'); 
    2222require_once(OWA_BASE_CLASSES_DIR. 'owa_observer.php'); 
    2323 
  • trunk/modules/base/classes/column.php

    r334 r498  
    3131class owa_dbColumn { 
    3232         
     33        var $name; 
     34         
    3335        var $value; 
     36         
     37        var $data_type; 
    3438         
    3539        var $foriegn_key; 
    3640         
     41        var $is_primary_key = false; 
     42         
    3743        var $auto_increment = false; 
    3844         
    39         function owa_dbColumn() { 
     45        var $is_unique = false; 
     46         
     47        var $is_not_null = false; 
     48         
     49        var $label; 
     50         
     51        function owa_dbColumn($params = array()) { 
     52                 
     53                 
     54                if (!empty($params)): 
     55                         
     56                        foreach ($params as $k => $v) { 
     57                                 
     58                                $this->$k = $v; 
     59                         
     60                        } 
     61                         
     62                endif; 
    4063                 
    4164                return; 
     65        } 
     66         
     67        function get($name) { 
     68         
     69                return $this->$name; 
     70        } 
     71         
     72        function set($name, $value) { 
     73         
     74                $this->$name = $value; 
     75                 
     76                return; 
     77        } 
     78         
     79        function getDefinition() { 
     80         
     81                $definition = ''; 
     82                 
     83                $definition .= $this->get('data_type'); 
     84                         
     85                // Check for auto increment 
     86                if ($this->get('auto_increment') == true): 
     87                        $definition .= ' '.OWA_DTD_AUTO_INCREMENT; 
     88                endif; 
     89                         
     90                // Check for auto Not null 
     91                if ($this->get('is_not_null') == true): 
     92                        $definition .= ' '.OWA_DTD_NOT_NULL; 
     93                endif; 
     94                         
     95                // Check for unique 
     96                if ($this->get('is_unique') == true): 
     97                        $definition .= ' '.OWA_DTD_UNIQUE; 
     98                endif; 
     99                         
     100                // check for primary key 
     101                if ($this->get('is_primary_key') == true): 
     102                        $definition .= ' '.OWA_DTD_PRIMARY_KEY; 
     103                        //$definition .= sprintf(", INDEX (%s)", $this->get('name')); 
     104                endif; 
     105                 
     106                // check for index 
     107                if ($this->get('index') == true): 
     108                        $definition .= sprintf(", INDEX (%s)", $this->get('name')); 
     109                endif; 
     110 
     111                return $definition; 
     112                         
    42113        } 
    43114         
  • trunk/modules/base/classes/entityManager.php

    r446 r498  
    9898                $all_cols = $this->entity->getColumns(); 
    9999                 
    100                 $cols = ''; 
     100                $cols = array(); 
     101                 
    101102                // Control loop 
    102103                foreach ($all_cols as $k => $v){ 
     
    127128         
    128129        /** 
     130         * Create Table 
     131         * 
     132         * Handled by DB abstraction layer because the SQ associated with this is way too DB specific 
     133         */ 
     134        function createTable() { 
     135                 
     136                // Persist table 
     137                $status = $this->db->createTable($this->entity); 
     138                 
     139                if ($status == true): 
     140                        $this->e->notice(sprintf("%s Table Created.", get_class($this->entity))); 
     141                        return true; 
     142                else: 
     143                        $this->e->notice(sprintf("%s Table Creation Failed.", get_class($this->entity))); 
     144                        return false; 
     145                endif; 
     146         
     147        } 
     148         
     149        /** 
     150         * DROP Table 
     151         * 
     152         * Drops a table. will throw error is table does not exist 
     153         */ 
     154        function dropTable() { 
     155                 
     156                // Persist table 
     157                $status = $this->db->dropTable(get_class($this->entity)); 
     158                 
     159                if ($status == true): 
     160                        return true; 
     161                else: 
     162                        return false; 
     163                endif; 
     164         
     165        } 
     166         
     167        function addColumn($column_name) { 
     168                 
     169                // Persist table 
     170                $status = $this->db->addColumn(get_class($this->entity), $column_name, $this->entity->$column_name->getDefinition()); 
     171                 
     172                if ($status == true): 
     173                        return true; 
     174                else: 
     175                        return false; 
     176                endif; 
     177                 
     178        } 
     179         
     180        function dropColumn($column_name) { 
     181                 
     182                $status = $this->db->dropColumn(get_class($this->entity), $column_name); 
     183                 
     184                if ($status == true): 
     185                        return true; 
     186                else: 
     187                        return false; 
     188                endif;           
     189                 
     190        } 
     191         
     192        function modifyColumn($column_name) { 
     193         
     194                $status = $this->db->modifyColumn(get_class($this->entity), $column_name, $this->entity->$column_name->getDefinition()); 
     195                 
     196                if ($status == true): 
     197                        return true; 
     198                else: 
     199                        return false; 
     200                endif;           
     201         
     202         
     203        } 
     204         
     205        function renameColumn($old_column_name, $column_name) { 
     206         
     207                $status = $this->db->renameColumn(get_class($this->entity), $old_column_name, $column_name); 
     208                 
     209                if ($status == true): 
     210                        return true; 
     211                else: 
     212                        return false; 
     213                endif;           
     214                 
     215        } 
     216         
     217        function renameTable($new_table_name) { 
     218         
     219                $status = $this->db->renameTable(get_class($this->entity), $new_table_name); 
     220                 
     221                if ($status == true): 
     222                        return true; 
     223                else: 
     224                        return false; 
     225                endif;           
     226                return; 
     227        } 
     228         
     229         
     230         
     231        /** 
    129232         * Update all properties of an Existing object 
    130233         * 
  • trunk/modules/base/classes/error.php

    r478 r498  
    366366         
    367367        function logPhpErrors() { 
    368          
     368                error_reporting(E_ALL); 
     369                ini_set('display_errors', E_ALL); 
    369370                return set_error_handler(array("owa_error", "handlePhpError")); 
    370371         
     
    406407                return; 
    407408        } 
     409         
     410        function backtrace() { 
     411                 
     412                $dbgTrace = debug_backtrace(); 
     413                $bt = array(); 
     414                foreach($dbgTrace as $dbgIndex => $dbgInfo) { 
     415                         
     416                        $bt[$dbgIndex] = array('file' => $dbgInfo['file'],  
     417                                                                        'line' => $dbgInfo['line'],  
     418                                                                        'function' => $dbgInfo['function'], 
     419                                                                        'args' => $dbgInfo['args']); 
     420                } 
     421                 
     422                return $bt; 
     423 
     424        } 
    408425 
    409426} 
  • trunk/modules/base/classes/event.php

    r480 r498  
    9999        function setTime($timestamp = '') { 
    100100                 
    101                 $this->properties['timestamp'] = $timestamp; 
    102                 $this->properties['year'] = date("Y", $this->properties['timestamp']); 
    103                 $this->properties['month'] = date("n", $this->properties['timestamp']); 
    104                 $this->properties['day'] = date("d", $this->properties['timestamp']); 
    105                 $this->properties['dayofweek'] = date("D", $this->properties['timestamp']); 
    106                 $this->properties['dayofyear'] = date("z", $this->properties['timestamp']); 
    107                 $this->properties['weekofyear'] = date("W", $this->properties['timestamp']); 
    108                 $this->properties['hour'] = date("G", $this->properties['timestamp']); 
    109                 $this->properties['minute'] = date("i", $this->properties['timestamp']); 
    110                 $this->properties['second'] = date("s", $this->properties['timestamp']); 
     101                $this->set('timestamp', $timestamp); 
     102                $this->set('year', date("Y", $timestamp)); 
     103                $this->set('month', date("n", $timestamp)); 
     104                $this->set('day', date("d", $timestamp)); 
     105                $this->set('dayofweek', date("D", $timestamp)); 
     106                $this->set('dayofyear', date("z", $timestamp)); 
     107                $this->set('weekofyear', date("W", $timestamp)); 
     108                $this->set('hour', date("G", $timestamp)); 
     109                $this->set('minute', date("i", $timestamp)); 
     110                $this->set('second', date("s", $timestamp)); 
    111111                 
    112112                //epoc time 
    113113                list($msec, $sec) = explode(" ", microtime()); 
    114                 $this->properties['sec'] = $sec; 
    115                 $this->properties['msec'] = $msec; 
     114                $this->set('sec', $sec); 
     115                $this->set('msec', $msec); 
    116116                 
    117117                // Calc time sinse the last request 
     
    593593        } 
    594594 
    595  
     595        function get($name) { 
     596                 
     597                return $this->properties[$name]; 
     598        } 
     599         
     600         
     601        function set($name, $value) { 
     602         
     603                $this->properties[$name] = $value; 
     604                return; 
     605        } 
    596606         
    597607} 
  • trunk/modules/base/classes/settings.php

    r486 r498  
    411411                        'do_not_log_admins'                             => true, 
    412412                        'do_not_log_ips'                                => '', 
    413                         'track_feed_links'                                      => true 
     413                        'track_feed_links'                              => true, 
     414                        'start_page'                                    => 'base.reportDashboard' 
    414415                         
    415416                        )); 
  • trunk/modules/base/classes/userManager.php

    r467 r498  
    4343        } 
    4444         
     45        function owa_userManager() { 
     46         
     47                return $this->__construct(); 
     48        } 
     49         
    4550        function createNewUser($user_params) { 
    4651         
  • trunk/modules/base/entities/click.php

    <
    r238 r498  
    3131class owa_click extends owa_entity { 
    3232         
    33         var $id; // BIGINT, 
    34         var $last_impression_id; //BIGINT, 
    35         var $visitor_id; // BIGINT, 
    36         var $session_id; // BIGINT, 
    37         var $document_id; // BIGINT, 
    38         var $target_id; // BIGINT, 
    39         var $target_url; // VARCHAR(255), 
    40         var $timestamp; // BIGINT, 
    41         var $year; // INT, 
    42         var $month; // INT, 
    43         var $day; // INT, 
    44         var $dayofyear; // INT, 
    45         var $weekofyear; // INT, 
    46         var $hour; // TINYINT(2), 
    47         var $minute; // TINYINT(2), 
    48         var $second; // INT, 
    49         var $msec; // VARCHAR(255), 
    50         var $click_x; // INT, 
    51         var $click_y; // INT, 
    52         var $page_width; // INT, 
    53         var $page_height; // INT, 
    54         var $position; // BIGINT, 
    55         var $approx_position; // BIGINT, 
    56         var $dom_element_x; // INT, 
    57         var $dom_element_y; // INT, 
    58         var $dom_element_name; // VARCHAR(255), 
    59         var $dom_element_id; // VARCHAR(255), 
    60         var $dom_element_value; // VARCHAR(255), 
    61         var $dom_element_tag; // VARCHAR(255), 
    62         var $dom_element_text; // VARCHAR(255), 
    63         var $tag_id; // BIGINT, 
    64         var $placement_id; // BIGINT, 
    65         var $campaign_id; // BIGINT,