2001-07-12 01:17:32 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - InfoLog *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
|
|
|
* originaly based on todo written by Joseph Engo <jengo@phpgroupware.org> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* 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$ */
|
|
|
|
|
|
|
|
class boinfolog // BO: buiseness objects: internal logic
|
|
|
|
{
|
|
|
|
var $public_functions = array
|
|
|
|
(
|
2001-10-07 22:11:32 +02:00
|
|
|
'init' => True, // in class soinfolog
|
|
|
|
'read' => True,
|
|
|
|
'write' => True,
|
|
|
|
'delete' => True,
|
|
|
|
'check_access' => True,
|
|
|
|
'readProj' => True,
|
|
|
|
'readAddr' => True,
|
|
|
|
'anzSubs' => True,
|
|
|
|
'readIdArray' => True,
|
|
|
|
'accountInfo' => True, // in class boinfolog (this class)
|
|
|
|
'addr2name' => True,
|
|
|
|
'attach_file' => True,
|
|
|
|
'delete_attached'=> True,
|
|
|
|
'info_attached' => True,
|
|
|
|
'list_attached' => True,
|
|
|
|
'read_attached' => True,
|
2002-09-02 10:57:35 +02:00
|
|
|
'attached_local' => True,
|
|
|
|
'link_title' => True,
|
|
|
|
'link_query' => True
|
2001-07-12 01:17:32 +02:00
|
|
|
);
|
|
|
|
var $enums;
|
|
|
|
var $so;
|
2001-10-07 22:11:32 +02:00
|
|
|
var $vfs;
|
|
|
|
var $vfs_basedir='/infolog';
|
|
|
|
var $valid_pathes = array();
|
|
|
|
var $send_file_ips = array();
|
2001-07-12 01:17:32 +02:00
|
|
|
|
2002-02-14 21:14:15 +01:00
|
|
|
function boinfolog( $info_id = 0)
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-10-03 21:21:08 +02:00
|
|
|
$this->enums = array(
|
2001-07-12 01:17:32 +02:00
|
|
|
'priority' => array (
|
|
|
|
'urgent' => 'urgent','high' => 'high','normal' => 'normal',
|
|
|
|
'low' => 'low' ),
|
|
|
|
'status' => array(
|
|
|
|
'offer' => 'offer','ongoing' => 'ongoing','call' => 'call',
|
|
|
|
'will-call' => 'will-call','done' => 'done',
|
|
|
|
'billed' => 'billed' ),
|
|
|
|
'confirm' => array(
|
|
|
|
'not' => 'not','accept' => 'accept','finish' => 'finish',
|
|
|
|
'both' => 'both' ),
|
|
|
|
'type' => array(
|
2001-09-26 19:10:03 +02:00
|
|
|
'task' => 'task','phone' => 'phone','note' => 'note'
|
|
|
|
/* ,'confirm' => 'confirm','reject' => 'reject','email' => 'email',
|
2001-07-15 23:42:17 +02:00
|
|
|
'fax' => 'fax' no implemented so far */ )
|
2001-07-12 01:17:32 +02:00
|
|
|
);
|
2001-07-19 03:28:16 +02:00
|
|
|
$this->status = array(
|
|
|
|
'defaults' => array(
|
|
|
|
'task' => 'ongoing', 'phone' => 'call', 'note' => 'done'),
|
|
|
|
'task' => array(
|
|
|
|
'offer' => 'offer','ongoing' => 'ongoing',
|
|
|
|
'done' => 'done', 'billed' => 'billed' ),
|
|
|
|
'phone' => array(
|
|
|
|
'call' => 'call','will-call' => 'will-call',
|
|
|
|
'done' => 'done', 'billed' => 'billed' ),
|
|
|
|
'note' => array(
|
|
|
|
'ongoing' => 'ongoing', 'done' => 'done'
|
|
|
|
));
|
2001-10-03 21:21:08 +02:00
|
|
|
|
2001-07-12 01:17:32 +02:00
|
|
|
$this->so = CreateObject('infolog.soinfolog');
|
2001-10-07 22:11:32 +02:00
|
|
|
$this->vfs = CreateObject('infolog.vfs');
|
|
|
|
|
|
|
|
$this->config = CreateObject('phpgwapi.config');
|
|
|
|
$this->config->read_repository();
|
|
|
|
|
|
|
|
if ($this->config->config_data)
|
|
|
|
{
|
2001-10-07 23:08:49 +02:00
|
|
|
$this->link_pathes = unserialize($this->config->config_data['link_pathes']);
|
|
|
|
$this->send_file_ips = unserialize($this->config->config_data['send_file_ips']);
|
2001-10-07 22:11:32 +02:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
|
|
|
|
$this->read( $info_id);
|
|
|
|
}
|
2001-10-03 21:21:08 +02:00
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function accountInfo($id,$account_data=0)
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
if (!$id) return ' ';
|
2001-10-03 21:21:08 +02:00
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
if (!is_array($account_data))
|
|
|
|
{
|
2001-10-03 21:37:26 +02:00
|
|
|
if (!isset($this->account_data[$id])) // do some cacheing
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->accounts->accounts($id);
|
|
|
|
$GLOBALS['phpgw']->accounts->read_repository();
|
|
|
|
$this->account_data[$id] = $GLOBALS['phpgw']->accounts->data;
|
|
|
|
}
|
|
|
|
$account_data = $this->account_data[$id];
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2001-10-03 21:21:08 +02:00
|
|
|
if ($GLOBALS['phpgw_info']['user']['preferences']['infolog']['longNames'])
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
return $account_data['firstname'].' '.$account_data['lastname'];
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
2001-10-03 21:21:08 +02:00
|
|
|
return $account_data['account_lid'];
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function addr2name( $addr )
|
|
|
|
{
|
2002-05-12 09:14:01 +02:00
|
|
|
if (!is_array($addr) && !($addr = $this->readAddr($addr)))
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
$name = $addr['n_family'];
|
|
|
|
if ($addr['n_given'])
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$name .= ', '.$addr['n_given'];
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
if ($addr['n_prefix'])
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$name .= ', '.$addr['n_prefix'];
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
if ($addr['org_name'])
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$name = $addr['org_name'].': '.$name;
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
2001-10-03 21:21:08 +02:00
|
|
|
return $GLOBALS['phpgw']->strip_html($name);
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2002-05-12 09:14:01 +02:00
|
|
|
function proj2name( $proj )
|
|
|
|
{
|
|
|
|
if (!is_array($proj))
|
|
|
|
{
|
|
|
|
$proj = $this->readProj($proj);
|
|
|
|
}
|
|
|
|
return is_array($proj) ? $proj['title'] : '';
|
|
|
|
}
|
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function readProj($proj_id)
|
|
|
|
{
|
|
|
|
if ($proj_id)
|
|
|
|
{
|
2002-05-12 09:14:01 +02:00
|
|
|
if (!is_object($this->projects) && file_exists(PHPGW_SERVER_ROOT.'/projects'))
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2002-02-14 21:14:15 +01:00
|
|
|
$this->projects = createobject('projects.boprojects');
|
2001-10-03 21:21:08 +02:00
|
|
|
}
|
2002-09-01 20:11:57 +02:00
|
|
|
if (is_object($this->projects) && ($proj = $this->projects->read_single_project( $proj_id)))
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
return $proj;
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2002-02-14 21:14:15 +01:00
|
|
|
return False;
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function readAddr($addr_id)
|
|
|
|
{
|
|
|
|
if ($addr_id)
|
|
|
|
{
|
|
|
|
if (!is_object($this->contacts))
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$this->contacts = createobject('phpgwapi.contacts');
|
2002-02-14 21:14:15 +01:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
if (list( $addr ) = $this->contacts->read_single_entry( $addr_id ))
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
return $addr;
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2002-02-14 21:14:15 +01:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2002-05-12 09:14:01 +02:00
|
|
|
function event2name( $event )
|
|
|
|
{
|
|
|
|
if (!is_object($this->bocal) && file_exists(PHPGW_SERVER_ROOT.'/projects'))
|
|
|
|
{
|
|
|
|
$this->bocal = createobject('calendar.bocalendar');
|
|
|
|
}
|
|
|
|
if (is_object($this->bocal) && !is_array($event) && (int) $event > 0)
|
|
|
|
{
|
|
|
|
$event = $this->bocal->read_entry($event);
|
|
|
|
}
|
|
|
|
if (!is_array($event))
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
$name = $GLOBALS['phpgw']->common->show_date($this->bocal->maketime($event['start']) - $this->bocal->datetime->tz_offset);
|
|
|
|
$name .= ' -- ' . $GLOBALS['phpgw']->common->show_date($this->bocal->maketime($event['end']) - $this->bocal->datetime->tz_offset);
|
|
|
|
$name .= ': ' . $event['title'];
|
|
|
|
|
|
|
|
return $GLOBALS['phpgw']->strip_html($name);
|
|
|
|
}
|
|
|
|
|
|
|
|
function readEvent($cal_id)
|
|
|
|
{
|
|
|
|
if ($cal_id)
|
|
|
|
{
|
|
|
|
if (!is_object($this->bocal) && file_exists(PHPGW_SERVER_ROOT.'/projects'))
|
|
|
|
{
|
|
|
|
$this->bocal = createobject('calendar.bocalendar');
|
|
|
|
}
|
|
|
|
if (is_object($this->bocal) && $event = $this->bocal->read_entry( $cal_id ))
|
|
|
|
{
|
|
|
|
return $event;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2001-07-12 01:17:32 +02:00
|
|
|
/*
|
|
|
|
* check's if user has the requiered rights on entry $info_id
|
|
|
|
*/
|
2001-07-15 00:16:16 +02:00
|
|
|
function check_access( $info_id,$required_rights )
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
return $this->so->check_access( $info_id,$required_rights );
|
|
|
|
}
|
2002-02-14 21:14:15 +01:00
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function init()
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$this->so->init();
|
|
|
|
}
|
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function read($info_id)
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$this->so->read($info_id);
|
|
|
|
|
2001-09-26 19:10:03 +02:00
|
|
|
if ($this->so->data['info_subject'] ==
|
|
|
|
(substr($this->so->data['info_des'],0,60).' ...'))
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-09-26 19:10:03 +02:00
|
|
|
$this->so->data['info_subject'] = '';
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2001-09-26 19:10:03 +02:00
|
|
|
if ($this->so->data['info_addr_id'] && $this->so->data['info_from'] ==
|
|
|
|
$this->addr2name( $this->readAddr( $this->so->data['info_addr_id'] )))
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2001-09-26 19:10:03 +02:00
|
|
|
$this->so->data['info_from'] = '';
|
2001-10-07 22:11:32 +02:00
|
|
|
}
|
2001-09-26 19:10:03 +02:00
|
|
|
return $this->so->data;
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function delete($info_id)
|
|
|
|
{
|
2001-10-07 22:11:32 +02:00
|
|
|
$this->delete_attached($info_id);
|
|
|
|
|
|
|
|
$this->so->delete($info_id);
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function write($values)
|
|
|
|
{
|
|
|
|
if ($values['responsible'] && $values['status'] == 'offer')
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$values['status'] = 'ongoing'; // have to match if not finished
|
|
|
|
}
|
2001-07-15 00:16:16 +02:00
|
|
|
if (!$values['info_id'] && !$values['owner'])
|
|
|
|
{
|
2001-10-03 21:21:08 +02:00
|
|
|
$values['owner'] = $this->so->user;
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2002-05-12 09:14:01 +02:00
|
|
|
$values['datemodified'] = time();
|
2001-10-07 22:11:32 +02:00
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
if (!$values['subject'])
|
|
|
|
{
|
|
|
|
$values['subject'] = substr($values['des'],0,60).' ...';
|
2001-10-07 22:11:32 +02:00
|
|
|
}
|
2001-07-15 00:16:16 +02:00
|
|
|
if ($values['addr_id'] && !$values['from'])
|
|
|
|
{
|
2001-10-03 21:21:08 +02:00
|
|
|
$values['from'] = $this->addr2name( $this->readAddr( $values['addr_id'] ));
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
$this->so->write($values);
|
|
|
|
}
|
2001-10-07 22:11:32 +02:00
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function anzSubs( $info_id )
|
|
|
|
{
|
2001-07-14 23:44:01 +02:00
|
|
|
return $this->so->anzSubs( $info_id );
|
|
|
|
}
|
|
|
|
|
2002-05-01 19:16:27 +02:00
|
|
|
function readIdArray($order,$sort,$filter,$cat_id,$query,$action,$action_id,
|
|
|
|
$ordermethod,&$start,&$total)
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
|
|
|
return $this->so->readIdArray($order,$sort,$filter,$cat_id,$query,
|
2002-05-01 19:16:27 +02:00
|
|
|
$action,$action_id,$ordermethod,$start,$total);
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2001-10-07 22:11:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
function vfs_path($info_id,$file='')
|
|
|
|
{
|
|
|
|
return $this->vfs_basedir . '/' . $info_id . ($file ? '/' . $file : '');
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Put a file to the corrosponding place in the VFS and set the attributes
|
|
|
|
** ACL check is done by the VFS
|
|
|
|
*/
|
2001-10-08 13:39:20 +02:00
|
|
|
function attach_file($info_id,$filepos,$name,$size,$type,$comment='',$full_fname='',$ip='')
|
2001-10-07 22:11:32 +02:00
|
|
|
{
|
2001-10-08 13:39:20 +02:00
|
|
|
//echo "<p>attach_file: info_id='$info_id', filepos='$filepos', name='$name', size='$size', type='$type', comment='$comment', full_fname='$full_fname', ip='$ip'</p>\n";
|
2001-10-07 22:11:32 +02:00
|
|
|
|
|
|
|
// create the root for attached files in infolog, if it does not exists
|
|
|
|
if (!($this->vfs->file_exists($this->vfs_basedir,array(RELATIVE_ROOT))))
|
|
|
|
{
|
|
|
|
$this->vfs->override_acl = 1;
|
|
|
|
$this->vfs->mkdir($this->vfs_basedir,array(RELATIVE_ROOT));
|
|
|
|
$this->vfs->override_acl = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$dir=$this->vfs_path($info_id);
|
|
|
|
if (!($this->vfs->file_exists($dir,array(RELATIVE_ROOT))))
|
|
|
|
{
|
|
|
|
$this->vfs->override_acl = 1;
|
|
|
|
$this->vfs->mkdir($dir,array(RELATIVE_ROOT));
|
|
|
|
$this->vfs->override_acl = 0;
|
|
|
|
}
|
|
|
|
$fname = $this->vfs_path($info_id,$name);
|
|
|
|
$tfname = '';
|
|
|
|
if ($full_fname)
|
|
|
|
{
|
|
|
|
$full_fname = str_replace('\\\\','/',$full_fname); // vfs uses only '/'
|
2001-10-08 10:45:08 +02:00
|
|
|
@reset($this->link_pathes);
|
|
|
|
while ((list($valid,$trans) = @each($this->link_pathes)) && !$tfname)
|
2001-10-07 22:11:32 +02:00
|
|
|
{ // check case-insensitive for WIN etc.
|
|
|
|
$check = $valid[0] == '\\' || strstr(':',$valid) ? 'eregi' : 'ereg';
|
|
|
|
$valid2 = str_replace('\\','/',$valid);
|
2001-10-08 13:39:20 +02:00
|
|
|
//echo "<p>attach_file: ereg('".$this->send_file_ips[$valid]."', '$ip')=".ereg($this->send_file_ips[$valid],$ip)."</p>\n";
|
2001-10-07 22:11:32 +02:00
|
|
|
if ($check('^('.$valid2.')(.*)$',$full_fname,$parts) &&
|
|
|
|
ereg($this->send_file_ips[$valid],$ip) && // right IP
|
|
|
|
$this->vfs->file_exists($trans.$parts[2],array(RELATIVE_NONE|VFS_REAL)))
|
|
|
|
{
|
|
|
|
$tfname = $trans.$parts[2];
|
|
|
|
}
|
2001-10-08 13:39:20 +02:00
|
|
|
//echo "<p>attach_file: full_fname='$full_fname', valid2='$valid2', trans='$trans', check=$check, tfname='$tfname', parts=(x,'${parts[1]}','${parts[2]}')</p>\n";
|
2001-10-07 22:11:32 +02:00
|
|
|
}
|
|
|
|
if ($tfname && !$this->vfs->securitycheck($tfname))
|
|
|
|
{
|
|
|
|
return lang('Invalid filename').': '.$tfname;
|
|
|
|
}
|
|
|
|
}
|
2001-10-08 15:37:41 +02:00
|
|
|
$this->vfs->override_acl = 1;
|
2001-10-07 22:11:32 +02:00
|
|
|
if ($tfname) // file is local
|
|
|
|
{
|
|
|
|
$this->vfs->symlink($tfname,$fname,array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->vfs->cp($filepos,$fname,array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT));
|
|
|
|
}
|
|
|
|
$this->vfs->set_attributes ($fname, array (RELATIVE_ROOT),
|
|
|
|
array ('mime_type' => $type,
|
|
|
|
'comment' => stripslashes ($comment),
|
|
|
|
'app' => 'infolog'));
|
2001-10-08 15:37:41 +02:00
|
|
|
$this->vfs->override_acl = 0;
|
2001-10-07 22:11:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function delete_attached($info_id,$fname = '')
|
|
|
|
{
|
|
|
|
$file = $this->vfs_path($info_id,$fname);
|
|
|
|
|
|
|
|
if ($this->vfs->file_exists($file,array(RELATIVE_ROOT)))
|
|
|
|
{
|
|
|
|
$this->vfs->override_acl = 1;
|
|
|
|
$this->vfs->delete($file,array(RELATIVE_ROOT));
|
|
|
|
$this->vfs->override_acl = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function info_attached($info_id,$filename)
|
|
|
|
{
|
2001-10-08 15:37:41 +02:00
|
|
|
$this->vfs->override_acl = 1;
|
2001-10-07 22:11:32 +02:00
|
|
|
$attachments = $this->vfs->ls($this->vfs_path($info_id,$filename),array(REALTIVE_NONE));
|
2001-10-08 15:37:41 +02:00
|
|
|
$this->vfs->override_acl = 0;
|
2001-10-07 22:11:32 +02:00
|
|
|
|
|
|
|
if (!count($attachments) || !$attachments[0]['name'])
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
return $attachments[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
function list_attached($info_id)
|
|
|
|
{
|
2001-10-08 15:37:41 +02:00
|
|
|
$this->vfs->override_acl = 1;
|
2001-10-07 22:11:32 +02:00
|
|
|
$attachments = $this->vfs->ls($this->vfs_path($info_id),array(REALTIVE_NONE));
|
2001-10-08 15:37:41 +02:00
|
|
|
$this->vfs->override_acl = 0;
|
2001-10-07 22:11:32 +02:00
|
|
|
|
|
|
|
if (!count($attachments) || !$attachments[0]['name'])
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
while (list($keys,$fileinfo) = each($attachments))
|
|
|
|
{
|
|
|
|
$attached[$fileinfo['name']] = $fileinfo['comment'];
|
|
|
|
}
|
|
|
|
return $attached;
|
|
|
|
}
|
|
|
|
|
|
|
|
function is_win_path($path)
|
|
|
|
{
|
|
|
|
return $path[0] == '\\' || strstr($path,':');
|
|
|
|
}
|
|
|
|
|
|
|
|
function read_attached($info_id,$filename)
|
|
|
|
{
|
|
|
|
if (!$info_id || !$filename || !$this->check_access($info_id,PHPGW_ACL_READ))
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
2001-10-08 15:37:41 +02:00
|
|
|
$this->vfs->override_acl = 1;
|
2001-10-07 22:11:32 +02:00
|
|
|
return $this->vfs->read($this->vfs_path($info_id,$filename),array(RELATIVE_ROOT));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Checks if filename should be local availible and if so returns 'file:/path' for HTTP-redirect
|
|
|
|
* else return False
|
|
|
|
*/
|
|
|
|
function attached_local($info_id,$filename,$ip,$win_user)
|
|
|
|
{
|
|
|
|
//echo "<p>attached_local(info_id='$info_id', filename='$filename', ip='$ip', win_user='$win_user', count(send_file_ips)=".count($this->send_file_ips).")</p>\n";
|
|
|
|
|
|
|
|
if (!$info_id || !$filename || !$this->check_access($info_id,PHPGW_ACL_READ) ||
|
|
|
|
!count($this->send_file_ips))
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
$link = $this->vfs->readlink ($this->vfs_path($info_id,$filename), array (RELATIVE_ROOT));
|
|
|
|
|
|
|
|
if ($link)
|
|
|
|
{
|
|
|
|
reset($this->link_pathes); $fname = '';
|
|
|
|
while ((list($valid,$trans) = each($this->link_pathes)) && !$fname)
|
|
|
|
{
|
|
|
|
if (!$this->is_win_path($valid) == !$win_user && // valid for this OS
|
|
|
|
eregi('^'.$trans.'(.*)$',$link,$parts) && // right path
|
|
|
|
ereg($this->send_file_ips[$valid],$ip)) // right IP
|
|
|
|
{
|
|
|
|
$fname = $valid . $parts[1];
|
|
|
|
$fname = !$win_user ? str_replace('\\','/',$fname) : str_replace('/','\\',$fname);
|
|
|
|
return 'file:'.($win_user ? '//' : '' ).$fname;
|
|
|
|
}
|
|
|
|
// echo "<p>attached_local: link=$link, valid=$valid, trans='$trans', fname='$fname', parts=(x,'${parts[1]}','${parts[2]}')</p>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
2002-09-02 10:57:35 +02:00
|
|
|
/*!
|
2002-09-02 13:14:30 +02:00
|
|
|
@function link_title
|
|
|
|
@syntax link_title( $id )
|
|
|
|
@author ralfbecker
|
2002-09-02 10:57:35 +02:00
|
|
|
@abstract get title for an infolog entry identified by $id
|
|
|
|
*/
|
|
|
|
function link_title( $info )
|
|
|
|
{
|
|
|
|
if (!is_array($info))
|
|
|
|
{
|
2002-09-02 11:21:35 +02:00
|
|
|
$info = $this->read( $info );
|
2002-09-02 10:57:35 +02:00
|
|
|
}
|
|
|
|
return $info['info_subject'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2002-09-02 13:14:30 +02:00
|
|
|
@function link_query
|
|
|
|
@syntax link_query( $pattern )
|
|
|
|
@author ralfbecker
|
2002-09-02 10:57:35 +02:00
|
|
|
@abstract query infolog for entries matching $pattern
|
|
|
|
*/
|
2002-09-02 23:40:44 +02:00
|
|
|
function link_query( $pattern )
|
2002-09-02 10:57:35 +02:00
|
|
|
{
|
|
|
|
$start = $total = 0;
|
2002-09-02 11:21:35 +02:00
|
|
|
$ids = $this->readIdArray('','','','',$pattern,'','','',&$start,&$total);
|
2002-09-02 10:57:35 +02:00
|
|
|
$content = array();
|
|
|
|
while (is_array($ids) && list( $id,$parent ) = each( $ids ))
|
|
|
|
{
|
|
|
|
$content[$id] = $this->link_title($id);
|
|
|
|
}
|
|
|
|
return $content;
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|