egroupware/infolog/inc/class.boinfolog.inc.php

222 lines
5.8 KiB
PHP
Raw Normal View History

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
(
'init' => True, // in class soinfolog
'read' => True,
'write' => True,
'delete' => True,
'check_access' => True,
'readProj' => True,
'readAddr' => True,
'anzSubs' => True,
'readIdArray' => True,
2001-07-12 01:17:32 +02:00
'accountInfo' => True, // in class boinfolog (this class)
'addr2name' => True
2001-07-12 01:17:32 +02:00
);
var $enums;
var $so;
function boinfolog( $info_id = 0)
{
2001-07-12 01:17:32 +02:00
global $phpgw;
2001-07-12 01:17:32 +02:00
$this->enums = array(
'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(
'task' => 'task','phone' => 'phone','note' => 'note'
/* ,'confirm' => 'confirm','reject' => 'reject','email' => 'email',
'fax' => 'fax' no implemented so far */ )
2001-07-12 01:17:32 +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-07-12 01:17:32 +02:00
$this->so = CreateObject('infolog.soinfolog');
$this->read( $info_id);
}
function accountInfo($id,$account_data=0)
{
2001-07-14 17:49:04 +02:00
global $phpgw,$phpgw_info;
2001-07-12 01:17:32 +02:00
if (!$id) return '&nbsp;';
if (!is_array($account_data))
{
2001-07-12 01:17:32 +02:00
$accounts = createobject('phpgwapi.accounts',$id);
$accounts->db = $phpgw->db;
$accounts->read_repository();
$account_data = $accounts->data;
}
2001-07-14 17:49:04 +02:00
if ($phpgw_info['user']['preferences']['infolog']['longNames'])
{
2001-07-12 01:17:32 +02:00
return $account_data['firstname'].' '.$account_data['lastname'];
}
2001-07-12 01:17:32 +02:00
return $account_data['account_lid'];
}
function addr2name( $addr )
{
2001-07-12 01:17:32 +02:00
global $phpgw;
2001-07-12 01:17:32 +02:00
$name = $addr['n_family'];
if ($addr['n_given'])
{
2001-07-12 01:17:32 +02:00
$name .= ', '.$addr['n_given'];
}
else
{
2001-07-12 01:17:32 +02:00
if ($addr['n_prefix'])
{
2001-07-12 01:17:32 +02:00
$name .= ', '.$addr['n_prefix'];
}
}
2001-07-12 01:17:32 +02:00
if ($addr['org_name'])
{
2001-07-12 01:17:32 +02:00
$name = $addr['org_name'].': '.$name;
}
2001-07-12 01:17:32 +02:00
return $phpgw->strip_html($name);
}
function readProj($proj_id)
{
if ($proj_id)
{
if (!is_object($this->projects))
{
2001-07-12 01:17:32 +02:00
$this->projects = createobject('projects.projects');
}
if (list( $proj ) = $this->projects->read_single_project( $proj_id))
{
2001-07-12 01:17:32 +02:00
return $proj;
}
2001-07-12 01:17:32 +02:00
}
return False;
}
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');
}
if (list( $addr ) = $this->contacts->read_single_entry( $addr_id ))
{
2001-07-12 01:17:32 +02:00
return $addr;
}
2001-07-12 01:17:32 +02:00
}
return False;
}
/*
* check's if user has the requiered rights on entry $info_id
*/
function check_access( $info_id,$required_rights )
{
2001-07-12 01:17:32 +02:00
return $this->so->check_access( $info_id,$required_rights );
}
function init()
{
2001-07-12 01:17:32 +02:00
$this->so->init();
}
function read($info_id)
{
2001-07-12 01:17:32 +02:00
$this->so->read($info_id);
if ($this->so->data['info_subject'] ==
(substr($this->so->data['info_des'],0,60).' ...'))
{
$this->so->data['info_subject'] = '';
2001-07-12 01:17:32 +02:00
}
if ($this->so->data['info_addr_id'] && $this->so->data['info_from'] ==
$this->addr2name( $this->readAddr( $this->so->data['info_addr_id'] )))
{
$this->so->data['info_from'] = '';
2001-07-12 01:17:32 +02:00
}
return $this->so->data;
2001-07-12 01:17:32 +02:00
}
function delete($info_id)
{
2001-07-12 01:17:32 +02:00
$this->so->delete($info_id);
}
function write($values)
{
2001-07-12 01:17:32 +02:00
global $phpgw_info;
if ($values['responsible'] && $values['status'] == 'offer')
{
2001-07-12 01:17:32 +02:00
$values['status'] = 'ongoing'; // have to match if not finished
}
if (!$values['info_id'] && !$values['owner'])
{
2001-07-12 01:17:32 +02:00
$values['owner'] = $phpgw_info['user']['account_id'];
}
$values['datecreated'] = time(); // is now MODIFICATION-date
2001-07-12 01:17:32 +02:00
if (!$values['subject'])
{
$values['subject'] = substr($values['des'],0,60).' ...';
}
if ($values['addr_id'] && !$values['from'])
{
$values['from'] = $this->addr2name( $this->readAddr(
$values['addr_id'] ));
}
2001-07-12 01:17:32 +02:00
$this->so->write($values);
}
function anzSubs( $info_id )
{
return $this->so->anzSubs( $info_id );
}
function readIdArray($order,$sort,$filter,$cat_id,$query,$action,$addr_id,
$proj_id,$info_id,$ordermethod,&$start,&$total)
{
return $this->so->readIdArray($order,$sort,$filter,$cat_id,$query,
$action,$addr_id,$proj_id,$info_id,
$ordermethod,$start,$total);
}
2001-07-12 01:17:32 +02:00
}