Changeset 3167 for branches/2.2/workflow/inc/class.run_activity.inc.php
- Timestamp:
- 08/17/10 16:17:12 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/workflow/inc/class.run_activity.inc.php
r795 r3167 10 10 \**************************************************************************/ 11 11 12 require_once(dirname(__FILE__) . SEP . 'common.inc.php'); /* including common deifinitions */ 12 13 require_once(dirname(__FILE__) . SEP . 'class.WorkflowUtils.inc.php' ); /* superclass source code */ 13 14 require_once(dirname(__FILE__) . SEP . 'class.basecontroller.inc.php' ); /* module controller */ 14 15 require_once(dirname(__FILE__) . SEP . 'class.basemodel.inc.php' ); /* module logic */ 15 require_once(dirname(__FILE__) . SEP . 'class.process_factory.inc.php'); /* module process factory class */16 require_once(dirname(__FILE__) . SEP . 'class.utils.security.php' ); /* sanitizes input data */17 16 18 17 /** … … 169 168 var $agents = Array(); 170 169 171 /* CELEPAR */172 170 /** 173 171 * @var object $smarty holds a Smarty instance … … 195 193 */ 196 194 var $isChildInstance = false; 197 195 /** 196 * @var object Stores a 'workflow_smarty' object 197 * @access private 198 */ 198 199 private $workflowSmarty = null; 199 /* CELEPAR */ 200 /** 201 * @var object Log Object 202 * @access private 203 */ 204 private $logger = null; 205 200 206 /** 201 207 * Constructor … … 206 212 { 207 213 parent::WorkflowUtils(); 208 $this->runtime = CreateObject('workflow.workflow_wfruntime'); 214 215 /** 216 * We should always use newInstance to instantiate 217 * 'workflow_wfruntime' 218 */ 219 $this->runtime = &Factory::newInstance('workflow_wfruntime'); 209 220 $this->runtime->setDebug(_DEBUG); 210 //$this->base_activity = CreateObject('workflow.workflow_baseactivity'); 211 //$this->process = CreateObject('workflow.workflow_process'); 212 $this->GUI = CreateObject('workflow.workflow_gui'); 213 $this->categories = CreateObject('phpgwapi.categories'); 214 215 $this->workflowSmarty = CreateObject('workflow.workflow_smarty', false); 221 $this->GUI = &Factory::getInstance('workflow_gui'); 222 $this->categories = &Factory::getInstance('categories'); 223 224 $this->workflowSmarty = &Factory::getInstance('workflow_smarty', false); 225 226 // never configure a log of type "firebug" here. This will make goAjax stop running well =( 227 $this->logger = &Factory::getInstance('Logger', array('file')); 228 216 229 // TODO: open a new connection to the database under a different username to allow privilege handling on tables 217 /* CELEPAR */218 230 unset($this->db); 219 231 } … … 232 244 function go($activity_id=0, $iid=0, $auto=0) 233 245 { 246 $totalTime = microtime(true); 247 234 248 $result=Array(); 235 249 … … 301 315 $this->process_version = $this->process->getVersion(); 302 316 $this->activity_name = $activity->getName(); 303 $this->user_name = $GLOBALS['phpgw']->accounts->id2name($GLOBALS['user']);317 $this->user_name = $GLOBALS['phpgw']->accounts->id2name($GLOBALS['user']); 304 318 $this->view_activity = $this->GUI->gui_get_process_view_activity($this->process_id); 305 319 … … 315 329 $GLOBALS['workflow']['wf_user_id'] =& $GLOBALS['user']; 316 330 $GLOBALS['workflow']['wf_view_activity'] =& $this->view_activity; 331 $GLOBALS['workflow']['wf_webserver_url'] = $GLOBALS['phpgw_info']['server']['webserver_url']; 317 332 $GLOBALS['workflow']['wf_workflow_path'] = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'; 318 333 $GLOBALS['workflow']['wf_resources_path'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . SEP . 'workflow/redirect.php?pid=' . $this->process_id . '&file='; 319 $GLOBALS['workflow']['wf_default_resources_path'] = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('processes');320 $GLOBALS['workflow']['wf_workflow_resources_path'] = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('');334 $GLOBALS['workflow']['wf_default_resources_path'] = Factory::getInstance('TemplateServer')->generateLink('processes'); 335 $GLOBALS['workflow']['wf_workflow_resources_path'] = Factory::getInstance('TemplateServer')->generateLink(''); 321 336 $GLOBALS['workflow']['wf_activity_url'] = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'index.php?menuaction=workflow.'.get_class($this).'.go&activity_id='.$activity_id; 322 $GLOBALS['workflow']['wf_user_cnname'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($GLOBALS['user']);337 $GLOBALS['workflow']['wf_user_cnname'] = Factory::getInstance('WorkflowLDAP')->getName($GLOBALS['user']); 323 338 $GLOBALS['workflow']['wf_back_link'] = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'index.php?start_tab=1'; 324 339 $GLOBALS['workflow']['wf_js_path'] = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'js'.SEP.'jscode'; … … 330 345 $wf =& $GLOBALS['workflow']; 331 346 332 /* CELEPAR */333 347 /* path to the local functions developed by Celepar */ 334 348 $functions = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'functions' . SEP . 'local.functions.php'; … … 336 350 /* activate local functions */ 337 351 require_once($functions); 338 /* CELEPAR */339 352 340 353 //get configuration options with default values if no init was done before … … 375 388 376 389 /* check some permissions */ 377 if (($newUser == '*') || (!$this->runtime->checkUserRun($newUser)) || ( $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($newUser) === false))390 if (($newUser == '*') || (!$this->runtime->checkUserRun($newUser)) || (Factory::getInstance('WorkflowLDAP')->getName($newUser) === false)) 378 391 { 379 392 $_SESSION['phpgw_info']['workflow']['user_groups'] = $actualUserGroups; … … 385 398 return false; 386 399 } 387 $smarty = CreateObject('workflow.process_smarty');400 $smarty = Factory::getInstance('process_smarty'); 388 401 } 389 402 … … 396 409 $this->download_mode = get_var('download_mode', array('POST','GET'), false); 397 410 398 /* #celepar# smarty code*/ 399 400 $smarty = CreateObject('workflow.process_smarty'); 411 $smarty = Factory::getInstance('process_smarty'); 401 412 402 413 $smarty->template_dir = GALAXIA_PROCESSES.SEP.$this->process->getNormalizedName().SEP.'code'.SEP.'templates'; … … 418 429 $smarty->assign('wf_back_link',$GLOBALS['workflow']['wf_back_link']); 419 430 $smarty->assign('wf_activity_url',$GLOBALS['workflow']['wf_activity_url']); 420 431 421 432 /* register the prefilter smarty plugin wf_default_template */ 422 433 $smarty->load_filter('pre', 'wf_default_template'); … … 430 441 431 442 /* BEGIN WORKFLOW MVC SETTINGS */ 432 $env = array( );//create settings vector443 $env = array(); //create settings vector 433 444 $env['view'] =& $smarty; //view layer instance 434 445 $env['template_file'] =& $_template_name; //template file to be shown 435 $env['dao'] =& wf_create_object('wf_db');//data access object instance446 $env['dao'] =& Factory::newInstance('wf_db'); //data access object instance 436 447 $env['workflow'] =& $GLOBALS['workflow']; //workflow environment information 437 448 $env['instance'] =& $instance; //process manager instance 438 449 $env['activity'] =& $activity; //activity manager instance 439 $security =& new SecurityUtils(); //input sanitizer class450 $security =& Factory::newInstance('SecurityUtils'); //input sanitizer class 440 451 $env['request'] =& $security->process($_REQUEST); //sanitizes input data from client 441 $env['factory'] =& new ProcessFactory();//instantiation controller class442 $env['natural'] =& wf_create_object('wf_natural'); //data access object instance for mainframe452 $env['factory'] =& Factory::getInstance('ProcessWrapperFactory'); //instantiation controller class 453 $env['natural'] =& Factory::newInstance('wf_natural'); //data access object instance for mainframe 443 454 /* END WORKFLOW MVC SETTINGS */ 444 455 445 456 $GLOBALS['workflow_env'] = &$env; 446 //echo "<br><br><br><br><br>Including $source <br>In request: <pre>";print_r($_REQUEST);echo "</pre>"; 447 //[__leave_activity] is setted if needed in the xxx_pre code or by the user in his code 448 // HERE the user code is 'executed'. Note that we do not use include_once or require_once because 449 //it could the same code several times with automatic activities looping in the graph and it still 450 //need to be executed 457 458 /** 459 * [__leave_activity] is setted if needed in the xxx_pre code or by the user in his code 460 * HERE the user code is 'executed'. Note that we do not use include_once or require_once because 461 * it could the same code several times with automatic activities looping in the graph and it still 462 * need to be executed 463 */ 451 464 $_engineProcessCodeDirectory = GALAXIA_PROCESSES . SEP . $this->process->getNormalizedName(). SEP . 'code'; 452 465 $_engineCompilerDirectory = GALAXIA_LIBRARY . SEP . 'compiler'; … … 471 484 472 485 /* activate the security policy */ 473 $GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->enableSecurityPolicy(); 486 Factory::getInstance('WorkflowSecurity')->enableSecurityPolicy(); 487 488 /** 489 * Here we are going to use our new Security static class. 490 * From now, the factory frontend (static) will forward 491 * the messages for the process factory instead of Workflow 492 * factory. 493 */ 494 Security::enable(); 474 495 475 496 /* include the files */ 497 $processTime = microtime(true); 498 476 499 foreach ($_engineFiles as $_engineFile) 477 require $_engineFile; 500 require_once $_engineFile; 501 502 $processTime = (microtime(true) - $processTime); 478 503 479 504 unset($GLOBALS['workflow_env']); … … 517 542 } 518 543 544 $totalTime = (microtime(true) - $totalTime); 545 546 $logTime = sprintf("GO [pid=%s,iid=%s,uid=%s,aid=%s] [eng=%ss,proc=%ss]", 547 $this->process_id, 548 $this->instance_id, 549 $GLOBALS['user'], 550 $this->activity_id, 551 number_format(($totalTime - $processTime),3), 552 number_format($processTime,3) ); 553 554 $this->logger->debug($logTime); 555 519 556 // TODO: process instance comments 520 521 557 $instructions = $this->runtime->handle_postUserCode(_DEBUG); 522 558 switch($instructions['action']) … … 582 618 function goAjax($activity_id=0, $iid=0, $auto=0) 583 619 { 620 $totalTime = microtime(true); 621 584 622 $result=Array(); 585 623 … … 660 698 $GLOBALS['workflow']['wf_workflow_path'] = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'; 661 699 $GLOBALS['workflow']['wf_resources_path'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . SEP . 'workflow/redirect.php?pid=' . $this->process_id . '&file='; 662 $GLOBALS['workflow']['wf_default_resources_path'] = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('processes');663 $GLOBALS['workflow']['wf_workflow_resources_path'] = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('');700 $GLOBALS['workflow']['wf_default_resources_path'] = Factory::getInstance('TemplateServer')->generateLink('processes'); 701 $GLOBALS['workflow']['wf_workflow_resources_path'] = Factory::getInstance('TemplateServer')->generateLink(''); 664 702 $GLOBALS['workflow']['wf_activity_url'] = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'index.php?menuaction=workflow.'.get_class($this).'.go&activity_id='.$activity_id; 665 $GLOBALS['workflow']['wf_user_cnname'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($GLOBALS['user']);703 $GLOBALS['workflow']['wf_user_cnname'] = Factory::getInstance('WorkflowLDAP')->getName($GLOBALS['user']); 666 704 $GLOBALS['workflow']['wf_back_link'] = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'index.php?start_tab=1'; 667 705 $GLOBALS['workflow']['wf_js_path'] = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'js'.SEP.'jscode'; … … 672 710 unset($GLOBALS['workflow']['wf_instance_url']); 673 711 674 /* CELEPAR */675 712 /* activate local functions */ 676 713 require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'functions' . SEP . 'local.functions.php'); 677 /* CELEPAR */678 714 679 715 //get configuration options with default values if no init was done before … … 693 729 694 730 /* BEGIN WORKFLOW MVC SETTINGS */ 695 $env = array( );//create settings vector696 $env['dao'] =& wf_create_object('wf_db');//data access object instance731 $env = array(); //create settings vector 732 $env['dao'] =& Factory::newInstance('wf_db'); //data access object instance 697 733 $env['workflow'] =& $GLOBALS['workflow']; //workflow environment information 698 734 $env['instance'] =& $instance; //process manager instance 699 735 $env['activity'] =& $activity; //activity manager instance 700 $security =& new SecurityUtils();//input sanitizer class736 $security =& Factory::newInstance('SecurityUtils'); //input sanitizer class 701 737 $env['request'] =& $security->process($_REQUEST); //sanitizes input data from client 702 $env['factory'] =& new ProcessFactory();//instantiation controller class703 $env['natural'] =& wf_create_object('wf_natural'); //data access object instance for mainframe738 $env['factory'] =& Factory::newInstance('ProcessWrapperFactory'); //instantiation controller class 739 $env['natural'] =& Factory::newInstance('wf_natural'); //data access object instance for mainframe 704 740 /* END WORKFLOW MVC SETTINGS */ 705 741 … … 711 747 712 748 /* activate the security policy */ 713 $GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->enableSecurityPolicy(); 749 Factory::getInstance('WorkflowSecurity')->enableSecurityPolicy(); 750 751 /** 752 * here we are going to use our new Security static class. 753 * From now, the factory frontend (static) will forward 754 * the messages for the process factory instead of Workflow 755 * factory. Note that this is the same comment as the previous 756 * function... boooring.. 757 */ 758 Security::enable(); 714 759 715 760 $GLOBALS['workflow_env'] = &$env; 716 $nc = new NanoController();761 $nc = &Factory::newInstance('NanoController'); 717 762 $nc->setClassPath(GALAXIA_PROCESSES . SEP . $this->process->getNormalizedName(). SEP . 'code'); 763 764 $processTime = microtime(true); 718 765 $nc->iterateOverVirtualRequests(); 766 $processTime = microtime(true) - $processTime; 767 719 768 $nc->outputResultData(); 720 769 unset($GLOBALS['workflow_env']); … … 722 771 if (!is_null($iid)) 723 772 $instance->instance->sync(); 773 774 $totalTime = microtime(true) - $totalTime; 775 776 $logTime = sprintf("GOAJAX [pid=%s,iid=%s,uid=%s,aid=%s] [eng=%ss,proc=%ss]", 777 $this->process_id, 778 $this->instance_id, 779 $GLOBALS['user'], 780 $this->activity_id, 781 number_format(($totalTime - $processTime),3), 782 number_format($processTime,3) ); 783 784 $this->logger->debug($logTime); 724 785 } 725 786 … … 850 911 { 851 912 $headerConfig = 0; 852 if (!$this->download_mode )913 if (!$this->download_mode and !$this->print_mode) 853 914 { 854 915 $headerConfig |= workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_FOOTER;
Note: See TracChangeset
for help on using the changeset viewer.