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,
|
|
|
|
'anzSubs' => True,
|
2002-10-16 02:23:39 +02:00
|
|
|
'search' => True,
|
2002-10-14 02:39:47 +02:00
|
|
|
'get_rows' => True,
|
2002-09-02 10:57:35 +02:00
|
|
|
'link_title' => True,
|
2002-10-18 00:02:44 +02:00
|
|
|
'link_query' => True,
|
2003-03-20 18:22:53 +01:00
|
|
|
'link_id2from' => 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' ),
|
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
|
|
|
);
|
2001-07-19 03:28:16 +02:00
|
|
|
$this->status = array(
|
|
|
|
'defaults' => array(
|
|
|
|
'task' => 'ongoing', 'phone' => 'call', 'note' => 'done'),
|
|
|
|
'task' => array(
|
2002-10-18 00:02:44 +02:00
|
|
|
'offer' => 'offer','ongoing' => 'ongoing','done' => 'done',
|
|
|
|
'0%' => '0%', '10%' => '10%', '20%' => '20%', '30%' => '30%', '40%' => '40%',
|
|
|
|
'50%' => '50%', '60%' => '60%', '70%' => '70%', '80%' => '80%', '90%' => '90%',
|
|
|
|
'billed' => 'billed' ),
|
2001-07-19 03:28:16 +02:00
|
|
|
'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');
|
2002-10-18 00:02:44 +02:00
|
|
|
$this->link = CreateObject('infolog.bolink');
|
2001-10-07 22:11:32 +02:00
|
|
|
|
|
|
|
$this->config = CreateObject('phpgwapi.config');
|
|
|
|
$this->config->read_repository();
|
|
|
|
|
|
|
|
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'];
|
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
|
|
|
|
2002-10-18 00:02:44 +02:00
|
|
|
/*
|
|
|
|
* check's if user has the requiered rights on entry $info_id
|
|
|
|
*/
|
|
|
|
function check_access( $info_id,$required_rights )
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2002-10-18 00:02:44 +02:00
|
|
|
return $this->so->check_access( $info_id,$required_rights );
|
2002-02-14 21:14:15 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2003-03-20 18:22:53 +01:00
|
|
|
function link_id2from(&$info,$not_app='',$not_id='')
|
2002-05-12 09:14:01 +02:00
|
|
|
{
|
2003-03-20 18:31:01 +01:00
|
|
|
//echo "<p>boinfolog::link_id2from(subject='$info[info_subject]', link_id='$info[info_link_id], from='$info[info_from]')";
|
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-06-29 19:03:47 +02:00
|
|
|
|
|
|
|
if (htmlentities($title) == $info['info_from'])
|
|
|
|
{
|
|
|
|
$info['info_from'] = $title; // correct old entries
|
|
|
|
}
|
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
|
|
|
if ($title == $info['info_from'])
|
|
|
|
{
|
|
|
|
$info['info_from'] = '';
|
|
|
|
}
|
|
|
|
return False;
|
2002-05-12 09:14:01 +02:00
|
|
|
}
|
2003-06-29 19:03:47 +02:00
|
|
|
$info['info_link_view'] = $this->link->view($link['link_app'.$nr],$link['link_id'.$nr]);
|
|
|
|
$info['info_link_title'] = $title;
|
|
|
|
|
2003-03-20 18:22:53 +01:00
|
|
|
//echo " title='$title'</p>\n";
|
2002-10-18 00:02:44 +02:00
|
|
|
return $title;
|
2002-05-12 09:14:01 +02:00
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function read($info_id)
|
|
|
|
{
|
2002-10-14 02:39:47 +02:00
|
|
|
$err = $this->so->read($info_id) === False;
|
2002-10-18 00:02:44 +02:00
|
|
|
$data = &$this->so->data;
|
|
|
|
|
|
|
|
if ($data['info_subject'] == (substr($data['info_des'],0,60).' ...'))
|
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
|
|
|
}
|
2003-03-20 18:31:01 +01:00
|
|
|
$this->link_id2from($data);
|
2003-06-29 19:03:47 +02:00
|
|
|
;
|
2002-10-18 00:02:44 +02:00
|
|
|
if ($data['info_link_title'] == $data['info_from'])
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2002-10-18 00:02:44 +02:00
|
|
|
$data['info_from'] = '';
|
2001-10-07 22:11:32 +02:00
|
|
|
}
|
2002-10-18 00:02:44 +02:00
|
|
|
return $err ? False : $data;
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2001-07-15 00:16:16 +02:00
|
|
|
function delete($info_id)
|
|
|
|
{
|
2002-10-18 00:02:44 +02:00
|
|
|
$this->link->unlink(0,'infolog',$info_id);
|
2001-10-07 22:11:32 +02:00
|
|
|
|
|
|
|
$this->so->delete($info_id);
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2002-10-18 22:20:35 +02:00
|
|
|
function write($values,$check_defaults=True)
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2002-10-08 02:10:18 +02:00
|
|
|
while (list($key,$val) = each($values))
|
2001-07-15 00:16:16 +02:00
|
|
|
{
|
2002-10-08 02:10:18 +02:00
|
|
|
if (substr($key,0,5) != 'info_')
|
|
|
|
{
|
|
|
|
$values['info_'.$key] = $val;
|
|
|
|
unset($values[$key]);
|
|
|
|
}
|
|
|
|
}
|
2002-10-18 22:20:35 +02:00
|
|
|
if ($check_defaults)
|
2002-10-08 02:10:18 +02:00
|
|
|
{
|
2003-06-29 19:03:47 +02:00
|
|
|
if (!$values['info_enddate'] &&
|
|
|
|
($values['info_status'] == 'done' || $values['info_status'] == 'billed'))
|
|
|
|
{
|
|
|
|
$values['info_enddate'] = time(); // set enddate to today if status == done
|
|
|
|
}
|
2002-10-18 22:20:35 +02:00
|
|
|
if ($values['info_responsible'] && $values['info_status'] == 'offer')
|
|
|
|
{
|
|
|
|
$values['info_status'] = 'ongoing'; // have to match if not finished
|
|
|
|
}
|
|
|
|
if (!$values['info_id'] && !$values['info_owner'])
|
|
|
|
{
|
|
|
|
$values['info_owner'] = $this->so->user;
|
|
|
|
}
|
|
|
|
if (!$values['info_subject'])
|
|
|
|
{
|
|
|
|
$values['info_subject'] = substr($values['info_des'],0,60).' ...';
|
|
|
|
}
|
2003-03-20 18:31:01 +01:00
|
|
|
if ($values['info_link_id'] && empty($values['info_from']))
|
2002-10-18 22:20:35 +02:00
|
|
|
{
|
2003-03-20 18:31:01 +01:00
|
|
|
$this->link_id2from($values);
|
2002-10-18 22:20:35 +02:00
|
|
|
}
|
2001-07-15 00:16:16 +02:00
|
|
|
}
|
2002-10-18 00:02:44 +02:00
|
|
|
$values['info_datemodified'] = time();
|
|
|
|
$values['info_modifier'] = $this->so->user;
|
|
|
|
|
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-10-16 02:23:39 +02:00
|
|
|
function search($order,$sort,$filter,$cat_id,$query,$action,$action_id,
|
|
|
|
$ordermethod,&$start,&$total)
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2002-10-16 02:23:39 +02:00
|
|
|
return $this->so->search($order,$sort,$filter,$cat_id,$query,
|
|
|
|
$action,$action_id,$ordermethod,$start,$total);
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2001-10-07 22:11:32 +02:00
|
|
|
|
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-10-16 02:23:39 +02:00
|
|
|
$ids = $this->search('','','','',$pattern,'','','',&$start,&$total);
|
2002-09-02 10:57:35 +02:00
|
|
|
$content = array();
|
2002-10-16 02:23:39 +02:00
|
|
|
while (is_array($ids) && list( $id,$info ) = each( $ids ))
|
2002-09-02 10:57:35 +02:00
|
|
|
{
|
|
|
|
$content[$id] = $this->link_title($id);
|
|
|
|
}
|
|
|
|
return $content;
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|