Favor fazer a consulta com pelo menos 4 caracteres!
');
}
unset($dontsearch);
$templates = Array (
'preferences' => 'preference_acl.tpl',
'row_colspan' => 'preference_colspan.tpl',
'acl_row' => 'preference_acl_row.tpl'
);
$this->template->set_file($templates);
$common_hidden_vars =
' '."\n"
. ' '."\n"
. ' '."\n"
. ' '."\n"
. ' '."\n"
. ' '."\n"
. ' '."\n"
. ' '."\n";
$var = Array(
'errors' => '',
'title' => ' ',
'action_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app=' . $acl_app),
'bg_color' => $GLOBALS['phpgw_info']['theme']['th_bg'],
'submit_lang' => lang('Save'),
'common_hidden_vars_form' => $common_hidden_vars
);
$this->template->set_var($var);
if(isset($query_result) && $query_result)
{
$common_hidden_vars .= ''."\n";
}
$this->template->set_var('common_hidden_vars',$common_hidden_vars);
$vars = $this->template->get_undefined('row_colspan');
while (list(,$var) = each($vars))
{
if(strstr($var,'lang_'))
{
$value = str_replace('lang_','',$var);
$value = str_replace('_',' ',$value);
$this->template->set_var($var,lang($value));
}
}
if (isset($_POST['submit']))
{
$this->show_message(lang('ACL grants have been updated'));
$this->show_shared($users,$maxm,$acl_app,$s_users,$s_groups,$totalentries,$start,$total,$owner);
exit;
}
//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)")
if(((isset($_POST['search'])) && ($_GET['acl_app'] == 'calendar')) || ((isset($_POST['start'])) && ($_POST['start'] >= 0))){
if ((int)$s_groups <> count($groups))
{
$boo_header_group = false; //flag para exibir o header na table para os grupos
reset($groups);
for($k=0;$ktemplate->set_var('string',lang('Groups'));
$this->template->parse('row','row_colspan',True);
$boo_header_group = true;
}
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
$this->display_row($tr_color,'g_',$group['account_id'],$group['account_lid'],$is_group);
$s_groups++;
$processed[] = $group['account_id'];
$total++;
if($total == $maxm)
{
break;
}
}
}
}
if($total <> $maxm)
{
if($users)
{
$boo_header_users = false; //flag para exibir o header na table para os grupos
for($k=$s_users;$k<$totalentries || $k==count($users);$k++)
{
$user = $users[$k];
//echo ' acctid: '.$user['account_id'];
if ($user['account_id'])
{
$go = True;
}
else
{
$go = False;
}
/*
* We don't filter this way anymore
if($query)
{
// Results filtered using the cn attribute
//$name = ' '.$user['account_firstname'].' '.$user['account_lastname'].' '.$user['account_lid'].' ';
$name = ' '.$user['account_common_name'].' ';
// This iteration gets the $transformed_query variable and test if all the search arguments
// are present in the user name
foreach (explode('*', $transformed_query) as $i => $part)
{
if(!strpos(strtoupper($name),strtoupper($part))) //aqui, usava apenas $name e $query
{
$go = False;
break;
}
}
}
*/
if($go && $user['account_id'] != $owner) // Need to be $owner not $GLOBALS['phpgw_info']['user']['account_id']
{
//Condicional para tratar da exibição da linha base dos usuários na tela
if(!$boo_header_users){
$this->template->set_var('string',ucfirst(lang('Users')));
$this->template->parse('row','row_colspan',True);
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
$boo_header_users = true;
}
// or the admin can't get special grants from a group
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
//$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);
/*
* TODO: Make the display name configurable
*/
//Use cn attribute as the display name
$this->display_row($tr_color,'u_',$user['account_id'],$user['account_common_name'],$is_group);
$s_users++;
$processed[] = $user['account_id'];
$total++;
if($total == $maxm)
{
break;
}
}
}
}
}
//Condicional adicionado, para inibir a navegação de "anterior" e "próximo" limitado pelo número
//de registros de uma pesquisa
if($total < $maxm)
$totalentries2 = $total;
else
$totalentries2 = $totalentries;
$extra_parms = 'menuaction=preferences.uiaclprefs.index'
. '&acl_app=' . $acl_app
. '&s_users='.$s_users.'&s_groups='.$s_groups
. '&maxm=' . $maxm . '&totalentries=' . $totalentries
. '&total=' . ($start + $total) . '&owner='.$owner . '&query='.$transformed_query;
$var = Array(
'nml' => $GLOBALS['phpgw']->nextmatchs->left('/index.php',$start,$totalentries2,$extra_parms),
'nmr' => $GLOBALS['phpgw']->nextmatchs->right('/index.php',$start,$totalentries2,$extra_parms),
'search_value' => (isset($query) && $query?$query:''),
'search' => lang('search'),
'processed' => urlencode(serialize($processed))
);
$this->template->set_var($var);
$this->template->pfp('out','preferences');
}
//Bloco adicionado para exibir inicialmente os usuários que tenham sido atribuidos a alguma
//permissão para compartilhamento
else{
echo $this->show_shared($users,$maxm,$acl_app,$s_users,$s_groups,$totalentries,$start,$total,$owner);
}
}
function check_acl($label,$id,$acl,$rights,$right,$is_group=False)
{
$this->template->set_var($acl,$label.$GLOBALS['phpgw_info']['flags']['currentapp'].'['.$id.'_'.$right.']');
$rights_set = (($rights & $right)?' checked':'');
if ($is_group)
{
// This is so you can't select it in the GUI
$rights_set .= ' disabled';
}
$this->template->set_var($acl.'_selected',$rights_set);
}
function display_row($bg_color,$label,$id,$name,$is_group)
{
$this->template->set_var('row_color',$bg_color);
$this->template->set_var('user',$name);
$rights = $this->acl->get_rights($id,$GLOBALS['phpgw_info']['flags']['currentapp']);
// vv This is new
$grantors = $this->acl->get_ids_for_location($id,$rights,$GLOBALS['phpgw_info']['flags']['currentapp']);
$is_group_set = False;
while(@$grantors && list($key,$grantor) = each($grantors))
{
if($GLOBALS['phpgw']->accounts->get_type($grantor) == 'g')
{
$is_group_set = True;
}
}
// ^^ This is new
$this->check_acl($label,$id,'read',$rights,PHPGW_ACL_READ,($is_group_set && ($rights & PHPGW_ACL_READ) && !$is_group?$is_group_set:False));
$this->check_acl($label,$id,'add',$rights,PHPGW_ACL_ADD,($is_group_set && ($rights & PHPGW_ACL_ADD && !$is_group)?$is_group_set:False));
$this->check_acl($label,$id,'edit',$rights,PHPGW_ACL_EDIT,($is_group_set && ($rights & PHPGW_ACL_EDIT && !$is_group)?$is_group_set:False));
$this->check_acl($label,$id,'delete',$rights,PHPGW_ACL_DELETE,($is_group_set && ($rights & PHPGW_ACL_DELETE && !$is_group)?$is_group_set:False));
$this->check_acl($label,$id,'private',$rights,PHPGW_ACL_PRIVATE,$is_group);
$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));
$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));
$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));
$this->template->parse('row','acl_row',True);
}
//Metodo adicionado para exibir os usuarios que tem algum compartilhamento com o usuario logado
//no sistema
function show_shared($users,$maxm,$acl_app,$s_users,$s_groups,$totalentries,$start,$total,$owner){
//if ($users){
$boo_header_users = false;
//$shared_users_list = array();
//Laço que percorre nos usuários do Expresso, aqueles que possuem algum compartilhamento com o
//usuário logado
// search for users i share my schedule and generate an ldap search filter
$filter = $this->generate_search_filter($this->acl->get_location_list_for_id($GLOBALS['phpgw_info']['flags']['currentapp'], 1));
// Se filtro é vazio, não faz a pesquisa no ldap
if ($filter)
{
$acct = CreateObject('phpgwapi.accounts',$owner);
$shared_users_list = $acct->get_list('accounts','','ASC','account_common_name', '', '', 'filter', $filter);
}
/*
* We have the shared list already
for ($k=0; $kacl->get_rights($users[$k]['account_id'],$GLOBALS['phpgw_info']['flags']['currentapp'] != 0))
array_push($shared_users_list, $k);
}
*/
// use the search result above to generate output
//Se ha compartilhamentos encontrados, exibe-os inicialmente na tela desta opção no sistema
if (count($shared_users_list) > 0){
//for ($k=0; $knextmatchs->alternate_row_color($tr_color);
$this->template->set_var('string',ucfirst(lang('Users')));
$this->template->parse('row','row_colspan',True);
$boo_header_users = true;
}
//Exibe os dados do usuário em compartilhamento
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
//$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);
/*
* TODO: Make the display name configurable
*/
//Use cn attribute as the display name
$this->display_row($tr_color,'u_',$shared['account_id'],$shared['account_common_name'],$is_group);
$processed[] = $shared['account_id'];
//$this->display_row($tr_color,'u_',$users[$shared_users_list[$k]]['account_id'],$users[$shared_users_list[$k]]['account_common_name'],$is_group);
//$processed[] = $users[$shared_users_list[$k]]['account_id'];
}
}
//Não há compartilhamentos ativos, mostra tela default abaixo
else{
$this->show_message('
Não constam compartilhamentos ativos no sistema.
Utilize o sistema de busca para adicionar usuários em modo compartilhado.
');
}
//}
//Condicional adicionado, para inibir a navegação de "anterior" e "próximo" limitado pelo número
//de registros de uma pesquisa
if(count($shared_users_list) < $maxm)
$totalentries2 = count($shared_users_list);
else
$totalentries2 = $maxm;
$extra_parms = 'menuaction=preferences.uiaclprefs.index'
. '&acl_app=' . $acl_app
. '&s_users='.$s_users.'&s_groups='.$s_groups
. '&maxm=' . $maxm . '&totalentries=' . $totalentries
. '&total=' . ($start + $total) . '&owner='.$owner;
$var = Array(
'nml' => $GLOBALS['phpgw']->nextmatchs->left('/index.php',$start,$totalentries2,$extra_parms),
'nmr' => $GLOBALS['phpgw']->nextmatchs->right('/index.php',$start,$totalentries2,$extra_parms),
'search_value' => (isset($query) && $query?$query:''),
'search' => lang('search'),
'processed' => urlencode(serialize($processed))
);
$this->template->set_var($var);
//$this->template->pfp('out','preferences');
$this->template->pfp('out','preferences');
}
// Method to generate an ldap search filter based in a list generated from $this->acl->get_location_list_for_id
function generate_search_filter($shares)
{
if (count($shares) > 1){
$filter = '(&(phpgwaccounttype=u)(|';
foreach ($shares as $j)
{
if (strtolower($j) != 'run')
{
$filter .= "(uidNumber=$j)";
}
}
$filter .= '))';
return $filter;
}
else
{
return False;
}
}
//Metodo adicionado para exibir uma camada com uma string de mensagem
function show_message($message){
$this->template->set_var('string','