[3514] | 1 | <?php |
---|
| 2 | /*************************************************************************************\ |
---|
| 3 | * Expresso Administração * |
---|
| 4 | * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br) * |
---|
| 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 | class uimaillists |
---|
| 13 | { |
---|
| 14 | var $public_functions = array |
---|
| 15 | ( |
---|
| 16 | 'list_maillists' => True, |
---|
| 17 | 'add_maillists' => True, |
---|
| 18 | 'edit_maillists' => True, |
---|
| 19 | 'scl_maillists' => True, |
---|
| 20 | 'adm_maillists' => True, |
---|
| 21 | 'css' => True |
---|
| 22 | ); |
---|
| 23 | |
---|
| 24 | var $nextmatchs; |
---|
| 25 | var $functions; |
---|
| 26 | |
---|
| 27 | function uimaillists() |
---|
| 28 | { |
---|
| 29 | $this->maillist = CreateObject('listAdmin.maillist'); |
---|
| 30 | $this->functions = CreateObject('listAdmin.functions'); |
---|
| 31 | $this->ldap_functions = CreateObject('listAdmin.ldap_functions'); |
---|
| 32 | $this->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
| 33 | |
---|
| 34 | $c = CreateObject('phpgwapi.config','listAdmin'); |
---|
| 35 | $c->read_repository(); |
---|
| 36 | $this->current_config = $c->config_data; |
---|
| 37 | |
---|
| 38 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
| 39 | { |
---|
| 40 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 41 | } |
---|
| 42 | $GLOBALS['phpgw']->js->validate_file('jscode','connector','listAdmin');#diretorio, arquivo.js, aplicacao |
---|
| 43 | $GLOBALS['phpgw']->js->validate_file('jscode','expressoadmin','listAdmin'); |
---|
| 44 | $GLOBALS['phpgw']->js->validate_file('jscode','maillists','listAdmin'); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | function list_maillists() |
---|
| 48 | { |
---|
| 49 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 50 | //$acl = $this->functions->read_acl($account_lid); |
---|
| 51 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context']; |
---|
| 52 | $context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display']; |
---|
| 53 | |
---|
| 54 | if(isset($_POST['query'])) |
---|
| 55 | { |
---|
| 56 | // limit query to limit characters |
---|
[5928] | 57 | if(preg_match('/^[a-z_0-9_%-].+$/i',$_POST['query'])) |
---|
[3514] | 58 | $GLOBALS['query'] = $_POST['query']; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 62 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 63 | |
---|
| 64 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Email Lists'); |
---|
| 65 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 66 | |
---|
| 67 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 68 | $p->set_file(array('maillists' => 'maillists.tpl')); |
---|
| 69 | $p->set_block('maillists','list','list'); |
---|
| 70 | $p->set_block('maillists','row','row'); |
---|
| 71 | $p->set_block('maillists','row_empty','row_empty'); |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | //Pega o id do usuario atual da sessao |
---|
| 75 | $usuarioAtual=$_SESSION['phpgw_info']['expresso']['user']['account_lid']; |
---|
| 76 | //Pega o uidnumber do usuario atual |
---|
| 77 | $admUidnumber = $this->ldap_functions->uid2uidnumber($usuarioAtual); |
---|
| 78 | |
---|
| 79 | //Pega o email do usuario atual |
---|
| 80 | $admlista = $this->ldap_functions->uidnumber2mail($admUidnumber); |
---|
| 81 | |
---|
| 82 | $desabilitado = 'disabled'; |
---|
| 83 | |
---|
| 84 | if($this->ldap_functions->is_user_listAdmin($usuarioAtual) == 1) |
---|
| 85 | { |
---|
| 86 | $desabilitado = ''; |
---|
| 87 | $can_edit = True; |
---|
| 88 | $can_delete = True; |
---|
| 89 | } |
---|
| 90 | else |
---|
| 91 | { |
---|
| 92 | $can_edit = True; |
---|
| 93 | $can_delete = False; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | // Seta as variaveis padroes. |
---|
| 98 | $var = Array( |
---|
| 99 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
| 100 | 'back_url' => $GLOBALS['phpgw']->link('/listAdmin/index.php'), |
---|
| 101 | 'add_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.add_maillists'), |
---|
| 102 | 'add_email_lists_disabled' => $this->functions->check_acl($account_lid,'add_maillists') ? '' : 'disabled', |
---|
| 103 | 'context' => $context, |
---|
| 104 | 'context_display' => $context_display, |
---|
| 105 | 'desabilitado' => $desabilitado, |
---|
| 106 | 'lang_email_lists_uid' => lang('Email Lists Logins'), |
---|
| 107 | 'lang_email_lists_names' => lang('Email Lists Names'), |
---|
| 108 | 'lang_add_email_lists' => lang('Add Email Lists'), |
---|
| 109 | 'lang_edit' => lang('Edit'), |
---|
| 110 | 'lang_scl' => 'SCL', |
---|
| 111 | 'lang_adm' => 'ADM', |
---|
| 112 | 'lang_delete' => 'Excluir', |
---|
| 113 | 'lang_view' => lang('View'), |
---|
| 114 | 'lang_back' => lang('back'), |
---|
| 115 | 'lang_context' => lang('context'), |
---|
| 116 | 'lang_email' => lang('E-mail'), |
---|
| 117 | 'lang_search' => lang('search') |
---|
| 118 | ); |
---|
| 119 | $p->set_var($var); |
---|
| 120 | |
---|
| 121 | // Save query |
---|
| 122 | $p->set_var('query', $GLOBALS['query']); |
---|
| 123 | |
---|
| 124 | //Variavel recebe o contexto onde estao gravadas as listas no sistema; |
---|
| 125 | $contextoListas = $this->current_config['dn_listas']; |
---|
| 126 | |
---|
| 127 | $auto_list = $this->current_config['mm_ldap_query_automatic']; |
---|
| 128 | if( ($auto_list == "true") && ($GLOBALS['query'] == '') ) |
---|
| 129 | { |
---|
| 130 | //Retorna todas as listas que o usuario conectado administra |
---|
| 131 | $maillists_info = $this->functions->auto_list('maillists', $contextoListas, $admlista); |
---|
| 132 | }else { |
---|
| 133 | //Admin make a search |
---|
| 134 | if( ($GLOBALS['query'] != '') && (strlen($GLOBALS['query']) < 4) ) { |
---|
| 135 | $p->set_var('message',lang('Search argument too short')); |
---|
| 136 | }else if ($GLOBALS['query'] != ''){ |
---|
| 137 | //Retorna as listas que o usuario conectado administra, de acordo com o argumento de busca |
---|
| 138 | $maillists_info = $this->functions->get_list('maillists', $GLOBALS['query'], $contextoListas, $admlista); |
---|
| 139 | } |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | $total = count($maillists_info); |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | if (!count($total) && $GLOBALS['query'] != '') |
---|
| 146 | { |
---|
| 147 | $p->set_var('message',lang('No matches found')); |
---|
| 148 | } |
---|
| 149 | else if ($total) |
---|
| 150 | { |
---|
| 151 | |
---|
| 152 | foreach($maillists_info as $maillist) |
---|
| 153 | { |
---|
| 154 | $tr_color = $this->nextmatchs->alternate_row_color($tr_color); |
---|
| 155 | $var = array( |
---|
| 156 | 'tr_color' => $tr_color, |
---|
| 157 | 'row_uid' => $maillist['uid'], |
---|
| 158 | 'row_name' => $maillist['name'], |
---|
| 159 | 'row_email' => $maillist['email'] |
---|
| 160 | ); |
---|
| 161 | $p->set_var($var); |
---|
| 162 | |
---|
| 163 | if ($can_edit) |
---|
| 164 | { |
---|
| 165 | $p->set_var('edit_link',$this->row_action('edit','maillists',$maillist['uidnumber'],$maillist['uid'])); |
---|
| 166 | $p->set_var('scl_link',$this->row_action('scl','maillists',$maillist['uidnumber'],$maillist['uid'])); |
---|
| 167 | $p->set_var('adm_link',$this->row_action('adm','maillists',$maillist['uidnumber'],$maillist['uid'])); |
---|
| 168 | } |
---|
| 169 | else |
---|
| 170 | { |
---|
| 171 | $p->set_var('edit_link',' '); |
---|
| 172 | $p->set_var('scl_link',' '); |
---|
| 173 | $p->set_var('adm_link',' '); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | if ($can_delete) |
---|
| 177 | { |
---|
| 178 | $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_maillist(\"".$maillist['uid']."\",\"".$maillist['uidnumber']."\",\"".$context."\");'>Excluir</a>"); |
---|
| 179 | } |
---|
| 180 | else |
---|
| 181 | { |
---|
| 182 | $p->set_var('delete_link',' '); |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | $p->fp('rows','row',True); |
---|
| 186 | } |
---|
| 187 | } |
---|
| 188 | $p->parse('rows','row_empty',True); |
---|
| 189 | $p->set_var($var); |
---|
| 190 | $p->pfp('out','list'); |
---|
| 191 | |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | function add_maillists() |
---|
| 195 | { |
---|
| 196 | //$GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);'); |
---|
| 197 | |
---|
| 198 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 199 | //$acl = $this->functions->read_acl($account_lid); |
---|
| 200 | //$context = $acl[0]['context']; |
---|
| 201 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context']; |
---|
| 202 | //$context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display']; |
---|
| 203 | |
---|
| 204 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 205 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 206 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Create Email List'); |
---|
| 207 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 208 | |
---|
| 209 | // Set o template |
---|
| 210 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 211 | $p->set_file(Array('create_maillist' => 'maillists_form.tpl')); |
---|
| 212 | |
---|
| 213 | // Pega combo das organizações. |
---|
| 214 | $org = $this->functions->get_organizations($context, ''); |
---|
| 215 | |
---|
| 216 | // Seta variaveis utilizadas pelo tpl. |
---|
| 217 | $var = Array( |
---|
| 218 | 'color_bg1' => "#E8F0F0", |
---|
| 219 | 'color_bg2' => "#D3DCE3", |
---|
| 220 | 'type' => 'create_maillist', |
---|
| 221 | 'ldap_context' => $GLOBALS['phpgw_info']['server']['ldap_context'], |
---|
| 222 | 'uid' => 'lista-', |
---|
| 223 | 'exibir_div' => ' style="display: none;" ', |
---|
| 224 | 'accountStatus_checked' => 'CHECKED', |
---|
| 225 | // 'defaultMemberModeration_checked' => 'CHECKED', |
---|
| 226 | 'accountAdm_checked' => 'CHECKED', |
---|
| 227 | 'restrictionsOnEmailLists' => $this->current_config['expressoAdmin_restrictionsOnEmailLists'], |
---|
| 228 | 'lang_back' => lang('Back'), |
---|
| 229 | 'lang_save' => lang('save'), |
---|
| 230 | 'lang_org' => lang('Organizations'), |
---|
| 231 | 'lang_maillist_uid' => lang('Maillist login'), |
---|
| 232 | 'lang_maillist_mail' => lang('Maillist Mail'), |
---|
| 233 | 'lang_maillist_name' => lang('Maillist name'), |
---|
| 234 | 'lang_maillist_description' => lang('Maillist description'), |
---|
| 235 | 'lang_maillist_users' => lang('Maillist users'), |
---|
| 236 | 'lang_add_user' => lang('Add User'), |
---|
| 237 | 'lang_rem_user' => lang('Remove User'), |
---|
| 238 | 'lang_all_users' => lang('Show users from all sub-organizations'), |
---|
| 239 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'), |
---|
| 240 | 'combo_org' => $org, |
---|
| 241 | 'ea_select_usersInMaillist' => $ea_select_usersInMaillist |
---|
| 242 | ); |
---|
| 243 | $p->set_var($var); |
---|
| 244 | |
---|
| 245 | $p->pfp('out','create_maillist'); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | |
---|
| 249 | function edit_maillists() |
---|
| 250 | { |
---|
| 251 | |
---|
| 252 | $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);'); |
---|
| 253 | |
---|
| 254 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 255 | //$acl = $this->functions->read_acl($account_lid); |
---|
| 256 | //$manager_context = $acl[0]['context']; |
---|
| 257 | $manager_context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context']; |
---|
| 258 | //$context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display']; |
---|
| 259 | |
---|
| 260 | |
---|
| 261 | //Teste o tipo de lista que esta sendo editada (corporativa ou funcional); |
---|
| 262 | $uid_lista = $_GET['maillist_uid']; //recebe o uid da lista selecionada; |
---|
| 263 | $str = explode("-", $uid_lista); //separa pelo "-"; |
---|
| 264 | $str = $str[0]; //pega o primeiro elemento, que neste caso e o que indica o tipo de lista |
---|
| 265 | |
---|
| 266 | $somente_leitura = ""; |
---|
| 267 | $desabilitado = ""; |
---|
| 268 | if(($str == "listacorp") || ($str == "listafunc")) { |
---|
| 269 | $somente_leitura = "readonly"; //se lista for corp ou func, a variavel recebe readonly - sera usada em todos os input do form de edicao de listas; |
---|
| 270 | $desabilitado = "disabled"; |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | //Pega o id do administrador do Expresso (expresso-admin) |
---|
| 274 | $expressoAdmin = $GLOBALS['phpgw_info']['server']['header_admin_user']; |
---|
| 275 | |
---|
| 276 | //Pega o id do usuario atual da sessao |
---|
| 277 | $usuarioAtual = $_SESSION['phpgw_info']['expresso']['user']['account_lid']; |
---|
| 278 | |
---|
| 279 | if($expressoAdmin != $usuarioAtual) { |
---|
| 280 | |
---|
| 281 | $soAdminLe = "readonly"; //se usuarioAtual for diferente de expressoAdmin, a variavel recebe readonly - sera usada nos input com uid, mail e cn da lista; |
---|
| 282 | |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | |
---|
| 287 | |
---|
| 288 | // GET all infomations about the group. |
---|
| 289 | $maillist_info = $this->maillist->get_info($_GET['uidnumber'], $manager_context); |
---|
| 290 | // debug_array($maillist_info); |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 294 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 295 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Edit Email Lists'); |
---|
| 296 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 297 | |
---|
| 298 | // Set o template |
---|
| 299 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 300 | $p->set_file(Array('edit_maillist' => 'maillists_form.tpl')); |
---|
| 301 | |
---|
| 302 | // Pega combo das organizações e seleciona a org da lista. |
---|
| 303 | $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context']))); |
---|
| 304 | |
---|
| 305 | // Usuarios da lista. |
---|
| 306 | if (count($maillist_info['members_info']) > 0) |
---|
| 307 | { |
---|
| 308 | foreach ($maillist_info['members_info'] as $uidnumber=>$userinfo) |
---|
| 309 | { |
---|
| 310 | $array_users[$uidnumber] = $userinfo['cn']; |
---|
| 311 | $array_users_uid[$uidnumber] = $userinfo['uid']; |
---|
| 312 | $array_users_type[$uidnumber] = $userinfo['type']; |
---|
| 313 | } |
---|
| 314 | natcasesort($array_users); |
---|
| 315 | foreach ($array_users as $uidnumber=>$cn) |
---|
| 316 | { |
---|
| 317 | if ($array_users_type[$uidnumber] == 'u') |
---|
| 318 | { |
---|
| 319 | //$users .= "<option value=" . $uidnumber . ">" . $cn . " [" . $array_users_uid[$uidnumber] . "]</option>"; |
---|
| 320 | $users .= "<option value=" . $uidnumber . ">" . $cn . " [" . $maillist_info['members_info'][$uidnumber]['mail'] . "]</option>"; |
---|
| 321 | } |
---|
| 322 | elseif ($array_users_type[$uidnumber] == 'l') |
---|
| 323 | { |
---|
| 324 | $lists .= "<option value=" . $uidnumber . ">" . $cn . " [" . $array_users_uid[$uidnumber] . "]</option>"; |
---|
| 325 | } |
---|
| 326 | else |
---|
| 327 | { |
---|
| 328 | $unknow .= "<option value=" . $uidnumber . ">" . $cn . " [" . $array_users_uid[$uidnumber] . "]</option>"; |
---|
| 329 | } |
---|
| 330 | } |
---|
| 331 | |
---|
| 332 | if ($unknow != '') |
---|
| 333 | { |
---|
| 334 | //$opt_tmp_unknow = '<option value="-1" disabled>-------------------- E-mails não encontrados ------------------ </option>'."\n"; |
---|
| 335 | $opt_tmp_unknow = '<option value="-1" disabled>----------- Usuários não pertencentes ou não criados no Expresso ---------- </option>'."\n"; |
---|
| 336 | $ea_select_usersInMaillist .= $opt_tmp_unknow . $unknow; |
---|
| 337 | } |
---|
| 338 | if ($lists != '') |
---|
| 339 | { |
---|
| 340 | $opt_tmp_lists = '<option value="-1" disabled>------------------------------ Listas ------------------------------ </option>'."\n"; |
---|
| 341 | $ea_select_usersInMaillist .= $opt_tmp_lists . $lists; |
---|
| 342 | } |
---|
| 343 | $opt_tmp_users = '<option value="-1" disabled>----------------------------- Usuários ---------------------------- </option>'."\n"; |
---|
| 344 | $ea_select_usersInMaillist .= $opt_tmp_users . $users; |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | // Seta variaveis utilizadas pelo tpl. |
---|
| 348 | $var = Array( |
---|
| 349 | 'color_bg1' => "#E8F0F0", |
---|
| 350 | 'color_bg2' => "#D3DCE3", |
---|
| 351 | 'type' => 'edit_maillist', |
---|
| 352 | 'ldap_context' => $GLOBALS['phpgw_info']['server']['ldap_context'], |
---|
| 353 | 'lang_back' => lang('Back'), |
---|
| 354 | 'lang_save' => lang('save'), |
---|
| 355 | 'lang_org' => lang('Organizations'), |
---|
| 356 | 'lang_maillist_uid' => lang('Maillist login'), |
---|
| 357 | 'lang_maillist_mail' => lang('Maillist Mail'), |
---|
| 358 | 'lang_maillist_name' => lang('Maillist name'), |
---|
| 359 | 'lang_maillist_users' => lang('Maillist users'), |
---|
| 360 | 'lang_maillist_description' => lang('Maillist description'), |
---|
| 361 | 'lang_add_user' => lang('Add User'), |
---|
| 362 | 'lang_rem_user' => lang('Remove User'), |
---|
| 363 | 'lang_all_users' => lang('Select users from all sub-organizations'), |
---|
| 364 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'), |
---|
| 365 | // 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'), |
---|
| 366 | 'combo_org' => $org, |
---|
| 367 | 'manager_context' => $manager_context, |
---|
| 368 | 'somente_leitura' => $somente_leitura, //recebe a variavel testada acima; |
---|
| 369 | 'desabilitado' => $desabilitado, //recebe a variavel testada acima; |
---|
| 370 | 'soAdminLe' => $soAdminLe, //recebe a variavel testada acima; |
---|
| 371 | 'uidnumber' => $_GET['uidnumber'], |
---|
| 372 | 'uid' => $maillist_info['uid'], |
---|
| 373 | 'defaultMemberModeration' => $maillist_info['defaultMemberModeration'], |
---|
| 374 | 'admlista' => $maillist_info['admlista'], |
---|
| 375 | 'listPass' => $maillist_info['listPass'], |
---|
| 376 | 'exibir_div' => '', |
---|
| 377 | 'mail' => $maillist_info['mail'], |
---|
| 378 | 'description' => $maillist_info['description'], |
---|
| 379 | 'cn' => $maillist_info['cn'], |
---|
| 380 | 'accountStatus_checked' => $maillist_info['accountStatus'] == 'active' ? 'CHECKED' : '', |
---|
| 381 | 'accountAdm_checked' => $maillist_info['accountAdm'] == 'active' ? 'CHECKED' : '', |
---|
| 382 | |
---|
| 383 | 'phpgwAccountVisible_checked' => $maillist_info['phpgwAccountVisible'] == '-1' ? 'CHECKED' : '', |
---|
| 384 | 'defaultMemberModeration_checked' => $maillist_info['defaultMemberModeration'] == '1' ? 'CHECKED' : '', |
---|
| 385 | 'ea_select_usersInMaillist' => $ea_select_usersInMaillist |
---|
| 386 | ); |
---|
| 387 | $p->set_var($var); |
---|
| 388 | |
---|
| 389 | $p->pfp('out','edit_maillist'); |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | function adm_maillists() //Funcao que trata do modulo/template de administradores de listas |
---|
| 393 | { |
---|
| 394 | |
---|
| 395 | // $GLOBALS['phpgw']->js->set_onload('get_available_users_only(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);'); |
---|
| 396 | |
---|
| 397 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 398 | //$acl = $this->functions->read_acl($account_lid); |
---|
| 399 | //$manager_context = $acl[0]['context']; |
---|
| 400 | $manager_context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context']; |
---|
| 401 | //$context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display']; |
---|
| 402 | |
---|
| 403 | //Teste o tipo de lista que esta sendo editada (corporativa ou funcional); |
---|
| 404 | $uid_lista = $_GET['maillist_uid']; //recebe o uid da lista selecionada; |
---|
| 405 | $str = explode("-", $uid_lista); //separa pelo "-"; |
---|
| 406 | $str = $str[0]; //pega o primeiro elemento, que neste caso e o que indica o tipo de lista |
---|
| 407 | |
---|
| 408 | $somente_leitura = ""; |
---|
| 409 | $desabilitado = ""; |
---|
| 410 | if(($str == "listacorp") || ($str == "listafunc")) { |
---|
| 411 | $somente_leitura = "readonly"; //se lista for corp ou func, a variavel recebe readonly - sera usada nos input com uid, mail e cn da lista; |
---|
| 412 | $desabilitado = "disabled"; |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | |
---|
| 416 | // GET all infomations about the group. |
---|
| 417 | $maillist_info = $this->maillist->get_adm_info($_GET['uidnumber'], $manager_context); |
---|
| 418 | // debug_array($maillist_info); |
---|
| 419 | |
---|
| 420 | |
---|
| 421 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 422 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 423 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Admin Lists'); |
---|
| 424 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 425 | |
---|
| 426 | // Set o template |
---|
| 427 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 428 | $p->set_file(Array('adm_maillist' => 'maillists_adm.tpl')); |
---|
| 429 | |
---|
| 430 | // Pega combo das organizações e seleciona a org da lista. |
---|
| 431 | $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context']))); |
---|
| 432 | |
---|
| 433 | // Usuarios da lista. |
---|
| 434 | if (count($maillist_info['members_info']) > 0) |
---|
| 435 | { |
---|
| 436 | foreach ($maillist_info['members_info'] as $uidnumber=>$userinfo) |
---|
| 437 | { |
---|
| 438 | $array_users[$uidnumber] = $userinfo['cn']; |
---|
| 439 | $array_users_uid[$uidnumber] = $userinfo['uid']; |
---|
| 440 | $array_users_type[$uidnumber] = $userinfo['type']; |
---|
| 441 | } |
---|
| 442 | natcasesort($array_users); |
---|
| 443 | foreach ($array_users as $uidnumber=>$cn) |
---|
| 444 | { |
---|
| 445 | if ($array_users_type[$uidnumber] == 'u') |
---|
| 446 | { |
---|
| 447 | // $users .= "<option value=" . $uidnumber . ">" . $cn . " [" . $array_users_uid[$uidnumber] . "]</option>"; |
---|
| 448 | $users .= "<option value=" . $uidnumber . ">" . $cn . " [" . $maillist_info['members_info'][$uidnumber]['mail'] . "]</option>"; |
---|
| 449 | } |
---|
| 450 | else |
---|
| 451 | { |
---|
| 452 | $unknow .= "<option value=" . $uidnumber . ">" . $cn . " [" . $array_users_uid[$uidnumber] . "]</option>"; |
---|
| 453 | } |
---|
| 454 | } |
---|
| 455 | |
---|
| 456 | if ($unknow != '') |
---|
| 457 | { |
---|
| 458 | //$opt_tmp_unknow = '<option value="-1" disabled>-------------------- E-mails não encontrados ------------------ </option>'."\n"; |
---|
| 459 | $opt_tmp_unknow = '<option value="-1" disabled>----------- Usuários não pertencentes ou não criados no Expresso ---------- </option>'."\n"; |
---|
| 460 | $ea_select_ADM_Maillist .= $opt_tmp_unknow . $unknow; |
---|
| 461 | } |
---|
| 462 | $opt_tmp_users = '<option value="-1" disabled>----------------------------- Usuários ---------------------------- </option>'."\n"; |
---|
| 463 | $ea_select_ADM_Maillist .= $opt_tmp_users . $users; |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | // Seta variaveis utilizadas pelo tpl. |
---|
| 467 | $var = Array( |
---|
| 468 | 'color_bg1' => "#E8F0F0", |
---|
| 469 | 'color_bg2' => "#D3DCE3", |
---|
| 470 | 'type' => 'adm_maillist', |
---|
| 471 | 'ldap_context' => $GLOBALS['phpgw_info']['server']['ldap_context'], |
---|
| 472 | 'dn_listas' => $GLOBALS['phpgw_info']['server']['dn_listas'], |
---|
| 473 | 'lang_back' => lang('Back'), |
---|
| 474 | 'lang_save' => lang('save'), |
---|
| 475 | 'lang_org' => lang('Organizations'), |
---|
| 476 | 'lang_maillist_uid' => lang('Maillist login'), |
---|
| 477 | 'lang_maillist_mail' => lang('Maillist Mail'), |
---|
| 478 | 'lang_maillist_name' => lang('Maillist name'), |
---|
| 479 | 'lang_maillist_description' => lang('Maillist description'), |
---|
| 480 | 'lang_maillist_users' => lang('Maillist users'), |
---|
| 481 | 'lang_maillist_adm' => lang('Maillist adm'), |
---|
| 482 | 'lang_add_user' => lang('Add User'), |
---|
| 483 | 'lang_rem_user' => lang('Remove User'), |
---|
| 484 | 'lang_all_users' => lang('Select users from all sub-organizations'), |
---|
| 485 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'), |
---|
| 486 | 'combo_org' => $org, |
---|
| 487 | 'teste' => $maillist_info['context'], |
---|
| 488 | 'manager_context' => $manager_context, |
---|
| 489 | 'uidnumber' => $_GET['uidnumber'], |
---|
| 490 | 'uid' => $maillist_info['uid'], |
---|
| 491 | 'admlista' => $maillist_info['admlista'], |
---|
| 492 | 'somente_leitura' => $somente_leitura, //recebe a variavel testada acima; |
---|
| 493 | 'desabilitado' => $desabilitado, //recebe a variavel testada acima; |
---|
| 494 | 'mail' => $maillist_info['mail'], |
---|
| 495 | 'cn' => $maillist_info['cn'], |
---|
| 496 | 'description' => $maillist_info['description'], |
---|
| 497 | 'accountStatus_checked' => $maillist_info['accountStatus'] == 'active' ? 'CHECKED' : '', |
---|
| 498 | 'accountAdm_checked' => $maillist_info['accountAdm'] == 'active' ? 'CHECKED' : '', |
---|
| 499 | |
---|
| 500 | 'phpgwAccountVisible_checked' => $maillist_info['phpgwAccountVisible'] == '-1' ? 'CHECKED' : '', |
---|
| 501 | 'ea_select_ADM_Maillist' => $ea_select_ADM_Maillist |
---|
| 502 | ); |
---|
| 503 | |
---|
| 504 | $p->set_var($var); |
---|
| 505 | |
---|
| 506 | $p->pfp('out','adm_maillist'); |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | function scl_maillists() |
---|
| 510 | { |
---|
| 511 | $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);'); |
---|
| 512 | |
---|
| 513 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
| 514 | //$acl = $this->functions->read_acl($account_lid); |
---|
| 515 | //$manager_context = $acl[0]['context']; |
---|
| 516 | $manager_context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context']; |
---|
| 517 | //$context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display']; |
---|
| 518 | |
---|
| 519 | //Teste o tipo de lista que esta sendo editada (corporativa ou funcional); |
---|
| 520 | $uid_lista = $_GET['maillist_uid']; //recebe o uid da lista selecionada; |
---|
| 521 | $str = explode("-", $uid_lista); //separa pelo "-"; |
---|
| 522 | $str = $str[0]; //pega o primeiro elemento, que neste caso e o que indica o tipo de lista |
---|
| 523 | |
---|
| 524 | $somente_leitura = ""; |
---|
| 525 | $desabilitado = ""; |
---|
| 526 | if(($str == "listacorp") || ($str == "listafunc")) { |
---|
| 527 | $somente_leitura = "readonly"; //se lista for corp ou func, a variavel recebe readonly - sera usada nos input com uid, mail e cn da lista; |
---|
| 528 | $desabilitado = "disabled"; |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | // GET all infomations about the group. |
---|
| 532 | $maillist_info = $this->maillist->get_scl_info($_GET['uidnumber'], $manager_context); |
---|
| 533 | //_debug_array($maillist_info); |
---|
| 534 | |
---|
| 535 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 536 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 537 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Edit Sending Control List'); |
---|
| 538 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 539 | |
---|
| 540 | // Set o template |
---|
| 541 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 542 | $p->set_file(Array('sql_maillist' => 'maillists_scl.tpl')); |
---|
| 543 | |
---|
| 544 | // Pega combo das organizações e seleciona a org da lista. |
---|
| 545 | $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context']))); |
---|
| 546 | |
---|
| 547 | // Usuarios de senders. |
---|
| 548 | if (count($maillist_info['senders_info']) > 0) |
---|
| 549 | { |
---|
| 550 | foreach ($maillist_info['senders_info'] as $uidnumber=>$senderinfo) |
---|
| 551 | { |
---|
| 552 | $array_senders[$uidnumber] = $senderinfo['cn']; |
---|
| 553 | } |
---|
| 554 | natcasesort($array_senders); |
---|
| 555 | foreach ($array_senders as $uidnumber=>$cn) |
---|
| 556 | { |
---|
| 557 | $ea_select_users_SCL_Maillist .= "<option value=" . $uidnumber . ">" . $cn . " [" . $maillist_info['senders_info'][$uidnumber]['mail'] . "]</option>"; |
---|
| 558 | } |
---|
| 559 | } |
---|
| 560 | |
---|
| 561 | // Seta variaveis utilizadas pelo tpl. |
---|
| 562 | $var = Array( |
---|
| 563 | 'color_bg1' => "#E8F0F0", |
---|
| 564 | 'color_bg2' => "#D3DCE3", |
---|
| 565 | 'type' => 'edit_maillist', |
---|
| 566 | 'ldap_context' => $GLOBALS['phpgw_info']['server']['ldap_context'], |
---|
| 567 | 'dn' => $maillist_info['dn'], |
---|
| 568 | 'lang_back' => lang('Back'), |
---|
| 569 | 'lang_save' => lang('save'), |
---|
| 570 | 'lang_org' => lang('Organizations'), |
---|
| 571 | 'lang_maillist_uid' => lang('Maillist login'), |
---|
| 572 | 'lang_maillist_mail' => lang('Maillist Mail'), |
---|
| 573 | 'lang_maillist_name' => lang('Maillist name'), |
---|
| 574 | 'lang_maillist_description' => lang('Maillist description'), |
---|
| 575 | 'lang_maillist_users' => lang('Maillist users'), |
---|
| 576 | 'lang_add_user' => lang('Add User'), |
---|
| 577 | 'lang_rem_user' => lang('Remove User'), |
---|
| 578 | 'lang_all_users' => lang('Show users from all sub-organizations'), |
---|
| 579 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'), |
---|
| 580 | 'combo_org' => $org, |
---|
| 581 | 'manager_context' => $manager_context, |
---|
| 582 | 'uidnumber' => $_GET['uidnumber'], |
---|
| 583 | 'uid' => $maillist_info['uid'], |
---|
| 584 | 'mail' => $maillist_info['mail'], |
---|
| 585 | 'cn' => $maillist_info['cn'], |
---|
| 586 | 'description' => $maillist_info['description'], |
---|
| 587 | 'admlista' => $maillist_info['admlista'], |
---|
| 588 | 'somente_leitura' => $somente_leitura, //recebe a variavel testada acima; |
---|
| 589 | 'desabilitado' => $desabilitado, //recebe a variavel testada acima; |
---|
| 590 | 'listPass' => $maillist_info['listPass'], |
---|
| 591 | 'accountRestrictive_checked' => $maillist_info['accountRestrictive'] == 'mailListRestriction' ? 'CHECKED' : '', |
---|
| 592 | 'participantCanSendMail_checked' => $maillist_info['participantCanSendMail'] == 'TRUE' ? 'CHECKED' : '', |
---|
| 593 | 'ea_select_users_SCL_Maillist' => $ea_select_users_SCL_Maillist |
---|
| 594 | ); |
---|
| 595 | $p->set_var($var); |
---|
| 596 | |
---|
| 597 | $p->pfp('out','sql_maillist'); |
---|
| 598 | } |
---|
| 599 | |
---|
| 600 | function row_action($action,$type,$uidnumber,$maillist_uid) |
---|
| 601 | { |
---|
| 602 | return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array( |
---|
| 603 | 'menuaction' => 'listAdmin.uimaillists.'.$action.'_'.$type, |
---|
| 604 | 'uidnumber' => $uidnumber, |
---|
| 605 | 'maillist_uid' => $maillist_uid |
---|
| 606 | )).'"> '.lang($action).' </a>'; |
---|
| 607 | } |
---|
| 608 | |
---|
| 609 | function css() |
---|
| 610 | { |
---|
| 611 | $appCSS = ''; |
---|
| 612 | return $appCSS; |
---|
| 613 | } |
---|
| 614 | } |
---|
| 615 | ?> |
---|