source: trunk/workflow/controller.php @ 1468

Revision 1468, 2.2 KB checked in by asaikawa, 15 years ago (diff)

Ticket #671 - Alteracoes para incluir arquivo header.session.inc.php para que a sessao seja verificada

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