[795] | 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 | require_once dirname(__FILE__) . SEP . 'common.inc.php'; |
---|
| 13 | require_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 | */ |
---|
| 21 | class 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 | { |
---|
[2372] | 43 | $this->bo = Factory::getInstance('bo_participants'); |
---|
[795] | 44 | } |
---|
| 45 | |
---|
| 46 | /** |
---|
| 47 | * Constrói a interface de participantes |
---|
| 48 | * @access public |
---|
| 49 | * @return void |
---|
| 50 | */ |
---|
| 51 | function form() |
---|
| 52 | { |
---|
[2372] | 53 | $smarty = Factory::getInstance('workflow_smarty', false); |
---|
[795] | 54 | $smarty->setHeader(workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_FOOTER); |
---|
[2372] | 55 | $ldap = Factory::getInstance('WorkflowLDAP'); |
---|
[795] | 56 | $userDN = $GLOBALS['phpgw_info']['user']['account_dn']; |
---|
[2372] | 57 | $account = Factory::getInstance('accounts', $userDN); |
---|
[795] | 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 | |
---|
[3060] | 94 | // the default value of $onlyVisibleAccounts is true |
---|
| 95 | if((isset($_REQUEST['onlyVisibleAccounts'])) && (empty($_REQUEST['onlyVisibleAccounts']) || $_REQUEST['onlyVisibleAccounts'] === 'false')) |
---|
| 96 | $onlyVisibleAccounts = false; |
---|
| 97 | else |
---|
| 98 | $onlyVisibleAccounts = true; |
---|
| 99 | |
---|
[795] | 100 | /* define the initial organization */ |
---|
| 101 | $selectedOrganization = $ldap->getOrganizationFromDN($userDN); |
---|
| 102 | /* check for request supplied organization */ |
---|
| 103 | if (isset($_REQUEST['organization'])) |
---|
| 104 | if (preg_match('/^[a-z0-9_\- ]+$/i', $_REQUEST['organization']) > 0) |
---|
| 105 | $selectedOrganization = $_REQUEST['organization']; |
---|
| 106 | /* if the organization is invalid, use the first in the list */ |
---|
| 107 | if (($selectedOrganization === false) || !in_array(strtolower($selectedOrganization), array_map('strtolower', $organizationList))) |
---|
| 108 | $selectedOrganization = $organizationList[0]; |
---|
| 109 | |
---|
| 110 | $organizationRoot = 'ou=' . $selectedOrganization . ',' . $ldap->getLDAPContext(); |
---|
| 111 | $selectedSector = $organizationRoot; |
---|
| 112 | if (isset($_REQUEST['sector'])) |
---|
| 113 | { |
---|
| 114 | if (preg_match('/^[a-z0-9_\- =,]+$/i', $_REQUEST['sector']) > 0) |
---|
| 115 | { |
---|
| 116 | $requestedSector = $ldap->getSectors(null, false, $_REQUEST['sector']); |
---|
| 117 | if ($requestedSector !== false) |
---|
| 118 | $selectedSector = $_REQUEST['sector']; |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | /* send the variables to Smarty */ |
---|
| 123 | $smarty->assign('organizations', $organizationList); |
---|
| 124 | $smarty->assign('selectedOrganization', $selectedOrganization); |
---|
[3060] | 125 | $smarty->assign('sectors', $this->bo->getSectors(array('organization' => $selectedOrganization, 'onlyVisibleAccounts' => $onlyVisibleAccounts), true)); |
---|
[795] | 126 | $smarty->assign('selectedSector', $selectedSector); |
---|
[3060] | 127 | $smarty->assign('participants', $this->bo->getEntities(array('entities' => $entities, 'id' => $id, 'context' => $selectedSector, 'onlyVisibleAccounts' => $onlyVisibleAccounts, 'usePreffix' => $usePreffix), true)); |
---|
[795] | 128 | $smarty->assign('entities', $entities); |
---|
| 129 | $smarty->assign('id', $id); |
---|
| 130 | $smarty->assign('target', $_REQUEST['target_element']); |
---|
| 131 | $smarty->assign('usePreffix', $usePreffix); |
---|
| 132 | $smarty->assign('hideOrganizations', $hideOrganizations); |
---|
| 133 | $smarty->assign('hideSectors', $hideSectors); |
---|
[3060] | 134 | $smarty->assign('onlyVisibleAccounts', $onlyVisibleAccounts); |
---|
[795] | 135 | $smarty->assign('header', $smarty->expressoHeader); |
---|
| 136 | $smarty->assign('txt_loading', lang("loading")); |
---|
| 137 | $smarty->assign('javaScripts', $javaScripts); |
---|
| 138 | $smarty->display('participants.tpl'); |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | } |
---|
| 142 | ?> |
---|