mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
Add the ability to hide and hold deleted links, pending final deletion of linked record. This prevents links to deleted items showing when deleted items are held for purging.
This commit is contained in:
parent
453945c9c9
commit
1482dbc1be
@ -304,11 +304,12 @@ class egw_link extends solink
|
|||||||
* @param string $order='link_lastmod DESC' defaults to newest links first
|
* @param string $order='link_lastmod DESC' defaults to newest links first
|
||||||
* @param boolean $cache_titles=false should all titles be queryed and cached (allows to query each link app only once!)
|
* @param boolean $cache_titles=false should all titles be queryed and cached (allows to query each link app only once!)
|
||||||
* This option also removes links not viewable by current user from the result!
|
* This option also removes links not viewable by current user from the result!
|
||||||
|
* @param boolean $deleted Include links that have been flagged as deleted, waiting for purge.
|
||||||
* @return array of links or empty array if no matching links found
|
* @return array of links or empty array if no matching links found
|
||||||
*/
|
*/
|
||||||
static function get_links( $app,$id,$only_app='',$order='link_lastmod DESC',$cache_titles=false )
|
static function get_links( $app,$id,$only_app='',$order='link_lastmod DESC',$cache_titles=false,$deleted=false )
|
||||||
{
|
{
|
||||||
if (self::DEBUG) echo "<p>egw_link::get_links(app='$app',id='$id',only_app='$only_app',order='$order')</p>\n";
|
if (self::DEBUG) echo "<p>egw_link::get_links(app='$app',id='$id',only_app='$only_app',order='$order',deleted='$deleted')</p>\n";
|
||||||
|
|
||||||
if (is_array($id) || !$id)
|
if (is_array($id) || !$id)
|
||||||
{
|
{
|
||||||
@ -330,7 +331,7 @@ class egw_link extends solink
|
|||||||
}
|
}
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
$ids = solink::get_links($app,$id,$only_app,$order);
|
$ids = solink::get_links($app,$id,$only_app,$order,$deleted);
|
||||||
if (empty($only_app) || $only_app == self::VFS_APPNAME ||
|
if (empty($only_app) || $only_app == self::VFS_APPNAME ||
|
||||||
($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME))
|
($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME))
|
||||||
{
|
{
|
||||||
@ -474,11 +475,12 @@ class egw_link extends solink
|
|||||||
* @param string/array $id='' id in $app or array with links, if 1. entry not yet created
|
* @param string/array $id='' id in $app or array with links, if 1. entry not yet created
|
||||||
* @param string $app2='' app of second endpoint
|
* @param string $app2='' app of second endpoint
|
||||||
* @param string $id2='' id in $app2
|
* @param string $id2='' id in $app2
|
||||||
|
* @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete
|
||||||
* @return the number of links deleted
|
* @return the number of links deleted
|
||||||
*/
|
*/
|
||||||
static function unlink($link_id,$app='',$id='',$owner='',$app2='',$id2='')
|
static function unlink($link_id,$app='',$id='',$owner='',$app2='',$id2='',$hold_for_purge=false)
|
||||||
{
|
{
|
||||||
return self::unlink2($link_id,$app,$id,$owner,$app2,$id2);
|
return self::unlink2($link_id,$app,$id,$owner,$app2,$id2,$hold_for_purge);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -489,9 +491,10 @@ class egw_link extends solink
|
|||||||
* @param string/array &$id='' id in $app or array with links, if 1. entry not yet created
|
* @param string/array &$id='' id in $app or array with links, if 1. entry not yet created
|
||||||
* @param string $app2='' app of second endpoint, or !file (other !app are not yet supported!)
|
* @param string $app2='' app of second endpoint, or !file (other !app are not yet supported!)
|
||||||
* @param string $id2='' id in $app2
|
* @param string $id2='' id in $app2
|
||||||
|
* @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete
|
||||||
* @return the number of links deleted
|
* @return the number of links deleted
|
||||||
*/
|
*/
|
||||||
static function unlink2($link_id,$app,&$id,$owner='',$app2='',$id2='')
|
static function unlink2($link_id,$app,&$id,$owner='',$app2='',$id2='',$hold_for_purge=false)
|
||||||
{
|
{
|
||||||
if (self::DEBUG)
|
if (self::DEBUG)
|
||||||
{
|
{
|
||||||
@ -516,7 +519,7 @@ class egw_link extends solink
|
|||||||
self::delete_attached($app,$id); // deleting all attachments
|
self::delete_attached($app,$id); // deleting all attachments
|
||||||
self::delete_cache($app,$id);
|
self::delete_cache($app,$id);
|
||||||
}
|
}
|
||||||
$deleted =& solink::unlink($link_id,$app,$id,$owner,$app2 != '!'.self::VFS_APPNAME ? $app2 : '',$id2);
|
$deleted =& solink::unlink($link_id,$app,$id,$owner,$app2 != '!'.self::VFS_APPNAME ? $app2 : '',$id2,$hold_for_purge);
|
||||||
|
|
||||||
// only notify on real links, not the one cached for writing or fileattachments
|
// only notify on real links, not the one cached for writing or fileattachments
|
||||||
self::notify_unlink($deleted);
|
self::notify_unlink($deleted);
|
||||||
|
@ -114,13 +114,14 @@ class solink
|
|||||||
* @param string/array $id id(s) in $app
|
* @param string/array $id id(s) in $app
|
||||||
* @param string $only_app if set return only links from $only_app (eg. only addressbook-entries) or NOT from if $only_app[0]=='!'
|
* @param string $only_app if set return only links from $only_app (eg. only addressbook-entries) or NOT from if $only_app[0]=='!'
|
||||||
* @param string $order defaults to newest links first
|
* @param string $order defaults to newest links first
|
||||||
|
* @param boolean $deleted Include links that have been flagged as deleted, waiting for purge of linked record.
|
||||||
* @return array id => links pairs if $id is an array or just the links (only_app: ids) or empty array if no matching links found
|
* @return array id => links pairs if $id is an array or just the links (only_app: ids) or empty array if no matching links found
|
||||||
*/
|
*/
|
||||||
static function get_links( $app,$id,$only_app='',$order='link_lastmod DESC' )
|
static function get_links( $app,$id,$only_app='',$order='link_lastmod DESC',$deleted )
|
||||||
{
|
{
|
||||||
if (self::DEBUG)
|
if (self::DEBUG)
|
||||||
{
|
{
|
||||||
echo "<p>solink.get_links($app,".print_r($id,true).",$only_app,$order)</p>\n";
|
echo "<p>solink.get_links($app,".print_r($id,true).",$only_app,$order,$deleted)</p>\n";
|
||||||
}
|
}
|
||||||
if (($not_only = $only_app[0] == '!'))
|
if (($not_only = $only_app[0] == '!'))
|
||||||
{
|
{
|
||||||
@ -128,13 +129,14 @@ class solink
|
|||||||
}
|
}
|
||||||
#var_dump($not_only);echo "$only_app<br>";
|
#var_dump($not_only);echo "$only_app<br>";
|
||||||
$links = array();
|
$links = array();
|
||||||
foreach(self::$db->select(self::TABLE,'*',self::$db->expression(self::TABLE,'(',array(
|
foreach(self::$db->select(self::TABLE,'*',self::$db->expression(self::TABLE,'((',array(
|
||||||
'link_app1' => $app,
|
'link_app1' => $app,
|
||||||
'link_id1' => $id,
|
'link_id1' => $id,
|
||||||
),') OR (',array(
|
),') OR (',array(
|
||||||
'link_app2' => $app,
|
'link_app2' => $app,
|
||||||
'link_id2' => $id,
|
'link_id2' => $id,
|
||||||
),')'
|
),'))',
|
||||||
|
$deleted ? '' : ' AND deleted IS NULL'
|
||||||
),__LINE__,__FILE__,False,$order ? " ORDER BY $order" : '') as $row)
|
),__LINE__,__FILE__,False,$order ? " ORDER BY $order" : '') as $row)
|
||||||
{
|
{
|
||||||
// check if left side (1) is one of our targets --> add it
|
// check if left side (1) is one of our targets --> add it
|
||||||
@ -229,9 +231,10 @@ class solink
|
|||||||
* @param int $owner=0 account_id to delete all links of a given owner, or 0
|
* @param int $owner=0 account_id to delete all links of a given owner, or 0
|
||||||
* @param string $app2='' appname of 2. endpoint of the link
|
* @param string $app2='' appname of 2. endpoint of the link
|
||||||
* @param string $id2='' id in $app2
|
* @param string $id2='' id in $app2
|
||||||
|
* @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete of linked entry
|
||||||
* @return array with deleted links
|
* @return array with deleted links
|
||||||
*/
|
*/
|
||||||
static function &unlink($link_id,$app='',$id='',$owner=0,$app2='',$id2='')
|
static function &unlink($link_id,$app='',$id='',$owner=0,$app2='',$id2='',$hold_for_purge=false)
|
||||||
{
|
{
|
||||||
if (self::DEBUG)
|
if (self::DEBUG)
|
||||||
{
|
{
|
||||||
@ -282,12 +285,47 @@ class solink
|
|||||||
foreach(self::$db->select(self::TABLE,'*',$where,__LINE__,__FILE__) as $row)
|
foreach(self::$db->select(self::TABLE,'*',$where,__LINE__,__FILE__) as $row)
|
||||||
{
|
{
|
||||||
$deleted[] = $row;
|
$deleted[] = $row;
|
||||||
}
|
}
|
||||||
self::$db->delete(self::TABLE,$where,__LINE__,__FILE__);
|
if($hold_for_purge)
|
||||||
|
{
|
||||||
|
self::$db->update(self::TABLE,array('deleted'=> time()), $where, __LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self::$db->delete(self::TABLE,$where,__LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
|
||||||
return $deleted;
|
return $deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore links being held as deleted waiting for purge of linked record (un-delete)
|
||||||
|
*
|
||||||
|
* @param string $app='' app-name of links to remove
|
||||||
|
* @param string $id='' id in $app or '' remove all links from $app
|
||||||
|
*/
|
||||||
|
static function restore($app, $id)
|
||||||
|
{
|
||||||
|
if (self::DEBUG)
|
||||||
|
{
|
||||||
|
echo "<p>solink.restore($app,$id)</p>\n";
|
||||||
|
}
|
||||||
|
if ($app == '')
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$check1 = array('link_app1' => $app);
|
||||||
|
$check2 = array('link_app2' => $app);
|
||||||
|
if ($id != '')
|
||||||
|
{
|
||||||
|
$check1['link_id1'] = $id;
|
||||||
|
$check2['link_id2'] = $id;
|
||||||
|
}
|
||||||
|
$where = self::$db->expression(self::TABLE,'((',$check1,') OR (',$check2,'))');
|
||||||
|
self::$db->update(self::TABLE,array('deleted'=> null), $where, __LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes ownership of all links from $owner to $new_owner
|
* Changes ownership of all links from $owner to $new_owner
|
||||||
*
|
*
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
/* Basic information about this app */
|
/* Basic information about this app */
|
||||||
$setup_info['phpgwapi']['name'] = 'phpgwapi';
|
$setup_info['phpgwapi']['name'] = 'phpgwapi';
|
||||||
$setup_info['phpgwapi']['title'] = 'eGroupWare API';
|
$setup_info['phpgwapi']['title'] = 'eGroupWare API';
|
||||||
$setup_info['phpgwapi']['version'] = '1.9.002';
|
$setup_info['phpgwapi']['version'] = '1.9.003';
|
||||||
$setup_info['phpgwapi']['versions']['current_header'] = '1.29';
|
$setup_info['phpgwapi']['versions']['current_header'] = '1.29';
|
||||||
$setup_info['phpgwapi']['enable'] = 3;
|
$setup_info['phpgwapi']['enable'] = 3;
|
||||||
$setup_info['phpgwapi']['app_order'] = 1;
|
$setup_info['phpgwapi']['app_order'] = 1;
|
||||||
@ -77,3 +77,4 @@ $setup_info['groupdav']['author'] = $setup_info['groupdav']['maintainer'] = arra
|
|||||||
$setup_info['groupdav']['license'] = 'GPL';
|
$setup_info['groupdav']['license'] = 'GPL';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -318,11 +318,12 @@ $phpgw_baseline = array(
|
|||||||
'link_id2' => array('type' => 'varchar','precision' => '50','nullable' => False),
|
'link_id2' => array('type' => 'varchar','precision' => '50','nullable' => False),
|
||||||
'link_remark' => array('type' => 'varchar','precision' => '100'),
|
'link_remark' => array('type' => 'varchar','precision' => '100'),
|
||||||
'link_lastmod' => array('type' => 'int','precision' => '8','nullable' => False),
|
'link_lastmod' => array('type' => 'int','precision' => '8','nullable' => False),
|
||||||
'link_owner' => array('type' => 'int','precision' => '4','nullable' => False)
|
'link_owner' => array('type' => 'int','precision' => '4','nullable' => False),
|
||||||
|
'deleted' => array('type' => 'timestamp')
|
||||||
),
|
),
|
||||||
'pk' => array('link_id'),
|
'pk' => array('link_id'),
|
||||||
'fk' => array(),
|
'fk' => array(),
|
||||||
'ix' => array(array('link_app1','link_id1','link_lastmod'),array('link_app2','link_id2','link_lastmod')),
|
'ix' => array('deleted',array('link_app1','link_id1','link_lastmod'),array('link_app2','link_id2','link_lastmod')),
|
||||||
'uc' => array()
|
'uc' => array()
|
||||||
),
|
),
|
||||||
'egw_addressbook' => array(
|
'egw_addressbook' => array(
|
||||||
|
@ -41,3 +41,31 @@ function phpgwapi_upgrade1_9_001()
|
|||||||
|
|
||||||
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.9.002';
|
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.9.002';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function phpgwapi_upgrade1_9_002()
|
||||||
|
{
|
||||||
|
/* done by RefreshTable() anyway
|
||||||
|
$GLOBALS['egw_setup']->oProc->AddColumn('egw_links','deleted',array(
|
||||||
|
'type' => 'timestamp'
|
||||||
|
));*/
|
||||||
|
$GLOBALS['egw_setup']->oProc->RefreshTable('egw_links',array(
|
||||||
|
'fd' => array(
|
||||||
|
'link_id' => array('type' => 'auto','nullable' => False),
|
||||||
|
'link_app1' => array('type' => 'varchar','precision' => '25','nullable' => False),
|
||||||
|
'link_id1' => array('type' => 'varchar','precision' => '50','nullable' => False),
|
||||||
|
'link_app2' => array('type' => 'varchar','precision' => '25','nullable' => False),
|
||||||
|
'link_id2' => array('type' => 'varchar','precision' => '50','nullable' => False),
|
||||||
|
'link_remark' => array('type' => 'varchar','precision' => '100'),
|
||||||
|
'link_lastmod' => array('type' => 'int','precision' => '8','nullable' => False),
|
||||||
|
'link_owner' => array('type' => 'int','precision' => '4','nullable' => False),
|
||||||
|
'deleted' => array('type' => 'timestamp')
|
||||||
|
),
|
||||||
|
'pk' => array('link_id'),
|
||||||
|
'fk' => array(),
|
||||||
|
'ix' => array('deleted',array('link_app1','link_id1','link_lastmod'),array('link_app2','link_id2','link_lastmod')),
|
||||||
|
'uc' => array()
|
||||||
|
));
|
||||||
|
|
||||||
|
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.9.003';
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user