mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-09 07:28:43 +01:00
- new method get_3links, to get all links from a given app's entries to an other app's entries, which both link to the same 3. app and id
- documentation update phpDoc headers
This commit is contained in:
parent
96f0c4a199
commit
e88c4e3eb3
@ -1,41 +1,36 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare - eGroupWare Interapplication Links *
|
||||
* http://www.egroupware.org *
|
||||
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
||||
* -------------------------------------------- *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU General Public License as published by the *
|
||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
include_once(EGW_API_INC . '/class.solink.inc.php');
|
||||
|
||||
/**
|
||||
* generalized linking between entries of eGroupware apps - BO layer
|
||||
/**
|
||||
* API - Interapplicaton links BO layer
|
||||
*
|
||||
* Links have two ends each pointing to an entry, each entry is a double:
|
||||
* - app app-name or directory-name of an egw application, eg. 'infolog'
|
||||
* - id this is the id, eg. an integer or a tupple like '0:INBOX:1234'
|
||||
*
|
||||
* The BO-layer implementes 2 extra features on top of the so-layer:
|
||||
* @link http://www.egroupware.org
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @subpackage link
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
include_once(EGW_API_INC . '/class.solink.inc.php');
|
||||
|
||||
/**
|
||||
* generalized linking between entries of eGroupware apps - BO layer
|
||||
*
|
||||
* The BO-layer implementes some extra features on top of the so-layer:
|
||||
* 1) It handles links to not already existing entries. This is used by the eTemplate link-widget, which allows to
|
||||
* setup links even for new / not already existing entries, before they get saved.
|
||||
* In that case you have to set the first id to 0 for the link-function and pass the array returned in that id
|
||||
* (not the return-value) after saveing your new entry again to the link function.
|
||||
* 2) Attaching files: they are saved in the vfs and not the link-table (!).
|
||||
* Attached files are stored under $vfs_basedir='/infolog' in the vfs!
|
||||
*
|
||||
* @package api
|
||||
* @subpackage link
|
||||
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* 3) It manages the link-registry, in which apps can register themselfs by implementing some hooks
|
||||
* 4) It notifies apps, who registered for that service, about changes in the links their entries
|
||||
*/
|
||||
class bolink extends solink
|
||||
{
|
||||
class bolink extends solink
|
||||
{
|
||||
/**
|
||||
* other apps can participate in the linking by implementing a 'search_link' hook, which
|
||||
* has to return an array in the format of an app_register entry below
|
||||
@ -57,7 +52,7 @@
|
||||
),
|
||||
'view_id' => 'msgball[acctnum:folder:msgnum]' // id is a tupple/array, fields separated by ':'
|
||||
),
|
||||
*/
|
||||
*/
|
||||
);
|
||||
var $public_functions = array( // functions callable via menuaction
|
||||
'get_file' => True
|
||||
@ -1023,4 +1018,4 @@
|
||||
$this->notify('unlink',$link['link_app2'],$link['link_id2'],$link['link_app1'],$link['link_id1'],$link['link_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +1,49 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare - eGroupWare Interapplication Links *
|
||||
* http://www.egroupware.org *
|
||||
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
||||
* -------------------------------------------- *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU General Public License as published by the *
|
||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/**
|
||||
* generalized linking between entries of eGroupware apps - SO layer
|
||||
/**
|
||||
* API - Interapplicaton links BO layer
|
||||
*
|
||||
* Links have two ends each pointing to an entry, each entry is a double:
|
||||
* - app app-name or directory-name of an egw application, eg. 'infolog'
|
||||
* - id this is the id, eg. an integer or a tupple like '0:INBOX:1234'
|
||||
*
|
||||
* All vars passed to this class get correct escaped to prevent query insertion.
|
||||
*
|
||||
* @package API
|
||||
* @subpackage link
|
||||
* @author RalfBecker-At-outdoor-training.de
|
||||
* @link http://www.egroupware.org
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @subpackage link
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* generalized linking between entries of eGroupware apps - SO layer
|
||||
*
|
||||
* All vars passed to this class get correct escaped to prevent query insertion.
|
||||
*/
|
||||
class solink
|
||||
{
|
||||
/**
|
||||
* Instance of the db-class
|
||||
*
|
||||
* @var egw_db
|
||||
*/
|
||||
class solink
|
||||
{
|
||||
var $db;
|
||||
/**
|
||||
* Current user
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
var $user;
|
||||
/**
|
||||
* Name of the links table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $link_table = 'egw_links';
|
||||
/**
|
||||
* Turns on debug-messages
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $debug;
|
||||
|
||||
/**
|
||||
@ -314,4 +327,42 @@
|
||||
|
||||
return $this->db->affected_rows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all links from a given app's entries to an other app's entries, which both link to the same 3. app and id
|
||||
*
|
||||
* Example:
|
||||
* I search all timesheet's linked to a given project and id(s), who are also linked to other entries,
|
||||
* which link to the same project:
|
||||
*
|
||||
* ($app='timesheet'/some id) <--a--> (other app/other id) <--b--> ($t_app='projectmanager'/$t_id=$pm_id)
|
||||
* ^ ^
|
||||
* +---------------------------c-----------------------------------------+
|
||||
*
|
||||
* bolink::get_3links('timesheet','projectmanager',$pm_id) returns the links (c) between the timesheet and the project,
|
||||
* plus the other app/id in the keys 'app3' and 'id3'
|
||||
*
|
||||
* Please note / ToDo:
|
||||
* at the moment only those links are returned, who are initiated by $app1, means for whom link_app1=$app1
|
||||
*
|
||||
* @param string $app app the returned links are linked on one side (atm. this must be link_app1!)
|
||||
* @param string $target_app app the returned links other side link also to
|
||||
* @param string/array $target_id=null id(s) the returned links other side link also to
|
||||
* @return array with links from entries from $app to $target_app/$target_id plus the other (b) link_id/app/id in the keys 'link3'/'app3'/'id3'
|
||||
*/
|
||||
function get_3links($app,$target_app,$target_id=null)
|
||||
{
|
||||
$links = array();
|
||||
$this->db->select($this->link_table,'c.*,b.link_app1 AS app3,b.link_id1 AS id3,b.link_id AS link3',
|
||||
'a.link_app1='.$this->db->quote($app).' AND c.link_app2='.$this->db->quote($target_app).
|
||||
(!$target_id ? '' : $this->db->expression($this->link_table,' AND c.',array('link_id2' => $target_id))),
|
||||
__LINE__,__FILE__,false,'',false,0," a
|
||||
JOIN $this->link_table b ON a.link_id2=b.link_id1 AND a.link_app2=b.link_app1
|
||||
JOIN $this->link_table c ON a.link_id1=c.link_id1 AND a.link_app1=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app2 AND c.link_id2=b.link_id2");
|
||||
while (($row = $this->db->row(true,'link_')))
|
||||
{
|
||||
$links[] = $row;
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user