source: branches/1.2/workflow/inc/class.bo_adminsource.inc.php @ 1349

Revision 1349, 20.3 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
1<?php
2/**************************************************************************\
3* eGroupWare                                                                   *
4* http://www.egroupware.org                                                *
5* --------------------------------------------                             *
6*  This program is free software; you can redistribute it and/or modify it *
7*  under the terms of the GNU General Public License as published by the   *
8*  Free Software Foundation; either version 2 of the License, or (at your  *
9*  option) any later version.                                              *
10\**************************************************************************/
11
12require_once('class.bo_ajaxinterface.inc.php');
13
14require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php');
15require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'RoleManager.php');
16require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
17require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Process.php');
18
19/**
20 * Invalid file name identifier
21 * @name INVALID_FILE_NAME
22 */
23define( INVALID_FILE_NAME   , 0 );
24/**
25 * Invalid process id identifier
26 * @name INVALID_PROCESS_ID
27 */
28define( INVALID_PROCESS_ID  , 1 );
29/**
30 * File already exists identifier
31 * @name FILE_ALREADY_EXISTS
32 */
33define( FILE_ALREADY_EXISTS , 2 );
34/**
35 * File created indentifier
36 * @name FILE_CREATED
37 */
38define( FILE_CREATED            , 3 );
39/**
40 * File not created identifier
41 * @name FILE_NOT_CREATED
42 */
43define( FILE_NOT_CREATED        , 4 );
44/**
45 * @package Workflow
46 * @license http://www.gnu.org/copyleft/gpl.html GPL
47 * @author Rodrigo Daniel C de Lira - rodrigo.lira@gmail.com
48 * @author Sidnei Augusto Drovetto Junior - drovetto@gmail.com
49 */
50class bo_adminsource extends bo_ajaxinterface
51{
52
53        /**
54        * @var array $public_functions Array of public functions
55        * @access public
56        */
57        var $public_functions = array('export_file' => true
58                                      );
59       
60        /**
61        * Construtor
62        *
63        * @access public
64        */     
65        function bo_adminsource() {
66                parent::bo_ajaxinterface();             
67                }
68       
69        /**
70        * Assign Unit To File Size
71        * @param integer $value value
72        * @return string file size
73        * @access public
74        */
75        function _assignUnitToFileSize($value)
76        {
77                $fileSizeUnit = array();
78                $fileSizeUnit[] = 'bytes';
79                $fileSizeUnit[] = 'Kb';
80                $fileSizeUnit[] = 'Mb';
81                $fileSizeUnit[] = 'Gb';
82               
83                $unitSelect = 0;
84                while ($value > 1024.0)
85                {
86                        $value /= 1024.0;
87                        $unitSelect++;
88                }
89       
90                $output = round($value, 1);
91                $output .= " " . $fileSizeUnit[$unitSelect];
92       
93                return $output;
94        }
95       
96        /**
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               
108                $web_server_url  = $_SESSION['phpgw_info']['workflow']['server']['webserver_url'];
109                $img_default_dir = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink('');
110               
111                if ($proc_info['wf_is_valid'] == 'y')
112                {
113                        $dot_color = 'green';
114                        $alt_validity = tra('valid');
115                }
116                else
117                {
118                        $dot_color = 'red';
119                        $alt_validity = tra('invalid');
120                }
121       
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                if ($proc_info['wf_is_active'] == 'y')
124                {
125                        $start_stop_link = $web_server_url.'/index.php?menuaction=workflow.ui_adminactivities.form&p_id='. $proc_info['wf_p_id'] .'&deactivate_proc='. $proc_info['wf_p_id'];
126                        $start_stop_img  = $img_default_dir.'stop.gif';
127                        $start_stop_desc = 'Parar';
128                }
129                elseif ($proc_info['wf_is_valid'] == 'y')
130                {
131                        $start_stop_link = $web_server_url.'/index.php?menuaction=workflow.ui_adminactivities.form&p_id='. $proc_info['wf_p_id'] .'&activate_proc='. $proc_info['wf_p_id'];
132                        $start_stop_img  = $img_default_dir.'refresh2.gif';
133                        $start_stop_desc = 'Ativar';
134                }
135                else
136                {
137                        $start_stop_link = '';
138                        $start_stop_img  = '';
139                }
140       
141                /* load other processes link */
142                $proc_ids = $GLOBALS['ajax']->acl->get_granted_processes($_SESSION['phpgw_info']['workflow']['account_id']);
143                if (count($proc_ids))
144                        $where = ' wf_p_id in ('. implode(',',$proc_ids) .') ';
145                else
146                        $where = ' wf_p_id = -1 ';
147       
148                $processesInfo = &$process_manager->list_processes(0, -1, 'wf_name__asc', '', $where);
149                $otherProcesses = array();
150                foreach ($processesInfo['data'] as $pi)
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       
153                $toolbar_data = array (
154                        'proc_name'                                     => $proc_info['wf_name'],
155                        'version'                                       => $proc_info['wf_version'],
156                        'img_validity'                          => $img_default_dir.$dot_color.'_dot.gif',
157                        'alt_validity'                          => $alt_validity,
158                        'start_stop_link'                       => $start_stop_link,
159                        'start_stop_img'                        => $start_stop_img,
160                        'start_stop_desc'                       => $start_stop_desc,
161                        'link_admin_activities'         => $web_server_url.'/index.php?menuaction=workflow.ui_adminactivities.form&p_id='. $proc_info['wf_p_id'],
162                        'img_activity'                          => $img_default_dir.'Activity.gif',
163                        'link_admin_jobs'               => $web_server_url.'/index.php?menuaction=workflow.ui_adminjobs.form&p_id='. $proc_info['wf_p_id'],
164                        'img_job'                               => $img_default_dir.'clock.png',
165                        'link_admin_processes'          => $web_server_url.'/index.php?menuaction=workflow.ui_adminprocesses.form&p_id='. $proc_info['wf_p_id'],
166                        'img_change'                            => $img_default_dir.'change.gif',
167                        'link_admin_shared_source'      => $web_server_url.'/index.php?menuaction=workflow.ui_adminsource.form&p_id='. $proc_info['wf_p_id'],
168                        'img_code'                                      => $img_default_dir.'code.gif',
169                        'link_admin_export'                     => $web_server_url.'/index.php?menuaction=workflow.WorkflowUtils.export&p_id='. $proc_info['wf_p_id'],
170                        'link_admin_roles'                      => $web_server_url.'/index.php?menuaction=workflow.ui_adminroles.form&p_id='. $proc_info['wf_p_id'],
171                        'img_roles'                                     => $img_default_dir.'roles.png',
172                        'link_graph'                            => $web_server_url.'/index.php?menuaction=workflow.ui_adminactivities.show_graph&p_id=' . $proc_info['wf_p_id'],
173                        'img_process'                           => $img_default_dir.'Process.gif',
174                        'link_save_process'                     => $web_server_url.'/index.php?menuaction=workflow.ui_adminprocesses.save_process&id='. $proc_info['wf_p_id'],
175                        'img_save'                                      => $img_default_dir.'save.png',
176                        'proc_id'                                       => $p['proc_id'],
177                        'other_processes'                       => $otherProcesses
178                );
179                       
180                return $toolbar_data;
181                }
182               
183               
184        /**
185        * Get process model files
186        * @param  array $p process process data
187        * @return array
188        * @access public
189        */
190        function get_model_files($p)
191        {
192                switch($p['type'])
193                {
194                        case 'include'  : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'adminsource' . SEP . 'inc';
195                                                          break;
196                        case 'template' : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'adminsource' . SEP . 'templates';
197                                                          break;
198                        case 'js'       : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'local';
199                                                          break;
200                }
201
202                $col_file_name  = array();
203                $files          = array();
204
205                if ($handle = opendir($path))
206                {
207                        while (false !== ($file_name = readdir($handle)))
208                        {       
209                                if (!is_dir($path.SEP.$file_name))
210                                {
211                                        $files[] = array('file_name'     => $file_name);
212                                        $col_file_name[]  = $file_name;
213                                }
214                        }
215                }
216
217                array_multisort($col_file_name,SORT_ASC,$files);
218
219                return $files;
220        }
221
222        /**
223        * Get process php files
224        * @param array $p process data
225        * @return array
226        * @access public
227        */
228        function get_php_files($p)
229        {
230                $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
231                $proc_info          = $process_manager->get_process($p['proc_id']);
232                $activity_manager   = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
233                $process_activities = $activity_manager->list_activities($p['proc_id'], 0, -1, 'wf_name__asc', '','',false);
234                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'activities' . SEP;
235               
236                $files = array();
237
238                $col_file_name  = array();
239                $col_tamanho    = array();
240                $col_modificado = array();
241
242                foreach ($process_activities['data'] as $process_activity)
243                {
244                       
245                        $file_name   = $process_activity['wf_normalized_name'].'.php';
246                        $activity_id = $process_activity['wf_activity_id'];
247                        $tamanho     = filesize($path.$file_name);
248                        $modificado  = date('d/m/Y H:i:s', filemtime($path.$file_name) );
249                       
250                        $files[] = array('file_name'     => $file_name,
251                                                         'activity_id'   => $activity_id,
252                                                         'tamanho'           => $this->_assignUnitToFileSize($tamanho),
253                                                         'modificado'    => $modificado,
254                                                         'tipo_atividade'=> $process_activity['wf_type'],
255                                                         'interativa'    => $process_activity['wf_is_interactive'],
256                                                         'proc_name'     => $proc_info['wf_normalized_name'],
257                                                         'proc_id'               => $proc_info['wf_p_id'],
258                                                         'tipo_codigo'   => 'atividade'
259                        );
260                       
261                        $col_file_name[]  = $file_name;
262                        $col_tamanho[]    = $tamanho;
263                        $col_modificado[] = $modificado;
264                }
265               
266                if (isset($p['sort']))
267                {
268                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC;
269
270                        switch ($p['sort'])
271                        {
272                                case 'file_name' :  array_multisort($col_file_name,$order_by,$files);
273                                                                        break;
274                                case 'tamanho'   :  array_multisort($col_tamanho,SORT_NUMERIC,$order_by,$files);
275                                                                        break;
276                                case 'modificado':  array_multisort($col_modificado,$order_by,$files);
277                                                                        break;
278
279                        }
280                }
281               
282                return $files;
283        }
284       
285        /**
286        * Delete process file
287        * @param array $p process data
288        * @return array
289        * @access public
290        */
291        function delete_file($p)
292        {
293                if ((strpos($p['file_name'],'/') !== false) || (strpos($p['file_name'],'/') !== false))
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']);
297                $file_name = $p['file_name'];
298                $proc_name = $proc_info['wf_normalized_name'];
299                $type      = $p['type'];
300                if (strpos($file_name,'/')) return 'Nome de arquivo inválido.';
301                if (!strlen($proc_name)) return 'ID de Processo inválido.';
302               
303    switch($type)
304    {
305        case 'atividade':
306            $path =  'activities' . SEP . $file_name;
307            break;
308            case 'template':
309            $path =  'templates' . SEP . $file_name;
310            break;
311        case 'include':
312            $path = $file_name;
313            break;
314                case 'resource':
315                                $path = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources/' . $file_name;
316            break;
317                       
318    }
319   
320                if ($type == 'resource')
321                {
322                        $complete_path = $path;
323                }
324                else
325                {
326                        $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path;
327                }
328       
329                if (file_exists($complete_path))
330                {
331                        if (unlink($complete_path))
332                        {
333                                return 'Arquivo '.$file_name.' excluido com sucesso.';
334                        }
335                        else
336                        {
337                                return 'Não foi possivel excluir o arquivo '.$file_name.'.';
338                        }
339    }
340                else
341                {
342                        return 'O arquivo '.$file_name.' não existe.';
343                }
344        }       
345        /**
346        * Create process new file
347        * @param array $p process
348        * @return array
349        * @access public
350        */
351        function create_file($p)
352        {
353                $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
354                $proc_info = $process_manager->get_process($p['proc_id']);
355                $file_name = $p['file_name'];
356                $proc_name = $proc_info['wf_normalized_name'];
357                $type      = $p['type'];
358
359                if ((strpos($file_name,'/') !== false) || (strpos($file_name,'/') !== false))
360                {
361                        return INVALID_FILE_NAME;
362                }
363
364                if (!strlen($proc_name))
365                {
366                        return INVALID_PROCESS_ID;
367                }
368
369                switch($type)
370                {
371                        case 'atividade':
372                                $path =  'activities' . SEP . $file_name;
373                                $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path;
374                                break;
375                        case 'template':
376                                $path =  'templates' . SEP . $file_name;
377                                $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path;
378                                break;
379                        case 'include':
380                                $path = $file_name;
381                                $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path;
382                                break;
383                        case 'resource':
384                                $complete_path = GALAXIA_PROCESSES . '/' . $proc_name . '/resources/' . $file_name;
385                                break;
386                }
387
388                if (file_exists($complete_path))
389                {
390                        if (!$p['rewrite'])
391                        {
392                                return FILE_ALREADY_EXISTS;
393                        } else {
394                                unlink($complete_path);
395                        }
396                }
397
398                if ($fp = fopen($complete_path, 'w'))
399                {
400                        $basepath = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'js'.SEP.'adminsource';
401                        switch ($type)
402                        {
403                        case 'template':  $basepath = $basepath.SEP.'templates';
404                                break;
405                        case 'include' :  $basepath = $basepath.SEP.'inc';
406                                break;
407                        }
408
409                        if ($type == 'template' || $type == 'include')
410                        {
411                                if (file_exists($basepath.SEP.$p['modelo']))
412                                {
413                                        fwrite($fp,file_get_contents($basepath.SEP.$p['modelo']));
414                                }
415                        }
416
417                        fclose($fp);
418                        return FILE_CREATED;
419                }
420                else
421                {
422                        return FILE_NOT_CREATED;
423                }
424        }
425       
426        /**
427        * Get process include files
428        * @param  array $p process
429        * @return array
430        * @access public
431        */
432        function get_include_files($p)
433        {
434                $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
435                $proc_info          = $process_manager->get_process($p['proc_id']);
436                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code';
437
438
439                $col_file_name  = array();
440                $col_tamanho    = array();
441                $col_modificado = array();
442                $files          = array();
443
444                if ($handle = opendir($path))
445                {
446                        while (false !== ($file_name = readdir($handle)))
447                        {       
448                                if (!is_dir($path.SEP.$file_name))
449                                {
450                                        $tamanho     = filesize($path.SEP.$file_name);
451                                        $modificado  = date('d/m/Y H:i:s', filemtime($path.SEP.$file_name) );
452
453                                        $files[] = array('file_name'     => $file_name,
454                                                         'tamanho'           => $this->_assignUnitToFileSize($tamanho),
455                                                         'modificado'    => $modificado,
456                                                         'proc_name'     => $proc_info['wf_normalized_name'],
457                                                         'proc_id'               => $proc_info['wf_p_id'],
458                                                         'tipo_codigo'   => 'include'
459                                        );
460
461                                        $col_file_name[]  = $file_name;
462                                        $col_tamanho[]    = $tamanho;
463                                        $col_modificado[] = $modificado;
464                                }
465                        }
466                }
467
468
469                if (isset($p['sort']))
470                {
471                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC;
472
473                        switch ($p['sort'])
474                        {
475                                case 'file_name' :  array_multisort($col_file_name,$order_by,$files);
476                                                                        break;
477                                case 'tamanho'   :  array_multisort($col_tamanho,SORT_NUMERIC,$order_by,$files);
478                                                                        break;
479                                case 'modificado':  array_multisort($col_modificado,$order_by,$files);
480                                                                        break;
481
482                        }
483                }
484
485                return $files;
486        }
487
488        /**
489        * Get process template files
490        * @param array $p process data
491        * @return array
492        * @access public
493        */
494        function get_template_files($p)
495        {
496                $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
497                $proc_info          = $process_manager->get_process($p['proc_id']);
498                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates';
499
500                $col_file_name  = array();
501                $col_tamanho    = array();
502                $col_modificado = array();
503
504                if ($handle = opendir($path))
505                {
506                        while (false !== ($file_name = readdir($handle)))
507                        {       
508                                if (!is_dir($path.SEP.$file_name))
509                                {
510                                        $tamanho     = filesize($path.SEP.$file_name);
511                                        $modificado  = date('d/m/Y H:i:s', filemtime($path.SEP.$file_name) );
512
513                                        $files[] = array('file_name'     => $file_name,
514                                                         'tamanho'           => $this->_assignUnitToFileSize($tamanho),
515                                                         'modificado'    => $modificado,
516                                                         'proc_name'     => $proc_info['wf_normalized_name'],
517                                                         'proc_id'               => $proc_info['wf_p_id'],
518                                                         'tipo_codigo'   => 'template'
519                                        );
520
521                                        $col_file_name[]  = $file_name;
522                                        $col_tamanho[]    = $tamanho;
523                                        $col_modificado[] = $modificado;
524
525                                }
526                        }
527                }
528
529                if (isset($p['sort']))
530    {
531        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC;
532
533        switch ($p['sort'])
534        {
535            case 'file_name' :  array_multisort($col_file_name,$order_by,$files);
536                                break;
537            case 'tamanho'   :  array_multisort($col_tamanho,SORT_NUMERIC,$order_by,$files);
538                                break;
539            case 'modificado':  array_multisort($col_modificado,$order_by,$files);
540                                break;
541
542        }
543    }   
544
545                return $files;
546        }
547
548        /**
549        * Upload process resource 
550        *
551        * @param array $p process
552        * @return array
553        * @access public
554        */
555        function upload_resource($p)
556        {
557                $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
558                $proc_info = $process_manager->get_process($p['proc_id']);
559                $file_name = basename($_FILES['resource_file']['name']);
560
561                $base_path = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources';
562                $path = $base_path . '/' . $file_name;
563
564
565                if (!strlen($file_name))
566                        return 'É necessário selecionar um arquivo.';
567
568                if (!is_dir($base_path))
569                        return 'A pasta de resources ainda não foi criada no servidor.';
570
571                if (file_exists($path))
572                        return 'O arquivo '.$file_name.' já existe no servidor.';
573
574                if (move_uploaded_file($_FILES['resource_file']['tmp_name'],$path))
575                        return 'Upload realizado com sucesso.';
576                else
577                        return 'Não foi possível realizar upload do arquivo '.$file_name.'.';
578        }
579
580        /**
581        * Export process file
582        *
583        * @access public
584        */
585        function export_file()
586        {
587                if (strpos($_REQUEST['file_name'],'/') !== false)
588                        return 'Não foi possível executar a operação solicitada';
589                $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
590                $proc_info          = $process_manager->get_process($_REQUEST['proc_id']);
591
592                $proc_name = $proc_info['wf_normalized_name'];
593                $file_name = $_REQUEST['file_name'];
594                $type      = $_REQUEST['type'];
595
596                switch($type)
597                {
598                        case 'atividade':
599                                $path =  'activities' . SEP . $file_name;
600                                break;
601                        case 'template':
602                                $path =  'templates' . SEP . $file_name;
603                                break;
604                        case 'resource':
605                                $path = 'resources' . SEP . $file_name;
606                                break;
607                        case 'include':
608                                $path = $file_name;
609                                break;
610                        default:
611                                exit;
612                }
613
614                if ($type == 'resource')
615                        $completePath = GALAXIA_PROCESSES . SEP . $proc_name . SEP . $path;
616                else
617                        $completePath = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path;
618
619                $GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($completePath, 'application/force-download');
620                exit;
621        }
622
623        /**
624        * Get process resources files
625        *
626        * @param array $p process
627        * @return array
628        * @access public
629        */
630        function get_resource_files($p)
631        {
632                $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
633                $proc_info          = $process_manager->get_process($p['proc_id']);
634
635                $path       = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources';
636
637                if (!is_dir($path))
638                        mkdir($path, 0770);
639
640                $col_file_name  = array();
641                $col_tamanho    = array();
642                $col_modificado = array();
643                $col_tipo               = array();
644
645                if ($handle = opendir($path))
646                {
647                        while (false !== ($file_name = readdir($handle)))
648                        {
649                                if (!is_dir($path.SEP.$file_name))
650                                {
651                                        $tipo        = mime_content_type($path.SEP.$file_name);
652                                        $tamanho     = filesize($path.SEP.$file_name);
653                                        $modificado  = date('d/m/Y H:i:s', filemtime($path.SEP.$file_name) );
654
655                                        $files[] = array(
656                                                         'file_name'     => $file_name,
657                                                         'proc_name'     => $proc_info['wf_normalized_name'],
658                                                         'proc_id'               => $proc_info['wf_p_id'],
659                                                         'tamanho'           => $this->_assignUnitToFileSize($tamanho),
660                                                         'tipo'              => $tipo,
661                                                         'modificado'    => $modificado,
662                                                         'tipo_arquivo'  => 'resource'
663                                        );
664
665                                        $col_file_name[]  = $file_name;
666                                        $col_tamanho[]    = $tamanho;
667                                        $col_modificado[] = $modificado;
668                                        $col_tipo[]       = $tipo;
669
670                                }
671                        }
672                }
673
674                if (isset($p['sort']))
675                {
676                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC;
677
678                        switch ($p['sort'])
679                        {
680                                case 'file_name' :  array_multisort($col_file_name,$order_by,$files);
681                                                                        break;
682                                case 'tamanho'   :  array_multisort($col_tamanho,SORT_NUMERIC,$order_by,$files);
683                                                                        break;
684                                case 'modificado':  array_multisort($col_modificado,$order_by,$files);
685                                                                        break;
686                                case 'tipo'      :  array_multisort($col_tipo,$order_by,$files);
687                                                                        break;
688
689                        }
690                }
691
692                return $files;
693        }
694
695}
696?>
Note: See TracBrowser for help on using the repository browser.