source: trunk/expressoMail1_2/controller.php @ 5399

Revision 5399, 2.0 KB checked in by cristiano, 12 years ago (diff)

Ticket #2434 - Alteração da estrutura de diretórios da nova API

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2if(!isset($GLOBALS['phpgw_info'])){
3        $GLOBALS['phpgw_info']['flags'] = array(
4                'currentapp' => 'expressoMail1_2',
5                'nonavbar'   => true,
6                'noheader'   => true
7        );
8}
9require_once '../header.session.inc.php';
10require_once '../services/class.servicelocator.php';
11
12        //      Explode action from cExecuteForm function
13        $cExecuteFormReturn = false;
14        if( isset( $_POST['_action'] ) ) {             
15                if($_FILES) {
16                        $count_files = $_POST['countFiles'];
17                        $array_files = array();                 
18                        for($idx = 1; $idx <= $count_files; $idx++) {           
19                                if(array_key_exists('file_'.$idx , $_FILES) && $_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
20                                        $array_files[] = $_FILES['file_'.$idx];                                         
21                        }
22                        $_POST['FILES'] = $array_files;
23                }                               
24                $get_p = explode('.',@$_POST['_action']);
25
26                $cExecuteFormReturn = true;
27        }
28        //      Explode action from cExecute function
29        else if(array_key_exists('action', $_GET))
30                        $get_p = explode('.',@$_GET['action']);
31                       
32
33        // NO ACTION
34        else
35                return $_SESSION['response'] = 'Post-Content-Length';
36       
37        // Load dinamically class file.
38        if($get_p[0] == '$this')
39                $filename = 'inc/class.'.$get_p[1].'.inc.php';
40        else
41                $filename = '../'.$get_p[0].'/inc/class.'.$get_p[1].'.inc.php';
42               
43        include_once($filename);       
44       
45        // Create new Object  (class loaded).   
46        $obj = new $get_p[1];
47       
48        // Prepare parameters for execution.   
49        $params = array();
50       
51        // If array $_POST is not null , the submit method is POST.
52        if($_POST) {
53                $params = $_POST;
54        }
55        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
56        else if(count($_GET) > 1)       {               
57                array_shift($_GET);
58                $params = $_GET;
59        }
60
61        $result = array();
62       
63       
64        // if params is not empty, then class method with parameters.   
65        if($params)
66                $result = $obj -> $get_p[2]($params);
67        else           
68                $result = $obj -> $get_p[2]();
69               
70        // Return result serialized.   
71       
72
73        if(!$cExecuteFormReturn /*&& (!$_REQUEST['isPost'])*/ )
74                if(array_key_exists(3,$get_p))
75                        echo $result;
76                else
77                echo serialize($result);
78        else
79                $_SESSION['response'] = $result;
80?>
Note: See TracBrowser for help on using the repository browser.