mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-24 14:11:29 +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,38 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
/**************************************************************************\
|
/**
|
||||||
* eGroupWare - eGroupWare Interapplication Links *
|
* API - Interapplicaton links BO layer
|
||||||
* http://www.egroupware.org *
|
*
|
||||||
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
* 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'
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* - id this is the id, eg. an integer or a tupple like '0:INBOX:1234'
|
||||||
* 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 *
|
* @link http://www.egroupware.org
|
||||||
* option) any later version. *
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
\**************************************************************************/
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
|
* @package api
|
||||||
/* $Id$ */
|
* @subpackage link
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
include_once(EGW_API_INC . '/class.solink.inc.php');
|
include_once(EGW_API_INC . '/class.solink.inc.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generalized linking between entries of eGroupware apps - BO layer
|
* generalized linking between entries of eGroupware apps - BO layer
|
||||||
*
|
*
|
||||||
* Links have two ends each pointing to an entry, each entry is a double:
|
* The BO-layer implementes some extra features on top of the so-layer:
|
||||||
* - 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:
|
|
||||||
* 1) It handles links to not already existing entries. This is used by the eTemplate link-widget, which allows to
|
* 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.
|
* 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
|
* 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.
|
* (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 (!).
|
* 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!
|
* Attached files are stored under $vfs_basedir='/infolog' in the vfs!
|
||||||
*
|
* 3) It manages the link-registry, in which apps can register themselfs by implementing some hooks
|
||||||
* @package api
|
* 4) It notifies apps, who registered for that service, about changes in the links their entries
|
||||||
* @subpackage link
|
|
||||||
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
||||||
*/
|
*/
|
||||||
class bolink extends solink
|
class bolink extends solink
|
||||||
{
|
{
|
||||||
|
@ -1,36 +1,49 @@
|
|||||||
<?php
|
<?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:
|
* 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'
|
* - 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'
|
* - 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.
|
* @link http://www.egroupware.org
|
||||||
*
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
* @package API
|
|
||||||
* @subpackage link
|
|
||||||
* @author RalfBecker-At-outdoor-training.de
|
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
* @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
|
class solink
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Instance of the db-class
|
||||||
|
*
|
||||||
|
* @var egw_db
|
||||||
|
*/
|
||||||
var $db;
|
var $db;
|
||||||
|
/**
|
||||||
|
* Current user
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
var $user;
|
var $user;
|
||||||
|
/**
|
||||||
|
* Name of the links table
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
var $link_table = 'egw_links';
|
var $link_table = 'egw_links';
|
||||||
|
/**
|
||||||
|
* Turns on debug-messages
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
var $debug;
|
var $debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -314,4 +327,42 @@
|
|||||||
|
|
||||||
return $this->db->affected_rows();
|
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