source: branches/2.2/workflow/inc/class.WorkflowMacro.inc.php @ 3185

Revision 3185, 3.5 KB checked in by asaikawa, 14 years ago (diff)

Ticket #1172 - Inserido parametro para identificar se esta preparando o ambiente para um WS

Line 
1<?php
2/**************************************************************************\
3* eGroupWare                                                               *
4* http://www.egroupware.org                                                *
5* --------------------------------------------                             *
6*  This program is free software; you can redistribute it and/or modify it *
7*  under the terms of the GNU General Public License as published by the   *
8*  Free Software Foundation; either version 2 of the License, or (at your  *
9*  option) any later version.                                              *
10\**************************************************************************/
11
12/**
13 * Classe que implementa algumas ações que se repetem em várias partes do módulo
14 * @package Workflow
15 * @author Sidnei Augusto Drovetto Jr. - drovetto@gmail.com
16 * @license http://www.gnu.org/copyleft/gpl.html GPL
17 */
18class WorkflowMacro
19{
20        /**
21         * Construtor da classe WorkflowMacro
22         * @return object Objeto da classe WorkflowMacro
23         * @access public
24         */
25        public function WorkflowMacro()
26        {
27        }
28
29        /**
30         * Prepare the ExpressoLivre/Workflow's environment
31         * @param bool $preparingToWS True if it's preparing the environment to a webservice call, otherwise False
32         * @return void
33         * @access public
34         */
35        public function prepareEnvironment($preparingToWS = false)
36        {
37                define('SEP', '/');
38                /* if it's a command line or webservice call, set $currentApplication to 'login' */
39                $currentApplication = ((php_sapi_name() == 'cli') || $preparingToWS) ? 'login' : 'home';
40                $GLOBALS['phpgw_info']['flags'] = array('noheader' => true, 'nonavbar' => true, 'currentapp' => $currentApplication, 'enable_network_class' => true, 'enable_contacts_class' => true, 'enable_nextmatchs_class' => true);
41                require_once dirname(__FILE__) . '/../../header.inc.php';
42                require dirname(__FILE__) . '/../setup/setup.inc.php'; /* DO NOT USE require_once */
43                $GLOBALS['phpgw_info']['apps']['workflow'] = $setup_info['workflow'];
44                $row = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'))->fetchRow();
45                $_SESSION['phpgw_info']['workflow']['vfs_basedir'] = ($row !== false) ? $row['config_value'] : '/home/expressolivre';
46                $_SESSION['phpgw_info']['workflow']['phpgw_api_inc'] = PHPGW_API_INC;
47                $_SESSION['phpgw_info']['workflow']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
48                $_SESSION['phpgw_info']['workflow']['server']['webserver_url'] = $GLOBALS['phpgw_info']['server']['webserver_url'];
49
50                require_once PHPGW_API_INC . '/functions.inc.php';
51                require_once 'engine/class.ajax_config.inc.php';
52                require_once 'engine/config.ajax.inc.php';
53                $GLOBALS['ajax']->ldap = &Factory::getInstance('ajax_ldap');
54
55                /* definição de algumas constantes */
56                define('PHPGW_TEMPLATE_DIR', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir', 'phpgwapi'));
57                $_SERVER['DOCUMENT_ROOT'] = PHPGW_SERVER_ROOT;
58        }
59
60        /**
61         * Prepara o ambiente disponibilizado pelo Workflow para um dado processo
62         * @return void
63         * @access public
64         */
65        public function prepareProcessEnvironment($processID)
66        {
67                require_once PHPGW_SERVER_ROOT . '/workflow/inc/local/functions/local.functions.php';
68
69                $runtime = &Factory::getInstance('WfRuntime');
70                $runtime->loadProcess($processID);
71
72                /* GLOBALS */
73                $GLOBALS['workflow']['wf_runtime'] = &$runtime;
74                $GLOBALS['workflow']['wf_normalized_name'] = $runtime->process->getNormalizedName();
75        }
76}
77?>
Note: See TracBrowser for help on using the repository browser.