2005-10-01 22:18:41 +02:00
|
|
|
<?php
|
2006-08-26 17:58:26 +02:00
|
|
|
/**
|
|
|
|
* 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'
|
|
|
|
*
|
|
|
|
* @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$
|
|
|
|
*/
|
2005-10-01 22:18:41 +02:00
|
|
|
|
2006-08-26 17:58:26 +02:00
|
|
|
/**
|
2008-03-08 22:41:20 +01:00
|
|
|
* Generalized linking between entries of eGroupware apps - BO layer
|
|
|
|
*
|
|
|
|
* @deprecated use egw_link class with it's static methods instead
|
2006-08-26 17:58:26 +02:00
|
|
|
*/
|
2008-03-08 22:41:20 +01:00
|
|
|
class bolink extends egw_link
|
2006-08-26 17:58:26 +02:00
|
|
|
{
|
2008-03-08 22:41:20 +01:00
|
|
|
var $public_functions = array(
|
|
|
|
'get_file' => true,
|
2006-08-26 17:58:26 +02:00
|
|
|
);
|
2006-10-04 10:23:28 +02:00
|
|
|
/**
|
2008-03-08 22:41:20 +01:00
|
|
|
* @deprecated use egw_link::VFS_APPNAME
|
2006-10-04 10:23:28 +02:00
|
|
|
*/
|
2008-03-08 22:41:20 +01:00
|
|
|
var $vfs_appname = egw_link::VFS_APPNAME;
|
2006-10-04 10:23:28 +02:00
|
|
|
|
|
|
|
/**
|
2008-03-08 22:41:20 +01:00
|
|
|
* Overwrite private constructor of egw_links, to allow (depricated) instancated usage
|
2006-10-04 10:23:28 +02:00
|
|
|
*
|
|
|
|
*/
|
2008-03-08 22:41:20 +01:00
|
|
|
function __construct()
|
2006-10-04 10:23:28 +02:00
|
|
|
{
|
2006-08-26 17:58:26 +02:00
|
|
|
|
|
|
|
}
|
2005-10-01 22:18:41 +02:00
|
|
|
|
2006-08-26 17:58:26 +02:00
|
|
|
/**
|
2008-03-08 22:41:20 +01:00
|
|
|
* Download an attached file
|
2006-08-26 17:58:26 +02:00
|
|
|
*
|
2008-03-08 22:41:20 +01:00
|
|
|
* @todo replace it with egw_vfs::download_url, once egw_vfs/webdav supports the attachments
|
|
|
|
* @param array $link=null
|
|
|
|
* @return array with params (eg. menuaction) for download link
|
2006-08-26 17:58:26 +02:00
|
|
|
*/
|
2008-03-08 22:41:20 +01:00
|
|
|
function get_file(array $link=null)
|
2006-08-26 17:58:26 +02:00
|
|
|
{
|
|
|
|
if (is_array($link))
|
2005-10-01 22:18:41 +02:00
|
|
|
{
|
2006-08-26 17:58:26 +02:00
|
|
|
return array(
|
|
|
|
'menuaction' => 'phpgwapi.bolink.get_file',
|
|
|
|
'app' => $link['app2'],
|
|
|
|
'id' => $link['id2'],
|
|
|
|
'filename' => $link['id']
|
|
|
|
);
|
|
|
|
}
|
2008-03-08 22:41:20 +01:00
|
|
|
$app = $_GET['app'];
|
|
|
|
$id = $_GET['id'];
|
|
|
|
$filename = $_GET['filename'];
|
2005-10-01 22:18:41 +02:00
|
|
|
|
2006-08-26 17:58:26 +02:00
|
|
|
if (empty($app) || empty($id) || empty($filename) || !$this->title($app,$id))
|
|
|
|
{
|
2008-03-08 22:41:20 +01:00
|
|
|
$GLOBALS['egw']->framework->render('<h1 style="text-align: center; color: red;">'.lang('Access not permitted')." !!!</h1>\n",
|
|
|
|
lang('Access not permitted'),true);
|
2006-08-26 17:58:26 +02:00
|
|
|
$GLOBALS['egw']->common->egw_exit();
|
|
|
|
}
|
2008-03-08 22:41:20 +01:00
|
|
|
$browser = new browser();
|
2005-10-01 22:18:41 +02:00
|
|
|
|
2006-08-26 17:58:26 +02:00
|
|
|
$local = $this->attached_local($app,$id,$filename,$_SERVER['REMOTE_ADDR'],$browser->is_windows());
|
2005-10-01 22:18:41 +02:00
|
|
|
|
2006-08-26 17:58:26 +02:00
|
|
|
if ($local)
|
|
|
|
{
|
|
|
|
Header('Location: ' . $local);
|
2005-10-01 22:18:41 +02:00
|
|
|
}
|
2006-08-26 17:58:26 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$info = $this->info_attached($app,$id,$filename);
|
|
|
|
$browser->content_header($filename,$info['type']);
|
|
|
|
echo $this->read_attached($app,$id,$filename);
|
|
|
|
}
|
|
|
|
$GLOBALS['egw']->common->egw_exit();
|
2008-03-08 22:41:20 +01:00
|
|
|
}
|
2006-08-26 17:58:26 +02:00
|
|
|
}
|