source: branches/2.3/workflow/controller.php @ 3167

Revision 3167, 2.2 KB checked in by viani, 14 years ago (diff)

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

  • Property svn:executable set to *
Line 
1<?php
2        if (file_exists('../header.session.inc.php')) {
3                require_once '../header.session.inc.php';
4        }
5
6        /* if there is no session, abort the Ajax call */
7        if (empty($_SESSION))
8        {
9                $output = array(
10                        'error' => 'Sua sessão expirou. É necessário logar-se novamente.',
11                        'url' => '../login.php');
12                die(serialize($output));
13        }
14
15        if (!isset($_SESSION['phpgw_info']['workflow']['server_root']))
16        {
17                require_once dirname(__FILE__) . '/inc/common.inc.php';
18                Factory::getInstance('WorkflowMacro')->prepareEnvironment();
19        }
20
21        //      Explode action from cExecuteForm function
22        $cExecuteFormReturn = false;
23       
24        if($_POST['_form_data']) {             
25                list($app,$class,$method) = explode('.',@$_POST['_form_data']);
26                $cExecuteFormReturn = true;
27        }
28        else if($_POST['_action']) {           
29                if($_FILES) {
30                        $count_files = $_POST['countFiles'];
31                        $array_files = array();                 
32                        for($idx = 1; $idx <= $count_files; $idx++) {           
33                                if($_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
34                                        $array_files[] = $_FILES['file_'.$idx];                                         
35                        }
36                        $_POST['FILES'] = $array_files;
37                }                               
38                list($app,$class,$method) = explode('.',@$_POST['_action']);
39                $cExecuteFormReturn = true;
40        }
41        //      Explode action from cExecute function
42        else if($_GET['action'])
43                list($app,$class,$method) = explode('.',@$_GET['action']);
44        // NO ACTION
45        else
46                return $_SESSION['response'] = 'false';
47       
48        // Load dinamically class file.
49        if($app == '$this')
50                $filename = 'inc/class.'.$class.'.inc.php';
51        else
52                $filename = '../'.$app.'/inc/class.'.$class.'.inc.php';
53               
54        include_once($filename);       
55       
56        // Create new Object  (class loaded).   
57        $obj = new $class;
58       
59        // Prepare parameters for execution.   
60        $params = array();
61       
62        // If array $_POST is not null , the submit method is POST.
63        if($_POST) {
64                $params = $_POST;
65        }
66        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
67        else if(count($_GET) > 1)       {               
68                array_shift($_GET);
69                $params = $_GET;
70        }
71
72        $result = array();
73       
74       
75        // if params is not empty, then class method with parameters.   
76        if($params)
77                $result = $obj -> $method($params);
78        else           
79                $result = $obj -> $method();
80               
81        // Return result serialized.   
82       
83
84        if(!$cExecuteFormReturn)
85                echo serialize($result);
86        else
87                $_SESSION['response'] = $result;
88?>
Note: See TracBrowser for help on using the repository browser.