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$ */
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@class soinfolog
|
|
|
|
@abstract storage object / db-layer for InfoLog
|
|
|
|
@author Ralf Becker
|
|
|
|
@copyright GPL - GNU General Public License
|
|
|
|
@note all values passed to this class are run either through intval or addslashes to prevent query-inserting
|
|
|
|
and for pgSql 7.3 compatibility
|
|
|
|
*/
|
2001-07-12 01:17:32 +02:00
|
|
|
class soinfolog // DB-Layer
|
|
|
|
{
|
|
|
|
var $db,$db2;
|
|
|
|
var $grants;
|
|
|
|
var $data = array( );
|
2001-07-15 23:42:17 +02:00
|
|
|
var $filters = array( );
|
2001-10-03 20:56:42 +02:00
|
|
|
var $user;
|
2003-06-14 15:51:53 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@function soinfolog
|
|
|
|
@abstract constructor
|
|
|
|
*/
|
2001-07-14 23:44:01 +02:00
|
|
|
function soinfolog( $info_id = 0)
|
|
|
|
{
|
2001-10-03 20:56:42 +02:00
|
|
|
$this->db = $GLOBALS['phpgw']->db;
|
|
|
|
$this->grants = $GLOBALS['phpgw']->acl->get_grants('infolog');
|
|
|
|
$this->user = $GLOBALS['phpgw_info']['user']['account_id'];
|
|
|
|
|
2002-09-01 22:41:36 +02:00
|
|
|
$this->links = CreateObject('infolog.solink');
|
|
|
|
|
2001-07-14 23:44:01 +02:00
|
|
|
$this->read( $info_id );
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function check_access
|
|
|
|
@abstract checks if user has the $required_rights to access $info_id (private access is handled too)
|
|
|
|
@syntax check_access( $info_id,$required_rights )
|
|
|
|
@param $info_id Id of InfoLog entry
|
|
|
|
@param $required_rights PHPGW_ACL_xyz anded together
|
|
|
|
@returns True if access is granted else False
|
|
|
|
*/
|
2001-07-14 23:44:01 +02:00
|
|
|
function check_access( $info_id,$required_rights )
|
|
|
|
{
|
|
|
|
if ($info_id != $this->data['info_id']) // already loaded?
|
|
|
|
{
|
|
|
|
// dont change our own internal data,
|
|
|
|
// dont use new as it changes $phpgw->db
|
|
|
|
$private_info = $this;
|
2001-07-12 01:17:32 +02:00
|
|
|
$info = $private_info->read($info_id);
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$info = $this->data;
|
|
|
|
}
|
|
|
|
if (!$info || !$info_id)
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
return False;
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
$owner = $info['info_owner'];
|
2001-07-14 23:44:01 +02:00
|
|
|
|
2001-10-03 20:56:42 +02:00
|
|
|
$access_ok = $owner == $this->user || // user has all rights
|
2001-07-14 23:44:01 +02:00
|
|
|
// ACL only on public entrys || $owner granted _PRIVATE
|
|
|
|
!!($this->grants[$owner] & $required_rights) &&
|
|
|
|
($info['info_access'] == 'public' ||
|
|
|
|
!!($this->grants[$owner] & PHPGW_ACL_PRIVATE));
|
2001-07-12 01:17:32 +02:00
|
|
|
|
|
|
|
// echo "check_access(info_id=$info_id (owner=$owner, user=$user),required_rights=$required_rights): access".($access_ok?"Ok":"Denied");
|
|
|
|
|
|
|
|
return $access_ok;
|
|
|
|
}
|
2001-07-14 23:44:01 +02:00
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function aclFilter
|
|
|
|
@abstract generate sql to be AND'ed into a query to ensure ACL is respected (incl. _PRIVATE)
|
|
|
|
@param $filter: none|all - list all entrys user have rights to see<br>
|
|
|
|
private|own - list only his personal entrys (incl. those he is responsible for !!!)
|
|
|
|
@returns the necesary sql
|
|
|
|
*/
|
2001-07-14 23:44:01 +02:00
|
|
|
function aclFilter($filter = 'none')
|
|
|
|
{
|
2001-07-15 23:42:17 +02:00
|
|
|
ereg('.*(own|privat|all|none).*',$filter,$vars);
|
|
|
|
$filter = $vars[1];
|
|
|
|
|
2001-07-12 01:17:32 +02:00
|
|
|
if (isset($this->acl_filter[$filter]))
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
|
|
|
return $this->acl_filter[$filter]; // used cached filter if found
|
|
|
|
}
|
|
|
|
if (is_array($this->grants))
|
|
|
|
{
|
|
|
|
while (list($user,$grant) = each($this->grants))
|
|
|
|
{
|
|
|
|
// echo "<p>grants: user=$user, grant=$grant</p>";
|
2001-07-12 01:17:32 +02:00
|
|
|
if ($grant & (PHPGW_ACL_READ|PHPGW_ACL_EDIT))
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$public_user_list[] = $user;
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
if ($grant & PHPGW_ACL_PRIVATE)
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$private_user_list[] = $user;
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2001-07-14 23:44:01 +02:00
|
|
|
if (count($private_user_list))
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$has_private_access = 'info_owner IN ('.implode(',',$private_user_list).')';
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
}
|
2001-10-03 20:56:42 +02:00
|
|
|
$filtermethod = " (info_owner=$this->user"; // user has all rights
|
2001-07-12 01:17:32 +02:00
|
|
|
|
2001-07-14 23:44:01 +02:00
|
|
|
// private: own entries plus the one user is responsible for
|
2001-07-15 23:42:17 +02:00
|
|
|
if ($filter == 'private' || $filter == 'own')
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2001-10-04 21:04:58 +02:00
|
|
|
$filtermethod .= " OR (info_responsible=$this->user OR info_status = 'offer')".
|
|
|
|
" AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
|
|
|
else // none --> all entrys user has rights to see
|
|
|
|
{
|
|
|
|
if ($has_private_access)
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$filtermethod .= " OR $has_private_access";
|
|
|
|
}
|
2001-07-14 23:44:01 +02:00
|
|
|
if (count($public_user_list))
|
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$filtermethod .= " OR (info_access='public' AND info_owner IN(" . implode(',',$public_user_list) . '))';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$filtermethod .= ') ';
|
|
|
|
|
2001-07-14 23:44:01 +02:00
|
|
|
return $this->acl_filter[$filter] = $filtermethod; // cache the filter
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function statusFilter
|
|
|
|
@abstract generate sql to filter based on the status of the log-entry
|
|
|
|
@syntax statusFilter($filter = '')
|
|
|
|
@param $filter done = done or billed, open = not ()done or billed), offer = offer
|
|
|
|
@returns the necesary sql
|
|
|
|
*/
|
2001-07-15 23:42:17 +02:00
|
|
|
function statusFilter($filter = '')
|
|
|
|
{
|
|
|
|
ereg('.*(done|open|offer).*',$filter,$vars);
|
|
|
|
$filter = $vars[1];
|
|
|
|
|
|
|
|
switch ($filter)
|
|
|
|
{
|
|
|
|
case 'done': return " AND info_status IN ('done','billed')";
|
|
|
|
case 'open': return " AND NOT (info_status IN ('done','billed'))";
|
|
|
|
case 'offer': return " AND info_status = 'offer'";
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function dateFilter
|
|
|
|
@abstract generate sql to filter based on the start- and enddate of the log-entry
|
|
|
|
@syntax dateFilter($filter = '')
|
|
|
|
@param $filter upcoming = startdate is in the future<br>
|
|
|
|
today startdate < tomorrow<br>
|
|
|
|
overdue enddate < tomorrow
|
|
|
|
@returns the necesary sql
|
|
|
|
*/
|
2001-07-15 23:42:17 +02:00
|
|
|
function dateFilter($filter = '')
|
|
|
|
{
|
|
|
|
ereg('.*(upcoming|today|overdue).*',$filter,$vars);
|
|
|
|
$filter = $vars[1];
|
|
|
|
|
|
|
|
$now = getdate(time());
|
|
|
|
$tomorrow = mktime(0,0,0,$now['mon'],$now['mday']+1,$now['year']);
|
|
|
|
|
|
|
|
switch ($filter)
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
case 'upcoming':
|
|
|
|
return " AND info_startdate >= '$tomorrow'";
|
|
|
|
case 'today':
|
|
|
|
return " AND info_startdate < '$tomorrow'";
|
|
|
|
case 'overdue':
|
|
|
|
return " AND (info_enddate != 0 AND info_enddate < '$tomorrow')";
|
2001-07-15 23:42:17 +02:00
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function init
|
|
|
|
@abstract initialise the internal $this->data to be empty
|
|
|
|
@discussion only non-empty values got initialised
|
|
|
|
*/
|
2001-07-14 23:44:01 +02:00
|
|
|
function init()
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$this->data = array(
|
|
|
|
'info_owner' => $this->user,
|
|
|
|
'info_pri' => 'normal'
|
|
|
|
);
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2002-10-16 02:23:39 +02:00
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function db2data
|
|
|
|
@abstract copy data after a query into $data
|
|
|
|
@syntax db2data(&$data)
|
|
|
|
@param $data array to copy the data
|
2003-07-06 10:52:35 +02:00
|
|
|
@description copy only non-numeric keys
|
2003-06-14 15:51:53 +02:00
|
|
|
*/
|
2002-10-16 02:23:39 +02:00
|
|
|
function db2data(&$data)
|
|
|
|
{
|
2003-07-06 10:52:35 +02:00
|
|
|
$data = array();
|
|
|
|
foreach ($this->db->Record as $key => $val)
|
|
|
|
{
|
|
|
|
if (!is_numeric($key))
|
|
|
|
{
|
|
|
|
$data[$key] = $val;
|
|
|
|
}
|
|
|
|
}
|
2002-10-16 02:23:39 +02:00
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function read
|
|
|
|
@abstract read InfoLog entry $info_id
|
|
|
|
@syntax read( $info_id )
|
|
|
|
@param $info_id id of log-entry
|
|
|
|
@description some cacheing is done to prevent multiple reads of the same entry
|
|
|
|
@returns the entry as array
|
|
|
|
*/
|
2001-07-14 23:44:01 +02:00
|
|
|
function read($info_id) // did _not_ ensure ACL
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$info_id = intval($info_id);
|
|
|
|
|
2001-07-12 01:17:32 +02:00
|
|
|
if ($info_id <= 0 || $info_id != $this->data['info_id'] &&
|
2003-06-14 15:51:53 +02:00
|
|
|
(!$this->db->query("select * FROM phpgw_infolog where info_id=$info_id",__LINE__,__FILE__) ||
|
|
|
|
!$this->db->next_record()))
|
2001-07-12 01:17:32 +02:00
|
|
|
{
|
|
|
|
$this->init( );
|
|
|
|
return False;
|
|
|
|
}
|
2001-07-14 23:44:01 +02:00
|
|
|
if ($info_id != $this->data['info_id']) // data yet read in
|
|
|
|
{
|
2002-10-16 02:23:39 +02:00
|
|
|
$this->db2data($this->data);
|
2001-07-19 01:54:43 +02:00
|
|
|
}
|
2002-10-16 02:23:39 +02:00
|
|
|
return $this->data;
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function delete
|
|
|
|
@abstract delete InfoLog entry $info_id AND the links to it
|
|
|
|
@syntax delete( $info_id )
|
|
|
|
@param $info_id id of log-entry
|
|
|
|
*/
|
2001-07-14 23:44:01 +02:00
|
|
|
function delete($info_id) // did _not_ ensure ACL
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
if (($info_id = intval($info_id)) <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->db->query("delete FROM phpgw_infolog where info_id=$info_id or info_id_parent=$info_id" .
|
2003-06-16 00:21:52 +02:00
|
|
|
" AND ((info_access='public' and info_owner != $this->user) OR (info_owner=$this->user))",
|
2003-06-14 15:51:53 +02:00
|
|
|
__LINE__,__FILE__);
|
2001-07-12 01:17:32 +02:00
|
|
|
|
2002-09-01 22:41:36 +02:00
|
|
|
$this->links->unlink(0,'infolog',$info_id);
|
|
|
|
|
2001-07-12 01:17:32 +02:00
|
|
|
if ($this->data['info_id'] == $info_id)
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2001-07-12 01:17:32 +02:00
|
|
|
$this->init( );
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function change_delete_owner
|
|
|
|
@abstract changes or deletes entries with a spezified owner (for hook_delete_account)
|
|
|
|
@syntax change_delete_owner( $owner,$new_owner=0 )
|
|
|
|
@param $owner old owner
|
|
|
|
@param $new_owner new owner or 0 if entries should be deleted
|
|
|
|
*/
|
2002-11-20 20:58:15 +01:00
|
|
|
function change_delete_owner($owner,$new_owner=0) // new_owner=0 means delete
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$owner = intval($owner);
|
|
|
|
if (!($new_owner = intval($new_owner)))
|
2002-11-20 20:58:15 +01:00
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$sql = "delete FROM phpgw_infolog where info_owner=$owner";
|
|
|
|
$sql2 = "update phpgw_infolog set info_responsible=0 where info_responsible=$owner";
|
2002-11-20 20:58:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$sql = "update phpgw_infolog set info_owner=$new_owner where info_owner=$owner";
|
|
|
|
$sql2 = "update phpgw_infolog set info_responsible=$new_owner where info_responsible=$owner";
|
2002-11-20 20:58:15 +01:00
|
|
|
}
|
|
|
|
$this->db->query($sql,__LINE__,__FILE__);
|
|
|
|
$this->db->query($sql2,__LINE__,__FILE__);
|
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function write
|
|
|
|
@abstract writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0
|
|
|
|
@syntax write( $values )
|
|
|
|
@param $values array with the data of the log-entry
|
|
|
|
@returns nothing direct, but the info_id gets
|
|
|
|
*/
|
2001-07-14 23:44:01 +02:00
|
|
|
function write($values) // did _not_ ensure ACL
|
|
|
|
{
|
2002-10-08 02:10:18 +02:00
|
|
|
include(PHPGW_SERVER_ROOT.'/infolog/setup/tables_current.inc.php');
|
|
|
|
$db_cols = $phpgw_baseline['phpgw_infolog']['fd'];
|
|
|
|
unset($phpgw_baseline);
|
|
|
|
|
2001-07-14 23:44:01 +02:00
|
|
|
while (list($key,$val) = each($values))
|
|
|
|
{
|
2001-07-19 01:54:43 +02:00
|
|
|
if ($key != 'info_id')
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2002-10-08 02:10:18 +02:00
|
|
|
if (!isset($db_cols[$key]))
|
|
|
|
{
|
|
|
|
continue; // not in infolog-table
|
|
|
|
}
|
2001-07-19 01:54:43 +02:00
|
|
|
$this->data[$key] = $val; // update internal data
|
|
|
|
|
2003-07-09 01:19:18 +02:00
|
|
|
switch($db_cols[$key]['type']) // protection against query-insertion
|
2001-07-19 01:54:43 +02:00
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
case 'int': case 'auto':
|
|
|
|
$val = intval($val);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$val = "'".$this->db->db_addslashes($val)."'";
|
|
|
|
break;
|
2001-07-19 01:54:43 +02:00
|
|
|
}
|
2003-07-09 01:19:18 +02:00
|
|
|
$cols .= (strlen($cols) ? ',' : '').$key;
|
|
|
|
$vals .= (strlen($vals) ? ',' : '').$val;
|
|
|
|
$query .= (strlen($query) ? ',' : '')."$key=$val";
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
|
|
|
}
|
2003-06-14 15:51:53 +02:00
|
|
|
if (($this->data['info_id'] = intval($values['info_id'])) > 0)
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$query = "UPDATE phpgw_infolog SET $query where info_id='".$this->data['info_id']."'";
|
2002-09-01 22:41:36 +02:00
|
|
|
$this->db->query($query,__LINE__,__FILE__);
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-20 01:00:51 +02:00
|
|
|
$query = "INSERT INTO phpgw_infolog ($cols) VALUES ($vals)";
|
2001-10-03 20:56:42 +02:00
|
|
|
$this->db->query($query,__LINE__,__FILE__);
|
|
|
|
$this->data['info_id']=$this->db->get_last_insert_id('phpgw_infolog','info_id');
|
2001-07-20 01:00:51 +02:00
|
|
|
}
|
2002-09-01 22:41:36 +02:00
|
|
|
// echo "<p>soinfolog.write values= "; _debug_array($values);
|
|
|
|
// echo "<p>soinfolog.write this->data= "; _debug_array($this->data);
|
2003-06-14 15:51:53 +02:00
|
|
|
|
|
|
|
return $this->data['info_id'];
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|
2001-07-14 23:44:01 +02:00
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function anzSubs
|
|
|
|
@abstract count the sub-entries of $info_id
|
|
|
|
@syntax anzSubs( $info_id )
|
|
|
|
@param $info_id id of log-entry
|
|
|
|
@returns the number of sub-entries
|
|
|
|
*/
|
2001-07-14 23:44:01 +02:00
|
|
|
function anzSubs( $info_id )
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
if (($info_id = intval($info_id)) <= 0)
|
2002-10-16 02:23:39 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2003-06-14 15:51:53 +02:00
|
|
|
$this->db->query("select count(*) FROM phpgw_infolog where info_id_parent=$info_id",__LINE__,__FILE__);
|
2001-07-14 23:44:01 +02:00
|
|
|
|
|
|
|
$this->db->next_record();
|
|
|
|
|
|
|
|
return $this->db->f(0);
|
|
|
|
}
|
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
/*!
|
|
|
|
@function search
|
|
|
|
@abstract searches InfoLog for a certain pattern in $query
|
|
|
|
@syntax search( $order,$sort,$filter,$cat_id,$query,$action,$action_id,$ordermethod,&$start,&$total )
|
|
|
|
@param $order comma-separated list of columns to order the result (no 'ORDER BY'), eg. 'info_subject DESC'
|
|
|
|
@param $sort comma-separated list of columns to to sort by (incl. 'SORT BY') or ''
|
|
|
|
@param $filter string with combination of acl-, date- and status-filters, eg. 'own-open-today' or ''
|
|
|
|
@param $cat_id category to use or 0
|
|
|
|
@param $query pattern to search, search is done in info_from, info_subject and info_des
|
|
|
|
@param $action / $action_id if only entries linked to a specified app/entry show be used
|
|
|
|
@param &$start, &$total nextmatch-parameters will be used and set if query returns less entries
|
|
|
|
@returns array with id's as key of the matching log-entries
|
|
|
|
*/
|
|
|
|
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
|
|
|
//echo "<p>soinfolog.search(action='$action/$action_id')</p>\n";
|
2002-09-01 22:41:36 +02:00
|
|
|
$action2app = array(
|
2002-10-14 02:39:47 +02:00
|
|
|
'addr' => 'addressbook',
|
|
|
|
'proj' => 'projects',
|
2002-10-16 02:23:39 +02:00
|
|
|
'event' => 'calendar'
|
2002-09-01 22:41:36 +02:00
|
|
|
);
|
2002-10-16 02:23:39 +02:00
|
|
|
if (isset($action2app[$action]))
|
2002-09-01 22:41:36 +02:00
|
|
|
{
|
2002-10-16 02:23:39 +02:00
|
|
|
$action = $action2app[$action];
|
|
|
|
}
|
|
|
|
if ($action != '')
|
|
|
|
{
|
|
|
|
$links = $this->links->get_links($action=='sp'?'infolog':$action,$action_id,'infolog');
|
|
|
|
|
|
|
|
if (count($links))
|
2002-09-01 22:41:36 +02:00
|
|
|
{
|
2002-10-16 02:23:39 +02:00
|
|
|
$link_extra = ($action == 'sp' ? 'OR' : 'AND').' info_id IN ('.implode(',',$links).')';
|
2002-09-01 22:41:36 +02:00
|
|
|
}
|
|
|
|
}
|
2001-07-14 23:44:01 +02:00
|
|
|
if ($order)
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$ordermethod = 'ORDER BY ' . $this->db->db_addslashes($order) . ' ' . $this->db->db_addslashes($sort);
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-14 02:39:47 +02:00
|
|
|
$ordermethod = 'ORDER BY info_datemodified DESC'; // newest first
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
|
|
|
$filtermethod = $this->aclFilter($filter);
|
2001-07-15 23:42:17 +02:00
|
|
|
$filtermethod .= $this->statusFilter($filter);
|
|
|
|
$filtermethod .= $this->dateFilter($filter);
|
|
|
|
// echo "<p>filtermethod='$filtermethod'</p>";
|
2001-07-14 23:44:01 +02:00
|
|
|
|
2003-06-14 15:51:53 +02:00
|
|
|
if (intval($cat_id))
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$filtermethod .= ' AND info_cat='.intval($cat_id).' ';
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
|
|
|
if ($query) // we search in _from, _subject and _des for $query
|
|
|
|
{
|
2003-06-14 15:51:53 +02:00
|
|
|
$query = $this->db->db_addslashes($query);
|
2001-07-14 23:44:01 +02:00
|
|
|
$sql_query = "AND (info_from like '%$query%' OR info_subject ".
|
2002-10-14 02:39:47 +02:00
|
|
|
"LIKE '%$query%' OR info_des LIKE '%$query%') ";
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2002-05-01 19:16:27 +02:00
|
|
|
$pid = 'AND info_id_parent='.($action == 'sp' ? $action_id : 0);
|
2001-07-14 23:44:01 +02:00
|
|
|
|
|
|
|
if (!$phpgw_info['user']['preferences']['infolog']['listNoSubs'] &&
|
|
|
|
$action != 'sp')
|
|
|
|
{
|
|
|
|
$pid = '';
|
|
|
|
}
|
2002-10-16 02:23:39 +02:00
|
|
|
$ids = array( );
|
|
|
|
if ($action == '' || $action == 'sp' || count($links))
|
2003-06-14 15:51:53 +02:00
|
|
|
{
|
2002-10-16 02:23:39 +02:00
|
|
|
$this->db->query($sql="SELECT COUNT(*) FROM phpgw_infolog i WHERE ($filtermethod $pid $sql_query) $link_extra",__LINE__,__FILE__);
|
|
|
|
|
|
|
|
$this->db->next_record();
|
|
|
|
$total = $this->db->f(0);
|
2001-07-14 23:44:01 +02:00
|
|
|
|
2002-10-16 02:23:39 +02:00
|
|
|
if (!$start || $start > $total)
|
|
|
|
{
|
|
|
|
$start = 0;
|
|
|
|
}
|
|
|
|
$this->db->limit_query($sql="SELECT * FROM phpgw_infolog WHERE ($filtermethod $pid $sql_query) $link_extra $ordermethod",$start,__LINE__,__FILE__);
|
2001-07-14 23:44:01 +02:00
|
|
|
|
2002-10-16 02:23:39 +02:00
|
|
|
while ($this->db->next_record())
|
|
|
|
{
|
|
|
|
$this->db2data(&$info);
|
|
|
|
$ids[$info['info_id']] = $info;
|
|
|
|
}
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
2002-10-16 02:23:39 +02:00
|
|
|
else
|
2001-07-14 23:44:01 +02:00
|
|
|
{
|
2002-10-16 02:23:39 +02:00
|
|
|
$start = $total = 0;
|
2001-07-14 23:44:01 +02:00
|
|
|
}
|
|
|
|
return $ids;
|
|
|
|
}
|
2001-07-12 01:17:32 +02:00
|
|
|
}
|