source: trunk/workflow/inc/class.ui_ajaxinterface.inc.php @ 1452

Revision 1452, 7.0 KB checked in by viani, 15 years ago (diff)

Ticket #637 - Inclusao de variavel de sessao para funcionar o Voip.

  • Property svn:executable set to *
Line 
1<?php
2
3/**************************************************************************\
4* eGroupWare                                                               *
5* http://www.egroupware.org                                                *
6* --------------------------------------------                             *
7*  This program is free software; you can redistribute it and/or modify it *
8*  under the terms of the GNU General Public License as published by the   *
9*  Free Software Foundation; either version 2 of the License, or (at your  *
10*  option) any later version.                                              *
11\**************************************************************************/
12
13require_once 'class.workflow_acl.inc.php';
14require_once 'common.inc.php';
15require_once 'engine/class.ajax_config.inc.php';
16require_once 'engine/config.ajax.inc.php';
17/**
18 * Cria o ambiente de sessão para rodar Ajax e implementa alguns métodos
19 * básicos para inclusão de JavaScript e CSS
20 * 
21 * @package Workflow
22 * @license http://www.gnu.org/copyleft/gpl.html GPL
23 * @author Mauricio Luiz Viani - viani@celepar.pr.gov.br
24 */
25class ui_ajaxinterface
26{
27        /**
28        * @var int $num_version Identifica a verão dos arquivos JavaScript e CSS. Incremente o valor deste atribuito
29        * sempre que existirem alterações nos arquivos, para forçar o download pelo browser
30        * @access public
31        */             
32        var $num_version = 213;
33
34        /**
35         * Construtor
36         * @access public
37         * @return object
38         */                     
39        function ui_ajaxinterface()
40        {
41        }
42
43        /**
44        * Coloca na variável de sessão todas as informações que serão necessárias para
45        * rodar os métodos acionados pelas requisições Ajax.
46        *
47        * @return void
48        * @access public
49        */
50        function set_wf_session()
51        {
52                $acl = new workflow_acl();
53                $_SESSION['phpgw_info']['workflow']['server_root'] = PHPGW_SERVER_ROOT;
54                $_SESSION['phpgw_info']['workflow']['phpgw_api_inc'] = PHPGW_API_INC;
55                $_SESSION['phpgw_info']['workflow']['phpgw_include_root'] = PHPGW_INCLUDE_ROOT;
56                $vfs = createobject('phpgwapi.vfs');
57                $_SESSION['phpgw_info']['workflow']['vfs_basedir'] = $vfs->basedir;
58                $_SESSION['phpgw_info']['workflow']['server'] = $GLOBALS['phpgw_info']['server'];                       
59                $_SESSION['phpgw_info']['workflow']['lang'] = $GLOBALS['lang'];
60                $_SESSION['phpgw_info']['workflow']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
61                $_SESSION['phpgw_info']['workflow']['user_groups'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($GLOBALS['phpgw_info']['user']['account_id']);
62                $user_is_admin = $acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']);
63                $_SESSION['phpgw_info']['workflow']['user_is_admin'] = $user_is_admin;
64                $_SESSION['phpgw_info']['workflow']['user_can_admin_process'] = ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_workflow',1,'workflow')));
65                $_SESSION['phpgw_info']['workflow']['user_can_admin_instance'] = ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_instance_workflow',1,'workflow')));
66
67                $can_monitor = $acl->checkUserGroupAccessToType('MON', $GLOBALS['phpgw_info']['user']['account_id']);
68                $_SESSION['phpgw_info']['workflow']['user_can_monitor'] = ($user_is_admin || $can_monitor);
69                $_SESSION['phpgw_info']['workflow']['user_can_clean_instances'] = $_SESSION['phpgw_info']['workflow']['user_can_monitor'];
70                $_SESSION['phpgw_info']['workflow']['user_can_clean_aborted_instances'] = $_SESSION['phpgw_info']['workflow']['user_can_monitor'];
71                $_SESSION['phpgw_info']['workflow']['user']['preferences'] = $GLOBALS['phpgw_info']['user']['preferences']['workflow'];
72                $_SESSION['phpgw_info']['workflow']['voip_groups'] = $GLOBALS['phpgw_info']['server']['voip_groups'];
73        }
74
75        /**
76        * Insere código html para incorporar arquivos JavaScript de uso comum
77        *
78        * @return string codigo html para insercao do javascript
79        * @access public
80        */
81        function get_common_js()
82        {
83                $result = "<script language='javascript'>var _web_server_url = '" . $GLOBALS['phpgw_info']['server']['webserver_url'] . "';</script>";
84                $result = $result . $this->get_js_link('workflow','jscode', 'globals');                 
85                $result = $result . $this->get_js_link('workflow','jscode', 'common_functions');
86                $result = $result . $this->get_js_link('workflow','jscode', 'abas');
87                $result = $result . $this->get_js_link('workflow','jscode', 'connector');
88                $result = $result . $this->get_js_link('workflow','jscode', 'sniff_browser');
89                $result = $result . $this->get_js_link('workflow','jscode', 'wz_dragdrop');
90                $result = $result . $this->get_js_link('workflow','jscode', 'dJSWin');
91                $result = $result . $this->get_js_link('workflow','jscode', 'doiMenuDOM');
92               
93                return $result;
94        }
95
96        /**
97        * Insere o código html para inclusão do arquivo de estilo common.css
98        *
99        * @return string tag html completa para inserção do arquivo common.css
100        * @access public
101        */
102        function get_common_css()
103        {
104                return $this->get_css_link('common');
105        }
106
107        /**
108        * Insere o código html para inclusão de um arquivo de folha de estilo. Primeiramente
109        * procura o arquivo no template do usuário. Se não encontrado monta o link para o
110        * template default.
111        *
112        * @param string $CSSName nome do arquivo de folha de estilo.
113        * @param string $mediaType o tipo de mídia (padrão: all)
114        * @return string tag html completa para inserção do arquivo solicitado
115        * @access public
116        */
117        function get_css_link($CSSName, $mediaType = 'all')
118        {
119                $CSSName = "css/{$CSSName}.css";
120                $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
121                $CSSLink = $templateServer->getWebFile($CSSName);
122                $CSSFile = $templateServer->getSystemFile($CSSName);
123
124                return '<link href="' . $CSSLink . '?' . (file_exists($CSSFile) ? filesize($CSSFile) : $this->num_version) . '" type="text/css" rel="StyleSheet" media="' . $mediaType . '">';
125        }
126
127        /**
128        * Insere o código html para inclusão de um arquivo JavaScript.
129        *
130        * @param string $module nome do módulo do eGroupware (preferencialmente workflow)
131        * @param string $js_package nome do grupamento de arquivos javascript
132        * @param string $js_name nome do arquivo javascript
133        * @param array  $params parametros
134        * @return string tag html completa para inserção do arquivo solicitado
135        * @access public
136        */
137        function get_js_link($module, $js_package, $js_name, $params = null)
138        {
139                if (is_null($params))
140                        $params = array();
141                else
142                        if (!is_array($params))
143                                $params = array($params);
144
145                $localFile = $_SESSION['phpgw_info']['workflow']['server_root'] . SEP . $module . SEP . 'js' . SEP . $js_package . SEP . $js_name.'.js';
146                if (@file_exists($localFile))
147                        $params[] = filesize($localFile);
148                else
149                        $params[] = $this->num_version;
150                $js_file = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.$module.SEP.'js'.SEP.$js_package.SEP.$js_name.'.js';
151                return '<script src="'.$js_file.'?'.implode('&', $params).'" type="text/javascript"></script>';
152        }
153       
154        /**
155        * Executa a função inicial JavaScript que irá montar os dados da interface.
156        *
157        * @param string $param nome da função JavaScript
158        * @return string tag html completa com a chamada da função
159        * @access public
160        */
161        function run_init_script($param)
162        {
163                return '<script language="javascript">' . $param . '</script>';
164                }
165       
166        }
167?>
Note: See TracBrowser for help on using the repository browser.