diff --git a/preferences/acl_preferences.php b/preferences/acl_preferences.php new file mode 100644 index 0000000000..93c13d8257 --- /dev/null +++ b/preferences/acl_preferences.php @@ -0,0 +1,319 @@ + $acl_app, + 'enable_nextmatchs_class' => True, + 'noappheader' => True, + 'noappfooter' => True + ); + + $phpgw_info['flags'] = $phpgw_flags; + include('../header.inc.php'); + + $private_acl = True; + + if($private_acl == True) + { + define(PHPGW_ACL_PRIVATE,16); + } + + function check_acl($label,$id,$acl,$rights,$right) + { + global $phpgw_info, $p; + + $p->set_var($acl,$label.$phpgw_info['flags']['currentapp'].'['.$id.']['.$right.']'); + if ($rights & $right) + { + $p->set_var($acl.'_selected',' checked'); + } + else + { + $p->set_var($acl.'_selected',''); + } + } + + + function display_row($bg_color,$label,$id,$name) + { + global $phpgw_info, $acl, $private_acl, $p; + + $p->set_var('row_color',$bg_color); + $p->set_var('user',$name); + $rights = $acl->get_rights($id,$phpgw_info['flags']['currentapp']); + + check_acl($label,$id,'read',$rights,PHPGW_ACL_READ); + + check_acl($label,$id,'add',$rights,PHPGW_ACL_ADD); + + check_acl($label,$id,'edit',$rights,PHPGW_ACL_EDIT); + + check_acl($label,$id,'delete',$rights,PHPGW_ACL_DELETE); + + if($private_acl == True) + { + check_acl($label,$id,'private',$rights,PHPGW_ACL_PRIVATE); + } + + $p->parse('row','acl_row',True); + } + + if(!isset($owner) || !$phpgw_info['user']['apps']['admin']) + { + $owner = $phpgw_info['user']['account_id']; + } + + $acct = CreateObject('phpgwapi.accounts',$owner); + $groups = $acct->get_list('groups'); + $users = $acct->get_list('accounts'); + unset($acct); + $acl = CreateObject('phpgwapi.acl',intval($owner)); + $acl->read_repository(); + + if ($submit) + { + $to_remove = unserialize(urldecode($processed)); + + for($i=0;$idelete($phpgw_info['flags']['currentapp'],$to_remove[$i]); + } + + // Group records + $group_variable = 'g_'.$phpgw_info['flags']['currentapp']; + + if (!$$group_variable) + { + $$group_variable = array(); + } + @reset($$group_variable); + while(list($group_id,$acllist) = each($$group_variable)) + { + $totalacl = 0; + while(list($right,$permission) = each($acllist)) + { + $totalacl += $right; + } + $acl->add($phpgw_info['flags']['currentapp'],$group_id,$totalacl); + } + + // User records + $user_variable = 'u_'.$phpgw_info['flags']['currentapp']; + + if (!$$user_variable) + { + $$user_variable = array(); + } + @reset($$user_variable); + while(list($user_id,$acllist) = each($$user_variable)) + { + $totalacl = 0; + while(list($right,$permission) = each($acllist)) + { + $totalacl += $right; + } + $acl->add($phpgw_info['flags']['currentapp'],$user_id,$totalacl); + } + $acl->save_repository(); + } + + $processed = Array(); + + $total = 0; + + if(!isset($start)) + { + $start = 0; + } + + if(!$start) + { + $s_groups = 0; + $s_users = 0; + } + + if(!isset($s_groups)) + { + $s_groups = 0; + } + + if(!isset($s_users)) + { + $s_users = 0; + } + + if(!isset($query)) + { + $query = ""; + } + + if(!isset($maxm)) + { + $maxm = $phpgw_info['user']['preferences']['common']['maxmatchs']; + } + + if(!isset($totalentries)) + { + $totalentries = count($groups) + count($users); + if($totalentries < $maxm) + { + $maxm = $totalentries; + } + } + + $p = CreateObject('phpgwapi.Template',$phpgw_info['server']['app_tpl']); + if($private_acl == True) + { + $templates = Array ( + 'preferences' => 'preference_acl.tpl', + 'row_colspan' => 'preference_colspan_private.tpl', + 'acl_row' => 'preference_acl_row_private.tpl' + ); + } + else + { + $templates = Array ( + 'preferences' => 'preference_acl.tpl', + 'row_colspan' => 'preference_colspan.tpl', + 'acl_row' => 'preference_acl_row.tpl' + ); + } + + $p->set_file($templates); +// $p->set_var('errors','

This does nothing at this time!
Strictly as a template for use!
'); + + $common_hidden_vars = ' '."\n" + . ' '."\n" + . ' '."\n" + . ' '."\n" + . ' '."\n" + . ' '."\n" + . ' '."\n"; + + $var = Array( + 'errors' => '', + 'title' => '

'.lang($phpgw_info['flags']['currentapp'].' preferences').' - '.lang('acl').':


', + 'action_url' => $phpgw->link('/' . $phpgw_info['flags']['currentapp'] . '/acl_preferences.php'), + 'bg_color' => $phpgw_info['theme']['th_bg'], + 'submit_lang' => lang('submit'), + 'common_hidden_vars_form' => $common_hidden_vars + ); + + $p->set_var($var); + + if(isset($query_result) && $query_result) + { + $common_hidden_vars .= ''."\n"; + } + + $p->set_var('common_hidden_vars',$common_hidden_vars); + + $var = Array( + 'read_lang' => lang('Read'), + 'add_lang' => lang('Add'), + 'edit_lang' => lang('Edit'), + 'delete_lang' => lang('Delete') + ); + + $p->set_var($var); + + if($private_acl == True) + { + $p->set_var('private_lang',lang('Private')); + } + + if(intval($s_groups) <> count($groups)) + { + $p->set_var('string',lang('Groups')); + $p->parse('row','row_colspan',True); + + reset($groups); + for($k=0;$knextmatchs->alternate_row_color($tr_color); + display_row($tr_color,'g_',$group['account_id'],$group['account_lid']); + $s_groups++; + $processed[] = $group['account_id']; + $total++; + if($total == $maxm) + { + break; + } + } + } + } + + if($total <> $maxm) + { + if($users) + { + $p->set_var('string',ucfirst(lang('Users'))); + $p->parse('row','row_colspan',True); + $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); + for($k=$s_users;$k<$total || $k==count($users);$k++) + { + $user = $users[$k]; + $go = True; + if($query) + { + $name = ' '.$user['account_firstname'].' '.$user['account_lastname'].' '.$user['account_lid'].' '; + if(!strpos($name,$query)) + { + $go = False; + } + } + + if($go) + { + $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); + display_row($tr_color,'u_',$user['account_id'],$phpgw->common->display_fullname($user['account_lid'],$user['account_firstname'],$user['account_lastname'])); + $s_users++; + $processed[] = $user['account_id']; + $total++; + if($total == $maxm) + { + break; + } + } + } + } + } + + $extra_parms = '&s_users='.$s_users.'&s_groups='.$s_groups.'&maxm='.$maxm.'&totalentries='.$totalentries.'&total='.($start + $total).'&owner='.$owner; + + $var = Array( + 'nml' => $phpgw->nextmatchs->left('',$start,$totalentries,$extra_parms), + 'nmr' => $phpgw->nextmatchs->right('',$start,$totalentries,$extra_parms), + 'search_value' => (isset($query) && $query?$query:''), + 'search' => lang('search'), + 'processed' => urlencode(serialize($processed)) + ); + + $p->set_var($var); + + $p->pparse('out','preferences'); + $phpgw->common->phpgw_footer(); +?>