- Timestamp:
- 03/12/10 10:59:32 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/workflow/branches/609/inc/class.bo_adminsource.inc.php
r795 r2233 80 80 $fileSizeUnit[] = 'Mb'; 81 81 $fileSizeUnit[] = 'Gb'; 82 82 83 83 $unitSelect = 0; 84 84 while ($value > 1024.0) … … 87 87 $unitSelect++; 88 88 } 89 89 90 90 $output = round($value, 1); 91 91 $output .= " " . $fileSizeUnit[$unitSelect]; 92 92 93 93 return $output; 94 94 } 95 95 96 96 /** 97 97 * 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 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(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 106 $proc_info = $process_manager->get_process($p['proc_id']); 107 108 108 $web_server_url = $_SESSION['phpgw_info']['workflow']['server']['webserver_url']; 109 $img_default_dir = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink('');110 109 $img_default_dir = Factory::getInstance('TemplateServer')->generateImageLink(''); 110 111 111 if ($proc_info['wf_is_valid'] == 'y') 112 112 { … … 119 119 $alt_validity = tra('invalid'); 120 120 } 121 121 122 122 // 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 123 if ($proc_info['wf_is_active'] == 'y') … … 138 138 $start_stop_img = ''; 139 139 } 140 140 141 141 /* load other processes link */ 142 142 $proc_ids = $GLOBALS['ajax']->acl->get_granted_processes($_SESSION['phpgw_info']['workflow']['account_id']); … … 145 145 else 146 146 $where = ' wf_p_id = -1 '; 147 147 148 148 $processesInfo = &$process_manager->list_processes(0, -1, 'wf_name__asc', '', $where); 149 149 $otherProcesses = array(); 150 150 foreach ($processesInfo['data'] as $pi) 151 151 $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 152 153 153 $toolbar_data = array ( 154 154 'proc_name' => $proc_info['wf_name'], … … 177 177 'other_processes' => $otherProcesses 178 178 ); 179 179 180 180 return $toolbar_data; 181 181 } 182 183 182 183 184 184 /** 185 185 * Get process model files 186 * @param array $p process process data 187 * @return array 188 * @access public 186 * @param array $p process process data 187 * @return array 188 * @access public 189 189 */ 190 190 function get_model_files($p) 191 191 { 192 switch($p['type']) 192 switch($p['type']) 193 193 { 194 194 case 'include' : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'adminsource' . SEP . 'inc'; … … 203 203 $files = array(); 204 204 205 if ($handle = opendir($path)) 206 { 207 while (false !== ($file_name = readdir($handle))) 208 { 209 if (!is_dir($path.SEP.$file_name)) 205 if ($handle = opendir($path)) 206 { 207 while (false !== ($file_name = readdir($handle))) 208 { 209 if (!is_dir($path.SEP.$file_name)) 210 210 { 211 211 $files[] = array('file_name' => $file_name); … … 217 217 array_multisort($col_file_name,SORT_ASC,$files); 218 218 219 return $files; 219 return $files; 220 220 } 221 221 222 222 /** 223 223 * Get process php files 224 * @param array $p process data 225 * @return array 226 * @access public 224 * @param array $p process data 225 * @return array 226 * @access public 227 227 */ 228 228 function get_php_files($p) 229 229 { 230 $process_manager = new ProcessManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);230 $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 231 231 $proc_info = $process_manager->get_process($p['proc_id']); 232 $activity_manager = new ActivityManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);232 $activity_manager = new ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 233 233 $process_activities = $activity_manager->list_activities($p['proc_id'], 0, -1, 'wf_name__asc', '','',false); 234 234 $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'activities' . SEP; 235 235 236 236 $files = array(); 237 237 … … 242 242 foreach ($process_activities['data'] as $process_activity) 243 243 { 244 244 245 245 $file_name = $process_activity['wf_normalized_name'].'.php'; 246 246 $activity_id = $process_activity['wf_activity_id']; 247 247 $tamanho = filesize($path.$file_name); 248 248 $modificado = date('d/m/Y H:i:s', filemtime($path.$file_name) ); 249 249 250 250 $files[] = array('file_name' => $file_name, 251 251 'activity_id' => $activity_id, … … 258 258 'tipo_codigo' => 'atividade' 259 259 ); 260 260 261 261 $col_file_name[] = $file_name; 262 262 $col_tamanho[] = $tamanho; 263 263 $col_modificado[] = $modificado; 264 264 } 265 266 if (isset($p['sort'])) 265 266 if (isset($p['sort'])) 267 267 { 268 268 $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; … … 279 279 } 280 280 } 281 282 return $files; 283 } 284 285 /** 286 * Delete process file 281 282 return $files; 283 } 284 285 /** 286 * Delete process file 287 287 * @param array $p process data 288 288 * @return array 289 * @access public 289 * @access public 290 290 */ 291 291 function delete_file($p) … … 293 293 if ((strpos($p['file_name'],'/') !== false) || (strpos($p['file_name'],'/') !== false)) 294 294 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']); 295 $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 296 $proc_info = $process_manager->get_process($p['proc_id']); 297 297 $file_name = $p['file_name']; 298 $proc_name = $proc_info['wf_normalized_name']; 298 $proc_name = $proc_info['wf_normalized_name']; 299 299 $type = $p['type']; 300 300 if (strpos($file_name,'/')) return 'Nome de arquivo inválido.'; 301 301 if (!strlen($proc_name)) return 'ID de Processo inválido.'; 302 302 303 303 switch($type) 304 304 { … … 315 315 $path = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources/' . $file_name; 316 316 break; 317 317 318 318 } 319 320 if ($type == 'resource') 319 320 if ($type == 'resource') 321 321 { 322 322 $complete_path = $path; 323 } 324 else 323 } 324 else 325 325 { 326 326 $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 327 327 } 328 329 if (file_exists($complete_path)) 328 329 if (file_exists($complete_path)) 330 330 { 331 331 if (unlink($complete_path)) … … 342 342 return 'O arquivo '.$file_name.' não existe.'; 343 343 } 344 } 345 /** 346 * Create process new file 344 } 345 /** 346 * Create process new file 347 347 * @param array $p process 348 348 * @return array 349 * @access public 349 * @access public 350 350 */ 351 351 function create_file($p) 352 352 { 353 $process_manager = new ProcessManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);354 $proc_info = $process_manager->get_process($p['proc_id']); 353 $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 354 $proc_info = $process_manager->get_process($p['proc_id']); 355 355 $file_name = $p['file_name']; 356 $proc_name = $proc_info['wf_normalized_name']; 356 $proc_name = $proc_info['wf_normalized_name']; 357 357 $type = $p['type']; 358 358 … … 386 386 } 387 387 388 if (file_exists($complete_path)) 389 { 390 if (!$p['rewrite']) 388 if (file_exists($complete_path)) 389 { 390 if (!$p['rewrite']) 391 391 { 392 392 return FILE_ALREADY_EXISTS; … … 396 396 } 397 397 398 if ($fp = fopen($complete_path, 'w')) 398 if ($fp = fopen($complete_path, 'w')) 399 399 { 400 400 $basepath = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'js'.SEP.'adminsource'; … … 409 409 if ($type == 'template' || $type == 'include') 410 410 { 411 if (file_exists($basepath.SEP.$p['modelo'])) 411 if (file_exists($basepath.SEP.$p['modelo'])) 412 412 { 413 413 fwrite($fp,file_get_contents($basepath.SEP.$p['modelo'])); … … 423 423 } 424 424 } 425 425 426 426 /** 427 427 * Get process include files 428 428 * @param array $p process 429 429 * @return array 430 * @access public 430 * @access public 431 431 */ 432 432 function get_include_files($p) 433 433 { 434 $process_manager = new ProcessManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);435 $proc_info = $process_manager->get_process($p['proc_id']); 434 $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 435 $proc_info = $process_manager->get_process($p['proc_id']); 436 436 $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code'; 437 437 … … 442 442 $files = array(); 443 443 444 if ($handle = opendir($path)) 445 { 446 while (false !== ($file_name = readdir($handle))) 447 { 448 if (!is_dir($path.SEP.$file_name)) 444 if ($handle = opendir($path)) 445 { 446 while (false !== ($file_name = readdir($handle))) 447 { 448 if (!is_dir($path.SEP.$file_name)) 449 449 { 450 450 $tamanho = filesize($path.SEP.$file_name); … … 467 467 468 468 469 if (isset($p['sort'])) 469 if (isset($p['sort'])) 470 470 { 471 471 $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; … … 483 483 } 484 484 485 return $files; 486 } 487 488 /** 489 * Get process template files 490 * @param array $p process data 491 * @return array 492 * @access public 485 return $files; 486 } 487 488 /** 489 * Get process template files 490 * @param array $p process data 491 * @return array 492 * @access public 493 493 */ 494 494 function get_template_files($p) 495 495 { 496 $process_manager = new ProcessManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);497 $proc_info = $process_manager->get_process($p['proc_id']); 496 $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 497 $proc_info = $process_manager->get_process($p['proc_id']); 498 498 $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates'; 499 499 … … 502 502 $col_modificado = array(); 503 503 504 if ($handle = opendir($path)) 505 { 506 while (false !== ($file_name = readdir($handle))) 507 { 508 if (!is_dir($path.SEP.$file_name)) 504 if ($handle = opendir($path)) 505 { 506 while (false !== ($file_name = readdir($handle))) 507 { 508 if (!is_dir($path.SEP.$file_name)) 509 509 { 510 510 $tamanho = filesize($path.SEP.$file_name); … … 541 541 542 542 } 543 } 544 545 return $files; 546 } 547 548 /** 549 * Upload process resource 550 * 543 } 544 545 return $files; 546 } 547 548 /** 549 * Upload process resource 550 * 551 551 * @param array $p process 552 552 * @return array 553 * @access public 553 * @access public 554 554 */ 555 555 function upload_resource($p) 556 556 { 557 $process_manager = new ProcessManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);557 $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 558 558 $proc_info = $process_manager->get_process($p['proc_id']); 559 559 $file_name = basename($_FILES['resource_file']['name']); … … 587 587 if (strpos($_REQUEST['file_name'],'/') !== false) 588 588 return 'Não foi possível executar a operação solicitada'; 589 $process_manager = new ProcessManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);589 $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 590 590 $proc_info = $process_manager->get_process($_REQUEST['proc_id']); 591 591 … … 617 617 $completePath = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 618 618 619 $GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($completePath, 'application/force-download');619 Factory::getInstance('ResourcesRedirector')->show($completePath, 'application/force-download'); 620 620 exit; 621 621 } … … 630 630 function get_resource_files($p) 631 631 { 632 $process_manager = new ProcessManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);632 $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 633 633 $proc_info = $process_manager->get_process($p['proc_id']); 634 634
Note: See TracChangeset
for help on using the changeset viewer.