forked from extern/egroupware
Another update from calendar's version to fix group acl
This commit is contained in:
parent
4ea6a7c976
commit
c1a1c61066
@ -13,10 +13,10 @@
|
||||
|
||||
$phpgw_info["flags"] = array("currentapp" => "addressbook", "enable_nextmatchs_class" => True, "noappheader" => True, "noappfooter" => True);
|
||||
|
||||
if(isset($submit) && $submit) {
|
||||
$phpgw_info["flags"]["noheader"] = True;
|
||||
$phpgw_info["flags"]["nonavbar"] = True;
|
||||
}
|
||||
// if(isset($submit) && $submit) {
|
||||
// $phpgw_info["flags"]["noheader"] = True;
|
||||
// $phpgw_info["flags"]["nonavbar"] = True;
|
||||
// }
|
||||
|
||||
include("../header.inc.php");
|
||||
|
||||
@ -57,12 +57,14 @@
|
||||
|
||||
if ($submit) {
|
||||
|
||||
$phpgw->acl->remove_granted_rights($phpgw_info["flags"]["currentapp"],"u");
|
||||
$phpgw->acl->remove_granted_rights($phpgw_info["flags"]["currentapp"],"g");
|
||||
|
||||
$to_remove = unserialize(urldecode($processed));
|
||||
for($i=0;$i<count($to_remove);$i++) {
|
||||
$phpgw->acl->delete($phpgw_info["flags"]["currentapp"],$to_remove[$i],$phpgw_info["user"]["account_id"],'u');
|
||||
}
|
||||
// Group records
|
||||
$group_variable = 'g_'.$phpgw_info["flags"]["currentapp"];
|
||||
|
||||
|
||||
@reset($$group_variable);
|
||||
while(list($group_id,$acllist) = each($$group_variable)) {
|
||||
$totalacl = 0;
|
||||
while(list($acl,$permission) = each($acllist)) {
|
||||
@ -74,6 +76,7 @@
|
||||
// User records
|
||||
$user_variable = 'u_'.$phpgw_info["flags"]["currentapp"];
|
||||
|
||||
@reset($$user_variable);
|
||||
while(list($user_id,$acllist) = each($$user_variable)) {
|
||||
$totalacl = 0;
|
||||
while(list($acl,$permission) = each($acllist)) {
|
||||
@ -82,8 +85,46 @@
|
||||
$phpgw->acl->add($phpgw_info["flags"]["currentapp"],'u_'.$user_id,$phpgw_info["user"]["account_id"],'u',$totalacl);
|
||||
}
|
||||
|
||||
header("Location: ".$phpgw->link($phpgw_info["server"]["webserver_url"]."/preferences/index.php"));
|
||||
$phpgw->common->phpgw_exit();
|
||||
// header("Location: ".$phpgw->link($phpgw_info["server"]["webserver_url"]."/preferences/index.php"));
|
||||
// $phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
$groups = $phpgw->accounts->read_group_names($phpgw->info["user"]["account_id"]);
|
||||
$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);
|
||||
$db = $phpgw->db;
|
||||
$db->query("SELECT count(*) FROM accounts");
|
||||
$db->next_record();
|
||||
$totalentries += $db->f(0);
|
||||
}
|
||||
|
||||
$p = CreateObject('phpgwapi.Template',$phpgw_info["server"]["app_tpl"]);
|
||||
@ -97,32 +138,89 @@
|
||||
$p->set_var('action_url',$phpgw->link(''));
|
||||
$p->set_var('bg_color',$phpgw_info["theme"]["th_bg"]);
|
||||
$p->set_var('submit_lang',lang('submit'));
|
||||
$p->set_var('string',lang('Groups'));
|
||||
$p->set_var('read_lang',lang('Read'));
|
||||
$p->set_var('add_lang',lang('Add'));
|
||||
$p->set_var('edit_lang',lang('Edit'));
|
||||
$p->set_var('delete_lang',lang('Delete'));
|
||||
$p->parse('row','row_colspan',True);
|
||||
|
||||
$groups = $phpgw->accounts->read_group_names($phpgw->info["user"]["account_id"]);
|
||||
while(list(,$group) = each($groups)) {
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
display_row($tr_color,'g_',$group[0],$group[1]);
|
||||
}
|
||||
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
|
||||
. ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n"
|
||||
. ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n"
|
||||
. ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n"
|
||||
. ' <input type="hidden" name="start" value="'.$start.'">'."\n"
|
||||
. ' <input type="hidden" name="query" value="'.$query.'">'."\n";
|
||||
$p->set_var('common_hidden_vars_form',$common_hidden_vars);
|
||||
|
||||
if(isset($query_result) && $query_result)
|
||||
$common_hidden_vars .= "<input type=\"hidden\" name=\"query_result\" value=\"".$query_result."\">\n";
|
||||
|
||||
$db = $phpgw->db;
|
||||
$p->set_var('common_hidden_vars',$common_hidden_vars);
|
||||
$p->set_var(array('read_lang' => lang('Read'),
|
||||
'add_lang' => lang('Add'),
|
||||
'edit_lang' => lang('Edit'),
|
||||
'delete_lang' => lang('Delete')));
|
||||
|
||||
$db->query("select account_id from accounts ORDER BY account_lastname, account_firstname, account_lid",__LINE__,__FILE__);
|
||||
if($db->num_rows()) {
|
||||
$p->set_var('string',ucfirst(lang('Users')));
|
||||
if(intval($s_groups) <> count($groups)) {
|
||||
$p->set_var('string',lang('Groups'));
|
||||
$p->parse('row','row_colspan',True);
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
while($db->next_record()) {
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
$id = $db->f("account_id");
|
||||
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
|
||||
|
||||
while(list(,$group) = each($groups)) {
|
||||
$go = True;
|
||||
if($query) {
|
||||
if(!strpos(' '.$group[1].' ',$query)) {
|
||||
$go = False;
|
||||
}
|
||||
}
|
||||
if($go) {
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
display_row($tr_color,'g_',$group[0],$group[1]);
|
||||
$s_groups++;
|
||||
$processed[] = 'g_'.$group[0];
|
||||
$total++;
|
||||
if($total == $maxm) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($total <> $maxm) {
|
||||
if(!is_object($db)) {
|
||||
$db = $phpgw->db;
|
||||
}
|
||||
|
||||
$db->query("select account_id, account_firstname, account_lastname, account_lid from accounts ORDER BY account_lastname, account_firstname, account_lid ".$db->limit(intval($s_users),$maxm),__LINE__,__FILE__);
|
||||
$users = $db->num_rows();
|
||||
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);
|
||||
while($db->next_record()) {
|
||||
$go = True;
|
||||
if($query) {
|
||||
$name = ' '.$db->f("account_firstname").' '.$db->f("account_lastname").' '.$db->f("account_lid").' ';
|
||||
if(!strpos($name,$query)) {
|
||||
$go = False;
|
||||
}
|
||||
}
|
||||
if($go) {
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
$id = $db->f("account_id");
|
||||
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
|
||||
$s_users++;
|
||||
$processed[] = 'u_'.$id;
|
||||
$total++;
|
||||
if($total == $maxm) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$extra_parms = "&s_users=".$s_users."&s_groups=".$s_groups."&maxm=".$maxm."&totalentries=".$totalentries."&total=".($start + $total);
|
||||
|
||||
$p->set_var("nml",$phpgw->nextmatchs->left("",$start,$totalentries,$extra_parms));
|
||||
$p->set_var("nmr",$phpgw->nextmatchs->right("",$start,$totalentries,$extra_parms));
|
||||
|
||||
$p->set_var("search_value",(isset($query) && $query?$query:""));
|
||||
$p->set_var("search",lang("search"));
|
||||
|
||||
$p->set_var('processed',urlencode(serialize($processed)));
|
||||
$p->pparse('out','preferences');
|
||||
$phpgw->common->phpgw_footer();
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user