2001-07-12 01:17:32 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
2004-08-09 13:43:57 +02:00
|
|
|
* eGroupWare - InfoLog *
|
|
|
|
* http://www.egroupware.org *
|
2005-11-12 14:25:59 +01:00
|
|
|
* Written and (c) by Ralf Becker <RalfBecker@outdoor-training.de> *
|
2001-07-12 01:17:32 +02:00
|
|
|
* 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$ */
|
2005-04-06 13:05:57 +02:00
|
|
|
|
|
|
|
include_once(EGW_INCLUDE_ROOT.'/infolog/inc/class.soinfolog.inc.php');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class is the BO-layer of InfoLog, it also handles xmlrpc requests
|
|
|
|
*
|
|
|
|
* @package infolog
|
2005-11-12 14:25:59 +01:00
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
* @copyright (c) by Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2005-04-06 13:05:57 +02:00
|
|
|
*/
|
2005-11-12 14:25:59 +01:00
|
|
|
class boinfolog
|
2001-07-12 01:17:32 +02:00
|
|
|
{
|
|
|
|
var $enums;
|
|
|
|
var $so;
|
2005-04-08 20:51:59 +02:00
|
|
|
var $link;
|
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
|
|
|
|
2004-03-10 01:58:18 +01:00
|
|
|
var $xmlrpc_methods = array();
|
|
|
|
var $soap_functions = array(
|
|
|
|
'read' => array(
|
|
|
|
'in' => array('int'),
|
|
|
|
'out' => array('array')
|
|
|
|
),
|
|
|
|
'search' => array(
|
|
|
|
'in' => array('array'),
|
|
|
|
'out' => array('array')
|
|
|
|
),
|
|
|
|
'write' => array(
|
|
|
|
'in' => array('array'),
|
|
|
|
'out' => array()
|
|
|
|
),
|
|
|
|
'delete' => array(
|
|
|
|
'in' => array('int'),
|
|
|
|
'out' => array()
|
|
|
|
),
|
|
|
|
'categories' => array(
|
|
|
|
'in' => array('bool'),
|
|
|
|
'out' => array('array')
|
|
|
|
),
|
|
|
|
);
|
2004-03-13 18:58:37 +01:00
|
|
|
var $xmlrpc = False; // called via xmlrpc
|
2004-03-10 01:58:18 +01:00
|
|
|
|
2006-03-17 21:53:26 +01:00
|
|
|
var $tz_offset = 0;
|
2004-08-28 20:02:16 +02:00
|
|
|
/**
|
|
|
|
* @var int $tz_offset_s offset in secconds between user and server-time,
|
|
|
|
* it need to be add to a server-time to get the user-time or substracted from a user-time to get the server-time
|
|
|
|
*/
|
|
|
|
var $tz_offset_s = 0;
|
|
|
|
var $user_time_now;
|
2006-03-17 21:53:26 +01:00
|
|
|
/**
|
|
|
|
* @var array $timestamps name of timestamps in an InfoLog entry
|
|
|
|
*/
|
|
|
|
var $timestamps = array('info_startdate','info_enddate','info_datemodified','info_datecompleted');
|
2005-07-14 19:12:50 +02:00
|
|
|
/**
|
|
|
|
* @var array $config infolog configuration
|
|
|
|
*/
|
|
|
|
var $config;
|
2006-03-24 17:10:09 +01:00
|
|
|
/**
|
|
|
|
* @var array $responsible_edit=array('info_status','info_percent','info_datecompleted') fields the responsible user can change
|
|
|
|
*/
|
|
|
|
var $responsible_edit=array('info_status','info_percent','info_datecompleted');
|
|
|
|
/**
|
|
|
|
* @var string $implicit_rights='read' implicit ACL rights of the responsible user: read or edit
|
|
|
|
*/
|
|
|
|
var $implicit_rights='read';
|
2004-08-28 20:02:16 +02:00
|
|
|
|
2005-11-12 14:25:59 +01:00
|
|
|
/**
|
|
|
|
* Constructor Infolog BO
|
|
|
|
*
|
|
|
|
* @param int $info_id
|
|
|
|
* @param boolean $instanciate_link=true should the link class be instanciated, used by the link-registry to prevent infinit recursion
|
|
|
|
*/
|
|
|
|
function boinfolog($info_id = 0,$instanciate_link=true)
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
$this->enums = $this->stock_enums = array(
|
2001-07-12 01:17:32 +02:00
|
|
|
'priority' => array (
|
2005-07-14 19:12:50 +02:00
|
|
|
3 => 'urgent',
|
|
|
|
2 => 'high',
|
|
|
|
1 => 'normal',
|
|
|
|
0 => 'low'
|
|
|
|
),
|
2002-10-18 00:02:44 +02:00
|
|
|
/* 'status' => array(
|
2001-07-12 01:17:32 +02:00
|
|
|
'offer' => 'offer','ongoing' => 'ongoing','call' => 'call',
|
|
|
|
'will-call' => 'will-call','done' => 'done',
|
|
|
|
'billed' => 'billed' ),
|
2002-10-18 00:02:44 +02:00
|
|
|
*/ 'confirm' => array(
|
2001-07-12 01:17:32 +02:00
|
|
|
'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',
|
2002-10-18 00:02:44 +02:00
|
|
|
'fax' => 'fax' not implemented so far */ )
|
2001-07-12 01:17:32 +02:00
|
|
|
);
|
2003-08-28 16:31:11 +02:00
|
|
|
$this->status = $this->stock_status = array(
|
2001-07-19 03:28:16 +02:00
|
|
|
'defaults' => array(
|
2006-03-20 20:43:33 +01:00
|
|
|
'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done'),
|
2001-07-19 03:28:16 +02:00
|
|
|
'task' => array(
|
2006-03-17 21:53:26 +01:00
|
|
|
'offer' => 'offer', // --> NEEDS-ACTION
|
|
|
|
'not-started' => 'not-started', // iCal NEEDS-ACTION
|
|
|
|
'ongoing' => 'ongoing', // iCal IN-PROCESS
|
|
|
|
'done' => 'done', // iCal COMPLETED
|
|
|
|
'cancelled' => 'cancelled', // iCal CANCELLED
|
|
|
|
'billed' => 'billed' ), // --> DONE
|
2001-07-19 03:28:16 +02:00
|
|
|
'phone' => array(
|
2006-03-20 20:43:33 +01:00
|
|
|
'not-started' => 'call', // iCal NEEDS-ACTION
|
|
|
|
'ongoing' => 'will-call', // iCal IN-PROCESS
|
2006-03-17 21:53:26 +01:00
|
|
|
'done' => 'done', // iCal COMPLETED
|
|
|
|
'billed' => 'billed' ), // --> DONE
|
2001-07-19 03:28:16 +02:00
|
|
|
'note' => array(
|
2006-03-17 21:53:26 +01:00
|
|
|
'ongoing' => 'ongoing', // iCal has no status on notes
|
|
|
|
'done' => 'done'
|
2001-07-19 03:28:16 +02:00
|
|
|
));
|
2001-10-03 21:21:08 +02:00
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
$this->so =& new soinfolog();
|
2005-11-12 14:25:59 +01:00
|
|
|
|
|
|
|
if (!is_object($GLOBALS['egw']->link) && $instanciate_link)
|
|
|
|
{
|
|
|
|
$GLOBALS['egw']->link =& CreateObject('phpgwapi.bolink');
|
|
|
|
}
|
|
|
|
$this->link =& $GLOBALS['egw']->link;
|
2001-10-07 22:11:32 +02:00
|
|
|
|
2006-03-17 21:53:26 +01:00
|
|
|
$this->config =& CreateObject('phpgwapi.config','infolog');
|
2001-10-07 22:11:32 +02:00
|
|
|
$this->config->read_repository();
|
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
$this->customfields = array();
|
2001-10-07 22:11:32 +02:00
|
|
|
if ($this->config->config_data)
|
|
|
|
{
|
2002-11-05 17:00:01 +01:00
|
|
|
$this->link_pathes = $this->config->config_data['link_pathes'];
|
|
|
|
$this->send_file_ips = $this->config->config_data['send_file_ips'];
|
2003-08-28 16:31:11 +02:00
|
|
|
|
|
|
|
if (isset($this->config->config_data['status']) && is_array($this->config->config_data['status']))
|
|
|
|
{
|
|
|
|
foreach($this->config->config_data['status'] as $key => $data)
|
|
|
|
{
|
|
|
|
if (!is_array($this->status[$key]))
|
|
|
|
{
|
|
|
|
$this->status[$key] = array();
|
|
|
|
}
|
2005-02-14 11:39:10 +01:00
|
|
|
$this->status[$key] = array_merge($this->status[$key],$this->config->config_data['status'][$key]);
|
2003-08-28 16:31:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($this->config->config_data['types']) && is_array($this->config->config_data['types']))
|
|
|
|
{
|
|
|
|
//echo "stock-types:<pre>"; print_r($this->enums['type']); echo "</pre>\n";
|
|
|
|
//echo "config-types:<pre>"; print_r($this->config->config_data['types']); echo "</pre>\n";
|
|
|
|
$this->enums['type'] += $this->config->config_data['types'];
|
|
|
|
//echo "types:<pre>"; print_r($this->enums['type']); echo "</pre>\n";
|
|
|
|
}
|
|
|
|
if (isset($this->config->config_data['customfields']) && is_array($this->config->config_data['customfields']))
|
|
|
|
{
|
|
|
|
$this->customfields = $this->config->config_data['customfields'];
|
|
|
|
}
|
2006-03-24 17:10:09 +01:00
|
|
|
if (count(explode(',',$this->config->config_data['responsible_edit'])))
|
|
|
|
{
|
|
|
|
$this->responsible_edit = array_merge($this->responsible_edit,explode(',',$this->config->config_data['responsible_edit']));
|
|
|
|
}
|
|
|
|
if ($this->config->config_data['implicit_rights'] == 'edit')
|
|
|
|
{
|
|
|
|
$this->implicit_rights = 'edit';
|
|
|
|
}
|
2001-10-07 22:11:32 +02:00
|
|
|
}
|
2006-03-24 17:10:09 +01:00
|
|
|
$this->user = $GLOBALS['egw_info']['user']['account_id'];
|
2004-08-28 20:02:16 +02:00
|
|
|
/**
|
|
|
|
* @var int $tz_offset_s offset in secconds between user and server-time,
|
|
|
|
* it need to be add to a server-time to get the user-time or substracted from a user-time to get the server-time
|
|
|
|
*/
|
2005-04-06 13:05:57 +02:00
|
|
|
$this->tz_offset = $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
|
2004-08-28 20:02:16 +02:00
|
|
|
$this->tz_offset_s = 60*60*$this->tz_offset;
|
|
|
|
$this->user_time_now = time() + $this->tz_offset_s;
|
2001-07-12 01:17:32 +02:00
|
|
|
|
2004-03-10 01:58:18 +01:00
|
|
|
// are we called via xmlrpc?
|
|
|
|
$this->xmlrpc = is_object($GLOBALS['server']) && $GLOBALS['server']->last_method;
|
|
|
|
|
2004-03-13 18:58:37 +01:00
|
|
|
if ($info_id)
|
|
|
|
{
|
|
|
|
$this->read( $info_id );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->init();
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2001-10-03 21:21:08 +02:00
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* checks if there are customfields for typ $typ
|
|
|
|
*
|
|
|
|
* @param string $typ
|
|
|
|
* @return boolean True if there are customfields for $typ, else False
|
|
|
|
*/
|
2003-08-28 16:31:11 +02:00
|
|
|
function has_customfields($typ)
|
|
|
|
{
|
|
|
|
foreach($this->customfields as $name => $field)
|
|
|
|
{
|
|
|
|
if (empty($field['typ']) || $field['typ'] == $typ)
|
|
|
|
{
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
2002-10-18 00:02:44 +02:00
|
|
|
* check's if user has the requiered rights on entry $info_id
|
2005-04-06 13:05:57 +02:00
|
|
|
*
|
2005-11-12 14:25:59 +01:00
|
|
|
* @param int/array $info data or info_id of infolog entry to check
|
2005-04-06 13:05:57 +02:00
|
|
|
* @param int $required_rights EGW_ACL_{READ|EDIT|ADD|DELETE}
|
|
|
|
* @return boolean
|
2002-10-18 00:02:44 +02:00
|
|
|
*/
|
2005-11-12 14:25:59 +01:00
|
|
|
function check_access( $info,$required_rights )
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2005-10-05 09:50:47 +02:00
|
|
|
static $cache = array();
|
|
|
|
|
2005-11-12 14:25:59 +01:00
|
|
|
$info_id = is_array($info) ? $info['info_id'] : $info;
|
|
|
|
|
2005-10-05 09:50:47 +02:00
|
|
|
if (isset($cache[$info_id][$required_rights]))
|
|
|
|
{
|
|
|
|
return $cache[$info_id][$required_rights];
|
|
|
|
}
|
2006-03-24 17:10:09 +01:00
|
|
|
return $cache[$info_id][$required_rights] = $this->so->check_access( $info,$required_rights,$this->implicit_rights == 'edit' );
|
2002-02-14 21:14:15 +01:00
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* init internal data to be empty
|
|
|
|
*/
|
2002-10-18 00:02:44 +02:00
|
|
|
function init()
|
2002-05-12 09:14:01 +02:00
|
|
|
{
|
2002-10-18 00:02:44 +02:00
|
|
|
$this->so->init();
|
2002-05-12 09:14:01 +02:00
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* convert a link_id value into an info_from text
|
|
|
|
*
|
|
|
|
* @param array &$info infolog entry, key info_from gets set by this function
|
|
|
|
* @param string $not_app='' app to exclude
|
|
|
|
* @param string $not_id='' id to exclude
|
|
|
|
* @return boolean True if we have a linked item, False otherwise
|
|
|
|
*/
|
2003-03-20 18:22:53 +01:00
|
|
|
function link_id2from(&$info,$not_app='',$not_id='')
|
2002-05-12 09:14:01 +02:00
|
|
|
{
|
2006-03-17 12:36:27 +01:00
|
|
|
//echo "<p>boinfolog::link_id2from(subject='$info[info_subject]', link_id='$info[info_link_id]', from='$info[info_from]', not_app='$not_app', not_id='$not_id')";
|
2002-10-18 00:02:44 +02:00
|
|
|
if ($info['info_link_id'] > 0 &&
|
|
|
|
($link = $this->link->get_link($info['info_link_id'])) !== False)
|
2002-05-12 09:14:01 +02:00
|
|
|
{
|
2002-10-18 00:02:44 +02:00
|
|
|
$nr = $link['link_app1'] == 'infolog' && $link['link_id1'] == $info['info_id'] ? '2' : '1';
|
|
|
|
$title = $this->link->title($link['link_app'.$nr],$link['link_id'.$nr]);
|
2003-08-28 16:31:11 +02:00
|
|
|
|
2004-08-01 21:28:03 +02:00
|
|
|
if ($title == $info['info_from'] || @htmlentities($title) == $info['info_from'])
|
2003-06-29 19:03:47 +02:00
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
$info['info_from'] = '';
|
2003-06-29 19:03:47 +02:00
|
|
|
}
|
2002-10-18 00:02:44 +02:00
|
|
|
if ($link['link_app'.$nr] == $not_app && $link['link_id'.$nr] == $not_id)
|
2002-05-12 09:14:01 +02:00
|
|
|
{
|
2002-10-18 00:02:44 +02:00
|
|
|
return False;
|
2002-05-12 09:14:01 +02:00
|
|
|
}
|
2005-11-12 14:25:59 +01:00
|
|
|
$info['info_link'] = array(
|
|
|
|
'app' => $link['link_app'.$nr],
|
|
|
|
'id' => $link['link_id'.$nr],
|
|
|
|
'title' => (!empty($info['info_from']) ? $info['info_from'] : $title),
|
|
|
|
);
|
2003-08-28 16:31:11 +02:00
|
|
|
|
2003-03-20 18:22:53 +01:00
|
|
|
//echo " title='$title'</p>\n";
|
2003-08-28 16:31:11 +02:00
|
|
|
return $info['blur_title'] = $title;
|
2002-05-12 09:14:01 +02:00
|
|
|
}
|
2003-07-06 11:01:13 +02:00
|
|
|
else
|
|
|
|
{
|
2005-11-12 14:25:59 +01:00
|
|
|
$info['info_link'] = array('title' => $info['info_from']);
|
2003-08-28 16:31:11 +02:00
|
|
|
$info['info_link_id'] = 0; // link might have been deleted
|
2003-07-06 11:01:13 +02:00
|
|
|
}
|
2002-05-12 09:14:01 +02:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* Create a subject from a description: truncate it and add ' ...'
|
|
|
|
*/
|
2003-11-23 14:33:21 +01:00
|
|
|
function subject_from_des($des)
|
|
|
|
{
|
|
|
|
return substr($des,0,60).' ...';
|
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* Read an infolog entry specified by $info_id
|
|
|
|
*
|
|
|
|
* @param int/array $info_id integer id or array with key 'info_id' of the entry to read
|
2006-03-17 12:36:27 +01:00
|
|
|
* @param boolean $run_link_id2from=true should link_id2from run, default yes,
|
|
|
|
* need to be set to false if called from link-title to prevent an infinit recursion
|
2006-06-24 18:04:35 +02:00
|
|
|
* @return array/boolean infolog entry, null if not found or false if no permission to read it
|
2005-04-06 13:05:57 +02:00
|
|
|
*/
|
2006-03-17 12:36:27 +01:00
|
|
|
function &read($info_id,$run_link_id2from=true)
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2004-03-10 01:58:18 +01:00
|
|
|
if (is_array($info_id))
|
|
|
|
{
|
2006-03-02 09:21:25 +01:00
|
|
|
$info_id = (int) (isset($info_id['info_id']) ? $info_id['info_id'] : $info_id[0]);
|
2004-03-10 01:58:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->so->read($info_id) === False)
|
|
|
|
{
|
|
|
|
if ($this->xmlrpc)
|
|
|
|
{
|
|
|
|
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
|
|
|
|
}
|
2006-06-24 18:04:35 +02:00
|
|
|
return null;
|
2004-03-10 01:58:18 +01:00
|
|
|
}
|
2005-04-06 13:05:57 +02:00
|
|
|
if (!$this->check_access($info_id,EGW_ACL_READ)) // check behind read, to prevent a double read
|
2004-03-10 01:58:18 +01:00
|
|
|
{
|
|
|
|
if ($this->xmlrpc)
|
|
|
|
{
|
|
|
|
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
2004-08-28 20:02:16 +02:00
|
|
|
$data = $this->so->data;
|
2002-10-18 00:02:44 +02:00
|
|
|
|
2003-11-23 14:33:21 +01:00
|
|
|
if ($data['info_subject'] == $this->subject_from_des($data['info_des']))
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2002-10-18 00:02:44 +02:00
|
|
|
$data['info_subject'] = '';
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2006-03-17 12:36:27 +01:00
|
|
|
if ($run_link_id2from) $this->link_id2from($data);
|
2004-08-28 21:02:26 +02:00
|
|
|
|
2004-08-28 20:02:16 +02:00
|
|
|
// convert system- to user-time
|
2006-03-17 21:53:26 +01:00
|
|
|
foreach($this->timestamps as $time)
|
2004-08-28 20:02:16 +02:00
|
|
|
{
|
|
|
|
if ($data[$time]) $data[$time] += $this->tz_offset_s;
|
|
|
|
}
|
2004-03-10 01:58:18 +01:00
|
|
|
if ($this->xmlrpc)
|
|
|
|
{
|
|
|
|
$data = $this->data2xmlrpc($data);
|
|
|
|
}
|
|
|
|
return $data;
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* Delete an infolog entry, evtl. incl. it's children / subs
|
|
|
|
*
|
|
|
|
* @param int/array $info_id int id or array with keys 'info_id', 'delete_children' and 'new_parent' setting all 3 params
|
|
|
|
* @param boolean $delete_children should the children be deleted
|
|
|
|
* @param int/boolean $new_parent parent to use for not deleted children if > 0
|
|
|
|
* @return boolean True if delete was successful, False otherwise ($info_id does not exist or no rights)
|
|
|
|
*/
|
2004-03-10 01:58:18 +01:00
|
|
|
function delete($info_id,$delete_children=False,$new_parent=False)
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2004-03-10 01:58:18 +01:00
|
|
|
if (is_array($info_id))
|
|
|
|
{
|
|
|
|
$delete_children = $info_id['delete_children'];
|
|
|
|
$new_parent = $info_id['new_parent'];
|
2004-03-13 18:58:37 +01:00
|
|
|
$info_id = (int)(isset($info_id[0]) ? $info_id[0] : (isset($info_id['info_id']) ? $info_id['info_id'] : $info_id['info_id']));
|
|
|
|
}
|
|
|
|
if ($this->so->read($info_id) === False)
|
|
|
|
{
|
|
|
|
if ($this->xmlrpc)
|
|
|
|
{
|
|
|
|
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
|
|
|
|
}
|
|
|
|
return False;
|
2004-03-10 01:58:18 +01:00
|
|
|
}
|
2005-04-06 13:05:57 +02:00
|
|
|
if (!$this->check_access($info_id,EGW_ACL_DELETE))
|
2004-03-10 01:58:18 +01:00
|
|
|
{
|
|
|
|
if ($this->xmlrpc)
|
|
|
|
{
|
|
|
|
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2002-10-18 00:02:44 +02:00
|
|
|
$this->link->unlink(0,'infolog',$info_id);
|
2001-10-07 22:11:32 +02:00
|
|
|
|
2005-02-28 00:33:14 +01:00
|
|
|
$info = $this->read($info_id);
|
|
|
|
|
2003-12-19 03:26:17 +01:00
|
|
|
$this->so->delete($info_id,$delete_children,$new_parent);
|
2005-02-28 00:33:14 +01:00
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
$GLOBALS['egw']->contenthistory->updateTimeStamp('infolog_'.$info['info_type'], $info_id, 'delete', time());
|
|
|
|
|
|
|
|
return True;
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2005-02-07 08:09:33 +01:00
|
|
|
/**
|
|
|
|
* writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0
|
|
|
|
*
|
|
|
|
* checks and asures ACL
|
|
|
|
*
|
2005-11-12 14:25:59 +01:00
|
|
|
* @param array &$values values to write, if contains values for check_defaults and touch_modified,
|
|
|
|
* they have precedens over the parameters. The
|
2005-02-07 08:09:33 +01:00
|
|
|
* @param boolean $check_defaults=true check and set certain defaults
|
|
|
|
* @param boolean $touch_modified=true touch the modification data and sets the modiefier's user-id
|
|
|
|
* @return int/boolean info_id on a successfull write or false
|
|
|
|
*/
|
2005-11-12 14:25:59 +01:00
|
|
|
function write(&$values,$check_defaults=True,$touch_modified=True)
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2005-10-05 09:50:47 +02:00
|
|
|
//echo "boinfolog::write()values="; _debug_array($values);
|
2005-02-07 08:09:33 +01:00
|
|
|
// allow to (un)set check_defaults and touch_modified via values, eg. via xmlrpc
|
|
|
|
foreach(array('check_defaults','touch_modified') as $var)
|
|
|
|
{
|
|
|
|
if(isset($values[$var]))
|
|
|
|
{
|
|
|
|
$$var = $values[$var];
|
|
|
|
unset($values[$var]);
|
|
|
|
}
|
|
|
|
}
|
2005-10-05 09:50:47 +02:00
|
|
|
if ($status_only = $values['info_id'] && !$this->check_access($values['info_id'],EGW_ACL_EDIT))
|
|
|
|
{
|
|
|
|
if (!isset($values['info_responsible']))
|
|
|
|
{
|
|
|
|
if (!($values_read = $this->read($values['info_id']))) return false;
|
|
|
|
$responsible =& $values_read['info_responsible'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$responsible =& $values['info_responsible'];
|
|
|
|
}
|
|
|
|
$status_only = in_array($this->user, $responsible); // responsible has implicit right to change status
|
|
|
|
}
|
2005-04-06 13:05:57 +02:00
|
|
|
if ($values['info_id'] && !$this->check_access($values['info_id'],EGW_ACL_EDIT) && !$status_only ||
|
|
|
|
!$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],EGW_ACL_ADD))
|
2004-03-10 01:58:18 +01:00
|
|
|
{
|
|
|
|
if ($this->xmlrpc)
|
|
|
|
{
|
|
|
|
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
if ($this->xmlrpc)
|
|
|
|
{
|
|
|
|
$values = $this->xmlrpc2data($values);
|
|
|
|
}
|
2004-07-08 15:26:06 +02:00
|
|
|
if ($status_only) // make sure only status gets writen
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2006-03-17 21:53:26 +01:00
|
|
|
$set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set
|
|
|
|
(in_array($values['info_status'],array('done','billed','cancelled')) || (int)$values['info_percent'] == 100);
|
2004-07-08 15:26:06 +02:00
|
|
|
|
2005-11-12 14:25:59 +01:00
|
|
|
$backup_values = $values; // to return the full values
|
2004-07-08 15:26:06 +02:00
|
|
|
$values = array(
|
2005-11-12 14:25:59 +01:00
|
|
|
'info_id' => $values['info_id'],
|
|
|
|
'info_datemodified' => $values['info_datemodified'],
|
2004-07-08 15:26:06 +02:00
|
|
|
);
|
2006-03-24 17:10:09 +01:00
|
|
|
foreach($this->responsible_edit as $name)
|
|
|
|
{
|
|
|
|
if (isset($backup_values[$name])) $values[$name] = $backup_values[$name];
|
|
|
|
}
|
2006-03-17 21:53:26 +01:00
|
|
|
if ($set_completed)
|
2002-10-08 02:10:18 +02:00
|
|
|
{
|
2006-03-17 21:53:26 +01:00
|
|
|
$values['info_datecompleted'] = $this->user_time_now;
|
|
|
|
$values['info_percent'] = '100%';
|
|
|
|
if (!in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = 'done';
|
2002-10-08 02:10:18 +02:00
|
|
|
}
|
2004-07-08 15:26:06 +02:00
|
|
|
$check_defaults = False;
|
2002-10-08 02:10:18 +02:00
|
|
|
}
|
2002-10-18 22:20:35 +02:00
|
|
|
if ($check_defaults)
|
2002-10-08 02:10:18 +02:00
|
|
|
{
|
2006-03-17 21:53:26 +01:00
|
|
|
if (!$values['info_datecompleted'] &&
|
|
|
|
(in_array($values['info_status'],array('done','billed')) || (int)$values['info_percent'] == 100))
|
2003-06-29 19:03:47 +02:00
|
|
|
{
|
2006-03-17 21:53:26 +01:00
|
|
|
$values['info_datecompleted'] = $this->user_time_now; // set date completed to today if status == done
|
|
|
|
}
|
|
|
|
if (in_array($values['info_status'],array('done','billed')))
|
|
|
|
{
|
|
|
|
$values['info_percent'] == '100%';
|
|
|
|
}
|
|
|
|
if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'],array('done','billed','cancelled')))
|
|
|
|
{
|
|
|
|
$values['info_status'] = 'done';
|
2003-06-29 19:03:47 +02:00
|
|
|
}
|
2005-10-05 09:50:47 +02:00
|
|
|
if (count($values['info_responsible']) && $values['info_status'] == 'offer')
|
2002-10-18 22:20:35 +02:00
|
|
|
{
|
2006-03-17 21:53:26 +01:00
|
|
|
$values['info_status'] = 'not-started'; // have to match if not finished
|
2002-10-18 22:20:35 +02:00
|
|
|
}
|
2004-02-05 14:37:29 +01:00
|
|
|
if (isset($values['info_subject']) && empty($values['info_subject']))
|
2002-10-18 22:20:35 +02:00
|
|
|
{
|
2003-11-23 14:33:21 +01:00
|
|
|
$values['info_subject'] = $this->subject_from_des($values['info_des']);
|
2002-10-18 22:20:35 +02:00
|
|
|
}
|
2003-07-06 10:54:13 +02:00
|
|
|
}
|
2005-02-07 08:09:33 +01:00
|
|
|
if (!$values['info_id'] && !$values['info_owner'])
|
|
|
|
{
|
|
|
|
$values['info_owner'] = $this->so->user;
|
|
|
|
}
|
2006-02-04 08:49:47 +01:00
|
|
|
if ($info_from_set = ($values['info_link_id'] && isset($values['info_from']) && empty($values['info_from'])))
|
2003-07-06 10:54:13 +02:00
|
|
|
{
|
|
|
|
$values['info_from'] = $this->link_id2from($values);
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
2003-10-08 01:58:48 +02:00
|
|
|
if ($touch_modified || !$values['info_datemodified'])
|
|
|
|
{
|
2006-01-16 09:30:36 +01:00
|
|
|
// Should only an entry be updated which includes the original modification date?
|
|
|
|
// Used in the web-GUI to check against a modification by an other user while editing the entry.
|
|
|
|
// It's now disabled for xmlrpc, as otherwise the xmlrpc code need to be changed!
|
|
|
|
$check_modified = $values['info_datemodified'] && !$this->xmlrpc ? $values['info_datemodified']-$this->tz_offset_s : false;
|
2004-08-28 20:02:16 +02:00
|
|
|
$values['info_datemodified'] = $this->user_time_now;
|
2003-10-08 01:58:48 +02:00
|
|
|
}
|
|
|
|
if ($touch_modified || !$values['info_modifier'])
|
|
|
|
{
|
|
|
|
$values['info_modifier'] = $this->so->user;
|
|
|
|
}
|
2005-11-12 14:25:59 +01:00
|
|
|
$to_write = $values;
|
|
|
|
if ($status_only) $values = array_merge($backup_values,$values);
|
2004-08-28 20:02:16 +02:00
|
|
|
// convert user- to system-time
|
2006-03-17 21:53:26 +01:00
|
|
|
foreach($this->timestamps as $time)
|
2004-08-28 20:02:16 +02:00
|
|
|
{
|
2005-11-12 14:25:59 +01:00
|
|
|
if ($to_write[$time]) $to_write[$time] -= $this->tz_offset_s;
|
2004-08-28 20:02:16 +02:00
|
|
|
}
|
2005-11-12 14:25:59 +01:00
|
|
|
if(($info_id = $this->so->write($to_write,$check_modified)))
|
2005-02-28 00:33:14 +01:00
|
|
|
{
|
2005-04-08 20:51:59 +02:00
|
|
|
if (!isset($values['info_type']) || $status_only)
|
|
|
|
{
|
|
|
|
$values = $this->read($info_id);
|
|
|
|
}
|
2005-02-28 00:33:14 +01:00
|
|
|
if($values['info_id'])
|
|
|
|
{
|
|
|
|
// update
|
2005-04-06 13:05:57 +02:00
|
|
|
$GLOBALS['egw']->contenthistory->updateTimeStamp(
|
2005-02-28 00:33:14 +01:00
|
|
|
'infolog_'.$values['info_type'],
|
2005-04-08 20:51:59 +02:00
|
|
|
$info_id, 'modify', time()
|
2005-02-28 00:33:14 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// add
|
2005-04-06 13:05:57 +02:00
|
|
|
$GLOBALS['egw']->contenthistory->updateTimeStamp(
|
2005-02-28 00:33:14 +01:00
|
|
|
'infolog_'.$values['info_type'],
|
2005-04-08 20:51:59 +02:00
|
|
|
$info_id, 'add', time()
|
2005-02-28 00:33:14 +01:00
|
|
|
);
|
|
|
|
}
|
2005-11-12 14:25:59 +01:00
|
|
|
$values['info_id'] = $info_id;
|
|
|
|
|
2005-04-08 20:51:59 +02:00
|
|
|
// notify the link-class about the update, as other apps may be subscribt to it
|
|
|
|
$this->link->notify_update('infolog',$info_id,$values);
|
2005-02-28 00:33:14 +01:00
|
|
|
}
|
2006-02-04 08:49:47 +01:00
|
|
|
if ($info_from_set) $values['info_from'] = '';
|
|
|
|
|
2005-04-08 20:51:59 +02:00
|
|
|
return $info_id;
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2001-10-07 22:11:32 +02:00
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* Query the number of children / subs
|
|
|
|
*
|
|
|
|
* @param int $info_id id
|
|
|
|
* @return int number of subs
|
|
|
|
*/
|
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 );
|
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* searches InfoLog for a certain pattern in $query
|
|
|
|
*
|
|
|
|
* @param $query[order] column-name to sort after
|
|
|
|
* @param $query[sort] sort-order DESC or ASC
|
|
|
|
* @param $query[filter] string with combination of acl-, date- and status-filters, eg. 'own-open-today' or ''
|
|
|
|
* @param $query[cat_id] category to use or 0 or unset
|
|
|
|
* @param $query[search] pattern to search, search is done in info_from, info_subject and info_des
|
|
|
|
* @param $query[action] / $query[action_id] if only entries linked to a specified app/entry show be used
|
|
|
|
* @param &$query[start], &$query[total] nextmatch-parameters will be used and set if query returns less entries
|
|
|
|
* @param $query[col_filter] array with column-name - data pairs, data == '' means no filter (!)
|
|
|
|
* @return array with id's as key of the matching log-entries
|
|
|
|
*/
|
2004-08-28 20:02:16 +02:00
|
|
|
function &search(&$query)
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2004-03-13 18:58:37 +01:00
|
|
|
//echo "<p>boinfolog::search(".print_r($query,True).")</p>\n";
|
2004-03-10 01:58:18 +01:00
|
|
|
$ret = $this->so->search($query);
|
2004-08-28 20:02:16 +02:00
|
|
|
|
|
|
|
// convert system- to user-time
|
|
|
|
if (is_array($ret) && $this->tz_offset_s)
|
|
|
|
{
|
|
|
|
foreach($ret as $id => $data)
|
|
|
|
{
|
2006-03-17 21:53:26 +01:00
|
|
|
foreach($this->timestamps as $time)
|
2004-08-28 20:02:16 +02:00
|
|
|
{
|
|
|
|
if ($data[$time]) $ret[$id][$time] += $this->tz_offset_s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-10 01:58:18 +01:00
|
|
|
if ($this->xmlrpc && is_array($ret))
|
|
|
|
{
|
2006-03-17 21:53:26 +01:00
|
|
|
$infos =& $ret;
|
|
|
|
unset($ret);
|
2004-03-13 18:58:37 +01:00
|
|
|
$ret = array();
|
|
|
|
foreach($infos as $id => $data)
|
2004-03-10 01:58:18 +01:00
|
|
|
{
|
2004-03-13 18:58:37 +01:00
|
|
|
$ret[] = $this->data2xmlrpc($data);
|
2004-03-10 01:58:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//echo "<p>boinfolog::search(".print_r($query,True).")=<pre>".print_r($ret,True)."</pre>\n";
|
|
|
|
return $ret;
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2001-10-07 22:11:32 +02:00
|
|
|
|
2005-11-12 14:25:59 +01:00
|
|
|
/**
|
|
|
|
* Hook called by link-class to include infolog in the appregistry of the linkage
|
|
|
|
*
|
|
|
|
* @param array/string $location location and other parameters (not used)
|
|
|
|
* @return array with method-names
|
|
|
|
*/
|
|
|
|
function search_link($location)
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'query' => 'infolog.boinfolog.link_query',
|
|
|
|
'title' => 'infolog.boinfolog.link_title',
|
|
|
|
'view' => array(
|
|
|
|
'menuaction' => 'infolog.uiinfolog.index',
|
|
|
|
'action' => 'sp'
|
|
|
|
),
|
|
|
|
'view_id' => 'action_id',
|
|
|
|
'add' => array(
|
|
|
|
'menuaction' => 'infolog.uiinfolog.edit',
|
|
|
|
'type' => 'task'
|
|
|
|
),
|
|
|
|
'add_app' => 'action',
|
|
|
|
'add_id' => 'action_id',
|
|
|
|
'add_popup' => '750x550',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* get title for an infolog entry identified by $info
|
|
|
|
*
|
|
|
|
* Is called as hook to participate in the linking
|
|
|
|
*
|
|
|
|
* @param int/array $info int info_id or array with infolog entry
|
2006-06-24 18:04:35 +02:00
|
|
|
* @return string/boolean string with the title, null if $info not found, false if no perms to view
|
2005-04-06 13:05:57 +02:00
|
|
|
*/
|
2002-09-02 10:57:35 +02:00
|
|
|
function link_title( $info )
|
|
|
|
{
|
|
|
|
if (!is_array($info))
|
|
|
|
{
|
2006-03-17 12:36:27 +01:00
|
|
|
$info = $this->read( $info,false );
|
2002-09-02 10:57:35 +02:00
|
|
|
}
|
2003-11-23 14:33:21 +01:00
|
|
|
if (!$info)
|
|
|
|
{
|
2006-06-24 18:04:35 +02:00
|
|
|
return $info;
|
2003-11-23 14:33:21 +01:00
|
|
|
}
|
|
|
|
return !empty($info['info_subject']) ? $info['info_subject'] :
|
|
|
|
$this->subject_from_des($info['info_descr']);
|
2002-09-02 10:57:35 +02:00
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* query infolog for entries matching $pattern
|
|
|
|
*
|
|
|
|
* Is called as hook to participate in the linking
|
|
|
|
*
|
|
|
|
* @param string $pattern pattern to search
|
|
|
|
* @return array with info_id - title pairs of the matching entries
|
|
|
|
*/
|
2002-09-02 23:40:44 +02:00
|
|
|
function link_query( $pattern )
|
2002-09-02 10:57:35 +02:00
|
|
|
{
|
2004-03-10 01:58:18 +01:00
|
|
|
$query = array(
|
|
|
|
'search' => $pattern,
|
|
|
|
'start' => 0,
|
2004-09-08 18:04:37 +02:00
|
|
|
'subs' => true,
|
2004-03-10 01:58:18 +01:00
|
|
|
);
|
|
|
|
$ids = $this->search($query);
|
2002-09-02 10:57:35 +02:00
|
|
|
$content = array();
|
2004-03-10 01:58:18 +01:00
|
|
|
if (is_array($ids))
|
2002-09-02 10:57:35 +02:00
|
|
|
{
|
2004-03-10 01:58:18 +01:00
|
|
|
foreach($ids as $id => $info )
|
|
|
|
{
|
|
|
|
$content[$id] = $this->link_title($id);
|
|
|
|
}
|
2002-09-02 10:57:35 +02:00
|
|
|
}
|
|
|
|
return $content;
|
|
|
|
}
|
2003-09-07 18:55:36 +02:00
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* hook called be calendar to include events or todos in the cal-dayview
|
|
|
|
*
|
|
|
|
* @param int $args[year], $args[month], $args[day] date of the events
|
|
|
|
* @param int $args[owner] owner of the events
|
|
|
|
* @param string $args[location] calendar_include_{events|todos}
|
|
|
|
* @return array of events (array with keys starttime, endtime, title, view, icon, content)
|
|
|
|
*/
|
2003-09-07 18:55:36 +02:00
|
|
|
function cal_to_include($args)
|
|
|
|
{
|
|
|
|
//echo "<p>cal_to_include("; print_r($args); echo ")</p>\n";
|
2005-12-06 08:11:14 +01:00
|
|
|
$user = (int) $args['owner'];
|
2003-09-07 18:55:36 +02:00
|
|
|
if ($user <= 0 && !checkdate($args['month'],$args['day'],$args['year']))
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
2005-04-06 13:05:57 +02:00
|
|
|
if (!is_object($GLOBALS['egw']->html))
|
2003-09-14 12:25:05 +02:00
|
|
|
{
|
2005-04-06 13:05:57 +02:00
|
|
|
$GLOBALS['egw']->html =& CreateObject('phpgwapi.html');
|
2003-09-14 12:25:05 +02:00
|
|
|
}
|
2005-04-06 13:05:57 +02:00
|
|
|
$GLOBALS['egw']->translation->add_app('infolog');
|
2003-09-14 12:25:05 +02:00
|
|
|
|
2003-09-07 18:55:36 +02:00
|
|
|
$do_events = $args['location'] == 'calendar_include_events';
|
|
|
|
$to_include = array();
|
|
|
|
$date_wanted = sprintf('%04d/%02d/%02d',$args['year'],$args['month'],$args['day']);
|
2004-03-10 01:58:18 +01:00
|
|
|
$query = array(
|
|
|
|
'order' => 'info_startdate',
|
|
|
|
'sort' => $do_events ? 'ASC' : 'DESC',
|
|
|
|
'filter'=> "user$user".($do_events ? 'date' : 'opentoday').$date_wanted,
|
|
|
|
'start' => 0,
|
|
|
|
);
|
|
|
|
while ($infos = $this->search($query))
|
2003-09-07 18:55:36 +02:00
|
|
|
{
|
|
|
|
foreach($infos as $info)
|
|
|
|
{
|
2005-02-09 11:13:24 +01:00
|
|
|
$time = (int) adodb_date('Hi',$info['info_startdate']);
|
|
|
|
$date = adodb_date('Y/m/d',$info['info_startdate']);
|
2006-06-27 18:43:06 +02:00
|
|
|
/* As event-like infologs are not showen in current calendar,
|
|
|
|
we need to present all open infologs to the user! (2006-06-27 nelius)
|
2003-09-07 18:55:36 +02:00
|
|
|
if ($do_events && !$time ||
|
|
|
|
!$do_events && $time && $date == $date_wanted)
|
|
|
|
{
|
|
|
|
continue;
|
2006-06-27 18:43:06 +02:00
|
|
|
}*/
|
2005-04-06 13:05:57 +02:00
|
|
|
$title = ($do_events?$GLOBALS['egw']->common->formattime(adodb_date('H',$info['info_startdate']),adodb_date('i',$info['info_startdate'])).' ':'').
|
2003-09-07 18:55:36 +02:00
|
|
|
$info['info_subject'];
|
|
|
|
$view = $this->link->view('infolog',$info['info_id']);
|
2004-08-07 20:32:03 +02:00
|
|
|
$content=array();
|
2003-09-07 18:55:36 +02:00
|
|
|
foreach($icons = array(
|
|
|
|
$info['info_type'] => 'infolog',
|
2006-03-27 17:34:20 +02:00
|
|
|
$this->status[$info['info_type']][$info['info_status']] => 'infolog',
|
2003-09-07 18:55:36 +02:00
|
|
|
) as $name => $app)
|
|
|
|
{
|
2005-04-06 13:05:57 +02:00
|
|
|
$content[] = $GLOBALS['egw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"').' ';
|
2003-09-07 18:55:36 +02:00
|
|
|
}
|
2005-04-06 13:05:57 +02:00
|
|
|
$content[] = $GLOBALS['egw']->html->a_href($title,$view);
|
|
|
|
$content = $GLOBALS['egw']->html->table(array(1 => $content));
|
2003-09-07 18:55:36 +02:00
|
|
|
|
|
|
|
$to_include[] = array(
|
2004-08-28 20:02:16 +02:00
|
|
|
'starttime' => $info['info_startdate'],
|
|
|
|
'endtime' => ($info['info_enddate'] ? $info['info_enddate'] : $info['info_startdate']),
|
2003-09-07 18:55:36 +02:00
|
|
|
'title' => $title,
|
|
|
|
'view' => $view,
|
|
|
|
'icons' => $icons,
|
|
|
|
'content' => $content
|
|
|
|
);
|
|
|
|
}
|
2004-03-10 01:58:18 +01:00
|
|
|
if ($query['total'] <= ($query['start']+=count($infos)))
|
2003-09-07 18:55:36 +02:00
|
|
|
{
|
|
|
|
break; // no more availible
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//echo "boinfolog::cal_to_include("; print_r($args); echo ")<pre>"; print_r($to_include); echo "</pre>\n";
|
|
|
|
return $to_include;
|
|
|
|
}
|
2004-03-10 01:58:18 +01:00
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* handles introspection or discovery by the logged in client,
|
|
|
|
* in which case the input might be an array. The server always calls
|
|
|
|
* this function to fill the server dispatch map using a string.
|
|
|
|
*
|
|
|
|
* @param string $_type='xmlrpc' xmlrpc or soap
|
|
|
|
* @return array
|
|
|
|
*/
|
2004-03-10 01:58:18 +01:00
|
|
|
function list_methods($_type='xmlrpc')
|
|
|
|
{
|
|
|
|
if (is_array($_type))
|
|
|
|
{
|
|
|
|
$_type = $_type['type'] ? $_type['type'] : $_type[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
switch($_type)
|
|
|
|
{
|
|
|
|
case 'xmlrpc':
|
|
|
|
$xml_functions = array(
|
|
|
|
'read' => array(
|
|
|
|
'function' => 'read',
|
2004-03-13 18:58:37 +01:00
|
|
|
'signature' => array(array(xmlrpcInt,xmlrpcInt)),
|
2004-03-10 01:58:18 +01:00
|
|
|
'docstring' => lang('Read one record by passing its id.')
|
|
|
|
),
|
|
|
|
'search' => array(
|
|
|
|
'function' => 'search',
|
|
|
|
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
|
|
|
|
'docstring' => lang('Returns a list / search for records.')
|
|
|
|
),
|
|
|
|
'write' => array(
|
|
|
|
'function' => 'write',
|
|
|
|
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
|
|
|
|
'docstring' => lang('Write (add or update) a record by passing its fields.')
|
|
|
|
),
|
|
|
|
'delete' => array(
|
|
|
|
'function' => 'delete',
|
2004-03-13 18:58:37 +01:00
|
|
|
'signature' => array(array(xmlrpcInt,xmlrpcInt)),
|
2004-03-10 01:58:18 +01:00
|
|
|
'docstring' => lang('Delete one record by passing its id.')
|
|
|
|
),
|
|
|
|
'categories' => array(
|
|
|
|
'function' => 'categories',
|
2004-03-15 22:38:09 +01:00
|
|
|
'signature' => array(array(xmlrpcBoolean,xmlrpcBoolean)),
|
|
|
|
'docstring' => lang('List all categories')
|
2004-03-10 01:58:18 +01:00
|
|
|
),
|
|
|
|
'list_methods' => array(
|
|
|
|
'function' => 'list_methods',
|
|
|
|
'signature' => array(array(xmlrpcStruct,xmlrpcString)),
|
|
|
|
'docstring' => lang('Read this list of methods.')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
return $xml_functions;
|
|
|
|
break;
|
|
|
|
case 'soap':
|
|
|
|
return $this->soap_functions;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return array();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* Convert an InfoLog entry into its xmlrpc representation, eg. convert timestamps to datetime.iso8601
|
|
|
|
*
|
|
|
|
* @param array $data infolog entry
|
|
|
|
* @param array xmlrpc infolog entry
|
|
|
|
*/
|
2004-03-10 01:58:18 +01:00
|
|
|
function data2xmlrpc($data)
|
|
|
|
{
|
2004-03-13 18:58:37 +01:00
|
|
|
$data['rights'] = $this->so->grants[$data['info_owner']];
|
2005-12-02 18:18:28 +01:00
|
|
|
|
2004-03-10 01:58:18 +01:00
|
|
|
// translate timestamps
|
2005-12-02 18:18:28 +01:00
|
|
|
if($data['info_enddate'] == 0) unset($data['info_enddate']);
|
2006-03-17 21:53:26 +01:00
|
|
|
foreach($this->timestamps as $name)
|
2004-03-10 01:58:18 +01:00
|
|
|
{
|
|
|
|
if (isset($data[$name]))
|
|
|
|
{
|
|
|
|
$data[$name] = $GLOBALS['server']->date2iso8601($data[$name]);
|
|
|
|
}
|
|
|
|
}
|
2006-03-17 21:53:26 +01:00
|
|
|
$ret[$id]['info_percent'] = (int)$data['info_percent'].'%';
|
|
|
|
|
2004-03-10 01:58:18 +01:00
|
|
|
// translate cat_id
|
2004-03-13 18:58:37 +01:00
|
|
|
if (isset($data['info_cat']))
|
|
|
|
{
|
|
|
|
$data['info_cat'] = $GLOBALS['server']->cats2xmlrpc(array($data['info_cat']));
|
|
|
|
}
|
|
|
|
foreach($data as $name => $val)
|
2004-03-10 01:58:18 +01:00
|
|
|
{
|
2004-03-13 18:58:37 +01:00
|
|
|
if (substr($name,0,5) == 'info_')
|
|
|
|
{
|
|
|
|
unset($data[$name]);
|
|
|
|
$data[substr($name,5)] = $val;
|
|
|
|
}
|
2004-03-10 01:58:18 +01:00
|
|
|
}
|
2006-01-16 09:30:36 +01:00
|
|
|
// unsetting everything which could result in an typeless <value />
|
|
|
|
foreach($data as $key => $value)
|
|
|
|
{
|
|
|
|
if (is_null($value) || is_array($value) && !$value)
|
|
|
|
{
|
|
|
|
unset($data[$key]);
|
|
|
|
}
|
|
|
|
}
|
2004-03-10 01:58:18 +01:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* Convert an InfoLog xmlrpc representation into the internal one, eg. convert datetime.iso8601 to timestamps
|
|
|
|
*
|
|
|
|
* @param array $data infolog entry
|
|
|
|
* @param array xmlrpc infolog entry
|
|
|
|
*/
|
2004-03-10 01:58:18 +01:00
|
|
|
function xmlrpc2data($data)
|
|
|
|
{
|
2004-03-13 18:58:37 +01:00
|
|
|
foreach($data as $name => $val)
|
|
|
|
{
|
|
|
|
if (substr($name,0,5) != 'info_')
|
|
|
|
{
|
|
|
|
unset($data[$name]);
|
|
|
|
$data['info_'.$name] = $val;
|
|
|
|
}
|
|
|
|
}
|
2004-03-10 01:58:18 +01:00
|
|
|
// translate timestamps
|
2006-03-17 21:53:26 +01:00
|
|
|
foreach($this->timestamps as $name)
|
2004-03-10 01:58:18 +01:00
|
|
|
{
|
|
|
|
if (isset($data[$name]))
|
|
|
|
{
|
|
|
|
$data[$name] = $GLOBALS['server']->iso86012date($data[$name],True);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// translate cat_id
|
2004-03-13 18:58:37 +01:00
|
|
|
if (isset($data['info_cat']))
|
2004-03-10 01:58:18 +01:00
|
|
|
{
|
2004-03-13 18:58:37 +01:00
|
|
|
$cats = $GLOBALS['server']->xmlrpc2cats($data['info_cat']);
|
|
|
|
$data['info_cat'] = (int)$cats[0];
|
2004-03-10 01:58:18 +01:00
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2005-04-06 13:05:57 +02:00
|
|
|
/**
|
|
|
|
* return array with all infolog categories (for xmlrpc)
|
|
|
|
*
|
|
|
|
* @param boolean $complete true returns array with all data for each cat, else only the title is returned
|
|
|
|
* @return array with cat_id / title or data pairs (see above)
|
|
|
|
*/
|
2004-03-10 01:58:18 +01:00
|
|
|
function categories($complete = False)
|
|
|
|
{
|
2004-03-15 22:38:09 +01:00
|
|
|
return $this->xmlrpc ? $GLOBALS['server']->categories($complete) : False;
|
2004-03-10 01:58:18 +01:00
|
|
|
}
|
2006-02-04 08:49:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returm InfoLog (custom) status icons for projectmanager
|
|
|
|
*
|
|
|
|
* @param array $args array with id's in $args['infolog']
|
|
|
|
* @return array with id => icon pairs
|
|
|
|
*/
|
|
|
|
function pm_icons($args)
|
|
|
|
{
|
|
|
|
if (isset($args['infolog']) && count($args['infolog']))
|
|
|
|
{
|
|
|
|
$icons = $this->so->get_status($args['infolog']);
|
|
|
|
foreach((array) $icons as $id => $status)
|
|
|
|
{
|
|
|
|
if ($status && substr($status,-1) != '%')
|
|
|
|
{
|
|
|
|
$icons[$id] = 'infolog/'.$status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $icons;
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|