[903] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * phpGroupWare - Preferences * |
---|
| 4 | * http://www.phpgroupware.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 | class uiaclprefs |
---|
| 14 | { |
---|
| 15 | var $acl; |
---|
| 16 | var $template; |
---|
| 17 | |
---|
| 18 | var $public_functions = array('index' => True); |
---|
| 19 | |
---|
| 20 | function uiaclprefs() |
---|
| 21 | { |
---|
| 22 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | function index() |
---|
| 26 | { |
---|
| 27 | $acl_app = get_var('acl_app',array('POST','GET')); |
---|
| 28 | $start = get_var('start',array('POST','GET')); |
---|
| 29 | $query = get_var('query',array('POST','GET')); |
---|
| 30 | $s_groups = get_var('s_groups',array('POST','GET')); |
---|
| 31 | $s_users = get_var('s_users',array('POST','GET')); |
---|
| 32 | $owner = get_var('owner',array('POST','GET')); |
---|
| 33 | |
---|
| 34 | // Set the variable $dontsearch if the search parameter's length is less than 4 characters |
---|
| 35 | //if(((isset($_POST['search'])) && ($_GET['acl_app'] == 'calendar')) || ((isset($_POST['start'])) && ($_POST['start'] >= 0))){ |
---|
| 36 | if(((isset($_POST['search'])) && ($_GET['acl_app'] == 'calendar'))) |
---|
| 37 | { |
---|
| 38 | if (strlen($query) < 4) |
---|
| 39 | { |
---|
| 40 | $dontsearch = 1; |
---|
| 41 | } |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | // This operation parse a query and change the spaces (' ' and tabs) by stars '*' |
---|
| 45 | // to search with more than one argument |
---|
| 46 | $transformed_query = preg_replace('/\s+/', '*', $query); |
---|
| 47 | |
---|
| 48 | if (! $acl_app) |
---|
| 49 | { |
---|
| 50 | $acl_app = 'preferences'; |
---|
| 51 | $acl_app_not_passed = True; |
---|
| 52 | } |
---|
| 53 | else |
---|
| 54 | { |
---|
| 55 | $GLOBALS['phpgw']->translation->add_app($acl_app); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | $GLOBALS['phpgw_info']['flags']['currentapp'] = $acl_app; |
---|
| 59 | |
---|
| 60 | if ($acl_app_not_passed) |
---|
| 61 | { |
---|
| 62 | if(is_object($GLOBALS['phpgw']->log)) |
---|
| 63 | { |
---|
| 64 | $GLOBALS['phpgw']->log->message(array( |
---|
| 65 | 'text' => 'F-BadmenuactionVariable, failed to pass acl_app.', |
---|
| 66 | 'line' => __LINE__, |
---|
| 67 | 'file' => __FILE__ |
---|
| 68 | )); |
---|
| 69 | $GLOBALS['phpgw']->log->commit(); |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | if ($GLOBALS['phpgw_info']['server']['deny_user_grants_access'] && !isset($GLOBALS['phpgw_info']['user']['apps']['admin'])) |
---|
| 74 | { |
---|
| 75 | echo '<center><b>' . lang('Access not permitted') . '</b></center>'; |
---|
| 76 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | $this->template = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir($acl_app)); |
---|
| 80 | |
---|
| 81 | // Verifica se é o template da Celepar, então carrega outro .tpl |
---|
| 82 | //echo $this->template->root; |
---|
| 83 | if(strstr($this->template->root,'celepar')) { |
---|
| 84 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs2.index&acl_app='.$acl_app)); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | /* |
---|
| 88 | if(isset($save_my_owner) && $GLOBALS['phpgw_info']['user']['apps']['admin']) |
---|
| 89 | { |
---|
| 90 | $owner = $save_my_owner; |
---|
| 91 | unset($save_my_owner); |
---|
| 92 | } |
---|
| 93 | elseif(@isset($save_my_owner)) |
---|
| 94 | { |
---|
| 95 | echo '<center>'.lang('You do not have permission to set ACL\'s in this mode!').'</center>'; |
---|
| 96 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 97 | } |
---|
| 98 | */ |
---|
| 99 | |
---|
| 100 | if((!isset($owner) || empty($owner)) || !$GLOBALS['phpgw_info']['user']['apps']['admin']) |
---|
| 101 | { |
---|
| 102 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | // Don't search if variable $dontsearch is set |
---|
| 106 | if (!isset($dontsearch) && !empty($transformed_query) && !isset($_POST['submit'])){ |
---|
| 107 | $acct = CreateObject('phpgwapi.accounts',$owner); |
---|
| 108 | $groups = $acct->get_list('groups','','ASC','account_lid'); |
---|
| 109 | $users = $acct->get_list('accounts','','ASC','account_common_name', $transformed_query); |
---|
| 110 | //$users = $acct->get_list('accounts','','ASC','account_firstname'); |
---|
| 111 | $owner_name = $acct->id2name($owner); // get owner name for title |
---|
| 112 | if($is_group = $acct->get_type($owner) == 'g') |
---|
| 113 | { |
---|
| 114 | $owner_name = lang('Group').' ('.$owner_name.')'; |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | /* error_log("Users list:\n", 3, '/var/www/teste.log'); |
---|
| 119 | foreach($users as $i => $j) |
---|
| 120 | { |
---|
| 121 | error_log("\t$i => $j\n", 3, '/var/www/teste.log'); |
---|
| 122 | foreach($j as $k => $l) |
---|
| 123 | { |
---|
| 124 | error_log("\t\t$k => $l\n", 3, '/var/www/teste.log'); |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | */ |
---|
| 128 | |
---|
| 129 | unset($acct); |
---|
| 130 | $this->acl = CreateObject('phpgwapi.acl',(int)$owner); |
---|
| 131 | $this->acl->read_repository(); |
---|
| 132 | |
---|
| 133 | if ($_POST['submit']) |
---|
| 134 | { |
---|
| 135 | $processed = $_POST['processed']; |
---|
| 136 | $to_remove = unserialize(urldecode($processed)); |
---|
| 137 | |
---|
| 138 | for($i=0;$i<count($to_remove);$i++) |
---|
| 139 | { |
---|
| 140 | $this->acl->delete($GLOBALS['phpgw_info']['flags']['currentapp'],$to_remove[$i]); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | /* Group records */ |
---|
| 144 | $group_variable = $_POST['g_'.$GLOBALS['phpgw_info']['flags']['currentapp']]; |
---|
| 145 | |
---|
| 146 | if (!$group_variable) |
---|
| 147 | { |
---|
| 148 | $group_variable = array(); |
---|
| 149 | } |
---|
| 150 | @reset($group_variable); |
---|
| 151 | $totalacl = array(); |
---|
| 152 | while(list($rowinfo,$perm) = each($group_variable)) |
---|
| 153 | { |
---|
| 154 | list($group_id,$rights) = split('_',$rowinfo); |
---|
| 155 | $totalacl[$group_id] += $rights; |
---|
| 156 | } |
---|
| 157 | @reset($totalacl); |
---|
| 158 | while(list($group_id,$rights) = @each($totalacl)) |
---|
| 159 | { |
---|
| 160 | if($is_group) |
---|
| 161 | { |
---|
| 162 | /* Don't allow group-grants to grant private */ |
---|
| 163 | $rights &= ~PHPGW_ACL_PRIVATE; |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | $this->acl->add($GLOBALS['phpgw_info']['flags']['currentapp'],$group_id,$rights); |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | /* User records */ |
---|
| 170 | $user_variable = $_POST['u_'.$GLOBALS['phpgw_info']['flags']['currentapp']]; |
---|
| 171 | |
---|
| 172 | if (!$user_variable) |
---|
| 173 | { |
---|
| 174 | $user_variable = array(); |
---|
| 175 | } |
---|
| 176 | @reset($user_variable); |
---|
| 177 | $totalacl = array(); |
---|
| 178 | while(list($rowinfo,$perm) = each($user_variable)) |
---|
| 179 | { |
---|
| 180 | list($user_id,$rights) = split('_',$rowinfo); |
---|
| 181 | $totalacl[$user_id] += $rights; |
---|
| 182 | } |
---|
| 183 | @reset($totalacl); |
---|
| 184 | while(list($user_id,$rights) = @each($totalacl)) |
---|
| 185 | { |
---|
| 186 | if($is_group) |
---|
| 187 | { |
---|
| 188 | /* Don't allow group-grants to grant private */ |
---|
| 189 | $rights &= ~ PHPGW_ACL_PRIVATE; |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | $this->acl->add($GLOBALS['phpgw_info']['flags']['currentapp'],$user_id,$rights); |
---|
| 193 | } |
---|
| 194 | $this->acl->save_repository(); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | $processed = Array(); |
---|
| 198 | |
---|
| 199 | $total = 0; |
---|
| 200 | |
---|
| 201 | if(!isset($start)) |
---|
| 202 | { |
---|
| 203 | $start = 0; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | if(!$start) |
---|
| 207 | { |
---|
| 208 | $s_groups = 0; |
---|
| 209 | $s_users = 0; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | if(!isset($s_groups)) |
---|
| 213 | { |
---|
| 214 | $s_groups = 0; |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | if(!isset($s_users)) |
---|
| 218 | { |
---|
| 219 | $s_users = 0; |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | if(!isset($query)) |
---|
| 223 | { |
---|
| 224 | $query = ""; |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | if(!isset($maxm)) |
---|
| 228 | { |
---|
| 229 | $maxm = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | if(!isset($totalentries)) |
---|
| 233 | { |
---|
| 234 | $totalentries = count($groups) + count($users); |
---|
| 235 | if($totalentries < $maxm) |
---|
| 236 | { |
---|
| 237 | $maxm = $totalentries; |
---|
| 238 | } |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('%1 - Preferences',$GLOBALS['phpgw_info']['apps'][$acl_app]['title']).' - '.lang('acl').': '.$owner_name; |
---|
| 242 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 243 | echo parse_navbar(); |
---|
| 244 | |
---|
| 245 | $this->template = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir($acl_app)); |
---|
| 246 | |
---|
| 247 | // If variable $dontsearch is set, just print the message and unset the variable |
---|
| 248 | if (isset($dontsearch) && !isset($_POST['submit'])) |
---|
| 249 | { |
---|
| 250 | /* |
---|
| 251 | * TODO: Message's translation |
---|
| 252 | */ |
---|
| 253 | $this->show_message('<p>Favor fazer a consulta com pelo menos 4 caracteres!</p>'); |
---|
| 254 | } |
---|
| 255 | unset($dontsearch); |
---|
| 256 | |
---|
| 257 | $templates = Array ( |
---|
| 258 | 'preferences' => 'preference_acl.tpl', |
---|
| 259 | 'row_colspan' => 'preference_colspan.tpl', |
---|
| 260 | 'acl_row' => 'preference_acl_row.tpl' |
---|
| 261 | ); |
---|
| 262 | |
---|
| 263 | $this->template->set_file($templates); |
---|
| 264 | |
---|
| 265 | $common_hidden_vars = |
---|
| 266 | ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n" |
---|
| 267 | . ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n" |
---|
| 268 | . ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n" |
---|
| 269 | . ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n" |
---|
| 270 | . ' <input type="hidden" name="start" value="'.$start.'">'."\n" |
---|
| 271 | . ' <input type="hidden" name="query" value="'.$query.'">'."\n" |
---|
| 272 | . ' <input type="hidden" name="owner" value="'.$owner.'">'."\n" |
---|
| 273 | . ' <input type="hidden" name="acl_app" value="'.$acl_app.'">'."\n"; |
---|
| 274 | |
---|
| 275 | $var = Array( |
---|
| 276 | 'errors' => '', |
---|
| 277 | 'title' => '<br>', |
---|
| 278 | 'action_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app=' . $acl_app), |
---|
| 279 | 'bg_color' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
| 280 | 'submit_lang' => lang('Save'), |
---|
| 281 | 'common_hidden_vars_form' => $common_hidden_vars |
---|
| 282 | ); |
---|
| 283 | |
---|
| 284 | $this->template->set_var($var); |
---|
| 285 | |
---|
| 286 | if(isset($query_result) && $query_result) |
---|
| 287 | { |
---|
| 288 | $common_hidden_vars .= '<input type="hidden" name="query_result" value="'.$query_result.'">'."\n"; |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | $this->template->set_var('common_hidden_vars',$common_hidden_vars); |
---|
| 292 | |
---|
| 293 | $vars = $this->template->get_undefined('row_colspan'); |
---|
| 294 | while (list(,$var) = each($vars)) |
---|
| 295 | { |
---|
| 296 | if(strstr($var,'lang_')) |
---|
| 297 | { |
---|
| 298 | $value = str_replace('lang_','',$var); |
---|
| 299 | $value = str_replace('_',' ',$value); |
---|
| 300 | |
---|
| 301 | $this->template->set_var($var,lang($value)); |
---|
| 302 | } |
---|
| 303 | } |
---|
| 304 | |
---|
| 305 | if (isset($_POST['submit'])) |
---|
| 306 | { |
---|
| 307 | $this->show_message(lang('ACL grants have been updated')); |
---|
| 308 | $this->show_shared($users,$maxm,$acl_app,$s_users,$s_groups,$totalentries,$start,$total,$owner); |
---|
| 309 | exit; |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | //para não exibir os dados inicialmente na agenda (valida a postagem de dados para o aplicativo calendario, a partir do botao "busca(search)" ou imagens "proximo/anterior(start)") |
---|
| 313 | if(((isset($_POST['search'])) && ($_GET['acl_app'] == 'calendar')) || ((isset($_POST['start'])) && ($_POST['start'] >= 0))){ |
---|
| 314 | if ((int)$s_groups <> count($groups)) |
---|
| 315 | { |
---|
| 316 | $boo_header_group = false; //flag para exibir o header na table para os grupos |
---|
| 317 | |
---|
| 318 | reset($groups); |
---|
| 319 | for($k=0;$k<count($groups);$k++) |
---|
| 320 | { |
---|
| 321 | $group = $groups[$k]; |
---|
| 322 | $go = True; |
---|
| 323 | |
---|
| 324 | if($query) |
---|
| 325 | { |
---|
| 326 | //if(!strpos(' '.$group['account_lid'].' ',$query)) problema da consulta case insensitive |
---|
| 327 | if(!strpos(' '.strtoupper($group['account_lid']).' ', strtoupper($query))) |
---|
| 328 | { |
---|
| 329 | $go = False; |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | if($go) |
---|
| 334 | { |
---|
| 335 | //Condicional para tratar da exibição da linha base dos grupos na tela |
---|
| 336 | if(!$boo_header_group){ |
---|
| 337 | $this->template->set_var('string',lang('Groups')); |
---|
| 338 | $this->template->parse('row','row_colspan',True); |
---|
| 339 | $boo_header_group = true; |
---|
| 340 | } |
---|
| 341 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
| 342 | $this->display_row($tr_color,'g_',$group['account_id'],$group['account_lid'],$is_group); |
---|
| 343 | $s_groups++; |
---|
| 344 | $processed[] = $group['account_id']; |
---|
| 345 | $total++; |
---|
| 346 | if($total == $maxm) |
---|
| 347 | { |
---|
| 348 | break; |
---|
| 349 | } |
---|
| 350 | } |
---|
| 351 | } |
---|
| 352 | } |
---|
| 353 | if($total <> $maxm) |
---|
| 354 | { |
---|
| 355 | |
---|
| 356 | if($users) |
---|
| 357 | { |
---|
| 358 | $boo_header_users = false; //flag para exibir o header na table para os grupos |
---|
| 359 | |
---|
| 360 | for($k=$s_users;$k<$totalentries || $k==count($users);$k++) |
---|
| 361 | { |
---|
| 362 | $user = $users[$k]; |
---|
| 363 | //echo '<br>acctid: '.$user['account_id']; |
---|
| 364 | if ($user['account_id']) |
---|
| 365 | { |
---|
| 366 | $go = True; |
---|
| 367 | } |
---|
| 368 | else |
---|
| 369 | { |
---|
| 370 | $go = False; |
---|
| 371 | } |
---|
| 372 | |
---|
| 373 | /* |
---|
| 374 | * We don't filter this way anymore |
---|
| 375 | |
---|
| 376 | if($query) |
---|
| 377 | { |
---|
| 378 | // Results filtered using the cn attribute |
---|
| 379 | //$name = ' '.$user['account_firstname'].' '.$user['account_lastname'].' '.$user['account_lid'].' '; |
---|
| 380 | $name = ' '.$user['account_common_name'].' '; |
---|
| 381 | |
---|
| 382 | // This iteration gets the $transformed_query variable and test if all the search arguments |
---|
| 383 | // are present in the user name |
---|
| 384 | foreach (explode('*', $transformed_query) as $i => $part) |
---|
| 385 | { |
---|
| 386 | if(!strpos(strtoupper($name),strtoupper($part))) //aqui, usava apenas $name e $query |
---|
| 387 | { |
---|
| 388 | $go = False; |
---|
| 389 | break; |
---|
| 390 | } |
---|
| 391 | } |
---|
| 392 | } |
---|
| 393 | */ |
---|
| 394 | if($go && $user['account_id'] != $owner) // Need to be $owner not $GLOBALS['phpgw_info']['user']['account_id'] |
---|
| 395 | { |
---|
| 396 | //Condicional para tratar da exibição da linha base dos usuários na tela |
---|
| 397 | if(!$boo_header_users){ |
---|
| 398 | $this->template->set_var('string',ucfirst(lang('Users'))); |
---|
| 399 | $this->template->parse('row','row_colspan',True); |
---|
| 400 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
| 401 | $boo_header_users = true; |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | // or the admin can't get special grants from a group |
---|
| 405 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
| 406 | //$this->display_row($tr_color,'u_',$user['account_id'],$GLOBALS['phpgw']->common->display_fullname($user['account_lid'],$user['account_firstname'],$user['account_lastname']),$is_group); |
---|
| 407 | |
---|
| 408 | /* |
---|
| 409 | * TODO: Make the display name configurable |
---|
| 410 | */ |
---|
| 411 | //Use cn attribute as the display name |
---|
| 412 | $this->display_row($tr_color,'u_',$user['account_id'],$user['account_common_name'],$is_group); |
---|
| 413 | $s_users++; |
---|
| 414 | $processed[] = $user['account_id']; |
---|
| 415 | $total++; |
---|
| 416 | if($total == $maxm) |
---|
| 417 | { |
---|
| 418 | break; |
---|
| 419 | } |
---|
| 420 | } |
---|
| 421 | } |
---|
| 422 | } |
---|
| 423 | } |
---|
| 424 | //Condicional adicionado, para inibir a navegação de "anterior" e "próximo" limitado pelo número |
---|
| 425 | //de registros de uma pesquisa |
---|
| 426 | if($total < $maxm) |
---|
| 427 | $totalentries2 = $total; |
---|
| 428 | else |
---|
| 429 | $totalentries2 = $totalentries; |
---|
| 430 | |
---|
| 431 | $extra_parms = 'menuaction=preferences.uiaclprefs.index' |
---|
| 432 | . '&acl_app=' . $acl_app |
---|
| 433 | . '&s_users='.$s_users.'&s_groups='.$s_groups |
---|
| 434 | . '&maxm=' . $maxm . '&totalentries=' . $totalentries |
---|
| 435 | . '&total=' . ($start + $total) . '&owner='.$owner . '&query='.$transformed_query; |
---|
| 436 | |
---|
| 437 | $var = Array( |
---|
| 438 | 'nml' => $GLOBALS['phpgw']->nextmatchs->left('/index.php',$start,$totalentries2,$extra_parms), |
---|
| 439 | 'nmr' => $GLOBALS['phpgw']->nextmatchs->right('/index.php',$start,$totalentries2,$extra_parms), |
---|
| 440 | 'search_value' => (isset($query) && $query?$query:''), |
---|
| 441 | 'search' => lang('search'), |
---|
| 442 | 'processed' => urlencode(serialize($processed)) |
---|
| 443 | ); |
---|
| 444 | $this->template->set_var($var); |
---|
| 445 | $this->template->pfp('out','preferences'); |
---|
| 446 | } |
---|
| 447 | //Bloco adicionado para exibir inicialmente os usuários que tenham sido atribuidos a alguma |
---|
| 448 | //permissão para compartilhamento |
---|
| 449 | else{ |
---|
| 450 | echo $this->show_shared($users,$maxm,$acl_app,$s_users,$s_groups,$totalentries,$start,$total,$owner); |
---|
| 451 | } |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | function check_acl($label,$id,$acl,$rights,$right,$is_group=False) |
---|
| 455 | { |
---|
| 456 | $this->template->set_var($acl,$label.$GLOBALS['phpgw_info']['flags']['currentapp'].'['.$id.'_'.$right.']'); |
---|
| 457 | $rights_set = (($rights & $right)?' checked':''); |
---|
| 458 | if ($is_group) |
---|
| 459 | { |
---|
| 460 | // This is so you can't select it in the GUI |
---|
| 461 | $rights_set .= ' disabled'; |
---|
| 462 | } |
---|
| 463 | $this->template->set_var($acl.'_selected',$rights_set); |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | function display_row($bg_color,$label,$id,$name,$is_group) |
---|
| 467 | { |
---|
| 468 | $this->template->set_var('row_color',$bg_color); |
---|
| 469 | $this->template->set_var('user',$name); |
---|
| 470 | $rights = $this->acl->get_rights($id,$GLOBALS['phpgw_info']['flags']['currentapp']); |
---|
| 471 | // vv This is new |
---|
| 472 | $grantors = $this->acl->get_ids_for_location($id,$rights,$GLOBALS['phpgw_info']['flags']['currentapp']); |
---|
| 473 | $is_group_set = False; |
---|
| 474 | while(@$grantors && list($key,$grantor) = each($grantors)) |
---|
| 475 | { |
---|
| 476 | if($GLOBALS['phpgw']->accounts->get_type($grantor) == 'g') |
---|
| 477 | { |
---|
| 478 | $is_group_set = True; |
---|
| 479 | } |
---|
| 480 | } |
---|
| 481 | // ^^ This is new |
---|
| 482 | |
---|
| 483 | $this->check_acl($label,$id,'read',$rights,PHPGW_ACL_READ,($is_group_set && ($rights & PHPGW_ACL_READ) && !$is_group?$is_group_set:False)); |
---|
| 484 | $this->check_acl($label,$id,'add',$rights,PHPGW_ACL_ADD,($is_group_set && ($rights & PHPGW_ACL_ADD && !$is_group)?$is_group_set:False)); |
---|
| 485 | $this->check_acl($label,$id,'edit',$rights,PHPGW_ACL_EDIT,($is_group_set && ($rights & PHPGW_ACL_EDIT && !$is_group)?$is_group_set:False)); |
---|
| 486 | $this->check_acl($label,$id,'delete',$rights,PHPGW_ACL_DELETE,($is_group_set && ($rights & PHPGW_ACL_DELETE && !$is_group)?$is_group_set:False)); |
---|
| 487 | $this->check_acl($label,$id,'private',$rights,PHPGW_ACL_PRIVATE,$is_group); |
---|
| 488 | |
---|
| 489 | $this->check_acl($label,$id,'custom_1',$rights,PHPGW_ACL_CUSTOM_1,($is_group_set && ($rights & PHPGW_ACL_CUSTOM_1) && !$is_group?$is_group_set:False)); |
---|
| 490 | $this->check_acl($label,$id,'custom_2',$rights,PHPGW_ACL_CUSTOM_2,($is_group_set && ($rights & PHPGW_ACL_CUSTOM_2) && !$is_group?$is_group_set:False)); |
---|
| 491 | $this->check_acl($label,$id,'custom_3',$rights,PHPGW_ACL_CUSTOM_3,($is_group_set && ($rights & PHPGW_ACL_CUSTOM_3) && !$is_group?$is_group_set:False)); |
---|
| 492 | $this->template->parse('row','acl_row',True); |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | //Metodo adicionado para exibir os usuarios que tem algum compartilhamento com o usuario logado |
---|
| 496 | //no sistema |
---|
| 497 | function show_shared($users,$maxm,$acl_app,$s_users,$s_groups,$totalentries,$start,$total,$owner){ |
---|
| 498 | //if ($users){ |
---|
| 499 | $boo_header_users = false; |
---|
| 500 | //$shared_users_list = array(); |
---|
| 501 | //Laço que percorre nos usuários do Expresso, aqueles que possuem algum compartilhamento com o |
---|
| 502 | //usuário logado |
---|
| 503 | |
---|
| 504 | // search for users i share my schedule and generate an ldap search filter |
---|
| 505 | $filter = $this->generate_search_filter($this->acl->get_location_list_for_id($GLOBALS['phpgw_info']['flags']['currentapp'], 1)); |
---|
| 506 | |
---|
| 507 | // Se filtro é vazio, não faz a pesquisa no ldap |
---|
| 508 | if ($filter) |
---|
| 509 | { |
---|
| 510 | $acct = CreateObject('phpgwapi.accounts',$owner); |
---|
| 511 | $shared_users_list = $acct->get_list('accounts','','ASC','account_common_name', '', '', 'filter', $filter); |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | /* |
---|
| 515 | * We have the shared list already |
---|
| 516 | |
---|
| 517 | for ($k=0; $k<count($users); $k++){ |
---|
| 518 | // deixar para fazer a consulta de acordo com os resultados das acls |
---|
| 519 | if($this->acl->get_rights($users[$k]['account_id'],$GLOBALS['phpgw_info']['flags']['currentapp'] != 0)) |
---|
| 520 | array_push($shared_users_list, $k); |
---|
| 521 | } |
---|
| 522 | |
---|
| 523 | */ |
---|
| 524 | |
---|
| 525 | // use the search result above to generate output |
---|
| 526 | //Se ha compartilhamentos encontrados, exibe-os inicialmente na tela desta opção no sistema |
---|
| 527 | if (count($shared_users_list) > 0){ |
---|
| 528 | //for ($k=0; $k<count($shared_users_list); $k++){ |
---|
| 529 | foreach ($shared_users_list as $shared) |
---|
| 530 | { |
---|
| 531 | //Exibe o header com os dados da tabela |
---|
| 532 | if(!$boo_header_users){ |
---|
| 533 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
| 534 | $this->template->set_var('string',ucfirst(lang('Users'))); |
---|
| 535 | $this->template->parse('row','row_colspan',True); |
---|
| 536 | $boo_header_users = true; |
---|
| 537 | } |
---|
| 538 | //Exibe os dados do usuário em compartilhamento |
---|
| 539 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
| 540 | //$this->display_row($tr_color,'u_',$users[$shared_users_list[$k]]['account_id'],$GLOBALS['phpgw']->common->display_fullname($users[$shared_users_list[$k]]['account_lid'],$users[$shared_users_list[$k]]['account_firstname'],$users[$shared_users_list[$k]]['account_lastname']),$is_group); |
---|
| 541 | |
---|
| 542 | /* |
---|
| 543 | * TODO: Make the display name configurable |
---|
| 544 | */ |
---|
| 545 | //Use cn attribute as the display name |
---|
| 546 | $this->display_row($tr_color,'u_',$shared['account_id'],$shared['account_common_name'],$is_group); |
---|
| 547 | $processed[] = $shared['account_id']; |
---|
| 548 | //$this->display_row($tr_color,'u_',$users[$shared_users_list[$k]]['account_id'],$users[$shared_users_list[$k]]['account_common_name'],$is_group); |
---|
| 549 | //$processed[] = $users[$shared_users_list[$k]]['account_id']; |
---|
| 550 | } |
---|
| 551 | } |
---|
| 552 | //Não há compartilhamentos ativos, mostra tela default abaixo |
---|
| 553 | else{ |
---|
| 554 | $this->show_message('<p>Não constam compartilhamentos ativos no sistema.</p><p>Utilize o sistema de busca para adicionar usuários em modo compartilhado.</p>'); |
---|
| 555 | } |
---|
| 556 | //} |
---|
| 557 | //Condicional adicionado, para inibir a navegação de "anterior" e "próximo" limitado pelo número |
---|
| 558 | //de registros de uma pesquisa |
---|
| 559 | if(count($shared_users_list) < $maxm) |
---|
| 560 | $totalentries2 = count($shared_users_list); |
---|
| 561 | else |
---|
| 562 | $totalentries2 = $maxm; |
---|
| 563 | |
---|
| 564 | $extra_parms = 'menuaction=preferences.uiaclprefs.index' |
---|
| 565 | . '&acl_app=' . $acl_app |
---|
| 566 | . '&s_users='.$s_users.'&s_groups='.$s_groups |
---|
| 567 | . '&maxm=' . $maxm . '&totalentries=' . $totalentries |
---|
| 568 | . '&total=' . ($start + $total) . '&owner='.$owner; |
---|
| 569 | |
---|
| 570 | $var = Array( |
---|
| 571 | 'nml' => $GLOBALS['phpgw']->nextmatchs->left('/index.php',$start,$totalentries2,$extra_parms), |
---|
| 572 | 'nmr' => $GLOBALS['phpgw']->nextmatchs->right('/index.php',$start,$totalentries2,$extra_parms), |
---|
| 573 | 'search_value' => (isset($query) && $query?$query:''), |
---|
| 574 | 'search' => lang('search'), |
---|
| 575 | 'processed' => urlencode(serialize($processed)) |
---|
| 576 | ); |
---|
| 577 | $this->template->set_var($var); |
---|
| 578 | //$this->template->pfp('out','preferences'); |
---|
| 579 | $this->template->pfp('out','preferences'); |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | // Method to generate an ldap search filter based in a list generated from $this->acl->get_location_list_for_id |
---|
| 583 | function generate_search_filter($shares) |
---|
| 584 | { |
---|
| 585 | if (count($shares) > 1){ |
---|
| 586 | $filter = '(&(phpgwaccounttype=u)(|'; |
---|
| 587 | foreach ($shares as $j) |
---|
| 588 | { |
---|
| 589 | if (strtolower($j) != 'run') |
---|
| 590 | { |
---|
| 591 | $filter .= "(uidNumber=$j)"; |
---|
| 592 | } |
---|
| 593 | } |
---|
| 594 | $filter .= '))'; |
---|
| 595 | return $filter; |
---|
| 596 | } |
---|
| 597 | else |
---|
| 598 | { |
---|
| 599 | return False; |
---|
| 600 | } |
---|
| 601 | } |
---|
| 602 | |
---|
| 603 | //Metodo adicionado para exibir uma camada com uma string de mensagem |
---|
| 604 | function show_message($message){ |
---|
| 605 | $this->template->set_var('string','<div style="margin: 0 auto; text-align: center; padding: 10px; background-color: rgb(255,250,205); width:50%;">'.$message.'</div>'); |
---|
| 606 | $this->template->set_var('submit_lang',lang('Save')); |
---|
| 607 | $this->template->parse('row','string',True); |
---|
| 608 | } |
---|
| 609 | } |
---|
| 610 | ?> |
---|