Started working on ACL, so far index has been updated

This commit is contained in:
jengo 2001-03-24 09:58:09 +00:00
parent 1cfe152bad
commit f3df7a0ff4
4 changed files with 34 additions and 8 deletions

View File

@ -31,6 +31,11 @@
var $email_types; // VCard email type array
var $total_records; // This will contain numrows for data retrieved
function check_perms($has, $needed)
{
return (!!($has & $needed) == True);
}
function split_stock_and_extras($fields)
{
while (list($field,$value) = each($fields)) {

View File

@ -40,15 +40,17 @@
var $account_id;
var $stock_contact_fields; // This is an array of almost the fields in the phpgw_addressbook table, except id,owner,lid,tid
var $email_types; // VCard email type array
var $email_types; // VCard email type array
var $total_records; // This will contain numrows for data retrieved
var $grants; // This holds all of the users that have granted access to there entrys
function contacts_()
{
global $phpgw, $phpgw_info;
$this->db = $phpgw->db;
$this->account_id = $phpgw_info["user"]["account_id"];
$this->db = $phpgw->db;
$this->grants = $phpgw->acl->get_grants('addressbook');
$this->account_id = $phpgw_info['user']['account_id'];
// The left side are the array elements used throughout phpgw, right side are the db field names.
$this->stock_contact_fields = array(
@ -351,6 +353,24 @@
$fwhere = ' WHERE '; $fand = ' AND ';
}
}
$fwhere .= " owner=" . $phpgw_info['user']['account_id'];
if (is_array($this->grants))
{
$grants = $this->grants;
while (list($user) = each($grants))
{
$public_user_list[] = $user;
}
reset($public_user_list);
$fwhere .= " OR (access='public' AND owner in(" . implode(',',$public_user_list) . ")) AND ";
}
else
{
$fwhere .= ' AND ';
}
if ($DEBUG && $filtermethod) {
echo "<br>DEBUG - Filtering with: #" . $filtermethod . "#";
}

View File

@ -219,11 +219,12 @@
$t->set_var(row_vcard_link,$phpgw->link("/addressbook/vcardout.php","ab_id=$myid&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort"));
if ($rights & PHPGW_ACL_EDIT) {
$t->set_var(row_edit_link,$phpgw->link("/addressbook/edit.php","ab_id=$myid&start=$start&sort=$sort&order=$order"
. "&query=$query&sort=$sort"));
// echo '<br>: ' . $this->grants[$myowner] . ' - ' . $myowner;
if ($this->check_perms($this->grants[$myowner],PHPGW_ACL_EDIT) || $myowner == $phpgw_info['user']['account_id']) {
$t->set_var(row_edit,'<a href="' . $phpgw->link("/addressbook/edit.php","ab_id=$myid&start=$start&sort=$sort&order=$order"
. "&query=$query&sort=$sort") . '">' . lang('Edit') . '</a>');
} else {
$t->set_var(row_edit_link,'');
$t->set_var(row_edit,'&nbsp;');
}
$t->set_var(row_owner,$phpgw->accounts->id2name($myowner));

View File

@ -8,7 +8,7 @@
<font face="{font}" size=2><a href="{row_vcard_link}">{lang_vcard}</a></font>
</td>
<td valign="top" width="5%">
<font face="{font}" size="2"><a href="{row_edit_link}">{lang_edit}</a></font>
<font face="{font}" size="2">{row_edit}</font>
</td>
<td valign="top" width="5%">
<font face="{font}" size="2">{row_owner}</font>