2001-03-31 12:35:13 +02:00
|
|
|
<?php
|
2001-03-31 12:59:36 +02:00
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - Preferences *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
2001-03-31 12:35:13 +02:00
|
|
|
|
|
|
|
$phpgw_flags = Array(
|
|
|
|
'currentapp' => $acl_app,
|
|
|
|
'enable_nextmatchs_class' => True,
|
|
|
|
'noappheader' => True,
|
|
|
|
'noappfooter' => True
|
|
|
|
);
|
|
|
|
|
2001-07-23 23:18:31 +02:00
|
|
|
/*
|
2001-06-18 05:03:48 +02:00
|
|
|
// header from calendar-app resets $owner
|
|
|
|
if(isset($owner))
|
|
|
|
{
|
|
|
|
$save_my_owner = $owner;
|
|
|
|
}
|
2001-07-23 23:18:31 +02:00
|
|
|
*/
|
2001-06-18 05:03:48 +02:00
|
|
|
|
2001-03-31 12:35:13 +02:00
|
|
|
$phpgw_info['flags'] = $phpgw_flags;
|
|
|
|
include('../header.inc.php');
|
2001-07-23 23:18:31 +02:00
|
|
|
/*
|
2001-06-18 05:03:48 +02:00
|
|
|
if(isset($save_my_owner) && $phpgw_info['user']['apps']['admin'])
|
|
|
|
{
|
|
|
|
$owner = $save_my_owner;
|
|
|
|
unset($save_my_owner);
|
|
|
|
}
|
2001-06-18 05:26:57 +02:00
|
|
|
elseif(@isset($save_my_owner))
|
2001-06-18 05:03:48 +02:00
|
|
|
{
|
|
|
|
echo '<center>'.lang('You do not have permission to set ACL\'s in this mode!').'</center>';
|
|
|
|
$phpgw->common->phpgw_footer();
|
|
|
|
}
|
2001-07-23 23:18:31 +02:00
|
|
|
*/
|
2001-06-18 05:03:48 +02:00
|
|
|
function check_acl($label,$id,$acl,$rights,$right,$is_group=False)
|
2001-03-31 12:35:13 +02:00
|
|
|
{
|
|
|
|
global $phpgw_info, $p;
|
|
|
|
|
2001-07-18 22:31:55 +02:00
|
|
|
$p->set_var($acl,$label.$phpgw_info['flags']['currentapp'].'['.$id.'_'.$right.']');
|
2001-06-30 16:55:46 +02:00
|
|
|
$rights_set = (($rights & $right)?' checked':'');
|
2001-06-18 05:03:48 +02:00
|
|
|
if ($is_group)
|
2001-03-31 12:35:13 +02:00
|
|
|
{
|
2001-06-18 05:03:48 +02:00
|
|
|
// This is so you can't select it in the GUI
|
2001-06-30 16:55:46 +02:00
|
|
|
$rights_set .= ' disabled';
|
2001-03-31 12:35:13 +02:00
|
|
|
}
|
2001-06-30 16:55:46 +02:00
|
|
|
$p->set_var($acl.'_selected',$rights_set);
|
2001-03-31 12:35:13 +02:00
|
|
|
}
|
|
|
|
|
2001-06-18 05:03:48 +02:00
|
|
|
function display_row($bg_color,$label,$id,$name,$is_group)
|
2001-03-31 12:35:13 +02:00
|
|
|
{
|
2001-06-18 05:03:48 +02:00
|
|
|
global $phpgw, $phpgw_info, $acl, $p;
|
2001-04-17 21:31:26 +02:00
|
|
|
|
2001-03-31 12:35:13 +02:00
|
|
|
$p->set_var('row_color',$bg_color);
|
|
|
|
$p->set_var('user',$name);
|
|
|
|
$rights = $acl->get_rights($id,$phpgw_info['flags']['currentapp']);
|
2001-06-18 05:03:48 +02:00
|
|
|
// vv This is new
|
|
|
|
$grantors = $acl->get_ids_for_location($id,$rights,$phpgw_info['flags']['currentapp']);
|
|
|
|
$is_group_set = False;
|
2001-06-18 05:18:25 +02:00
|
|
|
while(@$grantors && list($key,$grantor) = each($grantors))
|
2001-06-18 05:03:48 +02:00
|
|
|
{
|
|
|
|
if($phpgw->accounts->get_type($grantor) == 'g')
|
|
|
|
{
|
|
|
|
$is_group_set = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ^^ This is new
|
2001-03-31 12:35:13 +02:00
|
|
|
|
2001-06-18 05:03:48 +02:00
|
|
|
check_acl($label,$id,'read',$rights,PHPGW_ACL_READ,($is_group_set && ($rights & PHPGW_ACL_READ) && !$is_group?$is_group_set:False));
|
|
|
|
check_acl($label,$id,'add',$rights,PHPGW_ACL_ADD,($is_group_set && ($rights & PHPGW_ACL_ADD && !$is_group)?$is_group_set:False));
|
|
|
|
check_acl($label,$id,'edit',$rights,PHPGW_ACL_EDIT,($is_group_set && ($rights & PHPGW_ACL_EDIT && !$is_group)?$is_group_set:False));
|
|
|
|
check_acl($label,$id,'delete',$rights,PHPGW_ACL_DELETE,($is_group_set && ($rights & PHPGW_ACL_DELETE && !$is_group)?$is_group_set:False));
|
|
|
|
check_acl($label,$id,'private',$rights,PHPGW_ACL_PRIVATE,$is_group);
|
2001-04-17 21:31:26 +02:00
|
|
|
|
2001-03-31 12:35:13 +02:00
|
|
|
$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');
|
2001-06-18 05:03:48 +02:00
|
|
|
$owner_name = $acct->id2name($owner); // get owner name for title
|
|
|
|
if($is_group = $acct->get_type($owner) == 'g')
|
|
|
|
{
|
|
|
|
$owner_name = lang('Group').' ('.$owner_name.')';
|
|
|
|
}
|
2001-03-31 12:35:13 +02:00
|
|
|
unset($acct);
|
|
|
|
$acl = CreateObject('phpgwapi.acl',intval($owner));
|
|
|
|
$acl->read_repository();
|
|
|
|
|
|
|
|
if ($submit)
|
|
|
|
{
|
|
|
|
$to_remove = unserialize(urldecode($processed));
|
|
|
|
|
|
|
|
for($i=0;$i<count($to_remove);$i++)
|
|
|
|
{
|
|
|
|
$acl->delete($phpgw_info['flags']['currentapp'],$to_remove[$i]);
|
|
|
|
}
|
2001-07-18 22:31:55 +02:00
|
|
|
|
|
|
|
/* Group records */
|
2001-03-31 12:35:13 +02:00
|
|
|
$group_variable = 'g_'.$phpgw_info['flags']['currentapp'];
|
|
|
|
|
|
|
|
if (!$$group_variable)
|
|
|
|
{
|
|
|
|
$$group_variable = array();
|
|
|
|
}
|
|
|
|
@reset($$group_variable);
|
2001-07-18 22:31:55 +02:00
|
|
|
$totalacl = array();
|
|
|
|
while(list($rowinfo,$perm) = each($$group_variable))
|
|
|
|
{
|
|
|
|
list($group_id,$rights) = split('_',$rowinfo);
|
|
|
|
$totalacl[$group_id] += $rights;
|
|
|
|
}
|
|
|
|
@reset($totalacl);
|
|
|
|
while(list($group_id,$rights) = @each($totalacl))
|
2001-03-31 12:35:13 +02:00
|
|
|
{
|
2001-06-18 05:03:48 +02:00
|
|
|
if($is_group)
|
|
|
|
{
|
2001-07-18 22:31:55 +02:00
|
|
|
$rights &= ~PHPGW_ACL_PRIVATE; /* Don't allow group-grants to grant private */
|
2001-06-18 05:03:48 +02:00
|
|
|
}
|
|
|
|
|
2001-07-18 22:31:55 +02:00
|
|
|
$acl->add($phpgw_info['flags']['currentapp'],$group_id,$rights);
|
2001-03-31 12:35:13 +02:00
|
|
|
}
|
|
|
|
|
2001-07-18 22:31:55 +02:00
|
|
|
/* User records */
|
2001-03-31 12:35:13 +02:00
|
|
|
$user_variable = 'u_'.$phpgw_info['flags']['currentapp'];
|
|
|
|
|
|
|
|
if (!$$user_variable)
|
|
|
|
{
|
|
|
|
$$user_variable = array();
|
|
|
|
}
|
|
|
|
@reset($$user_variable);
|
2001-07-18 22:31:55 +02:00
|
|
|
$totalacl = array();
|
|
|
|
while(list($rowinfo,$perm) = each($$user_variable))
|
|
|
|
{
|
|
|
|
list($user_id,$rights) = split('_',$rowinfo);
|
|
|
|
$totalacl[$user_id] += $rights;
|
|
|
|
}
|
|
|
|
@reset($totalacl);
|
|
|
|
while(list($user_id,$rights) = @each($totalacl))
|
2001-03-31 12:35:13 +02:00
|
|
|
{
|
2001-06-18 05:03:48 +02:00
|
|
|
if($is_group)
|
|
|
|
{
|
2001-07-18 22:31:55 +02:00
|
|
|
$rights &= ~ PHPGW_ACL_PRIVATE; /* Don't allow group-grants to grant private */
|
2001-06-18 05:03:48 +02:00
|
|
|
}
|
|
|
|
|
2001-07-18 22:31:55 +02:00
|
|
|
$acl->add($phpgw_info['flags']['currentapp'],$user_id,$rights);
|
2001-03-31 12:35:13 +02:00
|
|
|
}
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-27 11:26:01 +02:00
|
|
|
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
2001-03-31 12:59:36 +02:00
|
|
|
$templates = Array (
|
2001-04-01 22:47:02 +02:00
|
|
|
'preferences' => 'preference_acl.tpl',
|
|
|
|
'row_colspan' => 'preference_colspan.tpl',
|
|
|
|
'acl_row' => 'preference_acl_row.tpl'
|
2001-03-31 12:59:36 +02:00
|
|
|
);
|
2001-03-31 12:35:13 +02:00
|
|
|
|
|
|
|
$p->set_file($templates);
|
|
|
|
|
2001-07-04 05:00:05 +02:00
|
|
|
if ($submit)
|
|
|
|
{
|
|
|
|
$p->set_var('errors',lang('ACL grants have been updated'));
|
|
|
|
}
|
|
|
|
|
2001-03-31 12:35:13 +02:00
|
|
|
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
|
2001-04-01 22:47:02 +02:00
|
|
|
. ' <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"
|
|
|
|
. ' <input type="hidden" name="owner" value="'.$owner.'">'."\n";
|
2001-03-31 12:35:13 +02:00
|
|
|
|
|
|
|
$var = Array(
|
2001-04-01 22:47:02 +02:00
|
|
|
'errors' => '',
|
2001-06-18 05:03:48 +02:00
|
|
|
'title' => '<p><b>'.lang($phpgw_info['flags']['currentapp'].' preferences').' - '.lang('acl').': '.$owner_name.'</b><hr><p>',
|
2001-04-01 22:47:02 +02:00
|
|
|
'action_url' => $phpgw->link('/preferences/acl_preferences.php','acl_app=' . $acl_app),
|
|
|
|
'bg_color' => $phpgw_info['theme']['th_bg'],
|
|
|
|
'submit_lang' => lang('submit'),
|
|
|
|
'common_hidden_vars_form' => $common_hidden_vars
|
2001-03-31 12:35:13 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$p->set_var($var);
|
|
|
|
|
|
|
|
if(isset($query_result) && $query_result)
|
|
|
|
{
|
|
|
|
$common_hidden_vars .= '<input type="hidden" name="query_result" value="'.$query_result.'">'."\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$p->set_var('common_hidden_vars',$common_hidden_vars);
|
|
|
|
|
|
|
|
$var = Array(
|
2001-04-01 22:47:02 +02:00
|
|
|
'read_lang' => lang('Read'),
|
|
|
|
'add_lang' => lang('Add'),
|
|
|
|
'edit_lang' => lang('Edit'),
|
|
|
|
'delete_lang' => lang('Delete')
|
2001-03-31 12:35:13 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$p->set_var($var);
|
2001-03-31 12:59:36 +02:00
|
|
|
$p->set_var('private_lang',lang('Private'));
|
2001-03-31 12:35:13 +02:00
|
|
|
|
|
|
|
if(intval($s_groups) <> count($groups))
|
|
|
|
{
|
|
|
|
$p->set_var('string',lang('Groups'));
|
|
|
|
$p->parse('row','row_colspan',True);
|
|
|
|
|
|
|
|
reset($groups);
|
|
|
|
for($k=0;$k<count($groups);$k++)
|
|
|
|
{
|
|
|
|
$group = $groups[$k];
|
|
|
|
$go = True;
|
|
|
|
|
|
|
|
if($query)
|
|
|
|
{
|
|
|
|
if(!strpos(' '.$group['account_lid'].' ',$query))
|
|
|
|
{
|
|
|
|
$go = False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($go)
|
|
|
|
{
|
|
|
|
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
2001-06-18 05:03:48 +02:00
|
|
|
display_row($tr_color,'g_',$group['account_id'],$group['account_lid'],$is_group);
|
2001-03-31 12:35:13 +02:00
|
|
|
$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);
|
2001-04-17 21:31:26 +02:00
|
|
|
for($k=$s_users;$k<$totalentries || $k==count($users);$k++)
|
2001-03-31 12:35:13 +02:00
|
|
|
{
|
|
|
|
$user = $users[$k];
|
2001-04-17 21:31:26 +02:00
|
|
|
//echo '<br>acctid: '.$user['account_id'];
|
|
|
|
if ($user['account_id'])
|
|
|
|
{
|
|
|
|
$go = True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$go = False;
|
|
|
|
}
|
2001-03-31 12:35:13 +02:00
|
|
|
if($query)
|
|
|
|
{
|
|
|
|
$name = ' '.$user['account_firstname'].' '.$user['account_lastname'].' '.$user['account_lid'].' ';
|
|
|
|
if(!strpos($name,$query))
|
|
|
|
{
|
|
|
|
$go = False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-18 05:03:48 +02:00
|
|
|
if($go && $user['account_id'] != $owner) // Need to be $owner not $phpgw_info['user']['account_id']
|
|
|
|
{ // or the admin can't get special grants from a group
|
2001-03-31 12:35:13 +02:00
|
|
|
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
2001-06-18 05:03:48 +02:00
|
|
|
display_row($tr_color,'u_',$user['account_id'],$phpgw->common->display_fullname($user['account_lid'],$user['account_firstname'],$user['account_lastname']),$is_group);
|
2001-03-31 12:35:13 +02:00
|
|
|
$s_users++;
|
|
|
|
$processed[] = $user['account_id'];
|
|
|
|
$total++;
|
|
|
|
if($total == $maxm)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-17 20:37:07 +02:00
|
|
|
$extra_parms = '&acl_app=' . $acl_app
|
|
|
|
. '&s_users='.$s_users.'&s_groups='.$s_groups
|
|
|
|
. '&maxm=' . $maxm . '&totalentries=' . $totalentries
|
|
|
|
. '&total=' . ($start + $total) . '&owner='.$owner;
|
2001-03-31 12:35:13 +02:00
|
|
|
|
|
|
|
$var = Array(
|
2001-04-17 20:37:07 +02:00
|
|
|
'nml' => $phpgw->nextmatchs->left('/preferences/acl_preferences.php',$start,$totalentries,$extra_parms),
|
|
|
|
'nmr' => $phpgw->nextmatchs->right('/preferences/acl_preferences.php',$start,$totalentries,$extra_parms),
|
2001-04-01 22:47:02 +02:00
|
|
|
'search_value' => (isset($query) && $query?$query:''),
|
|
|
|
'search' => lang('search'),
|
|
|
|
'processed' => urlencode(serialize($processed))
|
2001-03-31 12:35:13 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$p->set_var($var);
|
|
|
|
|
2001-03-31 12:59:36 +02:00
|
|
|
$p->pfp('out','preferences');
|
2001-03-31 12:35:13 +02:00
|
|
|
$phpgw->common->phpgw_footer();
|
|
|
|
?>
|