Changeset 3167 for branches/2.2/workflow/inc/class.bo_adminsource.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.bo_adminsource.inc.php
r795 r3167 11 11 12 12 require_once('class.bo_ajaxinterface.inc.php'); 13 14 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php');15 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'RoleManager.php');16 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');17 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Process.php');18 13 19 14 /** … … 80 75 $fileSizeUnit[] = 'Mb'; 81 76 $fileSizeUnit[] = 'Gb'; 82 77 83 78 $unitSelect = 0; 84 79 while ($value > 1024.0) … … 87 82 $unitSelect++; 88 83 } 89 84 90 85 $output = round($value, 1); 91 86 $output .= " " . $fileSizeUnit[$unitSelect]; 92 87 93 88 return $output; 94 89 } 95 90 96 91 /** 97 92 * Get process toolbar data 98 * @param array $p process process data 99 * @return array 100 * @access public 101 */ 102 function get_toolbar_data($p) 103 { 104 105 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);106 $proc_info = $process_manager->get_process($p['proc_id']); 107 93 * @param array $p process process data 94 * @return array 95 * @access public 96 */ 97 function get_toolbar_data($p) 98 { 99 100 $process_manager = &Factory::newInstance('ProcessManager'); 101 $proc_info = $process_manager->get_process($p['proc_id']); 102 108 103 $web_server_url = $_SESSION['phpgw_info']['workflow']['server']['webserver_url']; 109 $img_default_dir = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink('');110 104 $img_default_dir = Factory::getInstance('TemplateServer')->generateImageLink(''); 105 111 106 if ($proc_info['wf_is_valid'] == 'y') 112 107 { … … 119 114 $alt_validity = tra('invalid'); 120 115 } 121 116 122 117 // if process is active show stop button. Else show start button, but only if it is valid. If it's not valid, don't show any activation or stop button. 123 118 if ($proc_info['wf_is_active'] == 'y') … … 138 133 $start_stop_img = ''; 139 134 } 140 135 141 136 /* load other processes link */ 142 137 $proc_ids = $GLOBALS['ajax']->acl->get_granted_processes($_SESSION['phpgw_info']['workflow']['account_id']); … … 145 140 else 146 141 $where = ' wf_p_id = -1 '; 147 142 148 143 $processesInfo = &$process_manager->list_processes(0, -1, 'wf_name__asc', '', $where); 149 144 $otherProcesses = array(); 150 145 foreach ($processesInfo['data'] as $pi) 151 146 $otherProcesses[] = array("name" => $pi['wf_name'] . " (v" . $pi['wf_version'] . ")", "link" => $web_server_url . "/index.php?menuaction=workflow.ui_adminsource.form&p_id=" . $pi['wf_p_id'], "pid" => $pi['wf_p_id']); 152 147 153 148 $toolbar_data = array ( 154 149 'proc_name' => $proc_info['wf_name'], … … 177 172 'other_processes' => $otherProcesses 178 173 ); 179 174 180 175 return $toolbar_data; 181 176 } 182 183 177 178 184 179 /** 185 180 * Get process model files 186 * @param array $p process process data 187 * @return array 188 * @access public 181 * @param array $p process process data 182 * @return array 183 * @access public 189 184 */ 190 185 function get_model_files($p) 191 186 { 192 switch($p['type']) 187 switch($p['type']) 193 188 { 194 189 case 'include' : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'adminsource' . SEP . 'inc'; … … 203 198 $files = array(); 204 199 205 if ($handle = opendir($path)) 206 { 207 while (false !== ($file_name = readdir($handle))) 208 { 209 if (!is_dir($path.SEP.$file_name)) 200 if ($handle = opendir($path)) 201 { 202 while (false !== ($file_name = readdir($handle))) 203 { 204 if (!is_dir($path.SEP.$file_name)) 210 205 { 211 206 $files[] = array('file_name' => $file_name); … … 217 212 array_multisort($col_file_name,SORT_ASC,$files); 218 213 219 return $files; 214 return $files; 220 215 } 221 216 222 217 /** 223 218 * Get process php files 224 * @param array $p process data 225 * @return array 226 * @access public 219 * @param array $p process data 220 * @return array 221 * @access public 227 222 */ 228 223 function get_php_files($p) 229 224 { 230 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);225 $process_manager = &Factory::newInstance('ProcessManager'); 231 226 $proc_info = $process_manager->get_process($p['proc_id']); 232 $activity_manager = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);227 $activity_manager = &Factory::newInstance('ActivityManager'); 233 228 $process_activities = $activity_manager->list_activities($p['proc_id'], 0, -1, 'wf_name__asc', '','',false); 234 229 $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'activities' . SEP; 235 230 236 231 $files = array(); 237 232 … … 242 237 foreach ($process_activities['data'] as $process_activity) 243 238 { 244 239 245 240 $file_name = $process_activity['wf_normalized_name'].'.php'; 246 241 $activity_id = $process_activity['wf_activity_id']; 247 242 $tamanho = filesize($path.$file_name); 248 243 $modificado = date('d/m/Y H:i:s', filemtime($path.$file_name) ); 249 244 250 245 $files[] = array('file_name' => $file_name, 251 246 'activity_id' => $activity_id, … … 258 253 'tipo_codigo' => 'atividade' 259 254 ); 260 255 261 256 $col_file_name[] = $file_name; 262 257 $col_tamanho[] = $tamanho; 263 258 $col_modificado[] = $modificado; 264 259 } 265 266 if (isset($p['sort'])) 260 261 if (isset($p['sort'])) 267 262 { 268 263 $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; … … 279 274 } 280 275 } 281 282 return $files; 283 } 284 285 /** 286 * Delete process file 276 277 return $files; 278 } 279 280 /** 281 * Delete process file 287 282 * @param array $p process data 288 283 * @return array 289 * @access public 284 * @access public 290 285 */ 291 286 function delete_file($p) … … 293 288 if ((strpos($p['file_name'],'/') !== false) || (strpos($p['file_name'],'/') !== false)) 294 289 return 'Não foi possível executar a operação solicitada'; 295 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);296 $proc_info = $process_manager->get_process($p['proc_id']); 290 $process_manager = &Factory::newInstance('ProcessManager'); 291 $proc_info = $process_manager->get_process($p['proc_id']); 297 292 $file_name = $p['file_name']; 298 $proc_name = $proc_info['wf_normalized_name']; 293 $proc_name = $proc_info['wf_normalized_name']; 299 294 $type = $p['type']; 300 295 if (strpos($file_name,'/')) return 'Nome de arquivo inválido.'; 301 296 if (!strlen($proc_name)) return 'ID de Processo inválido.'; 302 297 303 298 switch($type) 304 299 { … … 315 310 $path = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources/' . $file_name; 316 311 break; 317 312 318 313 } 319 320 if ($type == 'resource') 314 315 if ($type == 'resource') 321 316 { 322 317 $complete_path = $path; 323 } 324 else 318 } 319 else 325 320 { 326 321 $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 327 322 } 328 329 if (file_exists($complete_path)) 323 324 if (file_exists($complete_path)) 330 325 { 331 326 if (unlink($complete_path)) … … 342 337 return 'O arquivo '.$file_name.' não existe.'; 343 338 } 344 } 345 /** 346 * Create process new file 339 } 340 /** 341 * Create process new file 347 342 * @param array $p process 348 343 * @return array 349 * @access public 344 * @access public 350 345 */ 351 346 function create_file($p) 352 347 { 353 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);354 $proc_info = $process_manager->get_process($p['proc_id']); 348 $process_manager = &Factory::newInstance('ProcessManager'); 349 $proc_info = $process_manager->get_process($p['proc_id']); 355 350 $file_name = $p['file_name']; 356 $proc_name = $proc_info['wf_normalized_name']; 351 $proc_name = $proc_info['wf_normalized_name']; 357 352 $type = $p['type']; 358 353 … … 386 381 } 387 382 388 if (file_exists($complete_path)) 389 { 390 if (!$p['rewrite']) 383 if (file_exists($complete_path)) 384 { 385 if (!$p['rewrite']) 391 386 { 392 387 return FILE_ALREADY_EXISTS; … … 396 391 } 397 392 398 if ($fp = fopen($complete_path, 'w')) 393 if ($fp = fopen($complete_path, 'w')) 399 394 { 400 395 $basepath = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'js'.SEP.'adminsource'; … … 409 404 if ($type == 'template' || $type == 'include') 410 405 { 411 if (file_exists($basepath.SEP.$p['modelo'])) 406 if (file_exists($basepath.SEP.$p['modelo'])) 412 407 { 413 408 fwrite($fp,file_get_contents($basepath.SEP.$p['modelo'])); … … 423 418 } 424 419 } 425 420 426 421 /** 427 422 * Get process include files 428 423 * @param array $p process 429 424 * @return array 430 * @access public 425 * @access public 431 426 */ 432 427 function get_include_files($p) 433 428 { 434 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);435 $proc_info = $process_manager->get_process($p['proc_id']); 429 $process_manager = &Factory::newInstance('ProcessManager'); 430 $proc_info = $process_manager->get_process($p['proc_id']); 436 431 $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code'; 437 432 … … 442 437 $files = array(); 443 438 444 if ($handle = opendir($path)) 445 { 446 while (false !== ($file_name = readdir($handle))) 447 { 448 if (!is_dir($path.SEP.$file_name)) 439 if ($handle = opendir($path)) 440 { 441 while (false !== ($file_name = readdir($handle))) 442 { 443 if (!is_dir($path.SEP.$file_name)) 449 444 { 450 445 $tamanho = filesize($path.SEP.$file_name); … … 467 462 468 463 469 if (isset($p['sort'])) 464 if (isset($p['sort'])) 470 465 { 471 466 $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; … … 483 478 } 484 479 485 return $files; 486 } 487 488 /** 489 * Get process template files 490 * @param array $p process data 491 * @return array 492 * @access public 480 return $files; 481 } 482 483 /** 484 * Get process template files 485 * @param array $p process data 486 * @return array 487 * @access public 493 488 */ 494 489 function get_template_files($p) 495 490 { 496 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);497 $proc_info = $process_manager->get_process($p['proc_id']); 491 $process_manager = &Factory::newInstance('ProcessManager'); 492 $proc_info = $process_manager->get_process($p['proc_id']); 498 493 $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates'; 499 494 … … 502 497 $col_modificado = array(); 503 498 504 if ($handle = opendir($path)) 505 { 506 while (false !== ($file_name = readdir($handle))) 507 { 508 if (!is_dir($path.SEP.$file_name)) 499 if ($handle = opendir($path)) 500 { 501 while (false !== ($file_name = readdir($handle))) 502 { 503 if (!is_dir($path.SEP.$file_name)) 509 504 { 510 505 $tamanho = filesize($path.SEP.$file_name); … … 541 536 542 537 } 543 } 544 545 return $files; 546 } 547 548 /** 549 * Upload process resource 550 * 538 } 539 540 return $files; 541 } 542 543 /** 544 * Upload process resource 545 * 551 546 * @param array $p process 552 547 * @return array 553 * @access public 548 * @access public 554 549 */ 555 550 function upload_resource($p) 556 551 { 557 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);552 $process_manager = &Factory::newInstance('ProcessManager'); 558 553 $proc_info = $process_manager->get_process($p['proc_id']); 559 554 $file_name = basename($_FILES['resource_file']['name']); … … 587 582 if (strpos($_REQUEST['file_name'],'/') !== false) 588 583 return 'Não foi possível executar a operação solicitada'; 589 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);584 $process_manager = &Factory::newInstance('ProcessManager'); 590 585 $proc_info = $process_manager->get_process($_REQUEST['proc_id']); 591 586 … … 617 612 $completePath = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 618 613 619 $GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($completePath, 'application/force-download');614 Factory::getInstance('ResourcesRedirector')->show($completePath, 'application/force-download'); 620 615 exit; 621 616 } … … 630 625 function get_resource_files($p) 631 626 { 632 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);627 $process_manager = &Factory::newInstance('ProcessManager'); 633 628 $proc_info = $process_manager->get_process($p['proc_id']); 634 629
Note: See TracChangeset
for help on using the changeset viewer.