Changeset 2418 for sandbox/workflow/branches
- Timestamp:
- 04/05/10 15:30:21 (14 years ago)
- Location:
- sandbox/workflow/branches/993
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/workflow/branches/993/inc/class.WorkflowObjects.inc.php
r2372 r2418 13 13 * Provê objetos de multipropósito do Workflow 14 14 * @author Sidnei Augusto Drovetto Jr. - drovetto@gmail.com 15 * @author Pedro Eugenio Rocha - pedro.eugenio.rocha@gmail.com 15 16 * @version 1.0 16 17 * @package Workflow … … 23 24 * @access private 24 25 */ 25 private $cache ;26 private $cache = array(); 26 27 27 28 /** 28 * Construtor da classe 29 * @return object 30 * @access public 31 */ 32 function WorkflowObjects() 33 { 34 $this->cache = array(); 35 } 36 37 /** 29 * TODO We should remove this method.. 38 30 * Monta o ambiente requerido pelos métodos (somente se for necessário) 39 31 * @param bool $requireGalaxia Indica que os métodos da engine Galaxia são necessários … … 68 60 $this->assureEnvironment(); 69 61 70 /* load the configuration required to establish a connection to the Galaxia database */71 $dbConfigValues = galaxia_get_config_values(array(72 'workflow_database_name' => '',73 'workflow_database_host' => '',74 'workflow_database_port' => '',75 'workflow_database_user' => '',76 'workflow_database_password' => '',77 'workflow_database_type' => ''78 ));79 80 62 /* check if all configuration is OK */ 81 63 $dedicatedDB = true; 82 foreach ($dbConfigValues as $configName => $configValue)83 if (empty($configValue) && ($configName != 'workflow_database_password'))84 $dedicatedDB = false;85 64 65 /* if any parameter is not set, then we will return expresso database */ 66 if ((Settings::get('workflow', 'galaxia', 'db', 'name') == '') or 67 (Settings::get('workflow', 'galaxia', 'db', 'host') == '') or 68 (Settings::get('workflow', 'galaxia', 'db', 'port') == '') or 69 (Settings::get('workflow', 'galaxia', 'db', 'user') == '') or 70 (Settings::get('workflow', 'galaxia', 'db', 'type') == '')) 71 $dedicatedDB = false; 72 73 /* should we connect to a dedicated database? */ 86 74 if ($dedicatedDB) 87 75 { … … 91 79 $this->cache['DBGalaxia']->Halt_On_Error = 'no'; 92 80 $this->cache['DBGalaxia']->connect( 93 $dbConfigValues['workflow_database_name'],94 $dbConfigValues['workflow_database_host'],95 $dbConfigValues['workflow_database_port'],96 $dbConfigValues['workflow_database_user'],97 $dbConfigValues['workflow_database_password'],98 $dbConfigValues['workflow_database_type']81 Settings::get('workflow', 'galaxia', 'db', 'name'), 82 Settings::get('workflow', 'galaxia', 'db', 'host'), 83 Settings::get('workflow', 'galaxia', 'db', 'port'), 84 Settings::get('workflow', 'galaxia', 'db', 'user'), 85 Settings::get('workflow', 'galaxia', 'db', 'password'), 86 Settings::get('workflow', 'galaxia', 'db', 'type') 99 87 ); 100 88 Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBGalaxia']); … … 120 108 $this->assureEnvironment(false); 121 109 122 /* check where the connection parameters are */123 $connectionInfo = (isset($GLOBALS['phpgw_info']['server']['db_name'])) ?124 $GLOBALS['phpgw_info']['server'] :125 $_SESSION['phpgw_info']['workflow']['server'];126 127 /* the information was not found. Try to load the environment */128 if (!isset($connectionInfo['db_name']))129 {130 Factory::getInstance('WorkflowMacro')->prepareEnvironment();131 if (isset($GLOBALS['phpgw_info']['server']))132 $connectionInfo = $GLOBALS['phpgw_info']['server'];133 else134 return false;135 }136 137 110 /* connect to the database */ 138 111 $this->cache['DBExpresso'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); … … 140 113 $this->cache['DBExpresso']->Halt_On_Error = 'no'; 141 114 $this->cache['DBExpresso']->connect( 142 $connectionInfo['db_name'],143 $connectionInfo['db_host'],144 $connectionInfo['db_port'],145 $connectionInfo['db_user'],146 $connectionInfo['db_pass'],147 $connectionInfo['db_type']115 Settings::get('expresso', 'db', 'name'), 116 Settings::get('expresso', 'db', 'host'), 117 Settings::get('expresso', 'db', 'port'), 118 Settings::get('expresso', 'db', 'user'), 119 Settings::get('expresso', 'db', 'password'), 120 Settings::get('expresso', 'db', 'type') 148 121 ); 149 122 Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBExpresso']); … … 166 139 $this->assureEnvironment(); 167 140 168 /* load the configuration required to establish a connection to the Galaxia database */169 $dbConfigValues = galaxia_get_config_values(array(170 'database_name' => '',171 'database_host' => '',172 'database_port' => '',173 'database_admin_user' => '',174 'database_admin_password' => '',175 'database_type' => ''176 ));177 178 141 /* connect to the database */ 179 142 $this->cache['DBWorkflow'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); … … 181 144 $this->cache['DBWorkflow']->Halt_On_Error = 'no'; 182 145 $this->cache['DBWorkflow']->connect( 183 $dbConfigValues['database_name'],184 $dbConfigValues['database_host'],185 $dbConfigValues['database_port'],186 $dbConfigValues['database_admin_user'],187 $dbConfigValues['database_admin_password'],188 $dbConfigValues['database_type']146 Settings::get('workflow', 'db', 'name'), 147 Settings::get('workflow', 'db', 'host'), 148 Settings::get('workflow', 'db', 'port'), 149 Settings::get('workflow', 'db', 'admin_user'), 150 Settings::get('workflow', 'db', 'admin_password'), 151 Settings::get('workflow', 'db', 'type') 189 152 ); 190 153 Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBWorkflow']); … … 207 170 $this->assureEnvironment(); 208 171 209 /* check where the connection parameters are */ 210 $connectionInfo = (isset($GLOBALS['phpgw_info']['server']['ldap_host'])) ? 211 $GLOBALS['phpgw_info']['server'] : 212 $_SESSION['phpgw_info']['workflow']['server']; 213 214 /* load required information */ 215 $ldapConfigValues = galaxia_get_config_values(array('ldap_host' => '', 'ldap_user' => '', 'ldap_password'=> '', 'ldap_follow_referrals' => '')); 216 if (empty($ldapConfigValues['ldap_host'])) 217 $ldapConfigValues['ldap_host'] = $connectionInfo['ldap_host']; 172 /* which ldap host to connect? */ 173 $ldapHost = Settings::get('workflow', 'ldap', 'host'); 174 if (empty($ldapHost)) 175 $ldapHost = Settings::get('expresso', 'ldap', 'host'); 218 176 219 177 /* connect to the LDAP server */ 220 $this->cache['ldap'] = ldap_connect($ldap ConfigValues['ldap_host']);178 $this->cache['ldap'] = ldap_connect($ldapHost); 221 179 222 180 /* configure the connection */ 223 181 ldap_set_option($this->cache['ldap'], LDAP_OPT_PROTOCOL_VERSION, 3); 224 ldap_set_option($this->cache['ldap'], LDAP_OPT_REFERRALS, ( $ldapConfigValues['ldap_follow_referrals']== 1) ? 1 : 0);182 ldap_set_option($this->cache['ldap'], LDAP_OPT_REFERRALS, (Settings::get('workflow', 'ldap', 'follow_referrals') == 1) ? 1 : 0); 225 183 226 184 /* if username and password are available, bind the connection */ 227 if ((!empty($ldapConfigValues['ldap_user'])) && (!empty($ldapConfigValues['ldap_password']))) 228 ldap_bind($this->cache['ldap'], $ldapConfigValues['ldap_user'], $ldapConfigValues['ldap_password']); 185 if ((Settings::get('workflow', 'ldap', 'user') != '') and 186 (Settings::get('workflow', 'ldap', 'password') != '')) 187 ldap_bind( $this->cache['ldap'], 188 Settings::get('workflow', 'ldap', 'user'), 189 Settings::get('workflow', 'ldap', 'password') 190 ); 229 191 } 230 192 -
sandbox/workflow/branches/993/inc/class.bo_utils.inc.php
r2372 r2418 86 86 $ret_name = empty($params['name']) ? 'cn' : $params['name']; 87 87 88 /** 89 * This is wrong. We should incorporate this settings into 90 * workflow configuration table. Therefore, workflow should 91 * not depend on other modules.. 92 */ 88 93 $ajaxConfig = &Factory::newInstance('ajax_config', 'contactcenter'); 89 94 $config = $ajaxConfig->read_repository(); -
sandbox/workflow/branches/993/inc/class.so_userinterface.inc.php
r2372 r2418 60 60 $oldDB = $GLOBALS['phpgw']->db; 61 61 $GLOBALS['phpgw']->db = $GLOBALS['ajax']->db; 62 $config = &Factory::getInstance('config', 'workflow'); 63 $configValues = $config->read_repository(); 64 $submasksString = $configValues['intranet_subnetworks']; 62 $submasksString = Settings::get('workflow', 'intranet_subnetworks'); 65 63 $GLOBALS['phpgw']->db = $oldDB; 66 64 -
sandbox/workflow/branches/993/inc/class.ui_orgchart.inc.php
r2372 r2418 37 37 * @access public 38 38 */ 39 function ui_orgchart()39 public function ui_orgchart() 40 40 { 41 41 } … … 45 45 * @access public 46 46 */ 47 function draw($tab_index = "")47 public function draw($tab_index = "") 48 48 { 49 49 $this->workflow_acl = Factory::getInstance('workflow_acl'); … … 92 92 * Show the graph 93 93 * @access public 94 * @return void 94 * @return void 95 95 */ 96 function graph()96 public function graph() 97 97 { 98 98 if (!isset($_GET['organizationID'])) … … 104 104 die(); 105 105 106 $config_values = Factory::getInstance('config', 'workflow'); 107 $config_values->read_repository(); 108 $conf_db = $config_values->config_data; 109 $db = Factory::getInstance('db'); 110 $db->connect( 111 $conf_db['database_name'], 112 $conf_db['database_host'], 113 $conf_db['database_port'], 114 $conf_db['database_admin_user'], 115 $conf_db['database_admin_password'], 116 $conf_db['database_type'] 117 ); 118 $db = $db->Link_ID; 106 $db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID; 107 119 108 $attributes = array(); 120 109 $attributes['ranksep'] = '1.5 equally'; … … 122 111 $graph = &Factory::getInstance('Process_GraphViz', true, $attributes); 123 112 124 125 /** 126 * Get Hierarchical Area 127 * @param organizationID 128 * @param $parent 129 * @param $depth 130 * @param $db 131 * @param $graph 132 * @return 133 */ 134 function getHierarchicalArea($organizationID, $parent, $depth, $db, $graph) 135 { 136 /* orgchart graph configuration */ 137 $color='black'; 138 $fillcolor='lightblue2'; //blue TLS values 139 $fontsize = '10'; 140 $color = '0.25,1,0.28'; #dark green in TLS values 141 $arrowsize = 0.8; 142 143 if (is_null($parent)) 144 $result = $db->query("SELECT area_id, sigla, titular_funcionario_id FROM area WHERE (superior_area_id IS NULL) AND (organizacao_id = ?) AND (ativa = 'S') ORDER BY sigla", array($organizationID)); 145 else 146 $result = $db->query("SELECT area_id, sigla, titular_funcionario_id FROM area WHERE (superior_area_id = ?) AND (ativa = 'S') ORDER BY sigla", array($parent)); 147 148 $output = $result->GetArray(-1); 149 150 if (is_null($parent) && (count($output) == 0)) 151 return false; 152 153 $ldap = &Factory::getInstance('WorkflowLDAP'); 154 for ($i = 0; $i < count($output); $i++) 155 { 156 for ($j = 0; $j < $result->_numOfFields; $j++) 157 unset($output[$i][$j]); 158 if ($output[$i]['titular_funcionario_id'] != '') 159 { 160 $supervisor = $ldap->getName($output[$i]['titular_funcionario_id']); 161 $supervisor = str_replace(array(" da ", " de ", " do ", " das ", " dos "), " ", $supervisor); 162 $supervisorArray = explode(' ', $supervisor); 163 $supervisorName = ''; 164 for ($j = 0; $j < count($supervisorArray); $j++) 165 $supervisorName .= (($j == 0) || ($j == count($supervisorArray) - 1)) ? $supervisorArray[$j] . ' ' : $supervisorArray[$j][0] . '. '; 166 $supervisorName = trim(str_replace("Junior", "Jr", $supervisorName)); 167 } 168 else 169 $supervisorName = ''; 170 /* add the area box */ 171 $graph->addNode($output[$i]['area_id'],array( 172 'URL' => $output[$i]['area_id'], 173 'label' => $output[$i]['sigla'] . '\n' . $supervisorName, 174 'shape' => 'box', 175 'color' => $color, 176 'fillcolor' => $fillcolor, 177 'style' => 'filled', 178 'fontsize' => $fontsize, 179 'fontname' => 'serif' 180 ) 181 ); 182 183 /* add the conection between areas */ 184 if (!is_null($parent)) 185 $graph->addEdge(array($parent => $output[$i]['area_id']), array('color'=>$color,arrowsize=>$arrowsize)); 186 $output[$i]['children'] = getHierarchicalArea($organizationID, $output[$i]['area_id'], $depth + 1, $db, $graph); 187 $output[$i]['depth'] = $depth; 188 } 189 190 return $output; 191 } 192 193 194 $result = getHierarchicalArea($organizationID, null, 0, $db, $graph); 113 $result = $this->getHierarchicalArea($organizationID, null, 0, $db, $graph); 195 114 if ($result !== false) 196 115 $graph->image('png', '/tmp/grafico'); … … 198 117 die(); 199 118 } 119 120 121 /** 122 * Get Hierarchical Area 123 * @param organizationID 124 * @param $parent 125 * @param $depth 126 * @param $db 127 * @param $graph 128 * @return 129 */ 130 private function getHierarchicalArea($organizationID, $parent, $depth, $db, $graph) 131 { 132 /* orgchart graph configuration */ 133 $color='black'; 134 $fillcolor='lightblue2'; //blue TLS values 135 $fontsize = '10'; 136 $color = '0.25,1,0.28'; #dark green in TLS values 137 $arrowsize = 0.8; 138 139 if (is_null($parent)) 140 $result = $db->query("SELECT area_id, sigla, titular_funcionario_id FROM area WHERE (superior_area_id IS NULL) AND (organizacao_id = ?) AND (ativa = 'S') ORDER BY sigla", array($organizationID)); 141 else 142 $result = $db->query("SELECT area_id, sigla, titular_funcionario_id FROM area WHERE (superior_area_id = ?) AND (ativa = 'S') ORDER BY sigla", array($parent)); 143 144 $output = $result->GetArray(-1); 145 146 if (is_null($parent) && (count($output) == 0)) 147 return false; 148 149 $ldap = &Factory::getInstance('WorkflowLDAP'); 150 for ($i = 0; $i < count($output); $i++) 151 { 152 for ($j = 0; $j < $result->_numOfFields; $j++) 153 unset($output[$i][$j]); 154 if ($output[$i]['titular_funcionario_id'] != '') 155 { 156 $supervisor = $ldap->getName($output[$i]['titular_funcionario_id']); 157 $supervisor = str_replace(array(" da ", " de ", " do ", " das ", " dos "), " ", $supervisor); 158 $supervisorArray = explode(' ', $supervisor); 159 $supervisorName = ''; 160 for ($j = 0; $j < count($supervisorArray); $j++) 161 $supervisorName .= (($j == 0) || ($j == count($supervisorArray) - 1)) ? $supervisorArray[$j] . ' ' : $supervisorArray[$j][0] . '. '; 162 $supervisorName = trim(str_replace("Junior", "Jr", $supervisorName)); 163 } 164 else 165 $supervisorName = ''; 166 167 /* add the area box */ 168 $graph->addNode($output[$i]['area_id'],array( 169 'URL' => $output[$i]['area_id'], 170 'label' => $output[$i]['sigla'] . '\n' . $supervisorName, 171 'shape' => 'box', 172 'color' => $color, 173 'fillcolor' => $fillcolor, 174 'style' => 'filled', 175 'fontsize' => $fontsize, 176 'fontname' => 'serif' 177 ) 178 ); 179 180 /* add the conection between areas */ 181 if (!is_null($parent)) 182 $graph->addEdge(array($parent => $output[$i]['area_id']), array('color'=>$color,'arrowsize'=>$arrowsize)); 183 $output[$i]['children'] = $this->getHierarchicalArea($organizationID, $output[$i]['area_id'], $depth + 1, $db, $graph); 184 $output[$i]['depth'] = $depth; 185 } 186 187 return $output; 188 } 200 189 } 201 190 ?> -
sandbox/workflow/branches/993/inc/common.inc.php
r2372 r2418 11 11 12 12 /** 13 * Server base path. This constant is somewhat simililar to 14 * 'PHPGW_SERVER_ROOT'. Nevertheless, there are cases that we 15 * access Workflow directly and it must be defined somewhere. 16 * Recently discovered, when we are runnnig jobs HTTP_SERVER_VARS 17 * exported by apache are not available. 18 * Therefore, we are using this workaround here, setting 19 * EGW_SERVER_ROOT based on the location of this file. This constant 20 * should be updated properly every time we move this file. 13 * This is other big workaround. In ajax calls, we use controller.php 14 * directly, which do not includes header.inc for performance issues. 15 * However, for phpgwAPI to work properly we need to set several 16 * constants and objects, which are created in this file (header.inc). 17 * As much as this problem still unsolved (by phpAPI group), this potencially 18 * problematic and ugly code must still here.. =( 19 */ 20 $old = $GLOBALS['phpgw_info']['flags']; 21 $GLOBALS['phpgw_info']['flags'] = array( 22 'noheader' => True, 23 'nonavbar' => True, 24 'currentapp' => 'workflow' 25 ); 26 /* TODO TODO TODO TODO */ 27 $base = dirname(dirname(dirname(__FILE__))); 28 require_once ($base . '/header.inc.php'); 29 $GLOBALS['phpgw_info']['flags'] = $old; 30 31 32 /** 33 * Server base path. In this module, we should only use 34 * constants defined here. PHPGW_SERVER_ROOT is defined 35 * on 'header.inc.php' which is always included by this 36 * file. 21 37 * @name EGW_SERVER_ROOT 22 38 */ 23 define('EGW_SERVER_ROOT', dirname(dirname(dirname(__FILE__)))); 24 //define('EGW_SERVER_ROOT', $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']); 39 define('EGW_SERVER_ROOT', PHPGW_SERVER_ROOT); 25 40 26 41 /** … … 51 66 52 67 53 if (file_exists(EGW_SERVER_ROOT . '/header.session.inc.php')) {54 require_once EGW_SERVER_ROOT . '/header.session.inc.php';55 }56 57 68 58 69 /* assure that the correct encondig will be used (e.g string functions) */ … … 70 81 require_once WF_LIB_ROOT . 'factory/WorkflowFactory.php'; 71 82 require_once WF_LIB_ROOT . 'factory/ProcessFactory.php'; 83 require_once WF_LIB_ROOT . 'settings/Settings.php'; 84 85 Settings::load(); 72 86 73 87 $GLOBALS['workflow']['workflowObjects'] = Factory::getInstance('WorkflowObjects'); -
sandbox/workflow/branches/993/index.php
r2372 r2418 46 46 else 47 47 { 48 $GLOBALS['phpgw']->preferences->read_repository();49 48 $start_tab = $GLOBALS['phpgw_info']['user']['preferences']['workflow']['startpage']; 50 49 if (is_null($start_tab))
Note: See TracChangeset
for help on using the changeset viewer.