Changeset 3167 for branches/2.2/workflow/inc/local
- Timestamp:
- 08/17/10 16:17:12 (14 years ago)
- Location:
- branches/2.2/workflow/inc/local
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/workflow/inc/local/classes/class.JobBase.php
r1437 r3167 89 89 { 90 90 require_once 'common.inc.php'; 91 $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment();91 Factory::getInstance('WorkflowMacro')->prepareEnvironment(); 92 92 $this->jobID = $jobID; 93 93 $this->processID = $processID; 94 94 $this->currentDate = $currentDate; 95 $this->jobManager = &$GLOBALS['workflow']['factory']->getInstance('WorkflowJobManager');95 $this->jobManager = Factory::getInstance('WorkflowJobManager'); 96 96 $this->testMode = $testMode; 97 97 $this->maximumExecutionTime = $maximumExecutionTime; … … 148 148 final private function prepareEnvironment() 149 149 { 150 $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareProcessEnvironment($this->processID); 151 152 require_once PHPGW_SERVER_ROOT . '/workflow/inc/class.process_factory.inc.php'; 150 Factory::getInstance('WorkflowMacro')->prepareProcessEnvironment($this->processID); 153 151 154 152 $this->environment = array(); 155 $this->environment['factory'] = & new ProcessFactory();153 $this->environment['factory'] = &Factory::newInstance('ProcessWrapperFactory'); 156 154 } 157 155 … … 202 200 final public function createNewInstance($startActivityId, $instanceName=false, $properties=false, $user=false) 203 201 { 204 $activityManager = CreateObject('workflow.workflow_activitymanager');202 $activityManager = Factory::getInstance('workflow_activitymanager'); 205 203 $activity = $activityManager->get_activity($startActivityId); 206 204 -
branches/2.2/workflow/inc/local/classes/class.wf_engine.php
r795 r3167 68 68 $flagObject[0] = is_null($this->processManager); 69 69 if ($flagObject[0]) 70 $this->processManager = CreateObject('workflow.workflow_processmanager');70 $this->processManager = Factory::getInstance('workflow_processmanager'); 71 71 72 72 $output = array(); … … 86 86 * @return bool true caso a instância tenha sido continuada e false caso contrário. 87 87 * @access public 88 * @deprecated 1.7.00.00088 * @deprecated 2.2.00.000 89 89 */ 90 90 function continueInstance($activityID, $instanceID) 91 91 { 92 require_once 'class.wf_instance.php';93 $WFInstance = new wf_instance();92 wf_warn_deprecated_method('wf_instance', 'continueInstance'); 93 $WFInstance = &Factory::getInstance('wf_instance'); 94 94 return $WFInstance->continueInstance($activityID, $instanceID); 95 95 } … … 100 100 * @return boolean true se foi possível abortar a instância e false caso contrário. 101 101 * @access public 102 * @deprecated 1.7.00.000102 * @deprecated 2.2.00.000 103 103 */ 104 104 function abortInstance($instanceID) 105 105 { 106 require_once 'class.wf_instance.php';107 $WFInstance = new wf_instance();106 wf_warn_deprecated_method('wf_instance', 'abort'); 107 $WFInstance = &Factory::getInstance('wf_instance'); 108 108 return $WFInstance->abort($instanceID); 109 109 } … … 115 115 * @return boolean true se foi possível mudar o nome da instância e false caso contrário. 116 116 * @access public 117 * @deprecated 1.7.00.000117 * @deprecated 2.2.00.000 118 118 */ 119 119 function setInstanceName($instanceID, $name) 120 120 { 121 require_once 'class.wf_instance.php';122 $WFInstance = new wf_instance();121 wf_warn_deprecated_method('wf_instance', 'setName'); 122 $WFInstance = &Factory::getInstance('wf_instance'); 123 123 return $WFInstance->setName($instanceID, $name); 124 124 } … … 130 130 * @return boolean true se foi possível mudar a prioridade da instância e false caso contrário. 131 131 * @access public 132 * @deprecated 1.7.00.000132 * @deprecated 2.2.00.000 133 133 */ 134 134 function setInstancePriority($instanceID, $priority) 135 135 { 136 require_once 'class.wf_instance.php';137 $WFInstance = new wf_instance();136 wf_warn_deprecated_method('wf_instance', 'setPriority'); 137 $WFInstance = &Factory::getInstance('wf_instance'); 138 138 return $WFInstance->setPriority($instanceID, $priority); 139 139 } … … 145 145 * @return array As instâncias que satisfazem o critério de seleção. 146 146 * @access public 147 * @deprecated 1.7.00.000147 * @deprecated 2.2.00.000 148 148 */ 149 149 function getIdleInstances($numberOfDays, $activities = null) 150 150 { 151 require_once 'class.wf_instance.php';152 $WFInstance = new wf_instance();151 wf_warn_deprecated_method('wf_instance', 'getIdle'); 152 $WFInstance = &Factory::getInstance('wf_instance'); 153 153 return $WFInstance->getIdle($numberOfDays, $activities); 154 154 } … … 159 159 * @return array As instâncias que satisfazem o critério de seleção. 160 160 * @access public 161 * @deprecated 1.7.00.000161 * @deprecated 2.2.00.000 162 162 */ 163 163 function getInstances($activities = null) 164 164 { 165 wf_warn_deprecated_method('wf_instance', 'getIdle'); 165 166 return $this->getIdleInstances(0, $activities); 166 167 } … … 171 172 * @return array As instâncias que satisfazem o critério de seleção. 172 173 * @access public 173 * @deprecated 1.7.00.000174 * @deprecated 2.2.00.000 174 175 */ 175 176 function getInstancesByName($name) 176 177 { 177 require_once 'class.wf_instance.php';178 $WFInstance = new wf_instance();178 wf_warn_deprecated_method('wf_instance', 'getByName'); 179 $WFInstance = &Factory::getInstance('wf_instance'); 179 180 $preOutput = $WFInstance->getByName($name); 180 181 $output = array(); … … 193 194 * @return array As instâncias filhas do par instância/atividade atual 194 195 * @access public 195 * @deprecated 1.7.00.000196 * @deprecated 2.2.00.000 196 197 */ 197 198 function getChildInstances($instanceID = null, $activityID = null) 198 199 { 199 require_once 'class.wf_instance.php';200 $WFInstance = new wf_instance();201 $preOutput = $WFInstance->getChildren($instanceID , $activityID);200 wf_warn_deprecated_method('wf_instance', 'getChildren'); 201 $WFInstance = &Factory::getInstance('wf_instance'); 202 $preOutput = $WFInstance->getChildren($instanceID); 202 203 $output = array(); 203 204 foreach ($preOutput as $childInstance) … … 213 214 * @return mixed Uma array contento as propriedades da instância (no formato "nome_da_propriedade" => "valor"). Ou false em caso de erro. 214 215 * @access public 215 * @deprecated 1.7.00.000216 * @deprecated 2.2.00.000 216 217 */ 217 218 function getInstanceProperties($instanceID) 218 219 { 219 require_once 'class.wf_instance.php';220 $WFInstance = new wf_instance();220 wf_warn_deprecated_method('wf_instance', 'getProperties'); 221 $WFInstance = &Factory::getInstance('wf_instance'); 221 222 return $WFInstance->getProperties($instanceID); 222 223 } … … 227 228 * @return array Propriedades da instância filha. Array no formato "nome_da_propriedade" => "valor". 228 229 * @access public 229 * @deprecated 1.7.00.000230 * @deprecated 2.2.00.000 230 231 */ 231 232 function getChildInstanceProperties($instanceID) 232 233 { 233 require_once 'class.wf_instance.php';234 $WFInstance = new wf_instance();234 wf_warn_deprecated_method('wf_instance', 'getProperties'); 235 $WFInstance = &Factory::getInstance('wf_instance'); 235 236 return $WFInstance->getProperties($instanceID); 236 237 } … … 247 248 $flagObject[0] = is_null($this->acl); 248 249 if ($flagObject[0]) 249 $this->acl = CreateObject('workflow.workflow_acl');250 $this->acl = Factory::getInstance('workflow_acl'); 250 251 251 252 $output = $this->acl->getUserPermissions($type, $uid); … … 268 269 $flagObject[0] = is_null($this->acl); 269 270 if ($flagObject[0]) 270 $this->acl = CreateObject('workflow.workflow_acl');271 $this->acl = Factory::getInstance('workflow_acl'); 271 272 272 273 $output = $this->acl->getUserGroupPermissions($type, $uid); … … 291 292 /* build the SQL query */ 292 293 $query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_activity_id = ?) AND (wf_p_id = ?)"; 293 $db = & $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;294 $db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 294 295 $resultSet = $db->query($query, array($activityID, $processID)); 295 296 … … 319 320 /* build the SQL query */ 320 321 $query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_name = ?) AND (wf_p_id = ?)"; 321 $db = & $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;322 $db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 322 323 $resultSet = $db->query($query, array($activityName, $processID)); 323 324 … … 342 343 * @return array As instâncias que satisfazem o critério de seleção. 343 344 * @access public 344 * @deprecated 1.7.00.000345 * @deprecated 2.2.00.000 345 346 */ 346 347 function getUserInstances($users, $activities = null, $status = null) 347 348 { 348 require_once 'class.wf_instance.php';349 $WFInstance = new wf_instance();349 wf_warn_deprecated_method('wf_instance', 'getByUser'); 350 $WFInstance = &Factory::getInstance('wf_instance'); 350 351 return $WFInstance->getByUser($users, $activities, $status); 351 352 } … … 356 357 * @return bool true caso a propriedade tenha sido alterada com sucesso 357 358 * @access public 358 * @deprecated 1.7.00.000359 * @deprecated 2.2.00.000 359 360 */ 360 361 function setInstanceProperty($instanceID, $nameProperty, $value) 361 362 { 362 require_once 'class.wf_instance.php';363 $WFInstance = new wf_instance();363 wf_warn_deprecated_method('wf_instance', 'setProperty'); 364 $WFInstance = &Factory::getInstance('wf_instance'); 364 365 return $WFInstance->setProperty($instanceID, $nameProperty, $value); 365 366 } … … 373 374 * @return bool true se o usuário tiver acesso à instância (levando em consideração $writeAccess) ou false caso contrário 374 375 * @access public 375 * @deprecated 1.7.00.000376 * @deprecated 2.2.00.000 376 377 */ 377 378 function checkUserAccessToInstance($userID, $instanceID, $activityID, $writeAccess = true) 378 379 { 379 require_once 'class.wf_instance.php';380 $WFInstance = new wf_instance();380 wf_warn_deprecated_method('wf_instance', 'checkUserAccess'); 381 $WFInstance = &Factory::getInstance('wf_instance'); 381 382 return $WFInstance->checkUserAccess($userID, $instanceID, $activityID, $writeAccess); 382 383 } -
branches/2.2/workflow/inc/local/classes/class.wf_instance.php
r1385 r3167 77 77 { 78 78 $instanceID = (int) $instanceID; 79 $instance = CreateObject('workflow.workflow_instance');79 $instance = Factory::getInstance('workflow_instance'); 80 80 if (!$instance->getInstance($instanceID)) 81 81 return false; … … 92 92 { 93 93 /* load the DB */ 94 $this->db = & $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;94 $this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 95 95 96 96 /* load the process ID from the runtime */ … … 118 118 $instance = $this->getInstanceObject($instanceID); 119 119 120 $runActivity = CreateObject('workflow.run_activity');120 $runActivity = Factory::getInstance('run_activity'); 121 121 122 122 ob_start(); … … 250 250 251 251 /** 252 * Busca as instâncias filhas de uma instância 253 * Se os parâmetros não forem informados, retorna instâncias filhas das instância atual. 254 * @param int $instanceID O ID da instância pai (não obrigatório). 255 * @param int $activityID O ID da atividade corrente da instância pai 256 * @return array As instâncias filhas do par instância/atividade atual 257 * @access public 258 */ 259 public function getChildren($instanceID = null, $activityID = null) 252 * This method gets all children instances of the given instance. 253 * If there is no parameter, it gets the children instances of the current instance 254 * @param int $instanceID Dad instance's identification. 255 * @return array Array with the children instances, or false 256 * @access public 257 */ 258 public function getChildren($instanceID = null) 260 259 { 261 260 $output = array(); 262 261 if (is_null($instanceID)) 263 262 $instanceID = $GLOBALS['workflow']['wf_runtime']->instance_id; 264 if (is_null($activityID)) 265 $activityID = $GLOBALS['workflow']['wf_runtime']->activity_id; 266 267 /* check instanceID */ 268 if (!$this->checkInstanceAccess($instanceID, $activityID)) 263 264 /* check instanceID */ 265 if (!$this->checkInstanceAccess($instanceID)) 269 266 return $output; 270 267 271 268 /* build the SQL query */ 272 $query = 'SELECT i.wf_instance_id AS wf_instance_id, ia.wf_activity_id AS wf_activity_id, ia.wf_started AS wf_started, i.wf_name AS wf_name, i.wf_status AS wf_status, ia.wf_user AS wf_user, ir.wf_parent_lock AS wf_parent_lock '; 273 $query .= 'FROM egw_wf_interinstance_relations ir, egw_wf_instances i LEFT JOIN egw_wf_instance_activities ia ON (ia.wf_instance_id = i.wf_instance_id)'; 274 $query .= 'WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (ir.wf_parent_instance_id = ?) AND (ir.wf_parent_activity_id = ?)'; 275 276 $result = $this->db->query($query, array($instanceID, $activityID)); 269 $query = " 270 SELECT 271 i.wf_instance_id AS wf_instance_id, 272 ia.wf_activity_id AS wf_activity_id, 273 i.wf_started AS wf_started, 274 i.wf_name AS wf_name, 275 i.wf_status AS wf_status, 276 ia.wf_user AS wf_user, 277 ir.wf_parent_lock AS wf_parent_lock 278 FROM 279 egw_wf_interinstance_relations as ir 280 LEFT JOIN 281 egw_wf_instances as i 282 ON 283 i.wf_instance_id = ir.wf_child_instance_id 284 LEFT JOIN 285 egw_wf_instance_activities as ia 286 ON 287 i.wf_instance_id = ia.wf_instance_id 288 WHERE 289 ir.wf_parent_instance_id = ?"; 290 291 $result = $this->db->query($query, array($instanceID)); 277 292 $output = $result->GetArray(-1); 278 293 … … 423 438 424 439 /* load the required instance (for the required user) */ 425 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php'; 426 $GUI = new GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 440 $GUI = &Factory::newInstance('GUI'); 427 441 $userInstance = $GUI->gui_list_user_instances($userID, 0, -1, '', '', "(ga.wf_is_interactive = 'y') AND (gia.wf_activity_id = {$activityID}) AND (gia.wf_instance_id = {$instanceID})", false, $this->processID, true, false, true, false, false, false); 428 442 $userInstance = $userInstance['data']; … … 456 470 if ($userID !== '*') 457 471 { 458 require_once dirname(__FILE__) . '/class.wf_role.php'; 459 require_once dirname(__FILE__) . '/class.wf_engine.php'; 460 461 $wfRole = new wf_role(); 462 $engine = new wf_engine(); 472 $wfRole = Factory::getInstance('wf_role'); 473 $engine = Factory::getInstance('wf_engine'); 463 474 /* get information about the activity */ 464 475 if (($activityInfo = $engine->getActivityInformationByID($activityID)) === false) … … 529 540 530 541 /* try to get the role id */ 531 require_once dirname(__FILE__) . '/class.wf_role.php'; 532 $wfRole = new wf_role(); 542 $wfRole = Factory::getInstance('wf_role'); 533 543 if (($roleID = $wfRole->getRoleIdByName($roleName)) === false) 534 544 return false; -
branches/2.2/workflow/inc/local/classes/class.wf_ldap.php
r1067 r3167 1 1 <?php 2 require_once PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'classes' . SEP . 'class.wf_cached_ldap.php';3 2 4 3 /** … … 41 40 function wf_ldap() 42 41 { 43 $tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');42 $tmpLDAP = Factory::getInstance('WorkflowLDAP'); 44 43 $this->user_context = $tmpLDAP->getUserContext(); 45 44 $this->group_context = $tmpLDAP->getGroupContext(); 46 45 47 $this->ds = & $GLOBALS['workflow']['workflowObjects']->getLDAP();46 $this->ds = &Factory::getInstance('WorkflowObjects')->getLDAP(); 48 47 49 $this->cachedLDAP = new wf_cached_ldap();48 $this->cachedLDAP = &Factory::getInstance('wf_cached_ldap'); 50 49 $this->cachedLDAP->setOperationMode($this->cachedLDAP->OPERATION_MODE_LDAP); 51 50 } -
branches/2.2/workflow/inc/local/classes/class.wf_location.php
r795 r3167 36 36 function initialize() 37 37 { 38 $this->db = & $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID;38 $this->db = &Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID; 39 39 $this->db->setFetchMode(ADODB_FETCH_ASSOC); 40 40 $this->cityInfo = array(); … … 67 67 if (isset($this->cityInfo[$city_id])) 68 68 return $this->cityInfo[$city_id]; 69 70 $sql = 71 "SELECT 72 c.id_city AS id_city, 73 c.city_name AS city_name, 74 c.is_district, 75 s.id_state AS id_state, 76 s.state_name AS state_name, 77 s.state_symbol AS state_symbol 78 FROM 79 phpgw_cc_state s, 80 phpgw_cc_city c 81 WHERE 82 c.id_state = s.id_state AND 83 s.id_country = 'BR' AND 84 c.id_city = ?"; 85 86 $result = $this->db->query($sql, array($city_id)); 87 $output = $result->fetchRow(); 88 89 $this->cityInfo[$city_id] = $output; 90 return $output; 91 } 92 93 /** 94 * Busca as informações do estado pelo id passado 95 * @param int $state_id Numero ID do estado 96 * @return mixed (array ou boolean) 97 * @access public 98 */ 99 function getStateById($state_id) 100 { 101 if (!is_numeric($state_id)) 102 return false; 103 104 $state_id = (int) $state_id; 105 if (isset($this->stateInfo[$state_id])) 106 return $this->stateInfo[$state_id]; 107 108 $sql = 109 "SELECT 110 id_state, 111 state_name, 112 state_symbol 113 FROM 114 phpgw_cc_state 115 WHERE 116 id_country = 'BR' AND 117 id_state = ?"; 118 119 $result = $this->db->query($sql, array($state_id)); 120 $output = $result->fetchRow(); 121 122 $this->stateInfo[$city_id] = $output; 123 return $output; 124 } 125 /** 126 * Busca as cidades de um estado 127 * @param int $state_id Numero ID do estado 128 * @param bool $include_districts True, busca cidades e distritos. False, busca apenas cidades. 129 * @return mixed (array ou boolean) 130 * @access public 131 */ 132 function getCitiesFromState($state_id, $include_districts = true) 133 { 134 if (!is_numeric($state_id) || !is_bool($include_districts)) 135 return false; 136 137 $state_id = (int) $state_id; 138 if (isset($this->citiesFromState[$state_id])) 139 return $this->citiesFromState[$state_id]; 140 141 $where = ""; 142 if(!$include_districts){ 143 $where = " AND c.is_district = 'F' "; 144 } 145 146 $sql = 147 "SELECT 148 c.id_city AS id_city, 149 c.city_name AS city_name, 150 c.is_district 151 FROM 152 phpgw_cc_state s, 153 phpgw_cc_city c 154 WHERE 155 c.id_state = s.id_state AND 156 s.id_country = 'BR' AND 157 c.id_state = ? " . $where . " 158 ORDER BY 159 city_name"; 160 161 $result = $this->db->query($sql, array($state_id)); 162 $output = array(); 163 while ($row = $result->fetchRow()) 164 $output[] = $row; 165 166 $this->citiesFromState[$state_id] = $output; 167 return $output; 168 } 169 /** 170 * Busca as cidades por parte do nome, sem considerar maiúsculas e/ou minúsculas e nem acentuação (retorna 10 resultados) 171 * @param string Parte do nome da cidade 172 * @param int $state_id Numero ID do estado 173 * @param bool $include_districts True, busca cidades e distritos. False, busca apenas cidades. 174 * @return mixed (array ou boolean) 175 * @access public 176 */ 177 function getCitiesByKey($key, $state_id = 0, $include_districts = true) 178 { 179 if (!is_string($key) || !is_numeric($state_id) || !is_bool($include_districts)) 180 return false; 181 182 $where = ""; 183 if($state_id > 0){ 184 $where = " AND c.id_state = " . $state_id; 185 } 186 187 if(!$include_districts){ 188 $where = " AND c.is_district = 'F' "; 189 } 69 190 70 191 $sql = … … 81 202 c.id_state = s.id_state AND 82 203 s.id_country = 'BR' AND 83 c.id_city = ?"; 84 85 $result = $this->db->query($sql, array($city_id)); 86 $output = $result->fetchRow(); 87 88 $this->cityInfo[$city_id] = $output; 89 return $output; 90 } 91 92 /** 93 * Busca as informações do estado pelo id passado 94 * @param int $state_id Numero ID do estado 95 * @return mixed (array ou boolean) 96 * @access public 97 */ 98 function getStateById($state_id) 99 { 100 if (!is_numeric($state_id)) 101 return false; 102 103 $state_id = (int) $state_id; 104 if (isset($this->stateInfo[$state_id])) 105 return $this->stateInfo[$state_id]; 106 107 $sql = 108 "SELECT 109 id_state, 110 state_name, 111 state_symbol 112 FROM 113 phpgw_cc_state 114 WHERE 115 id_country = 'BR' AND 116 id_state = ?"; 117 118 $result = $this->db->query($sql, array($state_id)); 119 $output = $result->fetchRow(); 120 121 $this->stateInfo[$city_id] = $output; 122 return $output; 123 } 124 /** 125 * Busca as cidades de um estado 126 * @param int $state_id Numero ID do estado 127 * @return mixed (array ou boolean) 128 * @access public 129 */ 130 function getCitiesFromState($state_id) 131 { 132 if (!is_numeric($state_id)) 133 return false; 134 135 $state_id = (int) $state_id; 136 if (isset($this->citiesFromState[$state_id])) 137 return $this->citiesFromState[$state_id]; 138 139 $sql = 140 "SELECT 141 c.id_city AS id_city, 142 c.city_name AS city_name 143 FROM 144 phpgw_cc_state s, 145 phpgw_cc_city c 146 WHERE 147 c.id_state = s.id_state AND 148 s.id_country = 'BR' AND 149 c.id_state = ? 204 TO_ASCII(c.city_name) ILIKE TO_ASCII('" . $key . "%') 205 " . $where . " 150 206 ORDER BY 151 city_name"; 152 153 $result = $this->db->query($sql, array($state_id)); 154 $output = array(); 155 while ($row = $result->fetchRow()) 156 $output[] = $row; 157 158 $this->citiesFromState[$state_id] = $output; 159 return $output; 160 } 161 /** 162 * Busca os estados brasileiros 163 * @return mixed (array ou boolean) 164 * @access public 165 */ 166 function getStates() 167 { 168 $sql = 169 "SELECT 170 id_state, 171 state_name 172 FROM 173 phpgw_cc_state 174 WHERE 175 id_country = 'BR' 176 ORDER BY 177 state_name"; 207 city_name 208 LIMIT 10"; 178 209 179 210 $result = $this->db->query($sql); … … 184 215 return $output; 185 216 } 217 /** 218 * Busca os estados brasileiros 219 * @return mixed (array ou boolean) 220 * @access public 221 */ 222 function getStates() 223 { 224 $sql = 225 "SELECT 226 id_state, 227 state_name 228 FROM 229 phpgw_cc_state 230 WHERE 231 id_country = 'BR' 232 ORDER BY 233 state_name"; 234 235 $result = $this->db->query($sql); 236 $output = array(); 237 while ($row = $result->fetchRow()) 238 $output[] = $row; 239 240 return $output; 241 } 186 242 } 187 243 ?> -
branches/2.2/workflow/inc/local/classes/class.wf_mail.php
r795 r3167 39 39 $requiredConfiguration = array('mail_smtp_profile' => false); 40 40 $configuration = $GLOBALS['workflow']['wf_runtime']->process->getConfigValues($requiredConfiguration); 41 $bo_emailadmin = CreateObject('emailadmin.bo');41 $bo_emailadmin = Factory::getInstance('bo'); 42 42 $profileData = $bo_emailadmin->getProfile($configuration['mail_smtp_profile']); 43 43 -
branches/2.2/workflow/inc/local/classes/class.wf_natural.php
r795 r3167 1 1 <?php 2 require_once(PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'natural'.SEP.'class.natural.php'); 2 /**************************************************************************\ 3 * eGroupWare * 4 * http://www.egroupware.org * 5 * -------------------------------------------- * 6 * This program is free software; you can redistribute it and/or modify it * 7 * under the terms of the GNU General Public License as published by the * 8 * Free Software Foundation; either version 2 of the License, or (at your * 9 * option) any later version. * 10 \**************************************************************************/ 11 12 require_once(PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'natural'.SEP.'class.natural.php'); 13 14 /** 15 * Mainframe connection to workflow 16 * 17 * TODO - This class should be removed from here. Its based on a not 18 * public protocol, thus cannot be used for everybody. 19 * 20 * @package Workflow 21 * @subpackage local 22 * @license http://www.gnu.org/copyleft/gpl.html GPL 23 * @author Everton Flávio Rufino Seára 24 */ 25 class wf_natural extends Natural 26 { 3 27 4 28 /** 5 * Mainframe connection to workflow 6 * @author Everton Flávio Rufino Seára 7 * @package Workflow 8 * @subpackage local 9 * @license http://www.gnu.org/copyleft/gpl.html GPL 10 **/ 29 * @var object Log Object 30 * @access private 31 */ 32 private $logger = null; 11 33 12 class wf_natural extends Natural34 function __construct() 13 35 { 36 parent::Natural(); 14 37 15 function __construct() 16 { 17 parent::Natural(); 38 $natconf = array( 39 'mainframe_ip' => '', 40 'mainframe_port' => '', 41 'mainframe_key' => '', 42 'mainframe_password' => '', 43 'mainframe_environment' => '' 44 ); 18 45 19 $natconf = array( 20 'mainframe_ip' => '', 21 'mainframe_port' => '', 22 'mainframe_key' => '', 23 'mainframe_password' => '', 24 'mainframe_environment' => '' 25 ); 46 $nat_conf_values = &Factory::getInstance('workflow_wfruntime')->getConfigValues($natconf); 26 47 27 $nat_conf_values = $GLOBALS['workflow']['wf_runtime']->getConfigValues($natconf); 48 $this->setIPAddress($nat_conf_values['mainframe_ip']); 49 $this->setServerPort($nat_conf_values['mainframe_port']); 50 $this->setKey($nat_conf_values['mainframe_key']); 51 $this->setPassword($nat_conf_values['mainframe_password']); 52 $this->setApplication($nat_conf_values['mainframe_environment']); 28 53 29 $this->setIPAddress($nat_conf_values['mainframe_ip']); 30 $this->setServerPort($nat_conf_values['mainframe_port']); 31 $this->setKey($nat_conf_values['mainframe_key']); 32 $this->setPassword($nat_conf_values['mainframe_password']); 33 $this->setApplication($nat_conf_values['mainframe_environment']); 54 $this->logger = &Factory::getInstance('Logger', array('file')); 55 } 56 57 /** 58 * This method MUST be called before using execute method 59 * It specifies the natural sub-program to be accessed. 60 * 61 * @param Object $obj Object that specifies natural sub-program properties 62 * @return void 63 */ 64 public function configure($obj) 65 { 66 $this->obj = $obj; 67 68 $this->initialize($obj->name); 69 70 if ($obj->server != NULL){ 71 $this->setIPAddress($obj->server); 34 72 } 35 36 /** 37 * Method to configure the access to mainframe 38 * This method MUST be called before using execute method, else 'false' will be returned 39 * 40 * Only the first and second param are mandatory. 41 * 42 * @param String $subProgram - Name of sub-program 43 * @param String $inputParameter - Input parameters to sub-program 44 * 45 * @param String $ip - IP Address of Mainfram 46 * @param int $port - ServerPort to access the mainframe 47 * @param String $key - Access key (user) 48 * @param String $password - Key (user) password 49 * @param char $environment - Application environment access 'D' (development) or 'P' (production) 50 51 */ 52 53 public function configure($obj) 54 { 55 $this->obj = $obj; 56 57 $this->initialize($obj->name); 58 59 if ($obj->server != NULL){ 60 $this->setIPAddress($obj->server); 61 } 62 if ($obj->port != NULL){ 63 $this->setServerPort($obj->port); 64 } 65 if ($obj->key != NULL){ 66 $this->setKey($obj->key); 67 } 68 if ($obj->password != NULL){ 69 $this->setPassword($obj->password); 70 } 71 if ($obj->environment != NULL){ 72 $this->setApplication($obj->environment); 73 } 74 if ($obj->logon != NULL){ 75 $this->setLogon($obj->logon); 76 } 77 if ($obj->system != NULL){ 78 $this->setSystem($obj->system); 79 } 80 if ($obj->rc != NULL){ 81 $this->setRC($obj->rc); 82 } 73 if ($obj->port != NULL){ 74 $this->setServerPort($obj->port); 83 75 } 84 85 /* 86 87 public function configure($subProgram, $inputParameter, $ip = NULL, $port = NULL, 88 $key = NULL, $password = NULL, $environment = NULL, $logon = NULL, $system = NULL, $rc = NULL) 89 { 90 $this->initialize($subProgram, $inputParameter); 91 92 if ($ip != NULL){ 93 $this->setIPAddress($ip); 94 } 95 if ($port != NULL){ 96 $this->setServerPort($port); 97 } 98 if ($key != NULL){ 99 $this->setKey($key); 100 } 101 if ($password != NULL){ 102 $this->setPassword($password); 103 } 104 if ($environment != NULL){ 105 $this->setApplication($environment); 106 } 107 if ($logon != NULL){ 108 $this->setLogon($logon); 109 } 110 if ($system != NULL){ 111 $this->setSystem($system); 112 } 113 if ($rc != NULL){ 114 $this->setRC($rc); 115 } 116 76 if ($obj->key != NULL){ 77 $this->setKey($obj->key); 117 78 } 118 119 */ 120 121 /** 122 * Access and retrieve data from mainframe 123 * @return bool 124 */ 125 public function execute($inputParams = "") 126 { 127 return parent::execute($inputParams); 79 if ($obj->password != NULL){ 80 $this->setPassword($obj->password); 81 } 82 if ($obj->environment != NULL){ 83 $this->setApplication($obj->environment); 84 } 85 if ($obj->logon != NULL){ 86 $this->setLogon($obj->logon); 87 } 88 if ($obj->system != NULL){ 89 $this->setSystem($obj->system); 90 } 91 if ($obj->rc != NULL){ 92 $this->setRC($obj->rc); 128 93 } 129 94 } 95 96 /** 97 * Method for accessing and retrieving data from mainframe 98 * @return bool 99 */ 100 public function execute($inputParams = "") 101 { 102 // execute action and log wasted time 103 $totalTime = microtime(true); 104 $result = parent::execute($inputParams); 105 $totalTime = microtime(time) - $totalTime; 106 $log = sprintf("WF_NATURAL [subprogram=%s] [time=%ss]", 107 $this->obj->name, 108 number_format($totalTime,3) 109 ); 110 $this->logger->debug($log); 111 return $result; 112 } 113 } 130 114 ?> -
branches/2.2/workflow/inc/local/classes/class.wf_orgchart.php
r1320 r3167 24 24 function wf_orgchart() 25 25 { 26 $this->db = & $GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID;26 $this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID; 27 27 $this->db->setFetchMode(ADODB_FETCH_ASSOC); 28 28 } … … 117 117 * Este método irá buscar na tabela de áreas, todas as áreas que pertencem à organização solicitada. 118 118 * @param int $organizationID O ID da organização. 119 * @param int $onlyActiveAreas false= recupera todas as áreas; true= recupera somente as áreas ativas. 119 120 * @return array Uma array seqüencial contendo as áreas de uma organização. Cada linha do array conterá: 120 121 * - organizacao_id … … 131 132 * @access public 132 133 */ 133 function getOrganizationAreas($organizationID) 134 { 135 $query = "SELECT organizacao_id, area_id, area_status_id, " . 136 " superior_area_id, centro_custo_id, titular_funcionario_id," . 137 " substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 138 " FROM area" . 139 " WHERE (organizacao_id = ?)" . 140 " ORDER BY sigla, descricao"; 134 function getOrganizationAreas($organizationID, $onlyActiveAreas = false) 135 { 136 $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 137 " a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 138 " a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 139 " s.funcionario_id as substituto_funcionario_id " . 140 " FROM area a " . 141 " LEFT OUTER JOIN substituicao s " . 142 " ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 143 " WHERE " . 144 " (a.organizacao_id = ?) "; 145 // Se desejar somente retornar as áreas que estão ativas 146 if($onlyActiveAreas) 147 $query .=" AND a.ativa = 'S' "; 148 149 $query .= " ORDER BY a.sigla, a.descricao"; 141 150 142 151 $result = $this->db->query($query, array($organizationID)); … … 320 329 function getArea($areaID) 321 330 { 322 $query = "SELECT organizacao_id, area_id, area_status_id, " . 323 " superior_area_id, centro_custo_id, titular_funcionario_id," . 324 " substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 325 " FROM area" . 326 " WHERE (area_id = ?)"; 331 $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 332 " a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 333 " a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 334 " s.funcionario_id as substituto_funcionario_id " . 335 " FROM area a " . 336 " LEFT OUTER JOIN substituicao s " . 337 " ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 338 " WHERE " . 339 " (a.area_id = ?) " . 340 " ORDER BY a.sigla, a.descricao"; 341 327 342 328 343 $result = $this->db->query($query, array($areaID)); … … 357 372 function getAreaByName($acronym, $organizationID = 1) 358 373 { 359 $query = "SELECT organizacao_id, area_id, area_status_id, " . 360 " superior_area_id, centro_custo_id, titular_funcionario_id," . 361 " substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 362 " FROM area" . 363 " WHERE (UPPER(sigla) = UPPER(?) and (organizacao_id = ?))"; 374 $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 375 " a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 376 " a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 377 " s.funcionario_id as substituto_funcionario_id " . 378 " FROM area a " . 379 " LEFT OUTER JOIN substituicao s " . 380 " ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 381 " WHERE " . 382 " (UPPER(a.sigla) = UPPER(?)) " . 383 " AND " . 384 " (a.organizacao_id = ?) " . 385 " ORDER BY a.sigla, a.descricao"; 386 364 387 365 388 $result = $this->db->query($query, array($acronym, (int) $organizationID)); … … 395 418 $result = array(); 396 419 397 $query = "SELECT organizacao_id, area_id, area_status_id, " . 398 " superior_area_id, centro_custo_id, titular_funcionario_id," . 399 " substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 400 " FROM area" . 401 " WHERE (area_status_id = ?)"; 420 $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 421 " a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 422 " a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 423 " s.funcionario_id as substituto_funcionario_id " . 424 " FROM area a " . 425 " LEFT OUTER JOIN substituicao s " . 426 " ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 427 " WHERE " . 428 " (a.area_status_id = ?) " . 429 " ORDER BY a.sigla, a.descricao"; 430 431 402 432 403 433 $result = $this->db->query($query, array($areaStatusID)); … … 436 466 $areas = implode(', ', $areaIDs); 437 467 438 $query = "SELECT organizacao_id, area_id, area_status_id, " . 439 " superior_area_id, centro_custo_id, titular_funcionario_id," . 440 " substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 441 " FROM area" . 442 " WHERE area_id IN ($areas)" . 443 " ORDER BY sigla, descricao"; 468 $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 469 " a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 470 " a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 471 " s.funcionario_id as substituto_funcionario_id " . 472 " FROM area a " . 473 " LEFT OUTER JOIN substituicao s " . 474 " ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 475 " WHERE " . 476 " (a.area_id IN ($areas)) " . 477 " ORDER BY a.sigla, a.descricao"; 444 478 445 479 // A execução é realizada sem o segundo parâmetro pois este não pode estar entre aspas … … 448 482 return false; 449 483 484 $output = $result->GetArray(-1); 485 return $output; 486 } 487 488 /** 489 * Return all areas that the employee is a supervisor. 490 * 491 * Search in the organization for all areas that the employee is a supervisor. 492 * @param int $employeeID The ID of employee 493 * @return array Array containing all the areas that the employeee is a supervisor. 494 * @access public 495 */ 496 function getSupervisorAreas($employeeID) { 497 498 if (!$employeeID) { 499 return false; 500 } 501 502 $query = "SELECT 503 a.area_id 504 FROM 505 area a 506 LEFT OUTER JOIN substituicao s ON ((a.area_id = s.area_id) 507 AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) 508 WHERE 509 a.titular_funcionario_id = ? OR 510 s.funcionario_id = ? 511 GROUP BY 512 a.area_id"; 513 514 $result = $this->db->query($query, array($employeeID,$employeeID)); 515 if (!$result) 516 return false; 517 450 518 $output = $result->GetArray(-1); 451 519 return $output; … … 506 574 function getSubAreasByParentAreaID($parentAreaID, $onlyActiveAreas = false) 507 575 { 508 $query = "SELECT organizacao_id, area_id, area_status_id, " . 509 " superior_area_id, centro_custo_id, titular_funcionario_id," . 510 " substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 511 " FROM area" . 512 " WHERE superior_area_id = ?"; 576 $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 577 " a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 578 " a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 579 " s.funcionario_id as substituto_funcionario_id " . 580 " FROM area a " . 581 " LEFT OUTER JOIN substituicao s " . 582 " ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 583 " WHERE " . 584 " (a.superior_area_id = ?) "; 585 513 586 514 587 if ($onlyActiveAreas){ 515 588 $query .= " AND ativa = 'S'"; 516 589 } 517 $query .= " ORDER BY sigla,descricao";590 $query .= " ORDER BY a.sigla, a.descricao"; 518 591 519 592 $result = $this->db->query($query, array($parentAreaID)); … … 1168 1241 return false; 1169 1242 1170 return $employee['centro_custo_id']; 1243 $costCenterID = $employee['centro_custo_id']; 1244 if(!empty($costCenterID)){ 1245 return $costCenterID; 1246 } else { 1247 $employeeArea = $this->getArea($employee['area_id']); 1248 return $employeeArea['centro_custo_id']; 1249 } 1171 1250 } 1172 1251 -
branches/2.2/workflow/inc/local/classes/class.wf_role.php
r1048 r3167 57 57 $this->processID = (int) $GLOBALS['workflow']['job']['processID']; 58 58 59 $this->db = & $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;60 $this->roleManager = CreateObject('workflow.workflow_rolemanager');61 $this->activityManager = CreateObject('workflow.workflow_activitymanager');59 $this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 60 $this->roleManager = Factory::getInstance('workflow_rolemanager'); 61 $this->activityManager = Factory::getInstance('workflow_activitymanager'); 62 62 } 63 63 … … 186 186 $users = array((int) $users); 187 187 $roleID = $this->roleManager->get_role_id($this->processID, $roleName); 188 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');188 $ldap = Factory::getInstance('WorkflowLDAP'); 189 189 foreach ($users as $user) 190 190 { … … 212 212 $users = $this->roleManager->list_mapped_users($this->processID, false, array('wf_role_name' => $roleName)); 213 213 214 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');214 $ldap = Factory::getInstance('WorkflowLDAP'); 215 215 $output = array(); 216 216 foreach ($users as $id => $login) … … 367 367 368 368 /* get the roles */ 369 $userGroups = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($userID);369 $userGroups = Factory::getInstance('WorkflowLDAP')->getUserGroups($userID); 370 370 $query = 'SELECT DISTINCT role.wf_role_id, role.wf_name, role.wf_description FROM egw_wf_roles role, egw_wf_user_roles user_role WHERE (user_role.wf_role_id = role.wf_role_id) AND (role.wf_p_id = ?) AND (role.wf_role_id = ANY (?))'; 371 371 $query .= ' AND (((user_role.wf_user = ?) AND (user_role.wf_account_type = ?))'; -
branches/2.2/workflow/inc/local/classes/class.wf_workitem.php
r795 r3167 29 29 public function wf_workitem() 30 30 { 31 $this->db = & $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;31 $this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 32 32 $this->processID = (int) $GLOBALS['workflow']['wf_runtime']->activity->getProcessId(); 33 33 } -
branches/2.2/workflow/inc/local/functions/function.wf_create_object.php
r795 r3167 5 5 * @return mixed 6 6 * @license http://www.gnu.org/copyleft/gpl.html GPL 7 * @deprecated 1.4.00.000 - 08/03/20077 * @deprecated 2.2.00.000 8 8 * @package Workflow 9 9 * @subpackage local … … 12 12 function wf_create_object($class_name) 13 13 { 14 wf_warn_deprecated_method('Factory', 'getInstance'); 14 15 $obj = null; 15 16 $file_name = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'local'.SEP.'classes'.SEP.'class.'.$class_name.'.php';
Note: See TracChangeset
for help on using the changeset viewer.