fix egw_link::link to accept an array of links as 3. parameter, even if we dont have an $id1 yet

This commit is contained in:
Ralf Becker 2014-01-13 17:52:19 +00:00
parent 0c2ab2ada5
commit b08b507edb

View File

@ -289,6 +289,38 @@ class egw_link extends solink
{ {
return False; return False;
} }
if (is_array($app2) && !$id2)
{
reset($app2);
$link_id = True;
while ($link_id && list(,$link) = each($app2))
{
if (!is_array($link)) // check for unlink-marker
{
//echo "<b>link='$link' is no array</b><br>\n";
continue;
}
if (is_array($id1) || !$id1) // create link only in $id1 array
{
self::link($app1, $id1, $link['app'], $link['id'], $link['remark'],$link['owner'],$link['lastmod']);
continue;
}
if ($link['app'] == self::VFS_APPNAME)
{
$link_id = self::attach_file($app1,$id1,$link['id'],$link['remark']);
}
else
{
$link_id = solink::link($app1,$id1,$link['app'],$link['id'],
$link['remark'],$link['owner'],$link['lastmod']);
// notify both sides
if (!($no_notify&2)) self::notify('link',$link['app'],$link['id'],$app1,$id1,$link_id);
if (!($no_notify&1)) self::notify('link',$app1,$id1,$link['app'],$link['id'],$link_id);
}
}
return $link_id;
}
if (is_array($id1) || !$id1) // create link only in $id1 array if (is_array($id1) || !$id1) // create link only in $id1 array
{ {
if (!is_array($id1)) if (!is_array($id1))
@ -311,33 +343,6 @@ class egw_link extends solink
} }
return $link_id; return $link_id;
} }
if (is_array($app2) && !$id2)
{
reset($app2);
$link_id = True;
while ($link_id && list(,$link) = each($app2))
{
if (!is_array($link)) // check for unlink-marker
{
//echo "<b>link='$link' is no array</b><br>\n";
continue;
}
if ($link['app'] == self::VFS_APPNAME)
{
$link_id = self::attach_file($app1,$id1,$link['id'],$link['remark']);
}
else
{
$link_id = solink::link($app1,$id1,$link['app'],$link['id'],
$link['remark'],$link['owner'],$link['lastmod']);
// notify both sides
if (!($no_notify&2)) self::notify('link',$link['app'],$link['id'],$app1,$id1,$link_id);
if (!($no_notify&1)) self::notify('link',$app1,$id1,$link['app'],$link['id'],$link_id);
}
}
return $link_id;
}
if ($app1 == self::VFS_APPNAME) if ($app1 == self::VFS_APPNAME)
{ {
return self::attach_file($app2,$id2,$id1,$remark); return self::attach_file($app2,$id2,$id1,$remark);