diff --git a/asyncEventProcessor.php b/asyncEventProcessor.php index b61156a97..b46f37728 100644 --- a/asyncEventProcessor.php +++ b/asyncEventProcessor.php @@ -72,17 +72,21 @@ class asyncEventProcessor extends owa_caller { * @access public */ function asyncEventProcessor($config = null) { + $this->owa_caller($config); - + if ($this->config['error_handler'] == 'development'): - $this->config['error_handler'] = 'async_development'; + //$this->config['error_handler'] = 'async_development'; endif; - //$this->e = &owa_error::get_instance(); - // Turns off async setting so that the proper event queue is created $this->config['async_db'] = false; + $this->c->set('base', 'async_db', false); + + // load event queue $this->eq = &eventQueue::get_instance(); + + // load DAO $this->db = &owa_coreAPI::dbSingleton(); // Create Error Logger - NEEDED? @@ -124,36 +128,40 @@ function process_standard() { * */ function process_events($event_file) { - $this->e->info(sprintf('Starting Async Event Processing Run for: %s', - $event_file)); - //check for lock file - if (file_exists($this->config['async_log_dir'].$this->config['async_lock_file'])): - //read contents of lock file for last PID - $lock_file = fopen($this->config['async_log_dir'].$this->config['async_lock_file'], "r") or die ("Could not create lock file"); - if ($lock_file): - while (!feof($lock_file)) { - $former_pid = fgets($lock_file, 4096); - } - fclose($lock_file); + + if (file_exists($event_file)): + $this->e->info(sprintf('Starting Async Event Processing Run for: %s', $event_file)); + //check for lock file + if (file_exists($this->config['async_log_dir'].$this->config['async_lock_file'])): + //read contents of lock file for last PID + $lock_file = fopen($this->config['async_log_dir'].$this->config['async_lock_file'], "r") or die ("Could not create lock file"); + if ($lock_file): + while (!feof($lock_file)) { + $former_pid = fgets($lock_file, 4096); + } + fclose($lock_file); + endif; + //check to see if former PID is still running + $ps_check = $this->is_running($former_pid); + //if the process is still running, exit. + if ($ps_check == true): + $this->e->info(sprintf('Previous Process (%d) still active. Terminating Run.', + $former_pid)); + exit; + //if it's not running remove the lock file and proceead. + else: + $this->e->info(sprintf('Process %d is not running. Continuing Run... \n', + $former_pid)); + unlink ($this->config['async_log_dir'].$this->config['async_lock_file']); + $this->process_event_log($event_file); endif; - //check to see if former PID is still running - $ps_check = $this->is_running($former_pid); - //if the process is still running, exit. - if ($ps_check == true): - $this->e->info(sprintf('Previous Process (%d) still active. Terminating Run.', - $former_pid)); - exit; - //if it's not running remove the lock file and proceead. + else: - $this->e->info(sprintf('Process %d is not running. Continuing Run... \n', - $former_pid)); - unlink ($this->config['async_log_dir'].$this->config['async_lock_file']); $this->process_event_log($event_file); + endif; - else: - $this->process_event_log($event_file); - + $this->e->debug("No event file found at: ".$event_file); endif; return; } @@ -175,6 +183,7 @@ function process_event_log($file) { // check to see if event log file exisits if (file_exists($file)): + $this->db->connect(); if($this->db->connection_status == true): $this->create_lock_file(); diff --git a/conf/messages.php b/conf/messages.php index a5c762cf7..c4ac7eca6 100644 --- a/conf/messages.php +++ b/conf/messages.php @@ -36,7 +36,7 @@ 2001 => array("The e-mail %s was not found in our database. Please check the address and try again.",1), 2002 => array("Login Failed. Your user name or password did not match.",0), 2003 => array("Your Account lacks the necessary priviledges to access the requested resource.",0), -2004 => array("You must login to access the requested resource."), +2004 => array("You must login to access the requested resource.",0), 2010 => array("Sucess. Logout Complete.",0), // Options/Configuration related @@ -67,7 +67,7 @@ //install 3300 => array("Could not connect to the database. Please check the database connection settings in your configuration file and try again.",0), -3301 => array("The version of PHP installed on this server is too old. Please upgrade to at least PHP 4."), +3301 => array("The version of PHP installed on this server is too old. Please upgrade to at least PHP 4.",0), 3302 => array("Database Schema Installation failed. Please check the error log file for more details.",0), 3303 => array("Success. Default Site Added.",0), 3304 => array("Success. Admin User Added.",0), diff --git a/eventQueue.php b/eventQueue.php index de1961a45..c3b339295 100644 --- a/eventQueue.php +++ b/eventQueue.php @@ -17,8 +17,8 @@ // require_once(OWA_PEARLOG_DIR . DIRECTORY_SEPARATOR . 'Log.php'); -require_once(OWA_PLUGINS_DIR . DIRECTORY_SEPARATOR . 'log/queue.php'); -require_once(OWA_PLUGINS_DIR . DIRECTORY_SEPARATOR . 'log/async_queue.php'); +require_once(OWA_PLUGIN_DIR . 'log/queue.php'); +require_once(OWA_PLUGIN_DIR . 'log/async_queue.php'); require_once(OWA_BASE_CLASSES_DIR. 'owa_observer.php'); /** diff --git a/modules/base/classes/column.php b/modules/base/classes/column.php index e75a698bd..14c5e2bc2 100644 --- a/modules/base/classes/column.php +++ b/modules/base/classes/column.php @@ -30,17 +30,88 @@ class owa_dbColumn { + var $name; + var $value; + var $data_type; + var $foriegn_key; + var $is_primary_key = false; + var $auto_increment = false; - function owa_dbColumn() { + var $is_unique = false; + + var $is_not_null = false; + + var $label; + + function owa_dbColumn($params = array()) { + + + if (!empty($params)): + + foreach ($params as $k => $v) { + + $this->$k = $v; + + } + + endif; return; } + function get($name) { + + return $this->$name; + } + + function set($name, $value) { + + $this->$name = $value; + + return; + } + + function getDefinition() { + + $definition = ''; + + $definition .= $this->get('data_type'); + + // Check for auto increment + if ($this->get('auto_increment') == true): + $definition .= ' '.OWA_DTD_AUTO_INCREMENT; + endif; + + // Check for auto Not null + if ($this->get('is_not_null') == true): + $definition .= ' '.OWA_DTD_NOT_NULL; + endif; + + // Check for unique + if ($this->get('is_unique') == true): + $definition .= ' '.OWA_DTD_UNIQUE; + endif; + + // check for primary key + if ($this->get('is_primary_key') == true): + $definition .= ' '.OWA_DTD_PRIMARY_KEY; + //$definition .= sprintf(", INDEX (%s)", $this->get('name')); + endif; + + // check for index + if ($this->get('index') == true): + $definition .= sprintf(", INDEX (%s)", $this->get('name')); + endif; + + return $definition; + + } + } ?> \ No newline at end of file diff --git a/modules/base/classes/entityManager.php b/modules/base/classes/entityManager.php index fffaa7e51..1c48b0d98 100644 --- a/modules/base/classes/entityManager.php +++ b/modules/base/classes/entityManager.php @@ -97,7 +97,8 @@ function create() { $all_cols = $this->entity->getColumns(); - $cols = ''; + $cols = array(); + // Control loop foreach ($all_cols as $k => $v){ @@ -125,6 +126,108 @@ function create() { } + /** + * Create Table + * + * Handled by DB abstraction layer because the SQ associated with this is way too DB specific + */ + function createTable() { + + // Persist table + $status = $this->db->createTable($this->entity); + + if ($status == true): + $this->e->notice(sprintf("%s Table Created.", get_class($this->entity))); + return true; + else: + $this->e->notice(sprintf("%s Table Creation Failed.", get_class($this->entity))); + return false; + endif; + + } + + /** + * DROP Table + * + * Drops a table. will throw error is table does not exist + */ + function dropTable() { + + // Persist table + $status = $this->db->dropTable(get_class($this->entity)); + + if ($status == true): + return true; + else: + return false; + endif; + + } + + function addColumn($column_name) { + + // Persist table + $status = $this->db->addColumn(get_class($this->entity), $column_name, $this->entity->$column_name->getDefinition()); + + if ($status == true): + return true; + else: + return false; + endif; + + } + + function dropColumn($column_name) { + + $status = $this->db->dropColumn(get_class($this->entity), $column_name); + + if ($status == true): + return true; + else: + return false; + endif; + + } + + function modifyColumn($column_name) { + + $status = $this->db->modifyColumn(get_class($this->entity), $column_name, $this->entity->$column_name->getDefinition()); + + if ($status == true): + return true; + else: + return false; + endif; + + + } + + function renameColumn($old_column_name, $column_name) { + + $status = $this->db->renameColumn(get_class($this->entity), $old_column_name, $column_name); + + if ($status == true): + return true; + else: + return false; + endif; + + } + + function renameTable($new_table_name) { + + $status = $this->db->renameTable(get_class($this->entity), $new_table_name); + + if ($status == true): + return true; + else: + return false; + endif; + return; + } + + + /** * Update all properties of an Existing object * diff --git a/modules/base/classes/error.php b/modules/base/classes/error.php index 8e430dc35..2061d2f22 100644 --- a/modules/base/classes/error.php +++ b/modules/base/classes/error.php @@ -365,7 +365,8 @@ function make_mail_logger() { } function logPhpErrors() { - + error_reporting(E_ALL); + ini_set('display_errors', E_ALL); return set_error_handler(array("owa_error", "handlePhpError")); } @@ -405,6 +406,22 @@ function handlePhpError($errno = null, $errmsg, $filename, $linenum, $vars) { return; } + + function backtrace() { + + $dbgTrace = debug_backtrace(); + $bt = array(); + foreach($dbgTrace as $dbgIndex => $dbgInfo) { + + $bt[$dbgIndex] = array('file' => $dbgInfo['file'], + 'line' => $dbgInfo['line'], + 'function' => $dbgInfo['function'], + 'args' => $dbgInfo['args']); + } + + return $bt; + + } } diff --git a/modules/base/classes/event.php b/modules/base/classes/event.php index 58f0d38e7..254aedfb4 100644 --- a/modules/base/classes/event.php +++ b/modules/base/classes/event.php @@ -98,21 +98,21 @@ function owa_event() { */ function setTime($timestamp = '') { - $this->properties['timestamp'] = $timestamp; - $this->properties['year'] = date("Y", $this->properties['timestamp']); - $this->properties['month'] = date("n", $this->properties['timestamp']); - $this->properties['day'] = date("d", $this->properties['timestamp']); - $this->properties['dayofweek'] = date("D", $this->properties['timestamp']); - $this->properties['dayofyear'] = date("z", $this->properties['timestamp']); - $this->properties['weekofyear'] = date("W", $this->properties['timestamp']); - $this->properties['hour'] = date("G", $this->properties['timestamp']); - $this->properties['minute'] = date("i", $this->properties['timestamp']); - $this->properties['second'] = date("s", $this->properties['timestamp']); + $this->set('timestamp', $timestamp); + $this->set('year', date("Y", $timestamp)); + $this->set('month', date("n", $timestamp)); + $this->set('day', date("d", $timestamp)); + $this->set('dayofweek', date("D", $timestamp)); + $this->set('dayofyear', date("z", $timestamp)); + $this->set('weekofyear', date("W", $timestamp)); + $this->set('hour', date("G", $timestamp)); + $this->set('minute', date("i", $timestamp)); + $this->set('second', date("s", $timestamp)); //epoc time list($msec, $sec) = explode(" ", microtime()); - $this->properties['sec'] = $sec; - $this->properties['msec'] = $msec; + $this->set('sec', $sec); + $this->set('msec', $msec); // Calc time sinse the last request $this->time_since_lastreq = $this->timeSinceLastRequest(); @@ -592,7 +592,17 @@ function create_new_session($visitor_id) { } - + function get($name) { + + return $this->properties[$name]; + } + + + function set($name, $value) { + + $this->properties[$name] = $value; + return; + } } diff --git a/modules/base/classes/settings.php b/modules/base/classes/settings.php index b2afd0a95..9d2ee82ee 100644 --- a/modules/base/classes/settings.php +++ b/modules/base/classes/settings.php @@ -410,7 +410,8 @@ function getDefaultConfig() { 'cache_objects' => true, 'do_not_log_admins' => true, 'do_not_log_ips' => '', - 'track_feed_links' => true + 'track_feed_links' => true, + 'start_page' => 'base.reportDashboard' )); diff --git a/modules/base/classes/update.php b/modules/base/classes/update.php new file mode 100644 index 000000000..0800da4c7 --- /dev/null +++ b/modules/base/classes/update.php @@ -0,0 +1,170 @@ + + * @copyright Copyright © 2008 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_update extends owa_base { + + /** + * Module Name + * + * Name of the module that his update is invoked under. This is set by the + * factory. + * + * @var string + */ + var $module_name; + + /** + * Schema Version Number + * + * Version number of the schema that will be in place after update is applied. + * + * This is set by the module's update method from the concrete class filename + * when it creates the concrete version of this update class. This ensures + * that the schema version number is only set in one place (the file name) and + * that only one concrete update class can ever be applied for a particular + * schema version. + * + * @var integer + */ + var $schema_version; + + function __construct() { + + $this->owa_base(); + //$this->db = &owa_coreAPI::dbSingleton(); + + return; + } + + /** + * Applies an update + * + * @return boolean + */ + function apply() { + + // check for schema version. abort if not present or else updates will get out of sync. + if (empty($this->schema_version)): + $this->e->notice(sprintf("Aborting %s Update (%s): Schema Version Number is not set.", get_class(), $this->module_name)); + return false; + endif; + + // execute pre update proceadure + $ret = $this->pre(); + + if ($ret == true): + + $this->e->notice("Pre Update Proceadure Suceeded"); + + // execute actual update proceadure + $ret = $this->up(); + + if ($ret == true): + + // execute post update proceadure + $ret = $this->post(); + + if ($ret == true): + $this->e->notice("Post Update Proceadure Suceeded"); + $this->c->setSetting($this->module_name, 'schema_version', $this->schema_version); + $this->c->save(); + return true; + else: + $this->e->notice("Post Update Proceadure Failed"); + return false; + endif; + else: + $this->e->notice("Update Proceadure Failed"); + return false; + endif; + else: + $this->e->notice("Pre Update Proceadure Failed"); + return false; + endif; + + } + + + /** + * Rollsback an update + * + * @return boolean + */ + function rollback() { + + return false; + + } + + /** + * Abstract Pre-update hook + * + * @return boolean + */ + function pre() { + + return true; + } + + /** + * Abstract Post-update hook + * + * @return boolean + */ + function post() { + + return true; + } + + /** + * Abstract Method for update + * + * @return boolean + */ + function up() { + + return false; + } + + /** + * Abstract Method for reversing an update + * + * @return boolean + */ + function down() { + + return false; + } + +} + +?> \ No newline at end of file diff --git a/modules/base/classes/userManager.php b/modules/base/classes/userManager.php index 9b327e907..b3a1e4a6d 100644 --- a/modules/base/classes/userManager.php +++ b/modules/base/classes/userManager.php @@ -42,6 +42,11 @@ function __construct() { return; } + function owa_userManager() { + + return $this->__construct(); + } + function createNewUser($user_params) { // save new user to db diff --git a/modules/base/entities/click.php b/modules/base/entities/click.php index bc2175b67..66027522f 100644 --- a/modules/base/entities/click.php +++ b/modules/base/entities/click.php @@ -30,46 +30,46 @@ class owa_click extends owa_entity { - var $id; // BIGINT, - var $last_impression_id; //BIGINT, - var $visitor_id; // BIGINT, - var $session_id; // BIGINT, - var $document_id; // BIGINT, - var $target_id; // BIGINT, - var $target_url; // VARCHAR(255), - var $timestamp; // BIGINT, - var $year; // INT, - var $month; // INT, - var $day; // INT, - var $dayofyear; // INT, - var $weekofyear; // INT, - var $hour; // TINYINT(2), - var $minute; // TINYINT(2), - var $second; // INT, - var $msec; // VARCHAR(255), - var $click_x; // INT, - var $click_y; // INT, - var $page_width; // INT, - var $page_height; // INT, - var $position; // BIGINT, - var $approx_position; // BIGINT, - var $dom_element_x; // INT, - var $dom_element_y; // INT, - var $dom_element_name; // VARCHAR(255), - var $dom_element_id; // VARCHAR(255), - var $dom_element_value; // VARCHAR(255), - var $dom_element_tag; // VARCHAR(255), - var $dom_element_text; // VARCHAR(255), - var $tag_id; // BIGINT, - var $placement_id; // BIGINT, - var $campaign_id; // BIGINT, - var $ad_group_id; // BIGINT, - var $ad_id; // BIGINT, - var $site_id; // VARCHAR(255), - var $ua_id; // BIGINT, - var $ip_address; // VARCHAR(255), - var $host; // VARCHAR(255), - var $host_id; // VARCHAR(255), + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $last_impression_id = array('data_type' => OWA_DTD_BIGINT); //BIGINT, + var $visitor_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $session_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $document_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $target_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $target_url = array('data_type' => OWA_DTD_BIGINT); // VARCHAR(255), + var $timestamp = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $year = array('data_type' => OWA_DTD_INT); // INT, + var $month = array('data_type' => OWA_DTD_INT); // INT, + var $day = array('data_type' => OWA_DTD_INT); // INT, + var $dayofyear = array('data_type' => OWA_DTD_INT); // INT, + var $weekofyear = array('data_type' => OWA_DTD_INT); // INT, + var $hour = array('data_type' => OWA_DTD_TINYINT2); // TINYINT(2), + var $minute = array('data_type' => OWA_DTD_TINYINT2); // TINYINT(2), + var $second = array('data_type' => OWA_DTD_INT); // INT, + var $msec = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $click_x = array('data_type' => OWA_DTD_INT); // INT, + var $click_y = array('data_type' => OWA_DTD_INT); // INT, + var $page_width = array('data_type' => OWA_DTD_INT); // INT, + var $page_height = array('data_type' => OWA_DTD_INT); // INT, + var $position = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $approx_position = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $dom_element_x = array('data_type' => OWA_DTD_INT); // INT, + var $dom_element_y = array('data_type' => OWA_DTD_INT); // INT, + var $dom_element_name = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $dom_element_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $dom_element_value = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $dom_element_tag = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $dom_element_text = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $tag_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $placement_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $campaign_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $ad_group_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $ad_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $site_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $ua_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $ip_address = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $host = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $host_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), function owa_click() { diff --git a/modules/base/entities/configuration.php b/modules/base/entities/configuration.php index 881f50e58..fc97e2844 100644 --- a/modules/base/entities/configuration.php +++ b/modules/base/entities/configuration.php @@ -30,8 +30,8 @@ class owa_configuration extends owa_entity { - var $id; // BIGINT, - var $settings; // varchar(255) + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $settings = array('data_type' => OWA_DTD_TEXT); function owa_configuration() { diff --git a/modules/base/entities/document.php b/modules/base/entities/document.php index 5acdb44da..eb64084ea 100644 --- a/modules/base/entities/document.php +++ b/modules/base/entities/document.php @@ -30,10 +30,10 @@ class owa_document extends owa_entity { - var $id; - var $url; // varchar(255), - var $page_title; // varchar(255), - var $page_type; // varchar(255), + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); + var $url = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $page_title = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $page_type = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), function owa_document() { diff --git a/modules/base/entities/exit.php b/modules/base/entities/exit.php new file mode 100644 index 000000000..4cf8a71de --- /dev/null +++ b/modules/base/entities/exit.php @@ -0,0 +1,54 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_exit extends owa_entity { + + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $url = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $site_name = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $site = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $exit_anchortext = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $page_title = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + + function owa_exit() { + + $this->owa_entity(); + + return; + + } + + + +} + + + +?> \ No newline at end of file diff --git a/modules/base/entities/feed_request.php b/modules/base/entities/feed_request.php index c68c7d09f..6bb51cbdd 100644 --- a/modules/base/entities/feed_request.php +++ b/modules/base/entities/feed_request.php @@ -30,29 +30,33 @@ class owa_feed_request extends owa_entity { - var $id; // BIGINT, - var $visitor_id; // BIGINT, - var $session_id; // BIGINT, - var $document_id; // BIGINT, - var $ua_id; // VARCHAR(255), - var $site_id; // VARCHAR(255), - var $host_id; // BIGINT, - var $os_id; // VARCHAR(255), - var $feed_reader_guid; // VARCHAR(255), - var $subscription_id; // BIGINT, - var $timestamp; // bigint, - var $month; // INT, - var $day; // tinyint(2), - var $dayofweek; // varchar(10), - var $dayofyear; // INT, - var $weekofyear; // INT, - var $year; // INT, - var $hour; // tinyint(2), - var $minute; // tinyint(2), - var $second; // tinyint(2), - var $msec; // int, - var $last_req; // bigint, - var $feed_format; // VARCHAR(255), + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $visitor_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $session_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $document_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $ua_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $site_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $site = array('data_type' => OWA_DTD_VARCHAR255); // **** DROP **** + var $host_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $host = array('data_type' => OWA_DTD_VARCHAR255); // **** DROP **** + var $os_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $feed_reader_guid = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $subscription_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $timestamp = array('data_type' => OWA_DTD_BIGINT); // bigint, + var $month = array('data_type' => OWA_DTD_INT); // INT, + var $day = array('data_type' => OWA_DTD_TINYINT2); // tinyint(2), + var $dayofweek = array('data_type' => OWA_DTD_VARCHAR10); // varchar(10), + var $dayofyear = array('data_type' => OWA_DTD_INT); // INT, + var $weekofyear = array('data_type' => OWA_DTD_INT); // INT, + var $year = array('data_type' => OWA_DTD_INT); // INT, + var $hour = array('data_type' => OWA_DTD_TINYINT2); // tinyint(2), + var $minute = array('data_type' => OWA_DTD_TINYINT2); // tinyint(2), + var $second = array('data_type' => OWA_DTD_TINYINT2); // tinyint(2), + var $msec = array('data_type' => OWA_DTD_INT); // int, + var $last_req = array('data_type' => OWA_DTD_BIGINT); // bigint, + var $feed_format = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $ip_address = array('data_type' => OWA_DTD_VARCHAR255); // **** DROP **** + var $os = array('data_type' => OWA_DTD_VARCHAR255); // **** DROP **** function owa_feed_request() { diff --git a/modules/base/entities/host.php b/modules/base/entities/host.php index b2410e3c4..840287879 100644 --- a/modules/base/entities/host.php +++ b/modules/base/entities/host.php @@ -30,14 +30,14 @@ class owa_host extends owa_entity { - var $id; // BIGINT, - var $ip_address; // VARCHAR(255), - var $host; // VARCHAR(255), - var $full_host; // VARCHAR(255), - var $city; // varchar(255), - var $country; // varchar(255), - var $latitude; // varchar(255), - var $longitude; // varchar(255), + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $ip_address = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $host = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $full_host = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $city = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $country = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $latitude = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $longitude = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), function owa_host() { diff --git a/modules/base/entities/impression.php b/modules/base/entities/impression.php new file mode 100644 index 000000000..7c166ab92 --- /dev/null +++ b/modules/base/entities/impression.php @@ -0,0 +1,73 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_impression extends owa_entity { + + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $visitor_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $session_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $tag_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $placement_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $campaign_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $ad_group_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $ad_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $site_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $last_impression_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $last_impression_timestamp = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $timestamp = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $year = array('data_type' => OWA_DTD_INT); // INT, + var $month = array('data_type' => OWA_DTD_INT); // INT, + var $day = array('data_type' => OWA_DTD_INT); // INT, + var $dayofyear = array('data_type' => OWA_DTD_INT); // INT, + var $weekofyear = array('data_type' => OWA_DTD_INT); // INT, + var $hour = array('data_type' => OWA_DTD_TINYINT2); // tinyINT, + var $minute = array('data_type' => OWA_DTD_TINYINT2); // tinyINT, + var $msec = array('data_type' => OWA_DTD_BIGINT); // INT, + var $url = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $ua_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT + var $ip_address = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $host = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $host_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + + function owa_impression() { + + $this->owa_entity(); + + return; + + } + + + +} + + + +?> \ No newline at end of file diff --git a/modules/base/entities/os.php b/modules/base/entities/os.php new file mode 100644 index 000000000..add3292eb --- /dev/null +++ b/modules/base/entities/os.php @@ -0,0 +1,50 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_os extends owa_entity { + + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $name = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + + function owa_os() { + + $this->owa_entity(); + + return; + + } + + + +} + + + +?> \ No newline at end of file diff --git a/modules/base/entities/referer.php b/modules/base/entities/referer.php index 6eea9f2b8..01e348335 100644 --- a/modules/base/entities/referer.php +++ b/modules/base/entities/referer.php @@ -30,15 +30,15 @@ class owa_referer extends owa_entity { - var $id; // BIGINT, - var $url; // varchar(255), - var $site_name; // varchar(255), - var $site; // VARCHAR(255), - var $query_terms; // varchar(255), - var $refering_anchortext; // varchar(255), - var $page_title; // varchar(255), - var $snippet; // TEXT, - var $is_searchengine; // tinyint(1), + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $url = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $site_name = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $site = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $query_terms = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $refering_anchortext = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $page_title = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $snippet = array('data_type' => OWA_DTD_TEXT); // TEXT, + var $is_searchengine = array('data_type' => OWA_DTD_TINYINT); // tinyint(1), function owa_referer() { diff --git a/modules/base/entities/request.php b/modules/base/entities/request.php index 3581d93ca..9a64628e9 100644 --- a/modules/base/entities/request.php +++ b/modules/base/entities/request.php @@ -30,42 +30,42 @@ class owa_request extends owa_entity { - var $id; - var $visitor_id; - var $session_id; - var $inbound_visitor_id; - var $inbound_session_id; - var $feed_subscription_id; - var $user_name; - var $user_email; - var $timestamp; - var $last_req; - var $year; - var $month; - var $day; - var $dayofweek; - var $dayofyear; - var $weekofyear; - var $hour; - var $minute; - var $second; - var $msec; - var $referer_id; - var $document_id; - var $site; - var $site_id; - var $ip_address; - var $host_id; - var $os; - var $os_id; - var $ua_id; - var $is_new_visitor; - var $is_repeat_visitor; - var $is_comment; - var $is_entry_page; - var $is_browser; - var $is_robot; - var $is_feedreader; + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); + var $visitor_id = array('data_type' => OWA_DTD_BIGINT); + var $session_id = array('data_type' => OWA_DTD_BIGINT); + var $inbound_visitor_id = array('data_type' => OWA_DTD_BIGINT); + var $inbound_session_id = array('data_type' => OWA_DTD_BIGINT); + var $feed_subscription_id = array('data_type' => OWA_DTD_BIGINT); + var $user_name = array('data_type' => OWA_DTD_VARCHAR255); + var $user_email = array('data_type' => OWA_DTD_VARCHAR255); + var $timestamp = array('data_type' => OWA_DTD_BIGINT, 'index' => true); + var $last_req = array('data_type' => OWA_DTD_BIGINT); + var $year = array('data_type' => OWA_DTD_INT); + var $month = array('data_type' => OWA_DTD_INT); + var $day = array('data_type' => OWA_DTD_TINYINT2); + var $dayofweek = array('data_type' => OWA_DTD_VARCHAR10); + var $dayofyear = array('data_type' => OWA_DTD_INT); + var $weekofyear = array('data_type' => OWA_DTD_INT); + var $hour = array('data_type' => OWA_DTD_TINYINT2); + var $minute = array('data_type' => OWA_DTD_TINYINT2); + var $second = array('data_type' => OWA_DTD_TINYINT2); + var $msec = array('data_type' => OWA_DTD_INT); + var $referer_id = array('data_type' => OWA_DTD_VARCHAR255); + var $document_id = array('data_type' => OWA_DTD_VARCHAR255); + var $site = array('data_type' => OWA_DTD_VARCHAR255); + var $site_id = array('data_type' => OWA_DTD_VARCHAR255); + var $ip_address = array('data_type' => OWA_DTD_VARCHAR255); + var $host_id = array('data_type' => OWA_DTD_VARCHAR255); + var $os = array('data_type' => OWA_DTD_VARCHAR255); + var $os_id = array('data_type' => OWA_DTD_VARCHAR255); + var $ua_id = array('data_type' => OWA_DTD_VARCHAR255); + var $is_new_visitor = array('data_type' => OWA_DTD_TINYINT); + var $is_repeat_visitor = array('data_type' => OWA_DTD_TINYINT); + var $is_comment = array('data_type' => OWA_DTD_TINYINT); + var $is_entry_page = array('data_type' => OWA_DTD_TINYINT); + var $is_browser = array('data_type' => OWA_DTD_TINYINT); + var $is_robot = array('data_type' => OWA_DTD_TINYINT); + var $is_feedreader = array('data_type' => OWA_DTD_TINYINT); function owa_request() { diff --git a/modules/base/entities/session.php b/modules/base/entities/session.php index 8b77b2399..19034787d 100644 --- a/modules/base/entities/session.php +++ b/modules/base/entities/session.php @@ -30,41 +30,50 @@ class owa_session extends owa_entity { - var $id; // BIGINT, - var $visitor_id; // BIGINT, - var $timestamp; // bigint, - var $year; // INT, - var $month; // INT, - var $day; // TINYINT(2), - var $dayofweek; // varchar(10), - var $dayofyear; // INT, - var $weekofyear; // INT, - var $hour; // TINYINT(2), - var $minute; // TINYINT(2), - var $last_req; // BIGINT, - var $num_pageviews; // INT, - var $num_comments; // INT, - var $is_repeat_visitor; // TINYINT(1), - var $is_new_visitor; // TINYINT(1), - var $prior_session_lastreq; // BIGINT, - var $prior_session_id; // BIGINT, - var $time_sinse_priorsession; // INT, - var $prior_session_year; // INT(4), - var $prior_session_month; // varchar(255), - var $prior_session_day; // TINYINT(2), - var $prior_session_dayofweek; // int, - var $prior_session_hour; // TINYINT(2), - var $prior_session_minute; // TINYINT(2), - var $os_id; // varchar(255), - var $ua_id; // varchar(255), - var $first_page_id; // BIGINT, - var $last_page_id; // BIGINT, - var $referer_id; // BIGINT, - var $host_id; // varchar(255), - var $site_id; // varchar(255), - var $is_robot; // tinyint(1), - var $is_browser; // tinyint(1), - var $is_feedreader; // tinyint(1), + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $visitor_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $timestamp = array('data_type' => OWA_DTD_BIGINT, 'index' => true); // bigint, + var $user_name = array('data_type' => OWA_DTD_VARCHAR255); // **** DROP **** + var $user_email = array('data_type' => OWA_DTD_VARCHAR255); // **** DROP **** + var $year = array('data_type' => OWA_DTD_INT); // INT, + var $month = array('data_type' => OWA_DTD_INT); // INT, + var $day = array('data_type' => OWA_DTD_TINYINT2); // TINYINT(2), + var $dayofweek = array('data_type' => OWA_DTD_VARCHAR10); // varchar(10), + var $dayofyear = array('data_type' => OWA_DTD_INT); // INT, + var $weekofyear = array('data_type' => OWA_DTD_INT); // INT, + var $hour = array('data_type' => OWA_DTD_TINYINT2); // TINYINT(2), + var $minute = array('data_type' => OWA_DTD_TINYINT2); // TINYINT(2), + var $last_req = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $num_pageviews = array('data_type' => OWA_DTD_INT); // INT, + var $num_comments = array('data_type' => OWA_DTD_INT); // INT, + var $is_repeat_visitor = array('data_type' => OWA_DTD_TINYINT); // TINYINT(1), + var $is_new_visitor = array('data_type' => OWA_DTD_TINYINT); // TINYINT(1), + var $prior_session_lastreq = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $prior_session_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $time_sinse_priorsession = array('data_type' => OWA_DTD_INT); // INT, + var $prior_session_year = array('data_type' => OWA_DTD_TINYINT4); // INT(4), + var $prior_session_month = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $prior_session_day = array('data_type' => OWA_DTD_TINYINT2); // TINYINT(2), + var $prior_session_dayofweek = array('data_type' => OWA_DTD_INT); // int, + var $prior_session_hour = array('data_type' => OWA_DTD_TINYINT2); // TINYINT(2), + var $prior_session_minute = array('data_type' => OWA_DTD_TINYINT2); // TINYINT(2), + var $os = array('data_type' => OWA_DTD_VARCHAR255); // ****** DROP ****** + var $os_id = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $ua_id = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $first_page_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $last_page_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $referer_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $ip_address = array('data_type' => OWA_DTD_VARCHAR255); // ****** DROP ****** + var $host = array('data_type' => OWA_DTD_VARCHAR255); // ****** DROP ****** + var $host_id = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $source = array('data_type' => OWA_DTD_VARCHAR255); // + var $city = array('data_type' => OWA_DTD_VARCHAR255); // ****** DROP ****** + var $country = array('data_type' => OWA_DTD_VARCHAR255); // ****** DROP ****** + var $site = array('data_type' => OWA_DTD_VARCHAR255); // ****** DROP ****** + var $site_id = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $is_robot = array('data_type' => OWA_DTD_TINYINT); // tinyint(1), + var $is_browser = array('data_type' => OWA_DTD_TINYINT); // tinyint(1), + var $is_feedreader = array('data_type' => OWA_DTD_TINYINT); // tinyint(1), function owa_session() { diff --git a/modules/base/entities/site.php b/modules/base/entities/site.php index 7cf358136..9a2dd0e3f 100644 --- a/modules/base/entities/site.php +++ b/modules/base/entities/site.php @@ -32,12 +32,12 @@ class owa_site extends owa_entity { - var $id; - var $site_id; // VARCHAR(255), - var $domain; // VARCHAR(255), - var $name; // VARCHAR(255), - var $description; // TEXT, - var $site_family; // VARCHAR(255) + var $id = array('data_type' => OWA_DTD_SERIAL, 'auto_increment' => true); + var $site_id = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $domain = array('data_type' => OWA_DTD_VARCHAR255, 'is_not_hull' => true); // VARCHAR(255), + var $name = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $description = array('data_type' => OWA_DTD_TEXT); // TEXT, + var $site_family = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255) function owa_site() { diff --git a/modules/base/entities/ua.php b/modules/base/entities/ua.php index b904c402e..836be3884 100644 --- a/modules/base/entities/ua.php +++ b/modules/base/entities/ua.php @@ -30,10 +30,10 @@ class owa_ua extends owa_entity { - var $id; // BIGINT, - var $ua; // varchar(255), - var $browser_type;// varchar(255), - var $browser; // VARCHAR(255), + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $ua = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $browser_type = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $browser = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), function owa_ua() { diff --git a/modules/base/entities/user.php b/modules/base/entities/user.php index db205ca2b..25778f0f7 100644 --- a/modules/base/entities/user.php +++ b/modules/base/entities/user.php @@ -30,22 +30,22 @@ class owa_user extends owa_entity { - var $id; // SERIAL, - var $user_id; // varchar(255), - var $password; // VARCHAR(255), - var $role; // VARCHAR(255), - var $real_name; // VARCHAR(255), - var $email_address; // VARCHAR(255), - var $temp_passkey; // VARCHAR(255), - var $creation_date; // BIGINT, - var $last_update_date; // BIGINT, + var $id = array('data_type' => OWA_DTD_SERIAL, 'auto_increment' => true); // SERIAL, + var $user_id = array('data_type' => OWA_DTD_VARCHAR255, 'is_primary_key' => true); // varchar(255), + var $password = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $role = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $real_name = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $email_address = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $temp_passkey = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $creation_date = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $last_update_date = array('data_type' => OWA_DTD_BIGINT); // BIGINT, function owa_user() { $this->owa_entity(); - $this->id->auto_incement = true; + //$this->id->set('auto_increment', true); return; @@ -53,6 +53,8 @@ function owa_user() { + + } diff --git a/modules/base/entities/visitor.php b/modules/base/entities/visitor.php index f7d302c7a..de0b0a6d5 100644 --- a/modules/base/entities/visitor.php +++ b/modules/base/entities/visitor.php @@ -30,22 +30,22 @@ class owa_visitor extends owa_entity { - var $id; // BIGINT, - var $user_name; // VARCHAR(255), - var $user_email; // varchar(255), - var $first_session_id; // BIGINT, - var $first_session_year; // INT, - var $first_session_month; // varchar(255), - var $first_session_day; // INT, - var $first_session_dayofyear; // INT, - var $first_session_timestamp; // BIGINT, - var $last_session_id; // BIGINT, - var $last_session_year; // INT, - var $last_session_month; // varchar(255), - var $last_session_day; // INT, - var $last_session_dayofyear; // INT, + var $id = array('data_type' => OWA_DTD_BIGINT, 'is_primary_key' => true); // BIGINT, + var $user_name = array('data_type' => OWA_DTD_VARCHAR255); // VARCHAR(255), + var $user_email = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $first_session_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $first_session_year = array('data_type' => OWA_DTD_INT); // INT, + var $first_session_month = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $first_session_day = array('data_type' => OWA_DTD_INT); // INT, + var $first_session_dayofyear = array('data_type' => OWA_DTD_INT); // INT, + var $first_session_timestamp = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $last_session_id = array('data_type' => OWA_DTD_BIGINT); // BIGINT, + var $last_session_year = array('data_type' => OWA_DTD_INT); // INT, + var $last_session_month = array('data_type' => OWA_DTD_VARCHAR255); // varchar(255), + var $last_session_day = array('data_type' => OWA_DTD_INT); // INT, + var $last_session_dayofyear = array('data_type' => OWA_DTD_INT); // INT, - function owa_session() { + function owa_visitor() { $this->owa_entity(); diff --git a/modules/base/installEmbedded.php b/modules/base/installEmbedded.php index b9c469078..b906ee6be 100644 --- a/modules/base/installEmbedded.php +++ b/modules/base/installEmbedded.php @@ -94,6 +94,7 @@ function action() { // schema was not installed successfully else: + $this->e->notice('Aborting embedded install due to errors installing schema. Try dropping all OWA tables and try again.'); return false; endif; diff --git a/modules/base/installStart.php b/modules/base/installStart.php index 8006eee78..20fe063c9 100644 --- a/modules/base/installStart.php +++ b/modules/base/installStart.php @@ -43,12 +43,12 @@ function owa_installStartView() { function construct() { - // check for schema - $api = &owa_coreAPI::singleton(); - $installer = $api->modules['base']->installerFactory(); + //$api = &owa_coreAPI::singleton(); + //$installer = $api->modules['base']->installerFactory(); + //if ($installer->checkForSchema() == false): - if ($installer->checkForSchema() == false): + if (!empty($this->config['install_complete'])): // load body template $this->body->set_template('install_schema_detected.tpl'); else: @@ -58,18 +58,11 @@ function construct() { //page title $this->t->set('page_title', 'Installation'); - - // load wrapper template - - - + // fetch admin links from all modules - // $this->body->set('headline', 'Get Started...'); - //$this->body->set('', ''); - return; } diff --git a/modules/base/login.php b/modules/base/login.php index ea605a714..4c74b757c 100644 --- a/modules/base/login.php +++ b/modules/base/login.php @@ -79,7 +79,7 @@ function action() { //else redirect to home page else: $data['view_method'] = 'redirect'; - $data['do'] = 'base.reportDashboard'; + $data['do'] = $this->config['start_page']; endif; // return error view else: diff --git a/modules/base/module.php b/modules/base/module.php index 9461b7e89..5db06633d 100644 --- a/modules/base/module.php +++ b/modules/base/module.php @@ -42,9 +42,11 @@ function owa_baseModule() { $this->version = '1.0'; $this->description = 'Base functionality for OWA.'; $this->config_required = false; + $this->required_schema_version = 1; - $this->owa_module(); + $this->owa_module(); + $this->c->set('base', 'schema_version', '1'); return; } @@ -54,7 +56,7 @@ function owa_baseModule() { */ function registerAdminPanels() { - $this->addAdminPanel(array('view' => 'base.optionsGeneral', + $this->addAdminPanel(array('do' => 'base.optionsGeneral', 'priviledge' => 'admin', 'anchortext' => 'Main Configuration', 'group' => 'General', @@ -251,10 +253,28 @@ function _registerEventHandlers() { function _registerEntities() { - $this->entities[] = 'request'; + //$this->_addEntity('testtable'); + + $this->_addEntity(array('request', + 'session', + 'document', + 'feed_request', + 'click', + 'ua', + 'referer', + 'site', + 'visitor', + 'host', + 'exit', + 'os', + 'impression', + 'configuration')); + } + + } diff --git a/modules/base/optionsFlushCache.php b/modules/base/optionsFlushCache.php index 5185f15c0..3f2765794 100644 --- a/modules/base/optionsFlushCache.php +++ b/modules/base/optionsFlushCache.php @@ -47,8 +47,7 @@ function action() { $this->e->notice("Cache Flushed"); $data = array(); - $data['view'] = 'base.options'; - $data['subview'] = 'base.optionsGeneral'; + $data['do'] = 'base.optionsGeneral'; $data['view_method'] = 'redirect'; //$data['configuration'] = $nbsettings; $data['status_code'] = 2500; diff --git a/modules/base/optionsGeneral.php b/modules/base/optionsGeneral.php index 6718d6660..e21c7f7dd 100644 --- a/modules/base/optionsGeneral.php +++ b/modules/base/optionsGeneral.php @@ -16,8 +16,9 @@ // $Id$ // -require_once(OWA_BASE_DIR.'/owa_lib.php'); - +require_once(OWA_DIR.'owa_lib.php'); +require_once(OWA_DIR.'owa_view.php'); +require_once(OWA_DIR.'owa_adminController.php'); /** * Options View * @@ -50,10 +51,6 @@ function construct($data) { // fetch admin links from all modules $this->body->set('headline', 'General Configuration Options'); - if (empty($data['configuration'])): - $data['configuration'] = $this->c->fetch('base'); - endif; - //print_r($data['config']); // assign config data $this->body->set('config', $data['configuration']); @@ -64,5 +61,47 @@ function construct($data) { } +/** + * Admin Settings/Options Controller + * + * @author Peter Adams + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_optionsGeneralController extends owa_adminController { + + var $is_admin = true; + var $type = 'options'; + + function owa_optionsGeneralController($params) { + $this->owa_controller($params); + $this->priviledge_level = 'admin'; + + return; + } + + function action() { + + + + $this->data['configuration'] = $this->c->fetch('base'); + + // add data to container + $this->data['view'] = 'base.options'; + $this->data['subview'] = 'base.optionsGeneral'; + $this->data['view_method'] = 'delegate'; + + return $this->data; + + } + +} + + ?> \ No newline at end of file diff --git a/modules/base/optionsReset.php b/modules/base/optionsReset.php index 60fad2771..e56fcea51 100644 --- a/modules/base/optionsReset.php +++ b/modules/base/optionsReset.php @@ -40,22 +40,6 @@ function owa_optionsResetController($params) { } function action() { - - /*$api = &owa_coreAPI::singleton(); - - $caller_config = $api->caller_config_overrides; - - $default_config = $this->c->getDefaultConfig(); - - // merge the settings with those comming in as params - $nbsettings = array_merge($default_config['base'], $caller_config); - - // place the merge config array back to the global object - $this->c->replace('base', $nbsettings); - - // persist the global config - $this->c->update(); - */ $config = owa_coreAPI::entityFactory('base.configuration'); @@ -73,8 +57,8 @@ function action() { $this->e->notice($this->getMsg(2503)); $data = array(); - $data['view'] = 'base.options'; - $data['subview'] = 'base.optionsGeneral'; + + $data['do'] = 'base.optionsGeneral'; $data['view_method'] = 'redirect'; //$data['configuration'] = $nbsettings; $data['status_code'] = 2503; diff --git a/modules/base/optionsUpdate.php b/modules/base/optionsUpdate.php index de95ac5dd..3844072d4 100644 --- a/modules/base/optionsUpdate.php +++ b/modules/base/optionsUpdate.php @@ -41,19 +41,6 @@ function owa_optionsUpdateController($params) { function action() { - /*// get base module's config values from the global configuraton object - $bsettings = $this->c->fetch('base'); - - // merge the settings with those comming in as params - $nbsettings = array_merge($bsettings, $this->params['config']); - - // place the merge config array back to the global object - $this->c->replace('base', $nbsettings); - - // persist the global config - $this->c->update(); - */ - $configuration_id = $this->c->get('base', 'configuration_id'); $config = owa_coreAPI::entityFactory('base.configuration'); $config->getByPk('id', $configuration_id); @@ -86,10 +73,8 @@ function action() { $this->e->notice("Configuration changes saved to database."); $data = array(); - $data['view'] = 'base.options'; - $data['subview'] = 'base.optionsGeneral'; + $data['do'] = 'base.optionsGeneral'; $data['view_method'] = 'redirect'; - //$data['configuration'] = $nbsettings; $data['status_code'] = 2500; return $data; diff --git a/modules/base/sites.php b/modules/base/sites.php index eb79abb49..2d51b2ffa 100644 --- a/modules/base/sites.php +++ b/modules/base/sites.php @@ -56,6 +56,12 @@ function construct() { $this->body->set('sites', $sites); + + $tt = owa_coreAPI::entityFactory('base.testtable'); + $tt->dropTable(); + //print_r($tt); + + return; } diff --git a/modules/base/templates/header.tpl b/modules/base/templates/header.tpl index d3701d841..f4ad572c8 100644 --- a/modules/base/templates/header.tpl +++ b/modules/base/templates/header.tpl @@ -8,7 +8,7 @@ Analytics | - Admin Settings + Admin Settings | Help | diff --git a/modules/base/templates/news.tpl b/modules/base/templates/news.tpl index 8a0430df6..f70ccc94d 100644 --- a/modules/base/templates/news.tpl +++ b/modules/base/templates/news.tpl @@ -2,11 +2,8 @@ $value): ?> - - diff --git a/modules/base/templates/options_general.tpl b/modules/base/templates/options_general.tpl index b1a62544e..6d54fe28e 100644 --- a/modules/base/templates/options_general.tpl +++ b/modules/base/templates/options_general.tpl @@ -227,7 +227,7 @@
- Presenation + Presentation config['is_embedded'] == false):?>
Reporting Template Wrapper
diff --git a/modules/base/templates/updates.tpl b/modules/base/templates/updates.tpl new file mode 100644 index 000000000..d89a159ea --- /dev/null +++ b/modules/base/templates/updates.tpl @@ -0,0 +1,15 @@ +

It looks like the database that OWA uses needs to be updated.

+ +

Here is a list of modules that have updates that needs to be applied:

+ +
    + + $module): ?> + +
  • + + + +
