Skip to content

Commit

Permalink
- fixed bug were calling application config was not over writing user…
Browse files Browse the repository at this point in the history
… config values fetched from the db

- added several missing entity classes
- added check fro upgrades
- added upgrade call
- added several new DAO methods
- abstracted SQL into platfrom constants
- removed call to installer. Entities now create their own tables
  • Loading branch information
padams committed Jun 8, 2008
1 parent 6806055 commit 4365193
Show file tree
Hide file tree
Showing 62 changed files with 2,000 additions and 491 deletions.
67 changes: 38 additions & 29 deletions asyncEventProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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;
}
Expand All @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions conf/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
2001 => array("The e-mail <B>%s</B> was not found in our database. Please check the address and try again.",1),
2002 => array("<B>Login Failed</B>. 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
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions eventQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

/**
Expand Down
73 changes: 72 additions & 1 deletion modules/base/classes/column.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

}

?>
105 changes: 104 additions & 1 deletion modules/base/classes/entityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ function create() {

$all_cols = $this->entity->getColumns();

$cols = '';
$cols = array();

// Control loop
foreach ($all_cols as $k => $v){

Expand Down Expand Up @@ -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
*
Expand Down
19 changes: 18 additions & 1 deletion modules/base/classes/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

}
Expand Down Expand Up @@ -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;

}

}

Expand Down
Loading

0 comments on commit 4365193

Please sign in to comment.