Ignore:
Timestamp:
08/17/10 16:17:12 (14 years ago)
Author:
viani
Message:

Ticket #1135 - Merged r1990:3166 from /trunk/workflow into /branches/2.2/workflow

File:
1 edited

Legend:

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

    r795 r3167  
    1111 
    1212require_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'); 
    1813 
    1914/** 
     
    8075                $fileSizeUnit[] = 'Mb'; 
    8176                $fileSizeUnit[] = 'Gb'; 
    82                  
     77 
    8378                $unitSelect = 0; 
    8479                while ($value > 1024.0) 
     
    8782                        $unitSelect++; 
    8883                } 
    89          
     84 
    9085                $output = round($value, 1); 
    9186                $output .= " " . $fileSizeUnit[$unitSelect]; 
    92          
     87 
    9388                return $output; 
    9489        } 
    95          
     90 
    9691        /** 
    9792        * 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 
    108103                $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 
    111106                if ($proc_info['wf_is_valid'] == 'y') 
    112107                { 
     
    119114                        $alt_validity = tra('invalid'); 
    120115                } 
    121          
     116 
    122117                // 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. 
    123118                if ($proc_info['wf_is_active'] == 'y') 
     
    138133                        $start_stop_img  = ''; 
    139134                } 
    140          
     135 
    141136                /* load other processes link */ 
    142137                $proc_ids = $GLOBALS['ajax']->acl->get_granted_processes($_SESSION['phpgw_info']['workflow']['account_id']); 
     
    145140                else 
    146141                        $where = ' wf_p_id = -1 '; 
    147          
     142 
    148143                $processesInfo = &$process_manager->list_processes(0, -1, 'wf_name__asc', '', $where); 
    149144                $otherProcesses = array(); 
    150145                foreach ($processesInfo['data'] as $pi) 
    151146                        $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 
    153148                $toolbar_data = array ( 
    154149                        'proc_name'                                     => $proc_info['wf_name'], 
     
    177172                        'other_processes'                       => $otherProcesses 
    178173                ); 
    179                          
     174 
    180175                return $toolbar_data; 
    181176                } 
    182                  
    183                  
     177 
     178 
    184179        /** 
    185180        * 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 
    189184        */ 
    190185        function get_model_files($p) 
    191186        { 
    192                 switch($p['type'])  
     187                switch($p['type']) 
    193188                { 
    194189                        case 'include'  : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'adminsource' . SEP . 'inc'; 
     
    203198                $files          = array(); 
    204199 
    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)) 
    210205                                { 
    211206                                        $files[] = array('file_name'     => $file_name); 
     
    217212                array_multisort($col_file_name,SORT_ASC,$files); 
    218213 
    219                 return $files;  
     214                return $files; 
    220215        } 
    221216 
    222217        /** 
    223218        * 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 
    227222        */ 
    228223        function get_php_files($p) 
    229224        { 
    230                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     225                $process_manager    = &Factory::newInstance('ProcessManager'); 
    231226                $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'); 
    233228                $process_activities = $activity_manager->list_activities($p['proc_id'], 0, -1, 'wf_name__asc', '','',false); 
    234229                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'activities' . SEP; 
    235                  
     230 
    236231                $files = array(); 
    237232 
     
    242237                foreach ($process_activities['data'] as $process_activity) 
    243238                { 
    244                          
     239 
    245240                        $file_name   = $process_activity['wf_normalized_name'].'.php'; 
    246241                        $activity_id = $process_activity['wf_activity_id']; 
    247242                        $tamanho     = filesize($path.$file_name); 
    248243                        $modificado  = date('d/m/Y H:i:s', filemtime($path.$file_name) ); 
    249                          
     244 
    250245                        $files[] = array('file_name'     => $file_name, 
    251246                                                         'activity_id'   => $activity_id, 
     
    258253                                                         'tipo_codigo'   => 'atividade' 
    259254                        ); 
    260                          
     255 
    261256                        $col_file_name[]  = $file_name; 
    262257                        $col_tamanho[]    = $tamanho; 
    263258                        $col_modificado[] = $modificado; 
    264259                } 
    265                  
    266                 if (isset($p['sort']))  
     260 
     261                if (isset($p['sort'])) 
    267262                { 
    268263                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; 
     
    279274                        } 
    280275                } 
    281                  
    282                 return $files;  
    283         } 
    284          
    285         /** 
    286         * Delete process file  
     276 
     277                return $files; 
     278        } 
     279 
     280        /** 
     281        * Delete process file 
    287282        * @param array $p process data 
    288283        * @return array 
    289         * @access public  
     284        * @access public 
    290285        */ 
    291286        function delete_file($p) 
     
    293288                if ((strpos($p['file_name'],'/') !== false) || (strpos($p['file_name'],'/') !== false)) 
    294289                        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']); 
    297292                $file_name = $p['file_name']; 
    298                 $proc_name = $proc_info['wf_normalized_name'];  
     293                $proc_name = $proc_info['wf_normalized_name']; 
    299294                $type      = $p['type']; 
    300295                if (strpos($file_name,'/')) return 'Nome de arquivo inválido.'; 
    301296                if (!strlen($proc_name)) return 'ID de Processo inválido.'; 
    302                  
     297 
    303298    switch($type) 
    304299    { 
     
    315310                                $path = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources/' . $file_name; 
    316311            break; 
    317                          
     312 
    318313    } 
    319     
    320                 if ($type == 'resource')  
     314 
     315                if ($type == 'resource') 
    321316                { 
    322317                        $complete_path = $path; 
    323                 }  
    324                 else  
     318                } 
     319                else 
    325320                { 
    326321                        $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 
    327322                } 
    328          
    329                 if (file_exists($complete_path))  
     323 
     324                if (file_exists($complete_path)) 
    330325                { 
    331326                        if (unlink($complete_path)) 
     
    342337                        return 'O arquivo '.$file_name.' não existe.'; 
    343338                } 
    344         }        
    345         /** 
    346         * Create process new file  
     339        } 
     340        /** 
     341        * Create process new file 
    347342        * @param array $p process 
    348343        * @return array 
    349         * @access public  
     344        * @access public 
    350345        */ 
    351346        function create_file($p) 
    352347        { 
    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']); 
    355350                $file_name = $p['file_name']; 
    356                 $proc_name = $proc_info['wf_normalized_name'];  
     351                $proc_name = $proc_info['wf_normalized_name']; 
    357352                $type      = $p['type']; 
    358353 
     
    386381                } 
    387382 
    388                 if (file_exists($complete_path))  
    389                 { 
    390                         if (!$p['rewrite'])  
     383                if (file_exists($complete_path)) 
     384                { 
     385                        if (!$p['rewrite']) 
    391386                        { 
    392387                                return FILE_ALREADY_EXISTS; 
     
    396391                } 
    397392 
    398                 if ($fp = fopen($complete_path, 'w'))  
     393                if ($fp = fopen($complete_path, 'w')) 
    399394                { 
    400395                        $basepath = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'js'.SEP.'adminsource'; 
     
    409404                        if ($type == 'template' || $type == 'include') 
    410405                        { 
    411                                 if (file_exists($basepath.SEP.$p['modelo']))  
     406                                if (file_exists($basepath.SEP.$p['modelo'])) 
    412407                                { 
    413408                                        fwrite($fp,file_get_contents($basepath.SEP.$p['modelo'])); 
     
    423418                } 
    424419        } 
    425          
     420 
    426421        /** 
    427422        * Get process include files 
    428423        * @param  array $p process 
    429424        * @return array 
    430         * @access public  
     425        * @access public 
    431426        */ 
    432427        function get_include_files($p) 
    433428        { 
    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']); 
    436431                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code'; 
    437432 
     
    442437                $files          = array(); 
    443438 
    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)) 
    449444                                { 
    450445                                        $tamanho     = filesize($path.SEP.$file_name); 
     
    467462 
    468463 
    469                 if (isset($p['sort']))  
     464                if (isset($p['sort'])) 
    470465                { 
    471466                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; 
     
    483478                } 
    484479 
    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 
    493488        */ 
    494489        function get_template_files($p) 
    495490        { 
    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']); 
    498493                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates'; 
    499494 
     
    502497                $col_modificado = array(); 
    503498 
    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)) 
    509504                                { 
    510505                                        $tamanho     = filesize($path.SEP.$file_name); 
     
    541536 
    542537        } 
    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        * 
    551546        * @param array $p process 
    552547        * @return array 
    553         * @access public  
     548        * @access public 
    554549        */ 
    555550        function upload_resource($p) 
    556551        { 
    557                 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     552                $process_manager = &Factory::newInstance('ProcessManager'); 
    558553                $proc_info = $process_manager->get_process($p['proc_id']); 
    559554                $file_name = basename($_FILES['resource_file']['name']); 
     
    587582                if (strpos($_REQUEST['file_name'],'/') !== false) 
    588583                        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'); 
    590585                $proc_info          = $process_manager->get_process($_REQUEST['proc_id']); 
    591586 
     
    617612                        $completePath = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 
    618613 
    619                 $GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($completePath, 'application/force-download'); 
     614                Factory::getInstance('ResourcesRedirector')->show($completePath, 'application/force-download'); 
    620615                exit; 
    621616        } 
     
    630625        function get_resource_files($p) 
    631626        { 
    632                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     627                $process_manager    = &Factory::newInstance('ProcessManager'); 
    633628                $proc_info          = $process_manager->get_process($p['proc_id']); 
    634629 
Note: See TracChangeset for help on using the changeset viewer.