+ +Apply updates \ No newline at end of file diff --git a/modules/base/templates/wrapper_default.tpl b/modules/base/templates/wrapper_default.tpl index e54568ae5..1bce0aa78 100644 --- a/modules/base/templates/wrapper_default.tpl +++ b/modules/base/templates/wrapper_default.tpl @@ -5,14 +5,14 @@ Open Web Analytics - <?=$page_title;?> - includeTemplate('css.tpl');?> + setTemplate('css.tpl'));?> - includeTemplate('header.tpl');?> + setTemplate('header.tpl'));?> - includeTemplate('msgs.tpl');?> + setTemplate('msgs.tpl'));?> diff --git a/modules/base/templates/wrapper_gallery2.tpl b/modules/base/templates/wrapper_gallery2.tpl index 4ba3c6b63..fea0ffed2 100644 --- a/modules/base/templates/wrapper_gallery2.tpl +++ b/modules/base/templates/wrapper_gallery2.tpl @@ -1,7 +1,7 @@ -includeTemplate('css.tpl');?> +setTemplate('css.tpl'));?> -includeTemplate('header.tpl');?> +setTemplate('header.tpl'));?> -includeTemplate('msgs.tpl');?> +setTemplate('msgs.tpl'));?> diff --git a/modules/base/templates/wrapper_mediawiki.tpl b/modules/base/templates/wrapper_mediawiki.tpl index 137a37920..bb25583ce 100644 --- a/modules/base/templates/wrapper_mediawiki.tpl +++ b/modules/base/templates/wrapper_mediawiki.tpl @@ -4,13 +4,13 @@ Open Web Analytics - <?=$page_title;?> - includeTemplate('css.tpl');?> + setTemplate('css.tpl'));?> - - includeTemplate('msgs.tpl');?> + + setTemplate('msgs.tpl'));?> diff --git a/modules/base/templates/wrapper_public.tpl b/modules/base/templates/wrapper_public.tpl index 6c6fbc334..8634ef3a7 100644 --- a/modules/base/templates/wrapper_public.tpl +++ b/modules/base/templates/wrapper_public.tpl @@ -8,7 +8,7 @@ - includeTemplate('css.tpl');?> + setTemplate('css.tpl'));?>
- : - - + + -
@@ -30,7 +30,7 @@
- includeTemplate('msgs.tpl');?> + setTemplate('msgs.tpl'));?>
diff --git a/modules/base/templates/wrapper_wordpress.tpl b/modules/base/templates/wrapper_wordpress.tpl index 4ba3c6b63..fea0ffed2 100644 --- a/modules/base/templates/wrapper_wordpress.tpl +++ b/modules/base/templates/wrapper_wordpress.tpl @@ -1,7 +1,7 @@ -includeTemplate('css.tpl');?> +setTemplate('css.tpl'));?> -includeTemplate('header.tpl');?> +setTemplate('header.tpl'));?> -includeTemplate('msgs.tpl');?> +setTemplate('msgs.tpl'));?> diff --git a/modules/base/updates.php b/modules/base/updates.php new file mode 100644 index 000000000..d278582a1 --- /dev/null +++ b/modules/base/updates.php @@ -0,0 +1,86 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_updatesView extends owa_view { + + function owa_updatesView() { + + $this->owa_view(); + $this->priviledge_level = 'guest'; + + return; + } + + function construct($data) { + + //switch wrapper if OWA is not embedded + // needed becasue this view might be rendered before anything else. + if ($this->config['is_embedded'] != true): + $this->t->set_template('wrapper_public.tpl'); + endif; + + $this->body->set_template('updates.tpl');// This is the inner template + $this->body->set('headline', 'Your database needs to be upgraded...'); + $this->body->set('modules', $data['modules']); + + + } +} + +class owa_updatesController extends owa_controller { + + function owa_updatesController($params) { + $this->owa_controller($params); + $this->priviledge_level = 'guest'; + + return; + } + + function action() { + + $data = array(); + + $api = &owa_coreAPI::singleton(); + + $data['view_method'] = 'delegate'; + $data['view'] = 'base.updates'; + $data['modules'] = $api->getModulesNeedingUpdates(); + + return $data; + } + + +} + +?> \ No newline at end of file diff --git a/modules/base/updates/_002.php b/modules/base/updates/_002.php new file mode 100644 index 000000000..50c4fbdcd --- /dev/null +++ b/modules/base/updates/_002.php @@ -0,0 +1,58 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + +class owa_002_update extends owa_update { + + + function up() { + + $tt = owa_coreAPI::entityFactory('base.testtable'); + $ret = $tt->createTable(); + + if ($ret == true): + print 'table testtable created'; + return true; + else: + print 'table testtable creation failed'; + return false; + endif; + + + } + + function down() { + + return false; + } + +} + +?> \ No newline at end of file diff --git a/modules/base/updates/_003.php b/modules/base/updates/_003.php new file mode 100644 index 000000000..6b657a33f --- /dev/null +++ b/modules/base/updates/_003.php @@ -0,0 +1,58 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + +class owa_003_update extends owa_update { + + + function up() { + + $tt = owa_coreAPI::entityFactory('base.testtable'); + $ret = $tt->createTable(); + + if ($ret == true): + print 'table testtable2 created'; + return true; + else: + print 'table testtable2 creation failed'; + return false; + endif; + + + } + + function down() { + + return false; + } + +} + +?> \ No newline at end of file diff --git a/modules/hello/module.php b/modules/hello/module.php index 360f034ef..02f2796f0 100644 --- a/modules/hello/module.php +++ b/modules/hello/module.php @@ -42,6 +42,7 @@ function owa_helloModule() { $this->version = '1.0'; $this->description = 'Hello world sample module.'; $this->config_required = false; + $this->required_schema_version = 2; $this->owa_module(); diff --git a/mw_plugin.php b/mw_plugin.php index f1a5612b3..49d5d0151 100644 --- a/mw_plugin.php +++ b/mw_plugin.php @@ -30,6 +30,7 @@ // Build OWA's Mediawiki specific config overrides array $owa_config = array(); +$wiki_url = $wgScriptPath; // OWA DATABASE CONFIGURATION // Will use Mediawiki's config valuesunless there are values present in an OWA config file. diff --git a/owa_adminController.php b/owa_adminController.php new file mode 100644 index 000000000..3a05964e7 --- /dev/null +++ b/owa_adminController.php @@ -0,0 +1,57 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + +class owa_adminController extends owa_controller { + + var $is_admin = true; + + /** + * Constructor + * + * @param array $params + * @return owa_controller + */ + function owa_adminController($params) { + + $this->owa_controller($params); + + return; + + } + + +} + +?> \ No newline at end of file diff --git a/owa_auth.php b/owa_auth.php index 7f9c99659..709880aa3 100644 --- a/owa_auth.php +++ b/owa_auth.php @@ -204,17 +204,18 @@ function authenticateUser($necessary_role = '') { * * @return object */ - function &get_instance() { - - $c = &owa_coreAPI::configSingleton(); - $config = $c->fetch('base'); - - $auth = &owa_lib::singleton($config['plugin_dir'].'/auth/', - 'owa_auth_', - $config['authentication']); + function &get_instance($auth_module = '') { + if (empty($auth_module)): + + $c = &owa_coreAPI::configSingleton(); + $auth_module = $c->get('base', 'authentication'); + + endif; + + // this needs to not be a singleton + $auth = &owa_lib::singleton(OWA_PLUGIN_DIR.'auth'.DIRECTORY_SEPARATOR, 'owa_auth_', $auth_module); - return $auth; } diff --git a/owa_base.php b/owa_base.php index 910522d11..3a7cbe655 100644 --- a/owa_base.php +++ b/owa_base.php @@ -94,7 +94,7 @@ function owa_base() { */ function getMsg($code, $s1 = null, $s2 = null, $s3 = null, $s4 = null) { - include_once(OWA_BASE_DIR.'/conf/messages.php'); + include_once(OWA_DIR.'conf/messages.php'); switch ($_owa_messages[$code][1]) { diff --git a/owa_caller.php b/owa_caller.php index 7900c987e..fd7c611aa 100644 --- a/owa_caller.php +++ b/owa_caller.php @@ -50,8 +50,11 @@ class owa_caller extends owa_base { var $api; var $start_time; + var $end_time; + var $update_required; + /** * PHP4 Constructor * @@ -81,9 +84,19 @@ function __construct($config) { $config_file_exists = true; include($file); else: + $config_file_exists = false; //$this->e->debug("I can't find your configuration file...assuming that you didn't create one."); endif; + + if (!defined('OWA_DB_TYPE')): + owa_coreAPI::setupStorageEngine($config['db_type']); + else: + owa_coreAPI::setupStorageEngine(OWA_DB_TYPE); + endif; + + + // Parent Constructor. Sets default config and error logger $this->owa_base(); @@ -101,28 +114,12 @@ function __construct($config) { * the will override default config values */ - /* APPLY CALLER CONFIGURATION OVERRIDES */ - - /** - * This will apply configuration overirdes that are specified by the calling application. - * This is usually used by plugins to setup integration specific configuration values. - */ - $this->c->applyModuleOverrides('base', $config); - $this->e->debug('Caller configuration overrides applied.'); /* APPLY CONFIGURATION FILE OVERRIDES */ if ($config_file_exists == true): - /* OBJECT CACHING */ - - // Looks for object cache config constant - if (defined('OWA_CACHE_OBJECTS')): - $this->c->set('base', 'cache_objects', OWA_CACHE_OBJECTS); - endif; - - /* ERROR LOGGING */ // Looks for log level constant @@ -142,37 +139,50 @@ function __construct($config) { $this->c->set('base', 'configuration_id', OWA_CONFIGURATION_ID); endif; + /* OBJECT CACHING */ + + // Looks for object cache config constant + // must comebefore user db values are fetched from db + if (defined('OWA_CACHE_OBJECTS')): + $this->c->set('base', 'cache_objects', OWA_CACHE_OBJECTS); + endif; + endif; - $this->e->debug('PURL: '.OWA_PUBLIC_URL); - /* APPLY DATABASE CONFIGURATION */ + //$this->e->debug('PURL: '.OWA_PUBLIC_URL); + + /* DATABASE CONFIGURATION */ + // This needs to come before the fetch of user overrides from the DB + // Constants defined in the config file have the final word + // values passed from calling application must be applied prior + // to the rest of the caller's overrides if (!defined('OWA_DB_TYPE')): - define('OWA_DB_TYPE', $this->c->get('base', 'db_type')); + define('OWA_DB_TYPE', $config['db_type']); else: $this->c->set('base', 'db_type', OWA_DB_TYPE); endif; if (!defined('OWA_DB_NAME')): - define('OWA_DB_NAME', $this->c->get('base', 'db_name')); + define('OWA_DB_NAME', $config['db_name']); else: $this->c->set('base', 'db_name', OWA_DB_NAME); endif; if (!defined('OWA_DB_HOST')): - define('OWA_DB_HOST', $this->c->get('base', 'db_host')); + define('OWA_DB_HOST', $config['db_host']); else: $this->c->set('base', 'db_host', OWA_DB_HOST); endif; if (!defined('OWA_DB_USER')): - define('OWA_DB_USER', $this->c->get('base', 'db_user')); + define('OWA_DB_USER', $config['db_user']); else: $this->c->set('base', 'db_user', OWA_DB_USER); endif; if (!defined('OWA_DB_PASSWORD')): - define('OWA_DB_PASSWORD', $this->c->get('base', 'db_password')); + define('OWA_DB_PASSWORD', $config['db_password']); else: $this->c->set('base', 'db_password', OWA_DB_PASSWORD); endif; @@ -184,13 +194,22 @@ function __construct($config) { if ($this->c->get('base', 'do_not_fetch_config_from_db') != true): $this->c->load($this->c->get('base', 'configuration_id')); endif; + + /* APPLY CALLER CONFIGURATION OVERRIDES */ - /** - * Post User Config Framework Setup - * - */ + // overrides all default and user config values except defined in the config file + // must come after user overides are applied + // This will apply configuration overirdes that are specified by the calling application. + // This is usually used by plugins to setup integration specific configuration values. + + $this->c->applyModuleOverrides('base', $config); - // Looks for log handler constant from config file + $this->e->debug('Caller configuration overrides applied.'); + + /* SET ERROR HANDLER */ + + // Looks for log handler constant from config file otherwise respects + // user and caller overrides if (defined('OWA_ERROR_HANDLER')): $this->c->set('base', 'error_handler', OWA_ERROR_HANDLER); endif; @@ -199,18 +218,29 @@ function __construct($config) { // This will flush buffered msgs that were thrown up untill this point $this->e->setHandler($this->c->get('base', 'error_handler')); - // Create Request Container + /* SETUP REQUEST CONTAINER */ + + $this->request = owa_coreAPI::requestContainerSingleton(); $this->params = &owa_requestContainer::getInstance(); - // Load the core API + /* LOAD CORE API */ + + /** + * @todo This needs to be refactored into stateless api calls + */ $this->api = &owa_coreAPI::singleton(); $this->api->caller_config_overrides = $config; - // should only be called once to load all modules $this->api->setupFramework(); + // check for required schema updates and sets update flag + // this is needed if the calling application or plugin needs to check for updates + if (!empty($this->api->modules_needing_updates)): + $this->update_required = true; + endif; + /* SET SITE ID */ // needed in standalone installs where site_id is not set in config file. - if ($this->params['site_id']): + if (!empty($this->params['site_id'])): $this->c->set('base', 'site_id', $this->params['site_id']); endif; @@ -253,18 +283,13 @@ function log($caller_params = '') { */ function logEvent($event_type, $caller_params = '') { + $this->e->debug(print_r($this->e->backtrace(), true)); //change config value to incomming site_id - if(!empty($caller_params['site_id'])): - $this->config['site_id'] = $caller_params['site_id']; - $this->c->set('base', 'site_id', $caller_params['site_id']); - else: - $caller_params['site_id'] = $this->c->get('base', 'site_id'); - endif; - - - // do not log if the request is comming fro mthe preview plane of the admin interface - if ($this->params['preview'] == true): - return false; + if(!empty($caller_params['site_id'])): + $this->config['site_id'] = $caller_params['site_id']; + $this->c->set('base', 'site_id', $caller_params['site_id']); + else: + $caller_params['site_id'] = $this->c->get('base', 'site_id'); endif; // do not log if the request is from a reserved IP @@ -318,6 +343,8 @@ function logEvent($event_type, $caller_params = '') { * @return unknown */ function logEventFromUrl($caller_params) { + + // keeps php executing even if the client closes the connection ignore_user_abort(true); //$clean_params = owa_lib::inputFilter($caller_params); @@ -418,14 +445,14 @@ function performAction($action) { $controller = $this->api->moduleFactory($action, 'Controller', $this->params); //perfrom authentication - $auth = &owa_auth::get_instance(); + //$auth = &owa_auth::get_instance(); - $data = $auth->authenticateUser($controller->priviledge_level); + //$data = $auth->authenticateUser($controller->priviledge_level); // if auth was success then procead to do action specified in the intended controller. - if ($data['auth_status'] == true): + //if ($data['auth_status'] == true): $data = $controller->doAction(); - endif; + //endif; // Display view if controller calls for one. if (!empty($data['view']) || !empty($data['action'])): @@ -471,6 +498,7 @@ function handleRequest($caller_params = null) { static $init; // Override request parsms with those passed by caller + // TODO: make this an array merge if (!empty($caller_params)): foreach ($caller_params as $n => $v) { @@ -482,9 +510,8 @@ function handleRequest($caller_params = null) { if ($init != true): $this->e->debug('Request Params: '. print_r($this->params, true)); endif; - + if (!empty($this->params['action'])): - $result = $this->performAction($this->params['action']); unset($this->params['action']); @@ -500,6 +527,7 @@ function handleRequest($caller_params = null) { else: print "Caller: No view or action param found. I'm not sure what to do here."; return; + endif; $init = true; diff --git a/owa_controller.php b/owa_controller.php index b377ea039..a35f94df4 100644 --- a/owa_controller.php +++ b/owa_controller.php @@ -16,7 +16,7 @@ // $Id$ // -require_once('owa_base.php'); +require_once(OWA_BASE_DIR.'/owa_auth.php'); /** @@ -41,6 +41,20 @@ class owa_controller extends owa_base { */ var $params; + /** + * Controller Type + * + * @var array + */ + var $type; + + /** + * Is the controller for an admin function + * + * @var boolean + */ + var $is_admin; + /** * The priviledge level required to access this controller * @@ -48,6 +62,15 @@ class owa_controller extends owa_base { */ var $priviledge_level; + /** + * The auth module to use for this controller + * This can be overriden by concrete controller classes + * otherwise value will be pulled from the base module's configuration + * + * @var string + */ + var $auth_module; + /** * data validation control object * @@ -69,10 +92,13 @@ class owa_controller extends owa_base { * @return owa_controller */ function owa_controller($params) { - + $this->owa_base(); $this->params = $params; + // sets the auth module. requires a configuration object. + $this->_setAuthModule(); + return; } @@ -85,33 +111,64 @@ function doAction() { $this->e->debug('Performing Action: '.get_class($this)); - // set status msg - if (!empty($this->params['status_code'])): - $this->data['status_msg'] = $this->getMsg($this->params['status_code']); - endif; + // check if the schema needs to be updated and force the update + // not sure this should go here... + if ($this->is_admin == true): + // do not intercept if its the updatesApply action or else updates will never apply + if ($this->params['do'] != 'base.updatesApply'): + $api = &owa_coreAPI::singleton(); + + if ($api->update_required == true): + $this->e->debug('Updates Required. Redirecting action.'); + $data = array(); + $data['view_method'] = 'redirect'; + $data['action'] = 'base.updates'; + return $data; + endif; + endif; + endif; - // get error msg from error code passed on the query string from a redirect. - if (!empty($this->params['error_code'])): - $this->data['error_msg'] = $this->getMsg($this->params['error_code']); - endif; + //perfrom authentication + // TODO: make the auth module configurable by the controller + $auth = &owa_auth::get_instance(); - if (!empty($this->v)): + $data = $auth->authenticateUser($this->priviledge_level); - $this->v->doValidations(); + // if auth was success then procead + if ($data['auth_status'] == true): + + // set status msg + if (!empty($this->params['status_code'])): + $this->data['status_msg'] = $this->getMsg($this->params['status_code']); + endif; - if ($this->v->hasErrors == true): - - return $this->errorAction(); + // get error msg from error code passed on the query string from a redirect. + if (!empty($this->params['error_code'])): + $this->data['error_msg'] = $this->getMsg($this->params['error_code']); + endif; - else: - - return $this->action(); + // check to see if the controlelr has created a validator + if (!empty($this->v)): + // if so do the validations required + $this->v->doValidations(); + //check for erros + if ($this->v->hasErrors == true): + // if errors, do the errorAction instead of the normal action + return $this->errorAction(); + else: + return $this->action(); + endif; endif; + return $this->action(); + else: + // return the not priviledged error view set by owa_auth. + // TODO: owa_auth should probably not know anything about a view + return $data; + endif; - return $this->action(); } @@ -149,6 +206,26 @@ function getValidationErrorMsgs() { } + function isAdmin() { + + if ($this->is_admin == true): + return true; + else: + return false; + endif; + + } + + function _setAuthModule() { + + if (empty($this->auth_module)): + $this->auth_module = $this->c->get('base', 'authentication'); + endif; + + return; + + } + } ?> \ No newline at end of file diff --git a/owa_coreAPI.php b/owa_coreAPI.php index 3f7f69151..22147f292 100644 --- a/owa_coreAPI.php +++ b/owa_coreAPI.php @@ -39,6 +39,20 @@ class owa_coreAPI extends owa_base { var $init; + /** + * Array of modules whose schemas are out of date + * + * @var array + */ + var $modules_needing_updates = array(); + + /** + * Flag for schema update required + * + * @var boolean + */ + var $update_required; + /** * Container for request params * @@ -76,6 +90,23 @@ function &singleton($params = array()) { return $api; } + function setupStorageEngine($type) { + + if (!class_exists('owa_db')): + require_once(OWA_BASE_CLASSES_DIR.'owa_db.php'); + endif; + + $connection_class = "owa_db_" . $type; + $connection_class_path = OWA_PLUGINS_DIR.'/db/' . $connection_class . ".php"; + + if (!require_once($connection_class_path)): + $e->emerg(sprintf('Cannot locate proper db class at %s. Exiting.', $connection_class_path)); + endif; + + return; + + } + function &dbSingleton() { static $db; @@ -93,7 +124,7 @@ function &dbSingleton() { $connection_class = "owa_db_" . OWA_DB_TYPE; $connection_class_path = OWA_PLUGINS_DIR.'/db/' . $connection_class . ".php"; - if (!include($connection_class_path)): + if (!require_once($connection_class_path)): $e->emerg(sprintf('Cannot locate proper db class at %s. Exiting.', $connection_class_path)); return; @@ -162,6 +193,24 @@ function &cacheSingleton($params = array()) { return $cache; } + function requestContainerSingleton() { + + static $request; + + if(!isset($request)): + + if (!class_exists('owa_requestContainer')): + require_once(OWA_DIR.'owa_requestContainer.php'); + endif; + + $request = owa_lib::factory(OWA_DIR, '', 'owa_requestContainer'); + + endif; + + return $request; + + } + function setupFramework() { if ($this->init != true): @@ -180,10 +229,22 @@ function _loadModules() { foreach ($am as $k => $v) { $m = owa_coreAPI::moduleClassFactory($v); + $this->modules[$m->name] = $m; + // check for schema updates + $check = $this->modules[$m->name]->isSchemaCurrent(); + + if ($check != true): + $this->modules_needing_updates[] = $m->name; + endif; } + // set schema update flag + if (!empty($this->modules_needing_updates)): + $this->update_required = true; + endif; + return; } @@ -298,6 +359,29 @@ function moduleFactory($modulefile, $class_suffix = null, $params = '') { return $obj; } + function moduleGenericFactory($module, $sub_directory, $file, $class_suffix = null, $params = '') { + + $class = 'owa_'.$file.$class_suffix; + + // Require class file if class does not already exist + if(!class_exists($class)): + owa_coreAPI::moduleRequireOnce($module, $sub_directory, $file); + endif; + + $obj = owa_lib::factory(OWA_DIR.'modules'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$sub_directory, '', $class, $params); + + return $obj; + } + + function updateFactory($module, $class) { + + require_once(OWA_BASE_CLASS_DIR.'update.php'); + + $obj = owa_coreAPI::moduleGenericFactory($module, 'updates', $class, '_update'); + $obj->module_name = $module; + return $obj; + } + function subViewFactory($subview, $params = array()) { list($module, $class) = split("\.", $subview); @@ -558,6 +642,11 @@ function getActiveModules() { } + function getModulesNeedingUpdates() { + + return $this->modules_needing_updates; + } + } ?> \ No newline at end of file diff --git a/owa_entity.php b/owa_entity.php index 5756ff59c..a77f8e19a 100644 --- a/owa_entity.php +++ b/owa_entity.php @@ -40,7 +40,8 @@ function owa_entity() { foreach ($vars as $k => $v) { - $this->$v = new owa_dbColumn(); + $this->$v = new owa_dbColumn($this->$v); + $this->$v->set('name', $v); } return; @@ -120,6 +121,13 @@ function get($name) { return $this->$name->value; } + function getTableOptions() { + + return array('table_type' => 'disk'); + + } + + } ?> \ No newline at end of file diff --git a/owa_lib.php b/owa_lib.php index eeb0655d6..038592603 100644 --- a/owa_lib.php +++ b/owa_lib.php @@ -739,6 +739,43 @@ function microtime_float() { return ((float)$usec + (float)$sec); } + /** + * Lists all files in a Directory + * + */ + function listDir($start_dir='.') { + + $files = array(); + + if (is_dir($start_dir)): + + $fh = opendir($start_dir); + + while (($file = readdir($fh)) !== false) { + + // loop through the files, skipping . and .., and recursing if necessary + if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue; + $filepath = $start_dir . DIRECTORY_SEPARATOR . $file; + + if (is_dir($filepath)): + $files = array_merge($files, listDir($filepath)); + else: + array_push($files, array('name' => $file, 'path' => $filepath)); + endif; + } + + closedir($fh); + + else: + // false if the function was called with an invalid non-directory argument + $files = false; + endif; + + return $files; + + } + + } diff --git a/owa_module.php b/owa_module.php index ea8c290ef..3dd6a6dce 100644 --- a/owa_module.php +++ b/owa_module.php @@ -51,6 +51,13 @@ class owa_module extends owa_base { */ var $version; + /** + * Schema Version of Module + * + * @var string + */ + var $schema_version = 1100; + /** * Name of author of module * @@ -130,7 +137,21 @@ class owa_module extends owa_base { * * @var array */ - var $entities; + var $entities = array(); + + /** + * Required Schema Version + * + * @var array + */ + var $required_schema_version; + + /** + * Available Updates + * + * @var array + */ + var $updates = array(); /** * Constructor @@ -261,77 +282,137 @@ function addNavigationLink($link) { } /** - * Installation method for this module + * Registers Entity * - * Concrete classes must be placed in the install sub directory and - * use the following naming convention: owa_install_{module name}_{database type}. - * */ - function install() { + function _addEntity($entity_name) { - $obj = $this->installerFactory(); - //$this->e->notice(print_r($obj, true)); - - $this->e->notice('starting install'); - $tables_to_install = $obj->checkForSchema(); + if (is_array($entity_name)): + $this->entities = array_merge($this->entities, $entity_name); + else: + $this->entities[] = $name; + endif; - $table_errors = ''; + return; + } + + /** + * Installation method + * + * Creates database tables and sets schema version + * + */ + function install() { - if (!empty($tables_to_install)): + $this->e->notice('Starting installation of module: '.$this->name); + + $errors = ''; + + // Install schema + if (!empty($this->entities)): - foreach ($tables_to_install as $table) { + foreach ($this->entities as $k => $v) { - $status = $obj->create($table); + $entity = owa_coreAPI::entityFactory($this->name.'.'.$v); + //$this->e->debug("about to execute createtable"); + $status = $entity->createTable(); - if ($status == true): - $this->e->notice(sprintf("Created %s table.", $table)); - else: - $this->e->err(sprintf("Creation of %s table failed.", $table)); - $table_errors = 'error'; + if ($status != true): + $this->e->notice("Entity Installation Failed."); + $errors = true; + //return false; endif; } - + endif; - if ($table_errors != 'error'): + // activate module and persist configuration changes + if ($errors != true): - // save schema version to configuration - $this->c->setSetting($this->name, 'schema_version', $obj->version); - // activate module and persist configuration changes - $this->activate(); - - $this->e->notice(sprintf("Schema version %s installation complete.", $obj->version)); - return true; + // run post install hook + $ret = $this->postInstall(); + + if ($ret == true): + // save schema version to configuration + $this->c->setSetting($this->name, 'schema_version', $this->schema_version); + //activate the module and save the configuration + $this->activate(); + $this->e->notice("Installation complete."); + return true; + else: + $this->e->notice("Post install proceadure failed."); + return true; + endif; else: + $this->e->notice("Installation failed."); return false; endif; - + } - /** - * Install Class Factory - * - * @return object Concrete install class for this module + * Post installation hook + * */ - function installerFactory($params = array()) { - - $obj = owa_lib::factory(OWA_BASE_DIR.'/modules/'.$this->name.'/install/', 'owa_', 'install_'.$this->name.'_'.OWA_DB_TYPE, $params); - - $obj->module = $this->name; - - return $obj; - - } + function postInstall() { + return false; + } + /** * Checks for and applies schema upgrades for the module * */ - function upgrade() { + function update() { - return; + // list files in a directory + $files = owa_lib::listDir(OWA_DIR.'modules'.DIRECTORY_SEPARATOR.$this->name.DIRECTORY_SEPARATOR.'updates'); + //print_r($files); + + $current_schema_version = $this->c->get($this->name, 'schema_version'); + + // extract sequence + foreach ($files as $k => $v) { + // the use of %d casts the sequence number as an int which is critical for maintaining the + // order of the keys in the array that we are going ot create that holds the update objs + //$n = sscanf($v['name'], '%d_%s', $seq, $classname); + $seq = substr($v['name'], 0, -4); + + settype($seq, "integer"); + + if ($seq > $current_schema_version): + + if ($seq <= $this->required_schema_version): + $this->updates[$seq] = owa_coreAPI::updateFactory($this->name, substr($v['name'], 0, -4)); + // set schema version from sequence number in file name. This ensures that only one update + // class can ever be in use for a particular schema version + $this->updates[$seq]->schema_version = $seq; + endif; + endif; + + } + + // sort the array + ksort($this->updates, SORT_NUMERIC); + + print_r(array_keys($this->updates)); + + foreach ($this->updates as $k => $obj) { + + $this->e->notice(sprintf("Applying Update %d (%s)", $k, get_class($obj))); + + $ret = $obj->apply(); + + if ($ret == true): + $this->e->notice("Update Suceeded"); + else: + $this->e->notice("Update Failed"); + return false; + endif; + } + + return true; } /** @@ -382,9 +463,48 @@ function deactivate() { */ function _registerEntities() { + return false; + } + + /** + * Checks to se if the schema is up to date + * + */ + function isSchemaCurrent() { + + $current_schema = $this->c->get($this->name, 'schema_version'); + + if ($current_schema >= $this->required_schema_version): + return true; + else: + return false; + endif; + } + + /** + * Registers updates + * + */ + function _registerUpdates() { + + + return; + } + /** + * Adds an update class into the update array. + * This should be used to within the _registerUpdates method or else + * it will not get called. + * + */ + function _addUpdate($sequence, $class) { + + $this->updates[$sequence] = $class; + + return true; + } } diff --git a/owa_reportController.php b/owa_reportController.php index 5c70cc09c..d2ec3f34e 100644 --- a/owa_reportController.php +++ b/owa_reportController.php @@ -33,6 +33,9 @@ class owa_reportController extends owa_controller { + var $is_admin = true; + var $type = 'report'; + /** * Constructor * diff --git a/owa_requestContainer.php b/owa_requestContainer.php index e3d4b25ff..4bbf21005 100644 --- a/owa_requestContainer.php +++ b/owa_requestContainer.php @@ -30,27 +30,46 @@ class owa_requestContainer { + var $php_self; + var $cli_args; + var $gateway_interface; + var $server_ip_address; + var $server_name; + var $server_software; + var $server_protocol; + var $server_document_root; + var $request_method; + var $request_time; + var $query_string; + var $is_https; + var $remote_ip_address; + var $remote_host; + var $remote_port; + var $path_translated; + var $script_filename; + var $request_uri; + var $server_auth_user; + var $server_auth_password; + var $auth_type; + var $owa_params; + var $cookies; + var $request; + var $guid; + /** * Request Params - * + * @depricated * @var array */ var $params; - /** - * Constructor - * - * @return owa_requestParams - */ - function owa_requestContainer() { - - return; - } + /** * Singleton returns request params * * @return array + * @todo DEPRICATED */ function & getInstance() { @@ -59,7 +78,7 @@ function & getInstance() { if(!isset($params)): $params = owa_lib::getRequestParams(); - $params['guid'] = crc32(microtime().getmypid()); + $params['guid'] = $this->guid; return $params; @@ -71,6 +90,94 @@ function & getInstance() { } + function owa_requestContainer() { + + return $this->__construct(); + } + + function __construct() { + + $this->php_self = $_SERVER['PHP_SELF']; + $this->cli_args = $_SERVER['argv']; + $this->gateway_interface = $_SERVER['GATEWAY_INTERFACE']; + $this->server_ip_address = $_SERVER['SERVER_ADDR']; + $this->server_name = $_SERVER['SERVER_NAME']; + $this->server_software = $_SERVER['SERVER_SOFTWARE']; + $this->server_protocol = $_SERVER['SERVER_PROTOCOL']; + $this->server_document_root = $_SERVER['DOCUMENT_ROOT']; + $this->server_auth_user = $_SERVER['PHP_AUTH_USER']; + $this->server_auth_password = $_SERVER['PHP_AUTH_PW']; + $this->server_auth_type = $_SERVER['AUTH_TYPE']; + $this->server_path_translated = $_SERVER['PATH_TRANSLATED']; + $this->request_method = $_SERVER['REQUEST_METHOD']; + $this->request_time = $_SERVER['REQUEST_TIME']; + $this->query_string = $_SERVER['QUERY_STRING']; + $this->http_accept = $_SERVER['HTTP_ACCEPT']; + $this->http_accept_charset = $_SERVER['HTTP_ACCEPT_CHARSET']; + $this->http_accept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING']; + $this->http_accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE']; + $this->http_connection = $_SERVER['HTTP_CONNECTION']; + $this->http_host = $_SERVER['HTTP_HOST']; + $this->http_referer = $_SERVER['HTTP_REFERER']; + $this->http_user_agent = $_SERVER['HTTP_USER_AGENT']; + $this->remote_ip_address = $_SERVER['REMOTE_ADDR']; + $this->remote_host = $_SERVER['REMOTE_HOST']; + $this->remote_port = $_SERVER['REMOTE_PORT']; + $this->script_filename = $_SERVER['SCRIPT_FILENAME']; + $this->request_uri = $_SERVER['REQUEST_URI']; + + $this->cookies = $_COOKIE; + $this->request = owa_lib::inputFilter($_REQUEST); + $this->owa_params = owa_lib::stripParams($this->request); + $this->guid = crc32(microtime().getmypid()); + + if(isset($_SERVER['HTTPS'])): + $this->is_https = true; + endif; + + return; + + } + + function get($name) { + + return $this->$name; + + } + + function set($name, $value) { + + $this->$name = $value; + return true; + } + + function getOwaParam($name) { + + return $this->owa_params[$name]; + } + + function setOwaParam($name, $value) { + + $this->owa_params[$name] = $value; + return true; + } + + function getCookie($name) { + + return $this->cookies[$name]; + } + + function getHeader($name) { + + return $this->headers['name']; + } + + function getRequestParam($name) { + + return $this->request[$name]; + } + + } ?> \ No newline at end of file diff --git a/owa_template.php b/owa_template.php index 857394324..e21cafe22 100644 --- a/owa_template.php +++ b/owa_template.php @@ -473,6 +473,13 @@ function includeTemplate($file) { } + function setTemplate($file) { + + $this->set_template($file); + return $this->file; + + } + } diff --git a/plugins/db/owa_db_mysql.php b/plugins/db/owa_db_mysql.php index ddb5fe019..39071a3b6 100644 --- a/plugins/db/owa_db_mysql.php +++ b/plugins/db/owa_db_mysql.php @@ -16,8 +16,47 @@ // $Id$ // + +define('OWA_DTD_BIGINT', 'BIGINT'); +define('OWA_DTD_INT', 'INT'); +define('OWA_DTD_TINYINT', 'TINYINT(1)'); +define('OWA_DTD_TINYINT2', 'TINYINT(2)'); +define('OWA_DTD_TINYINT4', 'TINYINT(4)'); +define('OWA_DTD_BOOLEAN', 'BOOLEAN'); +define('OWA_DTD_SERIAL', 'SERIAL'); +define('OWA_DTD_PRIMARY_KEY', 'PRIMARY KEY'); +define('OWA_DTD_VARCHAR10', 'VARCHAR(10)'); +define('OWA_DTD_VARCHAR255', 'VARCHAR(255)'); +define('OWA_DTD_VARCHAR', 'VARCHAR(%s)'); +define('OWA_DTD_TEXT', 'TEXT'); +define('OWA_DTD_INDEX', 'KEY'); +define('OWA_DTD_AUTO_INCREMENT', 'AUTO_INCREMENT'); +define('OWA_DTD_NOT_NULL', 'NOT NULL'); +define('OWA_DTD_UNIQUE', 'UNIQUE'); +define('OWA_DTD_UNIQUE', 'PRIMARY KEY(%s)'); +define('OWA_SQL_ADD_COLUMN', 'ALTER TABLE %s ADD %s %s'); +define('OWA_SQL_DROP_COLUMN', 'ALTER TABLE %s DROP %s'); +define('OWA_SQL_MODIFY_COLUMN', 'ALTER TABLE %s MODIFY %s %s'); +define('OWA_SQL_RENAME_TABLE', 'ALTER TABLE %s RENAME %s'); +define('OWA_SQL_CREATE_TABLE', 'CREATE TABLE %s (%s) %s'); +define('OWA_SQL_DROP_TABLE', 'DROP TABLE IF EXISTS %s'); +define('OWA_SQL_INSERT_ROW', 'INSERT into %s (%s) VALUES (%s)'); +define('OWA_SQL_UPDATE_ROW', 'UPDATE %s SET %s WHERE %s'); +define('OWA_SQL_DELETE_ROW', "DELETE from %s WHERE %s = '%s'"); +define('OWA_SQL_CREATE_INDEX', 'CREATE INDEX %s ON %s (%s)'); +define('OWA_SQL_DROP_INDEX', 'DROP INDEX %s ON %s'); +define('OWA_SQL_INDEX', 'INDEX (%s)'); +define('OWA_SQL_BEGIN_TRANSACTION', 'BEGIN'); +define('OWA_SQL_END_TRANSACTION', 'COMMIT'); +define('OWA_DTD_TABLE_TYPE', 'ENGINE = %s'); +define('OWA_DTD_DEFAULT_TABLE_TYPE', 'INNODB'); +define('OWA_DTD_TABLE_TYPE_DISK', 'INNODB'); +define('OWA_DTD_TABLE_TYPE_MEMORY', 'MEMORY'); + + + /** - * MySQL Connection class + * MySQL Data Access Class * * @author Peter Adams * @copyright Copyright © 2006 Peter Adams @@ -39,24 +78,6 @@ function owa_db_mysql() { $this->owa_db(); - //$connectionString = sprintf('%s', OWA_DB_HOST); - - /*$this->connection = mysql_connect( - OWA_DB_HOST, - OWA_DB_USER, - OWA_DB_PASSWORD, - true - ); - - $this->database_selection = mysql_select_db(OWA_DB_NAME, $this->connection); - - if (!$this->connection || !$this->database_selection): - $this->e->alert('Could not connect to database. '); - $this->connection_status = false; - else: - $this->connection_status = true; - endif; - */ return; } @@ -72,7 +93,7 @@ function connect() { $this->database_selection = mysql_select_db(OWA_DB_NAME, $this->connection); if (!$this->connection || !$this->database_selection): - $this->e->alert('Could not connect to database. '); + $this->e->alert('Could not connect to database.'); $this->connection_status = false; return false; else: @@ -119,12 +140,6 @@ function query($sql) { $this->new_result = $result; - // hack for when calling applications catch all mysql errors and you nee to flush the error - // this only is an issue with respect to inserts that fail. - if ($result == false): - ;//mysql_ping($this->connection); - endif; - return $this->new_result; } @@ -236,7 +251,7 @@ function save($properties, $table) { } return $this->query(sprintf( - "INSERT into %s (%s) VALUES (%s)", + OWA_SQL_INSERT_ROW, $table, $sql_cols, $sql_values) @@ -273,16 +288,149 @@ function update($properties, $constraints, $table) { $where = owa_lib::addConstraints($constraints); - return $this->query(sprintf("UPDATE %s SET %s WHERE %s", $table, $set, $where)); + return $this->query(sprintf(OWA_SQL_UPDATE_ROW, $table, $set, $where)); } + /** + * Deletes Row from a table + * + */ function delete($id, $col, $table) { - return $this->query(sprintf("DELETE from %s WHERE %s = '%s'", $table, $col, $id)); + return $this->query(sprintf(OWA_SQL_DELETE_ROW, $table, $col, $id)); + + } + + /** + * Creates a new table + * + */ + function createTable($entity) { + + //create column defs + + $all_cols = $entity->getColumns(); + + $columns = ''; + + $table_defs = ''; + + $i = 0; + $count = count($all_cols); + + // Control loop + foreach ($all_cols as $k => $v){ + + // get column definition + $columns .= $v.' '.$entity->$v->getDefinition(); + + // Add commas to column statement + if ($i < $count - 1): + + $columns .= ', '; + + endif; + + $i++; + + } + + // make table options + $table_options = ''; + $options = $entity->getTableOptions(); + + // table type + switch ($options['table_type']) { + + case "disk": + $table_type = OWA_DTD_TABLE_TYPE_DISK; + break; + case "memory": + $table_type = OWA_DTD_TABLE_TYPE_MEMORY; + break; + default: + $table_type = OWA_DTD_TABLE_TYPE_DEFAULT; + + } + + $table_options .= sprintf(OWA_DTD_TABLE_TYPE, $table_type); + + return $this->query(sprintf(OWA_SQL_CREATE_TABLE, get_class($entity), $columns, $table_options)); } + /** + * Drops a table + * + */ + function dropTable($table_name) { + + return $this->query(sprintf(OWA_SQL_DROP_TABLE, $table_name)); + + } + + + /** + * Rename a table + * + */ + function renameTable($table_name, $new_table_name) { + + return $this->query(sprintf(OWA_SQL_RENAME_TABLE, $table_name, $new_table_name)); + + } + + + /** + * Adds new column to table + * + */ + function addColumn($table_name, $column_name, $column_definition) { + + return $this->query(sprintf(OWA_SQL_ADD_COLUMN, $table_name. $column_name, $column_definition)); + + } + + /** + * Drops a column from a table + * + */ + function dropColumn($table_name, $column_name) { + + return $this->query(sprintf(OWA_SQL_DROP_COLUMN, $table_name. $column_name)); + + } + + /** + * Begins a SQL transaction statement + * + */ + function beginTransaction() { + + return $this->query(OWA_SQL_BEGIN_TRANSACTION); + } + + /** + * Ends a SQL transaction statement + * + */ + function endTransaction() { + + return $this->query(OWA_SQL_END_TRANSACTION); + } + + /** + * Changes the definition of a column + * + */ + function modifyColumn($table_name, $column_name, $column_definition) { + + return $this->query(sprintf(OWA_SQL_MODIFY_COLUMN, $table_name. $column_name, $column_definition)); + + } + + function select($values, $constraints, $table) { $cols = ''; diff --git a/wp_plugin.php b/wp_plugin.php index 75f5d4088..35d24ad93 100644 --- a/wp_plugin.php +++ b/wp_plugin.php @@ -49,8 +49,8 @@ add_action('admin_menu', 'owa_dashboard_menu'); add_action('comment_post', 'owa_logComment'); add_action('admin_menu', 'owa_options_menu'); -add_action('activate_owa/wp_plugin.php', 'owa_install'); // Installation hook - +// Installation hook +register_activation_hook(__FILE__,'owa_install'); ///////////////////////////////////////////////////////////////////////////////// @@ -61,6 +61,7 @@ * * @return $owa object */ + function owa_getInstance($params = array()) { static $owa; @@ -85,8 +86,10 @@ function owa_getInstance($params = array()) { $owa_config['db_password'] = DB_PASSWORD; $owa_config['report_wrapper'] = 'wrapper_wordpress.tpl'; - $owa_config['images_url'] = OWA_PUBLIC_URL.'i/';//'../wp-content/plugins/owa/public/i/'; - $owa_config['images_absolute_url'] = get_bloginfo('url').'/wp-content/plugins/owa/public/i/';//'../wp-content/plugins/owa/public/i/'; + //'../wp-content/plugins/owa/public/i/'; + $owa_config['images_url'] = OWA_PUBLIC_URL.'i/'; + //'../wp-content/plugins/owa/public/i/'; + $owa_config['images_absolute_url'] = get_bloginfo('url').'/wp-content/plugins/owa/public/i/'; $owa_config['main_url'] = '../wp-admin/index.php?page=owa/public/wp.php'; $owa_config['main_absolute_url'] = get_bloginfo('url').'/wp-admin/index.php?page=owa/public/wp.php'; $owa_config['action_url'] = get_bloginfo('url').'/index.php?owa_specialAction'; @@ -101,6 +104,7 @@ function owa_getInstance($params = array()) { $owa = new owa_wp($config); // adds wordpress specific user priviledge info to the request params + global $user_level, $user_login, $user_ID, $user_email, $user_identity, $user_pass_md5; $owa->params['caller']['wordpress']['user_data'] = array( @@ -118,8 +122,10 @@ function owa_getInstance($params = array()) { return $owa; endif; + } + function owa_handleSpecialActionRequest() { $owa = owa_getInstance(); @@ -184,7 +190,7 @@ function owa_main() { $app_params['feed_format'] = $_GET['feed']; endif; - $app_params[$owa_wp->config['source_param']] = $_GET[$owa_wp->config['ns'].$owa_wp->config['source_param']]; + $app_params[$owa->config['source_param']] = $_GET[$owa->config['ns'].$owa->config['source_param']]; // Track users by the email address of that they used when posting a comment $app_params['user_email'] = $_COOKIE['comment_author_email_'.COOKIEHASH];