Changeset 500
- Timestamp:
- 06/28/08 01:39:45 (6 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 removed
- 13 modified
-
conf/messages.php (modified) (2 diffs)
-
modules/base/classes/entityManager.php (modified) (7 diffs)
-
modules/base/module.php (modified) (1 diff)
-
modules/base/updates/002.php (added)
-
modules/base/updates/_002.php (deleted)
-
modules/base/updates/_003.php (deleted)
-
modules/base/updatesApply.php (modified) (2 diffs)
-
modules/hello/module.php (modified) (1 diff)
-
owa_caller.php (modified) (6 diffs)
-
owa_coreAPI.php (modified) (2 diffs)
-
owa_entity.php (modified) (1 diff)
-
owa_lib.php (modified) (3 diffs)
-
owa_module.php (modified) (2 diffs)
-
owa_observer.php (modified) (4 diffs)
-
owa_requestContainer.php (modified) (4 diffs)
-
plugins/db/owa_db_mysql.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/conf/messages.php
r498 r500 46 46 2503 => array("Options reset to Default Values.",0), 47 47 48 48 49 //User managment 49 50 3000 => array("Success. User Added.", 0), … … 74 75 3305 => array("Success. Base Database Schema Installed.",0), 75 76 3306 => array("Error. User id already exists for some reason.",0), 77 3307 => array("Updates failed. Check the log file for more details and try again.",0), 76 78 77 79 // Graph related -
trunk/modules/base/classes/entityManager.php
r498 r500 96 96 function create() { 97 97 98 $all_cols = $this->entity->getColumns(); 99 100 $cols = array(); 101 102 // Control loop 103 foreach ($all_cols as $k => $v){ 104 105 // drop column is it is marked as auto-incement as DB will take car of that. 106 if ($this->entity->$v->auto_increment == true): 107 break; 108 else: 109 $cols[$v] = $this->entity->$v->value; 110 endif; 111 112 } 113 114 // Persist object 115 $status = $this->db->save($cols, get_class($this->entity)); 116 117 // Add to Cache 118 119 if ($status == true): 120 if ($this->config['cache_objects'] == true): 121 $this->cache->set(get_class($this->entity), 'id'.$this->entity->id->value, $this->entity); 122 endif; 123 endif; 124 125 return $status; 98 return $this->entity->create(); 126 99 127 100 } … … 130 103 * Create Table 131 104 * 132 * Handled by DB abstraction layer because the SQ associated with this is way too DB specific105 * Handled by DB abstraction layer because the SQL associated with this is way too DB specific 133 106 */ 134 107 function createTable() { … … 235 208 function update($where = '') { 236 209 237 if(empty($where)): 238 $constraint = array('id' => $this->entity->id->value); 239 else: 240 $constraint = array($where => $this->entity->$where->value); 241 endif; 242 243 244 // Persist object 245 $status = $this->db->update($this->_getProperties(), $constraint, get_class($this->entity)); 246 247 // Add to Cache 248 if ($status == true): 249 if ($this->config['cache_objects'] == true): 250 $this->cache->replace(get_class($this->entity), 'id'.$this->entity->id->value, $this->entity); 251 endif; 252 endif; 253 254 return $status; 210 $this->entity->update($where); 255 211 256 212 } … … 265 221 function partialUpdate($named_properties, $where) { 266 222 267 $properties = array(); 268 269 foreach ($named_properties as $n) { 270 271 $properties[$n] = $this->entity->$n->value; 272 273 } 274 275 276 // Persist object 277 $status = $this->db->update($properties, $where, get_class($this->entity)); 278 279 // Add to Cache 280 if ($status == true): 281 if ($this->config['cache_objects'] == true): 282 $this->cache->set(get_class($this->entity), 'id'.$this->entity->id->value, $this->entity); 283 endif; 284 endif; 285 286 return $status; 223 return $this->entity->partialUpdate($named_properties, $where); 287 224 288 225 } … … 295 232 function delete($id, $col = '') { 296 233 297 if (empty($col)): 298 $col = 'id'; 299 endif; 300 301 // Persist object 302 $status = $this->db->delete($id, $col, get_class($this->entity)); 303 304 // Add to Cache 305 if ($status == true): 306 if ($this->config['cache_objects'] == true): 307 $this->cache->remove(get_class($this->entity), 'id'.$this->entity->id->value); 308 endif; 309 endif; 310 311 return $status; 312 234 return $this->entity->delete($id, $col); 313 235 } 314 236 315 237 function getByPk($col, $value) { 316 238 317 return $this-> getByColumn($col, $value);239 return $this->entity->getByColumn($col, $value); 318 240 319 241 } … … 321 243 function getByColumn($col, $value) { 322 244 323 $cache_obj = ''; 324 325 if ($this->config['cache_objects'] == true): 326 $cache_obj = $this->cache->get(get_class($this->entity), $col.$value); 327 endif; 328 329 if (!empty($cache_obj)): 330 331 $this->entity = $cache_obj; 332 333 else: 334 335 $constraint = array($col => $value); 336 337 $properties = $this->db->select($this->_getProperties(), $constraint, get_class($this->entity)); 338 339 if (!empty($properties)): 340 341 $this->setProperties($properties); 342 343 if ($this->config['cache_objects'] == true): 344 $this->cache->set(get_class($this->entity), 'id'.$this->entity->id->value, $this->entity); 345 endif; 346 endif; 347 endif; 348 349 return; 245 return $this->entity->getByColumn($col, $value); 246 350 247 } 351 248 … … 402 299 } 403 300 404 301 /** 302 * Sets Values/Properties 303 * @depricated use setProperties() 304 */ 405 305 function setValues($values) { 406 306 407 $properties = array_keys(get_object_vars($this->entity)); 408 409 foreach ($properties as $k => $v) { 410 411 $this->entity->$v->value = $values[$v]; 412 413 } 414 415 return; 307 return $this->setProperties($values); 416 308 417 309 } -
trunk/modules/base/module.php
r498 r500 43 43 $this->description = 'Base functionality for OWA.'; 44 44 $this->config_required = false; 45 $this->required_schema_version = 1;45 $this->required_schema_version = 3; 46 46 47 47 48 48 $this->owa_module(); 49 $this->c->set('base', 'schema_version', '1');49 //$this->c->set('base', 'schema_version', '1'); 50 50 return; 51 51 } -
trunk/modules/base/updatesApply.php
r499 r500 51 51 52 52 $modules = $api->getModulesNeedingUpdates(); 53 //print_r($modules); 54 //return; 53 55 54 56 // foreach do update in order 57 58 $error = false; 55 59 56 60 foreach ($modules as $k => $v) { … … 59 63 60 64 if ($ret != true): 65 $error = true; 61 66 break; 62 67 endif; 63 68 64 69 } 70 71 if ($error == true): 72 $data['error_msg'] = 'something went wrong here with the updates.'; 73 $data['view'] = 'base.error'; 74 $data['view_method'] = 'delegate'; 75 else: 65 76 66 // add data to container 67 $this->data['status_code'] = ''; 68 $this->data['do'] = 'base.optionsGeneral'; 69 $this->data['view_method'] = 'delegate'; 77 // add data to container 78 $data['status_code'] = 3307; 79 $data['do'] = 'base.optionsGeneral'; 80 $data['view_method'] = 'redirect'; 81 82 endif; 70 83 71 return $this->data; 84 return $data; 85 72 86 73 87 } -
trunk/modules/hello/module.php
r498 r500 43 43 $this->description = 'Hello world sample module.'; 44 44 $this->config_required = false; 45 $this->required_schema_version = 2;45 $this->required_schema_version = 1; 46 46 47 47 $this->owa_module(); 48 //$this->c->set('hello', 'schema_version', '1'); 48 49 49 50 return; -
trunk/owa_caller.php
r499 r500 287 287 function logEvent($event_type, $caller_params = '') { 288 288 289 $this->e->debug(print_r($this->e->backtrace(), true)); 289 if ($this->c->get('base', 'error_log_level') > 9): 290 $this->e->debug(print_r($this->e->backtrace(), true)); 291 endif; 292 290 293 //change config value to incomming site_id 291 294 if(!empty($caller_params['site_id'])): … … 403 406 * 404 407 * @param array $caller_data 408 * @depricated 405 409 * @return string 406 410 */ … … 426 430 /** 427 431 * Displays a View without user authentication. Takes array of data as input 428 * 432 * @depricated 429 433 * @param array $data 430 434 */ … … 437 441 } 438 442 439 /**440 * Invokes controller to perform controller441 *442 * @param $action string443 *444 */445 function performAction($action) {446 447 // Load448 $controller = $this->api->moduleFactory($action, 'Controller', $this->params);449 450 //perfrom authentication451 //$auth = &owa_auth::get_instance();452 453 //$data = $auth->authenticateUser($controller->priviledge_level);454 455 // if auth was success then procead to do action specified in the intended controller.456 //if ($data['auth_status'] == true):457 $data = $controller->doAction();458 //endif;459 460 // Display view if controller calls for one.461 if (!empty($data['view']) || !empty($data['action'])):462 463 //464 if ($data['view_method'] == 'delegate'):465 return $this->api->displayView($data);466 467 // Redirect to a view468 elseif ($data['view_method'] == 'redirect'):469 owa_lib::redirectToView($data);470 return;471 472 // return an image . Will output headers and binary data.473 elseif ($data['view_method'] == 'image'):474 return $this->api->displayImage($data);475 476 else:477 return $this->api->displayView($data);478 479 endif;480 481 elseif(!empty($data['do'])):482 483 if ($data['view_method'] == 'redirect'):484 owa_lib::redirectToView($data);485 return;486 endif;487 endif;488 489 return;490 491 }492 493 443 494 444 /** … … 502 452 503 453 // Override request parsms with those passed by caller 504 // TODO: make this an array merge505 454 if (!empty($caller_params)): 506 507 foreach ($caller_params as $n => $v) { 508 $this->params[$n] = $v; 509 } 510 455 $this->params = array_merge($this->params, $caller_params); 511 456 endif; 512 457 … … 516 461 517 462 if (!empty($this->params['action'])): 518 $result = $this->performAction($this->params['action']);463 $result = owa_coreAPI::performAction($this->params['action'], $this->params); 519 464 unset($this->params['action']); 520 465 521 466 elseif (!empty($this->params['do'])): 522 $result = $this->performAction($this->params['do']);467 $result = owa_coreAPI::performAction($this->params['do'], $this->params); 523 468 //unset($this->params['action']); 524 469 525 470 elseif ($this->params['view']): 526 471 // its a view request so the only data is in whats in the params 527 $result = $this->renderView($this->params);472 $result = owa_coreAPI::displayView($this->params); 528 473 unset($this->params['view']); 529 474 -
trunk/owa_coreAPI.php
r498 r500 374 374 } 375 375 376 function updateFactory($module, $ class) {376 function updateFactory($module, $filename) { 377 377 378 378 require_once(OWA_BASE_CLASS_DIR.'update.php'); 379 379 380 $obj = owa_coreAPI::moduleGenericFactory($module, 'updates', $class, '_update'); 380 //$obj = owa_coreAPI::moduleGenericFactory($module, 'updates', $filename, '_update'); 381 $class = 'owa_'.$module.'_'.$filename.'_update'; 382 383 // Require class file if class does not already exist 384 if(!class_exists($class)): 385 owa_coreAPI::moduleRequireOnce($module, 'updates', $filename); 386 endif; 387 388 $obj = owa_lib::factory(OWA_DIR.'modules'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'updates', '', $class, $params); 389 381 390 $obj->module_name = $module; 382 391 return $obj; … … 648 657 } 649 658 659 /** 660 * Invokes controller to perform controller 661 * 662 * @param $action string 663 * 664 */ 665 function performAction($action, $params = array()) { 666 667 // Load 668 $controller = owa_coreAPI::moduleFactory($action, 'Controller', $params); 669 670 $data = $controller->doAction(); 671 672 // Display view if controller calls for one. 673 if (!empty($data['view']) || !empty($data['action'])): 674 675 // 676 if ($data['view_method'] == 'delegate'): 677 return owa_coreAPI::displayView($data); 678 679 // Redirect to a view 680 elseif ($data['view_method'] == 'redirect'): 681 owa_lib::redirectToView($data); 682 return; 683 684 // return an image . Will output headers and binary data. 685 elseif ($data['view_method'] == 'image'): 686 return owa_coreAPI::displayImage($data); 687 688 else: 689 return owa_coreAPI::displayView($data); 690 691 endif; 692 693 elseif(!empty($data['do'])): 694 //print_r($data); 695 owa_lib::redirectToView($data); 696 return; 697 698 endif; 699 700 701 702 } 703 704 /** 705 * Logs an event to the event queue 706 * 707 * This function sets the action to be perfromed, santizes, 708 * and adds all of PHP's $_SERVER vars to the $caller_params. 709 * $_REQUEST vars are already added to $this->params in the constructor. 710 * 711 * @param array $caller_params 712 * @param string $event_type 713 * @return boolean 714 */ 715 function logEvent($event_type, $caller_params = '') { 716 717 $c = owa_coreAPI::configSingleton(); 718 $e = owa_coreAPI::errorSingleton(); 719 $request_params = owa_coreAPI::requestContainer(); 720 721 if ($c->get('base', 'error_log_level') > 9): 722 $e->debug(print_r($e->backtrace(), true)); 723 endif; 724 725 // do not log if the do not log param is set by caller. 726 if ($request_params['do_not_log'] == true): 727 $e->debug("ABORTING LOG ACTION: do not log flag appears to be set"); 728 return false; 729 endif; 730 731 //change config value to incomming site_id 732 if(!empty($caller_params['site_id'])): 733 $c->set('base', 'site_id', $caller_params['site_id']); 734 else: 735 $caller_params['site_id'] = $c->get('base', 'site_id'); 736 endif; 737 738 // do not log if the request is from a reserved IP 739 // ips = $this->c->get('base', 'log_not_log_ips'); 740 // ... 741 742 $params = array(); 743 // Add PHP's $_SERVER scope variables to event properties 744 $params['server'] = $_SERVER; 745 746 // Apply caller's params to event properties 747 if (!empty($caller_params)): 748 $params['caller'] = $caller_params; 749 endif; 750 751 // set controller to invoke 752 $params['action'] = $event_type; 753 754 // Filter input 755 $params = owa_lib::inputFilter($params); 756 757 //Load browscap 758 $bcap = owa_coreAPI::supportClassFactory('base', 'browscap', $params['server']['HTTP_USER_AGENT']); 759 760 // Abort if the request is from a robot 761 if ($c->get('base', 'log_robots') != true): 762 if ($bcap->robotCheck() == true): 763 $e->debug("ABORTING LOG ACTION: request appears to be from a robot"); 764 return; 765 endif; 766 endif; 767 768 // Fetch browser capabilities and and apply to event params 769 $params['browscap'] = get_object_vars($bcap->browser); 770 771 return owa_coreAPI::handleRequest($params); 772 773 } 774 650 775 } 651 776 -
trunk/owa_entity.php
r498 r500 127 127 128 128 } 129 130 /** 131 * Persist new object 132 * 133 */ 134 function create() { 135 136 $db = owa_coreAPI::dbSingleton(); 137 $config = owa_coreAPI::configSingleton(); 138 $cache = owa_coreAPI::cacheSingleton(); 139 140 $all_cols = $this->getColumns(); 141 142 $cols = array(); 143 144 // Control loop 145 foreach ($all_cols as $k => $v){ 146 147 // drop column is it is marked as auto-incement as DB will take care of that. 148 if ($this->$v->auto_increment == true): 149 ; 150 else: 151 $cols
