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