forked from extern/egroupware
Change delete handling to avoid purging accessories when delete+hold resources
This commit is contained in:
parent
97fea10521
commit
81a674cd8c
@ -128,6 +128,8 @@ class resources_bo
|
|||||||
$extra_cols[] = 'acc_count';
|
$extra_cols[] = 'acc_count';
|
||||||
break;
|
break;
|
||||||
case self::DELETED:
|
case self::DELETED:
|
||||||
|
$join = $acc_join;
|
||||||
|
$extra_cols[] = 'acc_count';
|
||||||
$filter[] = 'deleted IS NOT NULL';
|
$filter[] = 'deleted IS NOT NULL';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -229,7 +231,7 @@ class resources_bo
|
|||||||
if($resource['acc_count'])
|
if($resource['acc_count'])
|
||||||
{
|
{
|
||||||
$resource['class'] .= 'hasAccessories ';
|
$resource['class'] .= 'hasAccessories ';
|
||||||
$accessories = $this->get_acc_list($resource['res_id']);
|
$accessories = $this->get_acc_list($resource['res_id'],$query['filter2']==self::DELETED);
|
||||||
foreach($accessories as $acc_id => $acc_name)
|
foreach($accessories as $acc_id => $acc_name)
|
||||||
{
|
{
|
||||||
$resource['accessories'][] = array('acc_id' => $acc_id, 'name' => $this->link_title($acc_id));
|
$resource['accessories'][] = array('acc_id' => $acc_id, 'name' => $this->link_title($acc_id));
|
||||||
@ -414,7 +416,14 @@ class resources_bo
|
|||||||
$accessories = $this->get_acc_list($res_id);
|
$accessories = $this->get_acc_list($res_id);
|
||||||
foreach($accessories as $acc_id => $name)
|
foreach($accessories as $acc_id => $name)
|
||||||
{
|
{
|
||||||
$this->delete($acc_id);
|
// Don't purge already deleted accessories
|
||||||
|
$acc = $this->read($acc_id);
|
||||||
|
if(!$acc['deleted'])
|
||||||
|
{
|
||||||
|
$acc['deleted'] = time();
|
||||||
|
$this->save($acc);
|
||||||
|
egw_link::unlink(0,'resources',$acc_id,'','','',true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -444,16 +453,18 @@ class resources_bo
|
|||||||
*
|
*
|
||||||
* Cornelius Weiss <egw@von-und-zu-weiss.de>
|
* Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||||
* @param int $res_id id of resource
|
* @param int $res_id id of resource
|
||||||
|
* @param boolean $deleted Include deleted accessories
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_acc_list($res_id)
|
function get_acc_list($res_id,$deleted=false)
|
||||||
{
|
{
|
||||||
if($res_id < 1){return;}
|
if($res_id < 1){return;}
|
||||||
$data = $this->so->search('','res_id,name','','','','','',$start,array('accessory_of' => $res_id),'',$need_full_no_count=true);
|
$data = $this->so->search('','res_id,name,deleted','','','','','',$start,array('accessory_of' => $res_id),'',$need_full_no_count=true);
|
||||||
$acc_list = array();
|
$acc_list = array();
|
||||||
if($data) {
|
if($data) {
|
||||||
foreach($data as $num => $resource)
|
foreach($data as $num => $resource)
|
||||||
{
|
{
|
||||||
|
if($resource['deleted'] && !$deleted) continue;
|
||||||
$acc_list[$resource['res_id']] = $resource['name'];
|
$acc_list[$resource['res_id']] = $resource['name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,6 +354,8 @@ class resources_ui
|
|||||||
$action_msg = lang('restored');
|
$action_msg = lang('restored');
|
||||||
foreach($checked as $n=>$id)
|
foreach($checked as $n=>$id)
|
||||||
{
|
{
|
||||||
|
// Extra data
|
||||||
|
if(!$id) continue;
|
||||||
$resource = $this->bo->read($id);
|
$resource = $this->bo->read($id);
|
||||||
$resource['deleted'] = null;
|
$resource['deleted'] = null;
|
||||||
$this->bo->save($resource);
|
$this->bo->save($resource);
|
||||||
@ -365,6 +367,8 @@ class resources_ui
|
|||||||
$promoted_accessories = 0;
|
$promoted_accessories = 0;
|
||||||
foreach($checked as $n => &$id)
|
foreach($checked as $n => &$id)
|
||||||
{
|
{
|
||||||
|
// Extra data
|
||||||
|
if(!$id) continue;
|
||||||
if($settings == 'promote')
|
if($settings == 'promote')
|
||||||
{
|
{
|
||||||
// Handle a selected accessory
|
// Handle a selected accessory
|
||||||
@ -396,6 +400,7 @@ class resources_ui
|
|||||||
// Remove checked accessories, deleting resource will remove them
|
// Remove checked accessories, deleting resource will remove them
|
||||||
// We get an error if we try to delete them after they're gone
|
// We get an error if we try to delete them after they're gone
|
||||||
$accessories = $this->bo->get_acc_list($id);
|
$accessories = $this->bo->get_acc_list($id);
|
||||||
|
|
||||||
foreach($accessories as $acc_id => $name)
|
foreach($accessories as $acc_id => $name)
|
||||||
{
|
{
|
||||||
$checked_key = array_search($acc_id, $checked);
|
$checked_key = array_search($acc_id, $checked);
|
||||||
|
Loading…
Reference in New Issue
Block a user