Ignore:
Timestamp:
02/10/10 15:29:22 (14 years ago)
Author:
fpcorrea
Message:

Ticket #597 - Alterações na classe VFS para o módulo filemanager

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/class.vfs_sql.inc.php

    r1928 r1998  
    10631063                                } 
    10641064                        } 
    1065  
    10661065                        /* We, however, have to decide this ourselves */ 
    10671066                        if ($this->file_exists (array( 
     
    11141113                                                                'size' => 0, 
    11151114                                                                'deleteable' => 'Y', 
    1116                                                                 'app' => $currentapp 
     1115                                                                'app' => $currentapp, 
     1116                                                                'comment' => '' 
    11171117                                                        ) 
    11181118                                        ) 
     
    11581158                        $quota = $this->get_quota(array('string' => SEP.$path[1].SEP.$path[2])); 
    11591159                        $size = $this->get_size(array('string' => SEP.$path[1].SEP.$path[2], 'relatives' => $data['relatives'][1])); 
    1160  
    11611160                        if ($quota > 0 && ($quota * 1024 * 1024) < $size) 
    11621161                                return false; 
     
    13191318                                } 
    13201319                                else 
    1321                                 { 
     1320                                {        
    13221321                                        $this->touch (array( 
    13231322                                                        'string'        => $t->fake_full_path, 
     
    24902489                        return $size; 
    24912490                } 
     2491 
     2492                /*return the total number of files in path*/ 
     2493                function count_files($data){ 
     2494                        if (!is_array ($data)) 
     2495                        { 
     2496                                $data = array (); 
     2497                        } 
     2498 
     2499                        $default_values = array 
     2500                                ( 
     2501                                        'relatives'     => array (RELATIVE_CURRENT) 
     2502                                ); 
     2503 
     2504                        $data = array_merge ($this->default_values ($data, $default_values), $data); 
     2505 
     2506                        $p = $this->path_parts (array( 
     2507                                        'string'        => $data['string'], 
     2508                                        'relatives'     => RELATIVE_NONE 
     2509                                ) 
     2510                        ); 
     2511 
     2512                        if (!$this->acl_check (array( 
     2513                                'string'        => $p->fake_full_path, 
     2514                                'relatives'     => $p->mask, 
     2515                                'operation'     => PHPGW_ACL_READ 
     2516                        )) 
     2517                        ) 
     2518                        { 
     2519                                return False; 
     2520                        } 
     2521                        $sql = "SELECT count(*) FROM phpgw_vfs WHERE directory = '".$GLOBALS['phpgw']->db->db_addslashes($data['string'])."'"; 
     2522                        $sql .= $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)); 
     2523                        $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__,__FILE__); 
     2524 
     2525                        $GLOBALS['phpgw']->db->next_record (); 
     2526                        $record = $GLOBALS['phpgw']->db->Record; 
     2527                        return $record['count']; 
     2528                } 
     2529 
    24922530                /* 
    24932531                 * get the quota defined for the path in sql table 
     
    26212659                                        'nofiles'       => False, 
    26222660                                        'summary'       => False, 
    2623                                         'orderby'       => 'directory' 
     2661                                        'orderby'       => 'directory', 
     2662                                        'otype'         => 1 
    26242663                                ); 
    26252664 
     
    26352674                                $this->attributes['summary'] = 'summary'; 
    26362675 
     2676                        $type = $this->file_type (array( 
     2677                                        'string'        => $dir, 
     2678                                        'relatives'     => array ($p->mask) 
     2679                                )); 
    26372680                        /* If they pass us a file or 'nofiles' is set, return the info for $dir only */ 
    2638                         if (@$data['file_id'] 
    2639                                 || ((($type = $this->file_type (array( 
    2640                                         'string'        => $dir, 
    2641                                         'relatives'     => array ($p->mask) 
    2642                                 )) != 'Directory')) 
    2643                                 || ($data['nofiles'])) && !$p->outside 
    2644                         ) 
     2681                        if (@$data['file_id'] || ($type != 'Directory' || $data['nofiles']) && !$p->outside) 
    26452682                        { 
    26462683                                /* SELECT all, the, attributes */ 
     
    27732810                                $sql .= " AND mime_type='".$data['mime_type']."'"; 
    27742811                        } 
    2775                         if (strlen($data['orderby']) > 0) 
    2776                                 $sql .= ' ORDER BY '.$data['orderby']; 
     2812                        if (strlen($data['orderby']) > 0 && $data['orderby'] != 'directory'){ 
     2813                                $order_direction = $data['otype'] ? ' ASC' : ' DESC'; 
     2814                                if ($data['orderby'] == 'name' || $data['orderby'] == 'comment') 
     2815                                        $sql .= ' ORDER BY upper('.$data['orderby'].')'.$order_direction; 
     2816                                else 
     2817                                        $sql .= ' ORDER BY '.$data['orderby'].$order_direction; 
     2818                                if ($data['orderby'] != 'name') 
     2819                                        $sql .= ', upper(name)'.$order_direction; 
     2820                        } 
     2821                        $data['offset'] = $data['offset'] ? $data['offset'] : 0; 
     2822                        $data['limit'] = $data['limit'] ? $data['limit'] : 10000; 
     2823                        if ($data['orderby'] != 'directory') 
     2824                                $sql .= ' LIMIT '.$data['limit'].' OFFSET '.$data['offset']; 
    27772825                        $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__); 
    27782826 
Note: See TracChangeset for help on using the changeset viewer.