source: trunk/workflow/inc/class.WorkflowMacro.inc.php @ 795

Revision 795, 3.4 KB checked in by viani, 15 years ago (diff)

Ticket #488 - Inclusão do módulo workflow no ramo trunk do repositório Expresso.

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         * Prepara o ambiente disponibilizado pelo ExpressoLivre/Workflow
31         * @return void
32         * @access public
33         */
34        public function prepareEnvironment()
35        {
36                define('SEP', '/');
37                $currentApplication = (php_sapi_name() == 'cli') ? 'login' : 'home';
38                $GLOBALS['phpgw_info']['flags'] = array('noheader' => true, 'nonavbar' => true, 'currentapp' => $currentApplication, 'enable_network_class' => true, 'enable_contacts_class' => true, 'enable_nextmatchs_class' => true);
39                require_once dirname(__FILE__) . '/../../header.inc.php';
40                require dirname(__FILE__) . '/../setup/setup.inc.php'; /* DO NOT USE require_once */
41                $GLOBALS['phpgw_info']['apps']['workflow'] = $setup_info['workflow'];
42                $row = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'))->fetchRow();
43                $_SESSION['phpgw_info']['workflow']['vfs_basedir'] = ($row !== false) ? $row['config_value'] : '/home/expressolivre';
44                $_SESSION['phpgw_info']['workflow']['phpgw_api_inc'] = PHPGW_API_INC;
45                $_SESSION['phpgw_info']['workflow']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
46                $_SESSION['phpgw_info']['workflow']['server']['webserver_url'] = $GLOBALS['phpgw_info']['server']['webserver_url'];
47
48                require_once PHPGW_API_INC . '/functions.inc.php';
49                require_once 'engine/class.ajax_config.inc.php';
50                require_once 'engine/class.ajax_ldap.inc.php';
51                require_once 'engine/config.ajax.inc.php';
52                $GLOBALS['ajax']->ldap = new ajax_ldap();
53
54                /* definição de algumas constantes */
55                define('PHPGW_TEMPLATE_DIR', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir', 'phpgwapi'));
56                $_SERVER['DOCUMENT_ROOT'] = PHPGW_SERVER_ROOT;
57        }
58
59        /**
60         * Prepara o ambiente disponibilizado pelo Workflow para um dado processo
61         * @return void
62         * @access public
63         */
64        public function prepareProcessEnvironment($processID)
65        {
66                require_once GALAXIA_LIBRARY . '/src/common/WfRuntime.php';
67                require_once PHPGW_SERVER_ROOT . '/workflow/inc/local/functions/local.functions.php';
68
69                $runtime = new WfRuntime($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
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.