mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-11 15:59:45 +01:00
added possebility to delegate to groups and filter by groups
This commit is contained in:
parent
208d226bf1
commit
34fb07492b
@ -285,6 +285,17 @@ class boinfolog
|
||||
}
|
||||
return $cache[$info_id][$required_rights] = $this->so->check_access( $info,$required_rights,$this->implicit_rights == 'edit' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if use is responsible for an entry: he or one of his memberships is in responsible
|
||||
*
|
||||
* @param array $info infolog entry as array
|
||||
* @return boolean
|
||||
*/
|
||||
function is_responsible($info)
|
||||
{
|
||||
return $this->so->is_responsible($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* init internal data to be empty
|
||||
|
@ -91,6 +91,23 @@ class soinfolog // DB-Layer
|
||||
$this->read( $info_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if use is responsible for an entry: he or one of his memberships is in responsible
|
||||
*
|
||||
* @param array $info infolog entry as array
|
||||
* @return boolean
|
||||
*/
|
||||
function is_responsible($info)
|
||||
{
|
||||
static $user_and_memberships;
|
||||
if (is_null($user_and_memberships))
|
||||
{
|
||||
$user_and_memberships = $GLOBALS['egw']->accounts->memberships($this->user,true);
|
||||
$user_and_memberships[] = $this->user;
|
||||
}
|
||||
return $info['info_responsible'] && array_intersect($info['info_responsible'],$user_and_memberships);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if user has the $required_rights to access $info_id (private access is handled too)
|
||||
*
|
||||
@ -121,19 +138,41 @@ class soinfolog // DB-Layer
|
||||
return False;
|
||||
}
|
||||
$owner = $info['info_owner'];
|
||||
|
||||
|
||||
$access_ok = $owner == $this->user || // user has all rights
|
||||
// ACL only on public entrys || $owner granted _PRIVATE
|
||||
(!!($this->grants[$owner] & $required_rights) ||
|
||||
// implicite rights for responsible user(s)
|
||||
in_array($this->user, $info['info_responsible']) && ($required_rights == EGW_ACL_READ || $required_rights == EGW_ACL_ADD || $implicit_edit && $required_rights == EGW_ACL_EDIT)) &&
|
||||
//$info['info_responsible'] == $this->user && $required_rights == EGW_ACL_READ) &&
|
||||
($info['info_access'] == 'public' ||
|
||||
!!($this->grants[$owner] & EGW_ACL_PRIVATE));
|
||||
$this->is_responsible($info) && // implicite rights for responsible user(s) and his memberships
|
||||
($required_rights == EGW_ACL_READ || $required_rights == EGW_ACL_ADD || $implicit_edit && $required_rights == EGW_ACL_EDIT)) &&
|
||||
($info['info_access'] == 'public' || !!($this->grants[$owner] & EGW_ACL_PRIVATE));
|
||||
|
||||
//echo "<p>check_access(info_id=$info_id (owner=$owner, user=$user),required_rights=$required_rights): access".($access_ok?"Ok":"Denied")."</p>\n";
|
||||
//echo "<p align=right>check_access(info_id=$info_id,requited=$required_rights,implicit_edit=$implicit_edit) owner=$owner, responsible=(".implode(',',$info['info_responsible'])."): access".($access_ok?"Ok":"Denied")."</p>\n";
|
||||
return $access_ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter for a given responsible user: info_responsible either contains a the user or one of his memberships
|
||||
*
|
||||
* @param int $user
|
||||
* @return string
|
||||
*
|
||||
* @todo make the responsible a second table and that filter a join with the responsible table
|
||||
*/
|
||||
function responsible_filter($user)
|
||||
{
|
||||
if (!$user) return '0';
|
||||
|
||||
$responsible = $user > 0 ? $GLOBALS['egw']->accounts->memberships($user,true) :
|
||||
$GLOBALS['egw']->accounts->members($user,true);
|
||||
|
||||
$responsible[] = $user;
|
||||
foreach($responsible as $key => $uid)
|
||||
{
|
||||
$responsible[$key] = $this->db->concat("','",'info_responsible',"','")." LIKE '%,$uid,%'";
|
||||
}
|
||||
//echo "<p align=right>responsible_filter($user) = ".'('.implode(' OR ',$responsible).')'."</p>\n";
|
||||
return '('.implode(' OR ',$responsible).')';
|
||||
}
|
||||
|
||||
/**
|
||||
* generate sql to be AND'ed into a query to ensure ACL is respected (incl. _PRIVATE)
|
||||
@ -152,6 +191,7 @@ class soinfolog // DB-Layer
|
||||
{
|
||||
return $this->acl_filter[$filter.$f_user]; // used cached filter if found
|
||||
}
|
||||
|
||||
if (is_array($this->grants))
|
||||
{
|
||||
foreach($this->grants as $user => $grant)
|
||||
@ -178,12 +218,12 @@ class soinfolog // DB-Layer
|
||||
$filtermethod .= " AND info_responsible='0'";
|
||||
}
|
||||
// implicit read-rights for responsible user
|
||||
$filtermethod .= " OR (".$this->db->concat("','",'info_responsible',"','")." LIKE '%,$this->user,%' AND info_access='public')";
|
||||
$filtermethod .= " OR (".$this->responsible_filter($this->user)." AND info_access='public')";
|
||||
|
||||
// private: own entries plus the one user is responsible for
|
||||
if ($filter == 'private' || $filter == 'own')
|
||||
{
|
||||
$filtermethod .= " OR (".$this->db->concat("','",'info_responsible',"','")." LIKE '%,$this->user,%'".
|
||||
$filtermethod .= " OR (".$this->responsible_filter($this->user).
|
||||
($filter == 'own' && count($public_user_list) ? // offer's should show up in own, eg. startpage, but need read-access
|
||||
" OR info_status = 'offer' AND info_owner IN(" . implode(',',$public_user_list) . ')' : '').")".
|
||||
" AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
|
||||
@ -203,7 +243,8 @@ class soinfolog // DB-Layer
|
||||
|
||||
if ($filter == 'user' && $f_user > 0)
|
||||
{
|
||||
$filtermethod = " ((info_owner=$f_user AND info_responsible=0 OR ".$this->db->concat("','",'info_responsible',"','")." LIKE '%,$f_user,%') AND $filtermethod)";
|
||||
$filtermethod = " ((info_owner=$f_user AND info_responsible=0 OR $filtermethod AND ".$this->responsible_filter($f_user).
|
||||
" AND $filtermethod)";
|
||||
}
|
||||
//echo "<p>aclFilter(filter='$filter_was',user='$user') = '$filtermethod', privat_user_list=".print_r($privat_user_list,True).", public_user_list=".print_r($public_user_list,True)."</p>\n";
|
||||
|
||||
@ -574,7 +615,8 @@ class soinfolog // DB-Layer
|
||||
{
|
||||
$data = (int) $data;
|
||||
if (!$data) continue;
|
||||
$filtermethod .= " AND (".$this->db->concat("','",'info_responsible',"','")." LIKE '%,$data,%' OR info_responsible='0' AND info_owner=$data)";
|
||||
$filtermethod .= " AND (".$this->responsible_filter($data)." OR info_responsible='0' AND info_owner";
|
||||
$filtermethod .= ($data > 0 ? '='.$data : ' IN ('.implode(',',$GLOBALS['egw']->accounts->members($data,true)).')').')';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -169,11 +169,12 @@ class uiinfolog
|
||||
$this->bo->link_id2from($info,$action,$action_id); // unset from for $action:$action_id
|
||||
$info['info_percent'] = (int) $info['info_percent'].'%';
|
||||
|
||||
$readonlys["edit[$id]"] = !$this->bo->check_access($info,EGW_ACL_EDIT);
|
||||
$readonlys["close[$id]"] = $done || ($readonlys["edit_status[$id]"] = !($this->bo->check_access($info,EGW_ACL_EDIT) ||
|
||||
in_array($this->user, (array)$info['info_responsible'])));
|
||||
$readonlys["edit[$id]"] = !($this->bo->check_access($info,EGW_ACL_EDIT) || // edit rights or more then standard responsible rights
|
||||
$this->bo->is_responsible($info) && array_diff($this->bo->responsible_edit,array('info_status','info_percent','info_datecompleted')));
|
||||
$readonlys["close[$id]"] = $done || ($readonlys["edit_status[$id]"] =
|
||||
!($this->bo->check_access($info,EGW_ACL_EDIT) || $this->bo->is_responsible($info)));
|
||||
$readonlys["edit_status[$id]"] = $readonlys["edit_percent[$id]"] =
|
||||
!$this->bo->check_access($info,EGW_ACL_EDIT) && !in_array($this->user, (array)$info['info_responsible']);
|
||||
!$this->bo->check_access($info,EGW_ACL_EDIT) && !$this->bo->is_responsible($info);
|
||||
$readonlys["delete[$id]"] = !$this->bo->check_access($info,EGW_ACL_DELETE);
|
||||
$readonlys["sp[$id]"] = !$this->bo->check_access($info,EGW_ACL_ADD);
|
||||
$readonlys["view[$id]"] = $info['info_anz_subs'] < 1;
|
||||
@ -658,7 +659,7 @@ class uiinfolog
|
||||
if (!($edit_acl = $this->bo->check_access($info_id,EGW_ACL_EDIT)))
|
||||
{
|
||||
$old = $this->bo->read($info_id);
|
||||
$status_only = in_array($this->user, $old['info_responsible']);
|
||||
$status_only = $this->bo->is_responsible($old);
|
||||
}
|
||||
}
|
||||
if (($button == 'save' || $button == 'apply') && (!$info_id || $edit_acl || $status_only))
|
||||
@ -846,7 +847,7 @@ class uiinfolog
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($info_id && !$this->bo->check_access($info_id,EGW_ACL_EDIT) && !in_array($this->user, (array)$content['info_responsible']))
|
||||
if ($info_id && !$this->bo->check_access($info_id,EGW_ACL_EDIT) && !$this->bo->is_responsible($content))
|
||||
{
|
||||
if ($no_popup)
|
||||
{
|
||||
@ -915,7 +916,7 @@ class uiinfolog
|
||||
}
|
||||
}
|
||||
// for implizit edit of responsible user make all fields readonly, but status and percent
|
||||
if ($info_id && !$this->bo->check_access($info_id,EGW_ACL_EDIT) && in_array($this->user, (array)$content['info_responsible']))
|
||||
if ($info_id && !$this->bo->check_access($info_id,EGW_ACL_EDIT) && $this->bo->is_responsible($content))
|
||||
{
|
||||
$content['status_only'] = !in_array('link_to',$this->bo->responsible_edit);
|
||||
foreach(array_diff(array_merge(array_keys($content),array('pm_id')),$this->bo->responsible_edit) as $name)
|
||||
|
File diff suppressed because one or more lines are too long
@ -40,7 +40,7 @@
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
<template id="infolog.edit.delegation" template="" lang="" group="0" version="1.2.002">
|
||||
<template id="infolog.edit.delegation" template="" lang="" group="0" version="1.3.001">
|
||||
<grid width="100%" height="245">
|
||||
<columns>
|
||||
<column width="100"/>
|
||||
@ -65,7 +65,7 @@
|
||||
</row>
|
||||
<row class="row" valign="top">
|
||||
<description value="Responsible" options=",,,info_responsible"/>
|
||||
<listbox type="select-account" rows="10" id="info_responsible" statustext="select a responsible user: a person you want to delegate this task"/>
|
||||
<listbox type="select-account" rows="10" options="both" id="info_responsible" statustext="select a responsible user: a person you want to delegate this task"/>
|
||||
</row>
|
||||
<row class="row" disabled="1">
|
||||
<description value="Confirm" options=",,,info_confirm"/>
|
||||
@ -239,4 +239,4 @@
|
||||
.link_select select { width: 250px; }
|
||||
</styles>
|
||||
</template>
|
||||
</overlay>
|
||||
</overlay>
|
@ -13,7 +13,7 @@
|
||||
<button image="note" label="Note" id="add[note]" statustext="Add a new Note" onclick="window.open(egw::link('/index.php','menuaction=infolog.uiinfolog.edit&type=note&action=$cont[action]&action_id=$cont[action_id]'),'_blank','dependent=yes,width=750,height=600,scrollbars=yes,status=yes'); return false;"/>
|
||||
</hbox>
|
||||
</template>
|
||||
<template id="infolog.index.rows-noheader" template="" lang="" group="0" version="1.3.001">
|
||||
<template id="infolog.index.rows-noheader" template="" lang="" group="0" version="1.3.002">
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="2%"/>
|
||||
@ -27,7 +27,7 @@
|
||||
</columns>
|
||||
<rows>
|
||||
<row class="th">
|
||||
<vbox options="0" orient="0">
|
||||
<vbox options="0,0">
|
||||
<description value="Type"/>
|
||||
<description value="Status" align="center"/>
|
||||
<description value="Completed" align="right"/>
|
||||
@ -36,7 +36,7 @@
|
||||
<description value="Subject"/>
|
||||
<description value="Description"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<vbox options="0,0">
|
||||
<description value="Startdate"/>
|
||||
<description value="Enddate"/>
|
||||
<description value="Date completed"/>
|
||||
@ -60,7 +60,7 @@
|
||||
<button image="$row_cont[info_percent]" label="$row_cont[info_percent]" id="edit_percent[$row_cont[info_id]]" statustext="Change the status of an entry, eg. close it" onclick="window.open(egw::link('/index.php','menuaction=infolog.uiinfolog.edit&info_id=$row_cont[info_id]'),'_blank','dependent=yes,width=750,height=600,scrollbars=yes,status=yes'); return false;"/>
|
||||
<image label="$row_cont[info_percent2]" src="{$row}[info_percent2]" onclick="window.open(egw::link('/index.php','menuaction=infolog.uiinfolog.edit&info_id=$row_cont[info_id]'),'_blank','dependent=yes,width=750,height=600,scrollbars=yes,status=yes'); return false;"/>
|
||||
</hbox>
|
||||
<vbox options="0" class="fullWidth" orient="0">
|
||||
<vbox options="0,0" class="fullWidth">
|
||||
<link label="%s $row_cont[info_addr]" id="${row}[info_link]" options="b"/>
|
||||
<hbox options="0,0">
|
||||
<description class="$row_cont[sub_class]" no_lang="1" id="${row}[info_subject]"/>
|
||||
@ -79,7 +79,7 @@
|
||||
<date-duration id="${row}[info_sum_timesheets]" readonly="true" options="@duration_format" class="timesheet"/>
|
||||
<date-duration id="${row}[info_planned_time]" span="all" class="planned" readonly="true" options="@duration_format"/>
|
||||
</vbox>
|
||||
<vbox options="0" orient="0">
|
||||
<vbox options="0,0">
|
||||
<menulist>
|
||||
<menupopup type="select-account" id="${row}[info_owner]" readonly="true"/>
|
||||
</menulist>
|
||||
@ -106,7 +106,7 @@
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
<template id="infolog.index.rows" template="" lang="" group="0" version="1.3.001">
|
||||
<template id="infolog.index.rows" template="" lang="" group="0" version="1.3.002">
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="2%"/>
|
||||
@ -120,7 +120,7 @@
|
||||
</columns>
|
||||
<rows>
|
||||
<row class="th">
|
||||
<vbox options="0" orient="0">
|
||||
<vbox options="0,0">
|
||||
<nextmatch-filterheader options="Type" id="info_type"/>
|
||||
<nextmatch-filterheader options="Status" id="info_status" align="center"/>
|
||||
<nextmatch-sortheader label="Completed" id="info_percent" align="right"/>
|
||||
@ -145,7 +145,7 @@
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<vbox>
|
||||
<vbox options="0,0">
|
||||
<nextmatch-sortheader label="Startdate" id="info_startdate"/>
|
||||
<nextmatch-sortheader label="Enddate" id="info_enddate"/>
|
||||
<nextmatch-sortheader id="info_datecompleted" label="Date completed"/>
|
||||
@ -154,9 +154,9 @@
|
||||
<nextmatch-sortheader label="Times" id="info_used_time"/>
|
||||
<nextmatch-sortheader id="info_planned_time" class="planned" label="planned"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<vbox options="0,0">
|
||||
<nextmatch-accountfilter id="info_owner" options="Owner" statustext="Select to filter by owner"/>
|
||||
<nextmatch-accountfilter id="info_responsible" options="Responsible" statustext="Select to filter by responsible"/>
|
||||
<nextmatch-accountfilter id="info_responsible" options="Responsible,both" statustext="Select to filter by responsible"/>
|
||||
</vbox>
|
||||
<nextmatch-sortheader label="last changed" id="info_datemodified" options="DESC"/>
|
||||
<description value="Sub" class="noPrint"/>
|
||||
@ -169,7 +169,7 @@
|
||||
<button image="$row_cont[info_percent]" label="$row_cont[info_percent]" id="edit_percent[$row_cont[info_id]]" statustext="Change the status of an entry, eg. close it" onclick="window.open(egw::link('/index.php','menuaction=infolog.uiinfolog.edit&info_id=$row_cont[info_id]'),'_blank','dependent=yes,width=750,height=600,scrollbars=yes,status=yes'); return false;"/>
|
||||
<image label="$row_cont[info_percent2]" src="{$row}[info_percent2]" onclick="window.open(egw::link('/index.php','menuaction=infolog.uiinfolog.edit&info_id=$row_cont[info_id]'),'_blank','dependent=yes,width=750,height=600,scrollbars=yes,status=yes'); return false;"/>
|
||||
</hbox>
|
||||
<vbox options="0" class="fullWidth" orient="0">
|
||||
<vbox options="0,0" class="fullWidth">
|
||||
<link label="%s $row_cont[info_addr]" id="${row}[info_link]" options="b"/>
|
||||
<hbox options="0,0">
|
||||
<description class="$row_cont[sub_class]" no_lang="1" id="${row}[info_subject]"/>
|
||||
@ -183,12 +183,12 @@
|
||||
<date class="$row_cont[end_class] fixedHeight" id="${row}[info_enddate]" readonly="true"/>
|
||||
<date-time id="${row}[info_datecompleted]" readonly="true" class="fixedHeight"/>
|
||||
</vbox>
|
||||
<vbox rows="3" cols="1" options="3">
|
||||
<vbox rows="3" cols="1">
|
||||
<date-duration id="${row}[info_used_time]" readonly="true" options="@duration_format"/>
|
||||
<date-duration id="${row}[info_sum_timesheets]" readonly="true" options="@duration_format" class="timesheet"/>
|
||||
<date-duration id="${row}[info_planned_time]" span="all" class="planned" readonly="true" options="@duration_format"/>
|
||||
</vbox>
|
||||
<vbox options="0" orient="0">
|
||||
<vbox options="0,0">
|
||||
<menulist>
|
||||
<menupopup type="select-account" id="${row}[info_owner]" readonly="true"/>
|
||||
</menulist>
|
||||
|
Loading…
Reference in New Issue
Block a user