source: sandbox/workflow/trunk/inc/class.ui_participants.inc.php @ 2372

Revision 2372, 5.0 KB checked in by pedroerp, 14 years ago (diff)

Ticket #609 - Merged 2197:2356 /sandbox/workflow/branches/609/ em /sandbox/workflow/trunk.

  • Property svn:executable set to *
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
12require_once dirname(__FILE__) . SEP . 'common.inc.php';
13require_once dirname(__FILE__) . SEP . 'class.ui_ajaxinterface.inc.php';
14
15/**
16 * @package Workflow
17 * @license http://www.gnu.org/copyleft/gpl.html GPL
18 * @author Sidnei Augusto Drovetto Jr. - drovetto@gmail.com
19 * @author Rodrigo Daniel C Lira - rodrigo.lira@gmail.com
20 */
21class ui_participants extends ui_ajaxinterface
22{
23        /**
24         * @var array $public_functions Array contento as funções públicas
25         * @access public
26         */
27        var $public_functions = array(
28        'form'  => true
29    );
30        /**
31         * @var object $bo Objeto que representa a camada Business
32         * @access public
33         */
34        var $bo;
35
36        /**
37         * Contrutor da classe
38         * @access public
39         * @return object
40         */
41        function ui_participants()
42        {
43                $this->bo = Factory::getInstance('bo_participants');
44        }
45
46        /**
47         * Constrói a interface de participantes
48         * @access public
49         * @return void
50         */
51        function form()
52        {
53                $smarty = Factory::getInstance('workflow_smarty', false);
54                $smarty->setHeader(workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_FOOTER);
55                $ldap = Factory::getInstance('WorkflowLDAP');
56                $userDN = $GLOBALS['phpgw_info']['user']['account_dn'];
57                $account = Factory::getInstance('accounts', $userDN);
58                $organizationList = $this->bo->getOrganizations();
59
60                $javaScripts = $this->get_common_js();
61                $javaScripts .= $this->get_js_link('workflow','jscode', 'prototype');
62                $javaScripts .= $this->get_js_link('workflow','jscode', 'participants');
63                $javaScripts .= $this->get_js_link('workflow','jscode', 'connector');
64
65                /* define the entities that should be listed */
66                if (!isset($_REQUEST['entities']))
67                {
68                        /* for backward compatibility */
69                        $entities = 'u';
70                        if (isset($_REQUEST['mail']))
71                                $entities .= 'l';
72                        else
73                                if (!isset($_REQUEST['hidegroups']))
74                                        $entities .= 'g';
75                }
76                else
77                        $entities = $_REQUEST['entities'];
78
79                /* define the type of information that should be returned */
80                if (isset($_REQUEST['mail']))
81                        $id = 'mail'; //return the e-mail
82                else
83                        $id = 'id'; //return the uidnumber
84
85                /* indicates wether the uidnumbers should be preffixed with a char that represents the type of the entity (e.g. 'u' for users) */
86                if (isset($_REQUEST['usePreffix']))
87                        $usePreffix = ($_REQUEST['usePreffix'] == '1') ? true : false;
88                else
89                        $usePreffix = false;
90
91                $hideOrganizations = ($_REQUEST['hideOrganizations'] == '1') ? true : false;
92                $hideSectors = ($_REQUEST['hideSectors'] == '1') ? true : false;
93
94                /* define the initial organization */
95                $selectedOrganization = $ldap->getOrganizationFromDN($userDN);
96                /* check for request supplied organization */
97                if (isset($_REQUEST['organization']))
98                        if (preg_match('/^[a-z0-9_\- ]+$/i', $_REQUEST['organization']) > 0)
99                                $selectedOrganization = $_REQUEST['organization'];
100                /* if the organization is invalid, use the first in the list */
101                if (($selectedOrganization === false) || !in_array(strtolower($selectedOrganization), array_map('strtolower', $organizationList)))
102                        $selectedOrganization = $organizationList[0];
103
104                $organizationRoot = 'ou=' . $selectedOrganization . ',' . $ldap->getLDAPContext();
105                $selectedSector = $organizationRoot;
106                if (isset($_REQUEST['sector']))
107                {
108                        if (preg_match('/^[a-z0-9_\- =,]+$/i', $_REQUEST['sector']) > 0)
109                        {
110                                $requestedSector = $ldap->getSectors(null, false, $_REQUEST['sector']);
111                                if ($requestedSector !== false)
112                                        $selectedSector = $_REQUEST['sector'];
113                        }
114                }
115
116                /* send the variables to Smarty */
117                $smarty->assign('organizations', $organizationList);
118                $smarty->assign('selectedOrganization', $selectedOrganization);
119                $smarty->assign('sectors', $this->bo->getSectors(array('organization' => $selectedOrganization), true));
120                $smarty->assign('selectedSector', $selectedSector);
121                $smarty->assign('participants', $this->bo->getEntities(array('entities' => $entities, 'id' => $id, 'context' => $selectedSector, 'usePreffix' => $usePreffix), true));
122                $smarty->assign('entities', $entities);
123                $smarty->assign('id', $id);
124                $smarty->assign('target', $_REQUEST['target_element']);
125                $smarty->assign('usePreffix', $usePreffix);
126                $smarty->assign('hideOrganizations', $hideOrganizations);
127                $smarty->assign('hideSectors', $hideSectors);
128                $smarty->assign('header', $smarty->expressoHeader);
129                $smarty->assign('txt_loading', lang("loading"));
130                $smarty->assign('javaScripts', $javaScripts);
131                $smarty->display('participants.tpl');
132        }
133
134}
135?>
Note: See TracBrowser for help on using the repository browser.