Ignore:
Timestamp:
03/12/10 10:59:32 (14 years ago)
Author:
pedroerp
Message:

Ticket #609 - Migração das classes do módulo workflow para a nova factory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/branches/609/inc/class.bo_adminsource.inc.php

    r795 r2233  
    8080                $fileSizeUnit[] = 'Mb'; 
    8181                $fileSizeUnit[] = 'Gb'; 
    82                  
     82 
    8383                $unitSelect = 0; 
    8484                while ($value > 1024.0) 
     
    8787                        $unitSelect++; 
    8888                } 
    89          
     89 
    9090                $output = round($value, 1); 
    9191                $output .= " " . $fileSizeUnit[$unitSelect]; 
    92          
     92 
    9393                return $output; 
    9494        } 
    95          
     95 
    9696        /** 
    9797        * 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 
    108108                $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 
    111111                if ($proc_info['wf_is_valid'] == 'y') 
    112112                { 
     
    119119                        $alt_validity = tra('invalid'); 
    120120                } 
    121          
     121 
    122122                // 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. 
    123123                if ($proc_info['wf_is_active'] == 'y') 
     
    138138                        $start_stop_img  = ''; 
    139139                } 
    140          
     140 
    141141                /* load other processes link */ 
    142142                $proc_ids = $GLOBALS['ajax']->acl->get_granted_processes($_SESSION['phpgw_info']['workflow']['account_id']); 
     
    145145                else 
    146146                        $where = ' wf_p_id = -1 '; 
    147          
     147 
    148148                $processesInfo = &$process_manager->list_processes(0, -1, 'wf_name__asc', '', $where); 
    149149                $otherProcesses = array(); 
    150150                foreach ($processesInfo['data'] as $pi) 
    151151                        $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 
    153153                $toolbar_data = array ( 
    154154                        'proc_name'                                     => $proc_info['wf_name'], 
     
    177177                        'other_processes'                       => $otherProcesses 
    178178                ); 
    179                          
     179 
    180180                return $toolbar_data; 
    181181                } 
    182                  
    183                  
     182 
     183 
    184184        /** 
    185185        * 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 
    189189        */ 
    190190        function get_model_files($p) 
    191191        { 
    192                 switch($p['type'])  
     192                switch($p['type']) 
    193193                { 
    194194                        case 'include'  : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'adminsource' . SEP . 'inc'; 
     
    203203                $files          = array(); 
    204204 
    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)) 
    210210                                { 
    211211                                        $files[] = array('file_name'     => $file_name); 
     
    217217                array_multisort($col_file_name,SORT_ASC,$files); 
    218218 
    219                 return $files;  
     219                return $files; 
    220220        } 
    221221 
    222222        /** 
    223223        * 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 
    227227        */ 
    228228        function get_php_files($p) 
    229229        { 
    230                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     230                $process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    231231                $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); 
    233233                $process_activities = $activity_manager->list_activities($p['proc_id'], 0, -1, 'wf_name__asc', '','',false); 
    234234                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'activities' . SEP; 
    235                  
     235 
    236236                $files = array(); 
    237237 
     
    242242                foreach ($process_activities['data'] as $process_activity) 
    243243                { 
    244                          
     244 
    245245                        $file_name   = $process_activity['wf_normalized_name'].'.php'; 
    246246                        $activity_id = $process_activity['wf_activity_id']; 
    247247                        $tamanho     = filesize($path.$file_name); 
    248248                        $modificado  = date('d/m/Y H:i:s', filemtime($path.$file_name) ); 
    249                          
     249 
    250250                        $files[] = array('file_name'     => $file_name, 
    251251                                                         'activity_id'   => $activity_id, 
     
    258258                                                         'tipo_codigo'   => 'atividade' 
    259259                        ); 
    260                          
     260 
    261261                        $col_file_name[]  = $file_name; 
    262262                        $col_tamanho[]    = $tamanho; 
    263263                        $col_modificado[] = $modificado; 
    264264                } 
    265                  
    266                 if (isset($p['sort']))  
     265 
     266                if (isset($p['sort'])) 
    267267                { 
    268268                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; 
     
    279279                        } 
    280280                } 
    281                  
    282                 return $files;  
    283         } 
    284          
    285         /** 
    286         * Delete process file  
     281 
     282                return $files; 
     283        } 
     284 
     285        /** 
     286        * Delete process file 
    287287        * @param array $p process data 
    288288        * @return array 
    289         * @access public  
     289        * @access public 
    290290        */ 
    291291        function delete_file($p) 
     
    293293                if ((strpos($p['file_name'],'/') !== false) || (strpos($p['file_name'],'/') !== false)) 
    294294                        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']); 
    297297                $file_name = $p['file_name']; 
    298                 $proc_name = $proc_info['wf_normalized_name'];  
     298                $proc_name = $proc_info['wf_normalized_name']; 
    299299                $type      = $p['type']; 
    300300                if (strpos($file_name,'/')) return 'Nome de arquivo inválido.'; 
    301301                if (!strlen($proc_name)) return 'ID de Processo inválido.'; 
    302                  
     302 
    303303    switch($type) 
    304304    { 
     
    315315                                $path = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources/' . $file_name; 
    316316            break; 
    317                          
     317 
    318318    } 
    319     
    320                 if ($type == 'resource')  
     319 
     320                if ($type == 'resource') 
    321321                { 
    322322                        $complete_path = $path; 
    323                 }  
    324                 else  
     323                } 
     324                else 
    325325                { 
    326326                        $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 
    327327                } 
    328          
    329                 if (file_exists($complete_path))  
     328 
     329                if (file_exists($complete_path)) 
    330330                { 
    331331                        if (unlink($complete_path)) 
     
    342342                        return 'O arquivo '.$file_name.' não existe.'; 
    343343                } 
    344         }        
    345         /** 
    346         * Create process new file  
     344        } 
     345        /** 
     346        * Create process new file 
    347347        * @param array $p process 
    348348        * @return array 
    349         * @access public  
     349        * @access public 
    350350        */ 
    351351        function create_file($p) 
    352352        { 
    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']); 
    355355                $file_name = $p['file_name']; 
    356                 $proc_name = $proc_info['wf_normalized_name'];  
     356                $proc_name = $proc_info['wf_normalized_name']; 
    357357                $type      = $p['type']; 
    358358 
     
    386386                } 
    387387 
    388                 if (file_exists($complete_path))  
    389                 { 
    390                         if (!$p['rewrite'])  
     388                if (file_exists($complete_path)) 
     389                { 
     390                        if (!$p['rewrite']) 
    391391                        { 
    392392                                return FILE_ALREADY_EXISTS; 
     
    396396                } 
    397397 
    398                 if ($fp = fopen($complete_path, 'w'))  
     398                if ($fp = fopen($complete_path, 'w')) 
    399399                { 
    400400                        $basepath = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'js'.SEP.'adminsource'; 
     
    409409                        if ($type == 'template' || $type == 'include') 
    410410                        { 
    411                                 if (file_exists($basepath.SEP.$p['modelo']))  
     411                                if (file_exists($basepath.SEP.$p['modelo'])) 
    412412                                { 
    413413                                        fwrite($fp,file_get_contents($basepath.SEP.$p['modelo'])); 
     
    423423                } 
    424424        } 
    425          
     425 
    426426        /** 
    427427        * Get process include files 
    428428        * @param  array $p process 
    429429        * @return array 
    430         * @access public  
     430        * @access public 
    431431        */ 
    432432        function get_include_files($p) 
    433433        { 
    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']); 
    436436                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code'; 
    437437 
     
    442442                $files          = array(); 
    443443 
    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)) 
    449449                                { 
    450450                                        $tamanho     = filesize($path.SEP.$file_name); 
     
    467467 
    468468 
    469                 if (isset($p['sort']))  
     469                if (isset($p['sort'])) 
    470470                { 
    471471                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; 
     
    483483                } 
    484484 
    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 
    493493        */ 
    494494        function get_template_files($p) 
    495495        { 
    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']); 
    498498                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates'; 
    499499 
     
    502502                $col_modificado = array(); 
    503503 
    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)) 
    509509                                { 
    510510                                        $tamanho     = filesize($path.SEP.$file_name); 
     
    541541 
    542542        } 
    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        * 
    551551        * @param array $p process 
    552552        * @return array 
    553         * @access public  
     553        * @access public 
    554554        */ 
    555555        function upload_resource($p) 
    556556        { 
    557                 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     557                $process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    558558                $proc_info = $process_manager->get_process($p['proc_id']); 
    559559                $file_name = basename($_FILES['resource_file']['name']); 
     
    587587                if (strpos($_REQUEST['file_name'],'/') !== false) 
    588588                        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); 
    590590                $proc_info          = $process_manager->get_process($_REQUEST['proc_id']); 
    591591 
     
    617617                        $completePath = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 
    618618 
    619                 $GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($completePath, 'application/force-download'); 
     619                Factory::getInstance('ResourcesRedirector')->show($completePath, 'application/force-download'); 
    620620                exit; 
    621621        } 
     
    630630        function get_resource_files($p) 
    631631        { 
    632                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     632                $process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    633633                $proc_info          = $process_manager->get_process($p['proc_id']); 
    634634 
Note: See TracChangeset for help on using the changeset viewer.