forked from extern/egroupware
fix Scrutinizer "bugs"
This commit is contained in:
parent
66c34f012d
commit
4b75ed5e7f
@ -391,17 +391,19 @@ class resources_bo
|
|||||||
Link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']);
|
Link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']);
|
||||||
|
|
||||||
// Check for resource changing to accessory - move its accessories to resource
|
// Check for resource changing to accessory - move its accessories to resource
|
||||||
if($old['accessory_of'] == -1 && $accessories = $this->get_acc_list($resource['res_id']))
|
if($old['accessory_of'] == -1 && ($accessories = $this->get_acc_list($resource['res_id'])))
|
||||||
{
|
{
|
||||||
foreach($accessories as $accessory => $name)
|
foreach($accessories as $accessory => $name)
|
||||||
{
|
{
|
||||||
Link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']);
|
Link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']);
|
||||||
$acc = $this->read($accessory);
|
if (($acc = $this->read($accessory)))
|
||||||
|
{
|
||||||
$acc['accessory_of'] = -1;
|
$acc['accessory_of'] = -1;
|
||||||
$this->so->save($acc);
|
$this->so->save($acc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if($resource['accessory_of'] != -1)
|
if($resource['accessory_of'] != -1)
|
||||||
{
|
{
|
||||||
Link::link('resources',$resource['res_id'],'resources',$resource['accessory_of']);
|
Link::link('resources',$resource['res_id'],'resources',$resource['accessory_of']);
|
||||||
@ -412,12 +414,14 @@ class resources_bo
|
|||||||
$accessories = $this->get_acc_list($resource['res_id']);
|
$accessories = $this->get_acc_list($resource['res_id']);
|
||||||
foreach($accessories as $accessory => $name)
|
foreach($accessories as $accessory => $name)
|
||||||
{
|
{
|
||||||
$acc = $this->so->read($accessory);
|
if (($acc = $this->so->read($accessory)))
|
||||||
|
{
|
||||||
$acc['cat_id'] = $resource['cat_id'];
|
$acc['cat_id'] = $resource['cat_id'];
|
||||||
$this->so->data = $acc;
|
$this->so->data = $acc;
|
||||||
$this->so->save();
|
$this->so->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$res_id = $this->so->save($resource);
|
$res_id = $this->so->save($resource);
|
||||||
|
|
||||||
@ -439,6 +443,7 @@ class resources_bo
|
|||||||
*
|
*
|
||||||
* @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
|
* @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
|
||||||
* @param int $res_id id of resource
|
* @param int $res_id id of resource
|
||||||
|
* @return string|false string with error or false on success
|
||||||
*/
|
*/
|
||||||
function delete($res_id)
|
function delete($res_id)
|
||||||
{
|
{
|
||||||
@ -448,9 +453,12 @@ class resources_bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if we only mark resources as deleted, or really delete them
|
// check if we only mark resources as deleted, or really delete them
|
||||||
$old = $this->read($res_id);
|
|
||||||
$config = Api\Config::read('resources');
|
$config = Api\Config::read('resources');
|
||||||
if ($config['history'] != '' && $old['deleted'] == null)
|
if (!($old = $this->read($res_id)))
|
||||||
|
{
|
||||||
|
// error is returned at end of function
|
||||||
|
}
|
||||||
|
elseif ($config['history'] != '' && $old['deleted'] == null)
|
||||||
{
|
{
|
||||||
$old['deleted'] = time();
|
$old['deleted'] = time();
|
||||||
$this->save($old);
|
$this->save($old);
|
||||||
@ -459,8 +467,7 @@ class resources_bo
|
|||||||
foreach($accessories as $acc_id => $name)
|
foreach($accessories as $acc_id => $name)
|
||||||
{
|
{
|
||||||
// Don't purge already deleted accessories
|
// Don't purge already deleted accessories
|
||||||
$acc = $this->read($acc_id);
|
if (($acc = $this->read($acc_id)) && !$acc['deleted'])
|
||||||
if(!$acc['deleted'])
|
|
||||||
{
|
{
|
||||||
$acc['deleted'] = time();
|
$acc['deleted'] = time();
|
||||||
$this->save($acc);
|
$this->save($acc);
|
||||||
@ -474,9 +481,8 @@ class resources_bo
|
|||||||
$accessories = $this->get_acc_list($res_id, true);
|
$accessories = $this->get_acc_list($res_id, true);
|
||||||
foreach($accessories as $acc_id => $name)
|
foreach($accessories as $acc_id => $name)
|
||||||
{
|
{
|
||||||
if($this->delete($acc_id))
|
if($this->delete($acc_id) && ($acc = $this->read($acc_id)))
|
||||||
{
|
{
|
||||||
$acc = $this->read($acc_id);
|
|
||||||
$acc['accessory_of'] = -1;
|
$acc['accessory_of'] = -1;
|
||||||
$this->save($acc);
|
$this->save($acc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user