| 55 | rodolico | 1 | <?php
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 |    function documentsView( $parameters ) {
 | 
        
           |  |  | 4 |       if ( isset( $parameters['device_id'] ) ) {
 | 
        
           |  |  | 5 |          $where = "owner_type = 'd' and owner_id = $parameters[device_id]";
 | 
        
           |  |  | 6 |          $join = 'join device on (device.device_id = documents.owner_id)';
 | 
        
           |  |  | 7 |       } elseif ( isset( $parameters['site_id'] ) ) {
 | 
        
           |  |  | 8 |          $where = "owner_type = 's' and owner_id = $parameters[site_id]";
 | 
        
           |  |  | 9 |          $join = 'join site on (site.site_id = documents.owner_id)';
 | 
        
           |  |  | 10 |       } elseif ( isset( $parameters['client_id'] ) ) {
 | 
        
           |  |  | 11 |          $where = "owner_type = 'c' and owner_id = $parameters[client_id]";
 | 
        
           |  |  | 12 |          $join = 'join client on (client.client_id = documents.owner_id)';
 | 
        
           |  |  | 13 |       } else {
 | 
        
           |  |  | 14 |          return null;
 | 
        
           |  |  | 15 |       }
 | 
        
           |  |  | 16 |       $query = "select 
 | 
        
           |  |  | 17 |                    document.document_id 'ID', 
 | 
        
           |  |  | 18 |                    document.name 'Name', 
 | 
        
           |  |  | 19 |                    document.description 'Description', 
 | 
        
           |  |  | 20 |                    document.mime_type 'MIME', 
 | 
        
           |  |  | 21 |                    document.added_date 'Added'
 | 
        
           |  |  | 22 |                 from document 
 | 
        
           |  |  | 23 |                      join document_mime_type using (document_mime_type_id)
 | 
        
           |  |  | 24 |                      $join
 | 
        
           |  |  | 25 |                 where
 | 
        
           |  |  | 26 |                    $where
 | 
        
           |  |  | 27 |                 order by document.name, document.added_date";
 | 
        
           |  |  | 28 |       // run the query
 | 
        
           |  |  | 29 |       // put it into some kind of table. NOTE: description should be on mouseover
 | 
        
           |  |  | 30 |       return null;
 | 
        
           |  |  | 31 |    }
 | 
        
           |  |  | 32 |   | 
        
           |  |  | 33 | ?>
 |