phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: infolog/inc class.boinfolog.inc.php,1.22,1.23 cl


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: infolog/inc class.boinfolog.inc.php,1.22,1.23 class.bolink.inc.php,1.6,1.7 class.linklist_widget.inc.php,1.1,1.2 class.linkto_widget.inc.php,1.3,1.4 class.soinfolog.inc.php,1.13,1.14 class.uiinfolog.inc.php,1.45,1.46
Date: Mon, 07 Oct 2002 20:10:04 -0400

Update of /cvsroot/phpgroupware/infolog/inc
In directory subversions:/tmp/cvs-serv26350

Modified Files:
        class.boinfolog.inc.php class.bolink.inc.php 
        class.linklist_widget.inc.php class.linkto_widget.inc.php 
        class.soinfolog.inc.php class.uiinfolog.inc.php 
Log Message:
first steps on infolog port to etemplates

Index: class.boinfolog.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.boinfolog.inc.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** class.boinfolog.inc.php     2 Sep 2002 21:40:44 -0000       1.22
--- class.boinfolog.inc.php     8 Oct 2002 00:10:02 -0000       1.23
***************
*** 1,480 ****
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - InfoLog                                                
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Ralf Becker <address@hidden>                  *
!       * originaly based on todo written by Joseph Engo <address@hidden>  *
!       * --------------------------------------------                          
   *
!       *  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,
!                       'accountInfo'    => True,       // in class boinfolog 
(this class)
!                       'addr2name'      => True,
!                       'attach_file'    => True,
!                       'delete_attached'=> True,
!                       'info_attached'  => True,
!                       'list_attached'  => True,
!                       'read_attached'  => True,
!                       'attached_local' => True,
!                       'link_title'     => True,
!                       'link_query'     => True
!               );
!               var $enums;
!               var $so;
!               var $vfs;
!               var $vfs_basedir='/infolog';
!               var $valid_pathes = array();
!               var $send_file_ips = array();
! 
!               function boinfolog( $info_id = 0)
!               {
!                       $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 */ 
)
!                       );
!                       $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'
!                       ));
! 
!                       $this->so = CreateObject('infolog.soinfolog');
!                       $this->vfs = CreateObject('infolog.vfs');
! 
!                       $this->config = CreateObject('phpgwapi.config');
!                       $this->config->read_repository();
! 
!                       if ($this->config->config_data)
!                       {
!                               $this->link_pathes   = 
unserialize($this->config->config_data['link_pathes']);
!                               $this->send_file_ips = 
unserialize($this->config->config_data['send_file_ips']);
!                       }
! 
!                       $this->read( $info_id);
!               }
! 
!               function accountInfo($id,$account_data=0)
!               {
!                       if (!$id) return '&nbsp;';
! 
!                       if (!is_array($account_data))
!                       {
!                               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];
!                       }
!                       if 
($GLOBALS['phpgw_info']['user']['preferences']['infolog']['longNames'])
!                       {
!                               return $account_data['firstname'].' 
'.$account_data['lastname'];
!                       }
!                       return $account_data['account_lid'];
!               }
! 
!               function addr2name( $addr )
!               {
!                       if (!is_array($addr) && !($addr = 
$this->readAddr($addr)))
!                       {
!                               return '';
!                       }
!                       $name = $addr['n_family'];
!                       if ($addr['n_given'])
!                       {
!                               $name .= ', '.$addr['n_given'];
!                       }
!                       else
!                       {
!                               if ($addr['n_prefix'])
!                               {
!                                       $name .= ', '.$addr['n_prefix'];
!                               }
!                       }
!                       if ($addr['org_name'])
!                       {
!                               $name = $addr['org_name'].': '.$name;
!                       }
!                       return $GLOBALS['phpgw']->strip_html($name);
!               }
! 
!               function proj2name( $proj )
!               {
!                       if (!is_array($proj))
!                       {
!                               $proj = $this->readProj($proj);
!                       }
!                       return is_array($proj) ? $proj['title'] : '';
!               }
! 
!               function readProj($proj_id)
!               {
!                       if ($proj_id)
!                       {
!                               if (!is_object($this->projects) && 
file_exists(PHPGW_SERVER_ROOT.'/projects'))
!                               {
!                                       $this->projects = 
createobject('projects.boprojects');
!                               }
!                               if (is_object($this->projects) && ($proj = 
$this->projects->read_single_project( $proj_id)))
!                               {
!                                       return $proj;
!                               }
!                       }
!                       return False;
!               }
! 
!               function readAddr($addr_id)
!               {
!                       if ($addr_id)
!                       {
!                               if (!is_object($this->contacts))
!                               {
!                                       $this->contacts = 
createobject('phpgwapi.contacts');
!                               }
!                               if (list( $addr ) = 
$this->contacts->read_single_entry( $addr_id ))
!                               {
!                                       return $addr;
!                               }
!                       }
!                       return False;
!               }
! 
!               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;
!               }
! 
!               /*
!                * check's if user has the requiered rights on entry $info_id
!                */
!               function check_access( $info_id,$required_rights )
!               {
!                       return $this->so->check_access( 
$info_id,$required_rights );
!               }
! 
!               function init()
!               {
!                       $this->so->init();
!               }      
! 
!               function read($info_id)
!               {
!                       $this->so->read($info_id);
!                               
!                       if ($this->so->data['info_subject'] ==
!                                (substr($this->so->data['info_des'],0,60).' 
...'))
!                       {
!                               $this->so->data['info_subject'] = '';
!                       }
!                       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'] = '';
!                       }
!                       return $this->so->data;
!               }
! 
!               function delete($info_id)
!               {
!                       $this->delete_attached($info_id);
! 
!                       $this->so->delete($info_id);
!               }
! 
!               function write($values)
!               {
!                       if ($values['responsible'] && $values['status'] == 
'offer')
!                       {
!                               $values['status'] = 'ongoing';   // have to 
match if not finished
!                       }
!                       if (!$values['info_id'] && !$values['owner'])
!                       {
!                               $values['owner'] = $this->so->user;
!                       }
!                       $values['datemodified'] = time();
! 
!                       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'] ));
!                       }
!                       $this->so->write($values);
!               }
! 
!               function anzSubs( $info_id )
!               {
!                       return $this->so->anzSubs( $info_id );
!               }
! 
!               function 
readIdArray($order,$sort,$filter,$cat_id,$query,$action,$action_id,
!                                                                       
$ordermethod,&$start,&$total)
!               {
!                       return 
$this->so->readIdArray($order,$sort,$filter,$cat_id,$query,
!                                                                               
                        $action,$action_id,$ordermethod,$start,$total);
!               }
! 
! 
!               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
!               */
!               function 
attach_file($info_id,$filepos,$name,$size,$type,$comment='',$full_fname='',$ip='')
!               {
!                       //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";
! 
!                       // 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 '/'
!                               @reset($this->link_pathes);
!                               while ((list($valid,$trans) = 
@each($this->link_pathes)) && !$tfname)
!                               {  // check case-insensitive for WIN etc.
!                                       $check = $valid[0] == '\\' || 
strstr(':',$valid) ? 'eregi' : 'ereg';
!                                       $valid2 = str_replace('\\','/',$valid);
!                                       //echo "<p>attach_file: 
ereg('".$this->send_file_ips[$valid]."', 
'$ip')=".ereg($this->send_file_ips[$valid],$ip)."</p>\n";
!                                       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];
!                                       }
!                                       //echo "<p>attach_file: 
full_fname='$full_fname', valid2='$valid2', trans='$trans', check=$check, 
tfname='$tfname', parts=(x,'${parts[1]}','${parts[2]}')</p>\n";
!                               }
!                               if ($tfname && 
!$this->vfs->securitycheck($tfname))
!                               {
!                                       return lang('Invalid filename').': 
'.$tfname;
!                               }
!                       }
!                       $this->vfs->override_acl = 1;
!                       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'));
!                       $this->vfs->override_acl = 0;
!               }
! 
!               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)
!               {
!                       $this->vfs->override_acl = 1;
!                       $attachments = 
$this->vfs->ls($this->vfs_path($info_id,$filename),array(REALTIVE_NONE));
!                       $this->vfs->override_acl = 0;
! 
!                       if (!count($attachments) || !$attachments[0]['name'])
!                       {
!                               return False;
!                       }
!                       return $attachments[0];
!               }
! 
!               function list_attached($info_id)
!               {
!                       $this->vfs->override_acl = 1;
!                       $attachments = 
$this->vfs->ls($this->vfs_path($info_id),array(REALTIVE_NONE));
!                       $this->vfs->override_acl = 0;
! 
!                       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;
!                       }
!                       $this->vfs->override_acl = 1;
!                       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;
!               }
!               /*!
!               @function link_title
!               @syntax link_title(  $id  )
!               @author ralfbecker
!               @abstract get title for an infolog entry identified by $id
!               */
!               function link_title( $info )
!               {
!                       if (!is_array($info))
!                       {
!                               $info = $this->read( $info );
!                       }
!                       return $info['info_subject'];
!               }
! 
!               /*!
!               @function link_query
!               @syntax link_query(  $pattern  )
!               @author ralfbecker
!               @abstract query infolog for entries matching $pattern
!               */
!               function link_query( $pattern )
!               {
!                       $start = $total = 0;
!                       $ids = 
$this->readIdArray('','','','',$pattern,'','','',&$start,&$total);
!                       $content = array();
!                       while (is_array($ids) && list( $id,$parent ) = each( 
$ids ))
!                       {
!                               $content[$id] = $this->link_title($id);
!                       }
!                       return $content;
!               }
!       }
--- 1,488 ----
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - InfoLog                                                
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Ralf Becker <address@hidden>                  *
!       * originaly based on todo written by Joseph Engo <address@hidden>  *
!       * --------------------------------------------                          
   *
!       *  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,
!                       'accountInfo'    => True,       // in class boinfolog 
(this class)
!                       'addr2name'      => True,
!                       'attach_file'    => True,
!                       'delete_attached'=> True,
!                       'info_attached'  => True,
!                       'list_attached'  => True,
!                       'read_attached'  => True,
!                       'attached_local' => True,
!                       'link_title'     => True,
!                       'link_query'     => True
!               );
!               var $enums;
!               var $so;
!               var $vfs;
!               var $vfs_basedir='/infolog';
!               var $valid_pathes = array();
!               var $send_file_ips = array();
! 
!               function boinfolog( $info_id = 0)
!               {
!                       $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 */ 
)
!                       );
!                       $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'
!                       ));
! 
!                       $this->so = CreateObject('infolog.soinfolog');
!                       $this->vfs = CreateObject('infolog.vfs');
! 
!                       $this->config = CreateObject('phpgwapi.config');
!                       $this->config->read_repository();
! 
!                       if ($this->config->config_data)
!                       {
!                               $this->link_pathes   = 
unserialize($this->config->config_data['link_pathes']);
!                               $this->send_file_ips = 
unserialize($this->config->config_data['send_file_ips']);
!                       }
! 
!                       $this->read( $info_id);
!               }
! 
!               function accountInfo($id,$account_data=0)
!               {
!                       if (!$id) return '&nbsp;';
! 
!                       if (!is_array($account_data))
!                       {
!                               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];
!                       }
!                       if 
($GLOBALS['phpgw_info']['user']['preferences']['infolog']['longNames'])
!                       {
!                               return $account_data['firstname'].' 
'.$account_data['lastname'];
!                       }
!                       return $account_data['account_lid'];
!               }
! 
!               function addr2name( $addr )
!               {
!                       if (!is_array($addr) && !($addr = 
$this->readAddr($addr)))
!                       {
!                               return '';
!                       }
!                       $name = $addr['n_family'];
!                       if ($addr['n_given'])
!                       {
!                               $name .= ', '.$addr['n_given'];
!                       }
!                       else
!                       {
!                               if ($addr['n_prefix'])
!                               {
!                                       $name .= ', '.$addr['n_prefix'];
!                               }
!                       }
!                       if ($addr['org_name'])
!                       {
!                               $name = $addr['org_name'].': '.$name;
!                       }
!                       return $GLOBALS['phpgw']->strip_html($name);
!               }
! 
!               function proj2name( $proj )
!               {
!                       if (!is_array($proj))
!                       {
!                               $proj = $this->readProj($proj);
!                       }
!                       return is_array($proj) ? $proj['title'] : '';
!               }
! 
!               function readProj($proj_id)
!               {
!                       if ($proj_id)
!                       {
!                               if (!is_object($this->projects) && 
file_exists(PHPGW_SERVER_ROOT.'/projects'))
!                               {
!                                       $this->projects = 
createobject('projects.boprojects');
!                               }
!                               if (is_object($this->projects) && ($proj = 
$this->projects->read_single_project( $proj_id)))
!                               {
!                                       return $proj;
!                               }
!                       }
!                       return False;
!               }
! 
!               function readAddr($addr_id)
!               {
!                       if ($addr_id)
!                       {
!                               if (!is_object($this->contacts))
!                               {
!                                       $this->contacts = 
createobject('phpgwapi.contacts');
!                               }
!                               if (list( $addr ) = 
$this->contacts->read_single_entry( $addr_id ))
!                               {
!                                       return $addr;
!                               }
!                       }
!                       return False;
!               }
! 
!               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;
!               }
! 
!               /*
!                * check's if user has the requiered rights on entry $info_id
!                */
!               function check_access( $info_id,$required_rights )
!               {
!                       return $this->so->check_access( 
$info_id,$required_rights );
!               }
! 
!               function init()
!               {
!                       $this->so->init();
!               }      
! 
!               function read($info_id)
!               {
!                       $this->so->read($info_id);
!                               
!                       if ($this->so->data['info_subject'] ==
!                                (substr($this->so->data['info_des'],0,60).' 
...'))
!                       {
!                               $this->so->data['info_subject'] = '';
!                       }
!                       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'] = '';
!                       }
!                       return $this->so->data;
!               }
! 
!               function delete($info_id)
!               {
!                       $this->delete_attached($info_id);
! 
!                       $this->so->delete($info_id);
!               }
! 
!               function write($values)
!               {
!                       while (list($key,$val) = each($values))
!                       {
!                               if (substr($key,0,5) != 'info_')
!                               {
!                                       $values['info_'.$key] = $val;
!                                       unset($values[$key]);
!                               }
!                       }
!                       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;
!                       }
!                       $values['info_datemodified'] = time();
! 
!                       if (!$values['info_subject'])
!                       {
!                               $values['info_subject'] = 
substr($values['info_des'],0,60).' ...';
!                       }
!                       if ($values['info_addr_id'] && !$values['info_from'])
!                       {
!                               $values['info_from'] = $this->addr2name( 
$this->readAddr( $values['info_addr_id'] ));
!                       }
!                       $this->so->write($values);
!               }
! 
!               function anzSubs( $info_id )
!               {
!                       return $this->so->anzSubs( $info_id );
!               }
! 
!               function 
readIdArray($order,$sort,$filter,$cat_id,$query,$action,$action_id,
!                                                                       
$ordermethod,&$start,&$total)
!               {
!                       return 
$this->so->readIdArray($order,$sort,$filter,$cat_id,$query,
!                                                                               
                        $action,$action_id,$ordermethod,$start,$total);
!               }
! 
! 
!               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
!               */
!               function 
attach_file($info_id,$filepos,$name,$size,$type,$comment='',$full_fname='',$ip='')
!               {
!                       //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";
! 
!                       // 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 '/'
!                               @reset($this->link_pathes);
!                               while ((list($valid,$trans) = 
@each($this->link_pathes)) && !$tfname)
!                               {  // check case-insensitive for WIN etc.
!                                       $check = $valid[0] == '\\' || 
strstr(':',$valid) ? 'eregi' : 'ereg';
!                                       $valid2 = str_replace('\\','/',$valid);
!                                       //echo "<p>attach_file: 
ereg('".$this->send_file_ips[$valid]."', 
'$ip')=".ereg($this->send_file_ips[$valid],$ip)."</p>\n";
!                                       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];
!                                       }
!                                       //echo "<p>attach_file: 
full_fname='$full_fname', valid2='$valid2', trans='$trans', check=$check, 
tfname='$tfname', parts=(x,'${parts[1]}','${parts[2]}')</p>\n";
!                               }
!                               if ($tfname && 
!$this->vfs->securitycheck($tfname))
!                               {
!                                       return lang('Invalid filename').': 
'.$tfname;
!                               }
!                       }
!                       $this->vfs->override_acl = 1;
!                       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'));
!                       $this->vfs->override_acl = 0;
!               }
! 
!               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)
!               {
!                       $this->vfs->override_acl = 1;
!                       $attachments = 
$this->vfs->ls($this->vfs_path($info_id,$filename),array(REALTIVE_NONE));
!                       $this->vfs->override_acl = 0;
! 
!                       if (!count($attachments) || !$attachments[0]['name'])
!                       {
!                               return False;
!                       }
!                       return $attachments[0];
!               }
! 
!               function list_attached($info_id)
!               {
!                       $this->vfs->override_acl = 1;
!                       $attachments = 
$this->vfs->ls($this->vfs_path($info_id),array(REALTIVE_NONE));
!                       $this->vfs->override_acl = 0;
! 
!                       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;
!                       }
!                       $this->vfs->override_acl = 1;
!                       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;
!               }
!               /*!
!               @function link_title
!               @syntax link_title(  $id  )
!               @author ralfbecker
!               @abstract get title for an infolog entry identified by $id
!               */
!               function link_title( $info )
!               {
!                       if (!is_array($info))
!                       {
!                               $info = $this->read( $info );
!                       }
!                       return $info['info_subject'];
!               }
! 
!               /*!
!               @function link_query
!               @syntax link_query(  $pattern  )
!               @author ralfbecker
!               @abstract query infolog for entries matching $pattern
!               */
!               function link_query( $pattern )
!               {
!                       $start = $total = 0;
!                       $ids = 
$this->readIdArray('','','','',$pattern,'','','',&$start,&$total);
!                       $content = array();
!                       while (is_array($ids) && list( $id,$parent ) = each( 
$ids ))
!                       {
!                               $content[$id] = $this->link_title($id);
!                       }
!                       return $content;
!               }
!       }

Index: class.bolink.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.bolink.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.bolink.inc.php        29 Sep 2002 08:40:51 -0000      1.6
--- class.bolink.inc.php        8 Oct 2002 00:10:02 -0000       1.7
***************
*** 1,438 ****
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - InfoLog Links                                          
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Ralf Becker <address@hidden>                  *
!       * --------------------------------------------                          
   *
!       *  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$ */
! 
!       include_once(PHPGW_INCLUDE_ROOT . '/infolog/inc/class.solink.inc.php');
! 
!       /*!
!       @class bolink
!       @author ralfbecker
!       @abstract generalized linking between entries of phpGroupware apps - BO 
layer
!       @discussion This class is the BO-layer of the links
!       @discussion Links have to ends each pointing to an entry, an entry is a 
double:
!       @discussion app   app-name or directory-name of an phpgw application, 
eg. 'infolog'
!       @discussion id    this is the id, eg. an integer or a tupple like 
'0:INBOX:1234'
!       */
!       class bolink extends solink
!       {
!               var $app_register = array(              // this should be 
setup/extended by setup
!                       'addressbook' => array(
!                               'query' => 'addressbook_query',
!                               'title' => 'addressbook_title',
!                               'view' => array(
!                                       'menuaction' => 
'addressbook.uiaddressbook.view'
!                               ),
!                               'view_id' => 'ab_id'
!                       ),
!                       'projects' => array(
!                               'query' => 'projects_query',
!                               'title' => 'projects_title',
!                               'view' => array (
!                                       'menuaction' => 
'projects.uiprocject.view_project'
!                               ),
!                               'view_id' => 'project_id'
!                       ),
!                       'calendar' => array(
!                               'query' => 'calendar_query',
!                               'title' => 'calendar_title',
!                               'view' => array (
!                                       'menuaction' => 
'calendar.uicalendar.view'
!                               ),
!                               'view_id' => 'cal_id'
!                       ), /*
!                       'email' => array(
!                               'view' => array(
!                                       'menuaction' => 
'email.uimessage.message'
!                               ),
!                               'view_id' => 'msgball[acctnum:folder:msgnum]'   
// id is a tupple/array, fields separated by ':'
!                       ), */
!                       'infolog' => array(
!                               'query' => 'infolog.boinfolog.link_query',
!                               'title' => 'infolog.boinfolog.link_title',
!                               'view' => array(
!                                       'menuaction' => 
'infolog.uiinfolog.get_list',
!                                       'action' => 'sp'
!                               ),
!                               'view_id' => 'info_id',
!                       )
!               );
! 
!               function bolink( )
!               {
!                       $this->solink( );                                       
                // call constructor of derived class
!                       $this->public_functions += array(       // extend the 
public_functions of solink
!                               'query' => True,
!                               'title' => True,
!                               'view'  => True
!                       );
!               }
! 
!               /*!
!               @function link
!               @syntax link(  $app1,$id1,$app2,$id2='',$remark='',$user=0  )
!               @author ralfbecker
!               @abstract creats a link between $app1,$id1 and $app2,$id2 - 
$id1 does NOT need to exist yet
!               @param $app1 app of $id1
!               @param $id1 id of item to linkto or 0 if item not yet created 
or array with links of not created item
!               @param $app2 app of 2.linkend or array with links ($id2 not 
used)
!               @param $remark Remark to be saved with the link (defaults to '')
!               @param $owner Owner of the link (defaults to user)
!               @discussion Does NOT check if link already exists
!               @result db-errno or -1 (for param-error) or 0 for success
!               @result if $id1==0 or already an array: $id1 is array with links
!               */
!               function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0 )
!               {
!                       if ($this->debug)
!                       {
!                               echo 
"<p>bolink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n";
!                       }
!                       if (!$app1 || !$app2 || !$id1 && isarray($id2) || $app1 
== $app2 && $id1 == $id2)
!                       {
!                               return -1;
!                       }
!                       if (is_array($id1) || !$id1)            // create link 
only in $id1 array
!                       {
!                               if (!is_array($id1))
!                               {
!                                       $id1 = array( );
!                               }
!                               $id1["$app2:$id2"] = array(
!                                       'app' => $app2,
!                                       'id'  => $id2,
!                                       'remark' => $remark,
!                                       'owner'  => $owner,
!                                       'link_id' => "$app2:$id2"
!                               );
!                               return 0;
!                       }
!                       if (is_array($app2) && !$id2)
!                       {
!                               reset($app2);
!                               $err = 0;
!                               while (!$err && list(,$link) = each($app2))
!                               {
!                                       $err = 
solink::link($app1,$id1,$link['app'],$link['id'],$link['remark'],$link['owner']);
!                               }
!                               return $err;
!                       }
!                       return 
solink::link($app1,$id1,$app2,$id2,$remark,$owner);
!               }
! 
!               /*!
!               @function get_links
!               @syntax get_links(  
$app,$id,$only_app='',$only_name='',$order='link_lastmod DESC'  )
!               @author ralfbecker
!               @abstract returns array of links to $app,$id (reimplemented to 
deal with not yet created items)
!               @param $id id of entry in $app or array of links if entry not 
yet created
!               @param $only_app if set return only links from $only_app (eg. 
only addressbook-entries) or NOT from if $only_app[0]=='!'
!               @param $order defaults to newest links first
!               @result array of links or empty array if no matching links found
!               */
!               function get_links( $app,$id,$only_app='',$order='link_lastmod 
DESC' )
!               {
!                       if (is_array($id) || !$id)
!                       {
!                               $ids = array();
!                               if (is_array($id))
!                               {
!                                       if ($not_only = $only_app[0])
!                                       {
!                                               $only_app = substr(1,$only_app);
!                                       }
!                                       reset($id);
!                                       while (list($key,$link) = each($id))
!                                       {
!                                               if ($only_app && $not_only == 
($link['app'] == $only_app))
!                                               {
!                                                       continue;
!                                               }
!                                               $ids[$key] = $link;
!                                       }
!                               }
!                               return $ids;
!                       }
!                       return solink::get_links($app,$id,$only_app,$order);
!               }
! 
!               /*!
!       @function unlink
!       @syntax unlink( $link_id,$app='',$id='',$owner='' )
!       @author ralfbecker
!               @abstract Remove link with $link_id or all links matching given 
$app,$id
!               @param $link_id link-id to remove if > 0
!               @param $app,$id,$owner if $link_id <= 0: removes all links 
matching the non-empty params
!               @discussion Note: if $link_id != '' and $id is an array: unlink 
removes links from that array only
!               @discussion       unlink has to be called with &$id so see the 
result !!!
!               @result the number of links deleted
!               */
!               function unlink($link_id,$app='',$id='',$owner='')
!               {
!                       if ($link_id > 0 || !is_array($id))
!                       {
!                               return solink::unlink($link_id,$app,$id,$owner);
!                       }
!                       $result = isset($id[$link_id]);
! 
!                       unset($id[$link_id]);
! 
!                       return $result;
!               }
! 
!               /*!
!               @function app_list
!               @syntax app_list(   )
!               @author ralfbecker
!               @abstrac get list/array of link-aware apps
!               @result array( $app => lang($app), ... )
!               */
!               function app_list( )
!               {
!                       reset ($this->app_register);
!                       $apps = array();
!                       while (list($app,$reg) = each($this->app_register))
!                       {
!                               $apps[$app] = lang($app);
!                       }
!                       return $apps;
!               }
! 
!               function check_method($method,&$class,&$func)
!               {
!                       // Idea: check if method exist and cache the class
!               }
! 
!               /*!
!               @function query
!               @syntax query( $app,$pattern )
!               @author ralfbecker
!               @abstract Searches for a $pattern in the entries of $app
!               @result an array of $id => $title pairs
!               */
!               function query($app,$pattern)
!               {
!                       if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['query']))
!                       {
!                               return array();
!                       }
!                       $method = $reg['query'];
! 
!                       if ($this->debug)
!                       {
!                               echo "<p>bolink.query('$app','$pattern') => 
'$method'</p>\n";
!                       }
!                       return strchr($method,'.') ? 
ExecMethod($method,$pattern) : $this->$method($pattern);
!               }
! 
!               /*!
!               @function title
!               @syntax title( $app,$id )
!               @author ralfbecker
!               @abstract returns the title (short description) of entry $id 
and $app
!               @result the title
!               */
!               function title($app,$id)
!               {
!                       if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['title']))
!                       {
!                               return array();
!                       }
!                       $method = $reg['title'];
! 
!                       return strchr($method,'.') ? ExecMethod($method,$id) : 
$this->$method($id);
!               }
! 
!               /*!
!               @function view
!               @syntax view( $app,$id )
!               @author ralfbecker
!               @abstract view entry $id of $app
!               @result array with name-value pairs for link to view-methode of 
$app to view $id
!               */
!               function view($app,$id)
!               {
!                       if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['view']) || !isset($reg['view_id']))
!                       {
!                               return array();
!                       }
!                       $view = $reg['view'];
! 
!                       $names = explode(':',$reg['view_id']);
!                       if (count($names) > 1)
!                       {
!                               $id = explode(':',$id);
!                               while (list($n,$name) = each($names))
!                               {
!                                       $view[$name] = $id[$n];
!                               }
!                       }
!                       else
!                       {
!                               $view[$reg['view_id']] = $id;
!                       }
!                       return $view;
!               }
! 
!               /*!
!               @function calendar_title
!               @syntax calendar_title(  $id  )
!               @author ralfbecker
!               @abstract get title for an event, should be moved to 
bocalendar.link_title
!               */
!               function calendar_title( $event )
!               {
!                       if (!is_object($this->bocal))
!                       {
!                               $this->bocal = 
createobject('calendar.bocalendar');
!                       }
!                       if (!is_array($event) && (int) $event > 0)
!                       {
!                               $event = $this->bocal->read_entry($event);
!                       }
!                       if (!is_array($event))
!                       {
!                               return 'not an event !!!';
!                       }
!                       $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 calendar_query
!               @syntax calendar_query(  $pattern  )
!               @author ralfbecker
!               @abstract query calendar for an event $matching pattern, should 
be moved to bocalendar.link_query
!               */
!               function calendar_query($pattern)
!               {
!                       if (!is_object($this->bocal))
!                       {
!                               $this->bocal = 
createobject('calendar.bocalendar');
!                       }
!                       $event_ids = $this->bocal->search_keywords($pattern);
! 
!                       $content = array( );
!                       while (is_array($event_ids) && list( $key,$id ) = each( 
$event_ids ))
!                       {
!                               $content[$id] = $this->calendar_title( $id );
!                       }
!                       return $content;
!               }
! 
!               /*!
!               @function addressbook_title
!               @syntax addressbook_title(  $id  )
!               @author ralfbecker
!               @abstract get title for an address, should be moved to 
boaddressbook.link_title
!               */
!               function addressbook_title( $addr )
!               {
!                       if (!is_object($this->contacts))
!                       {
!                               $this->contacts = 
createobject('phpgwapi.contacts');
!                       }
!                       if (!is_array($addr))
!                       {
!                               list( $addr ) = 
$this->contacts->read_single_entry( $addr );
!                       }
!                       $name = $addr['n_family'];
!                       if ($addr['n_given'])
!                       {
!                               $name .= ', '.$addr['n_given'];
!                       }
!                       else
!                       {
!                               if ($addr['n_prefix'])
!                               {
!                                       $name .= ', '.$addr['n_prefix'];
!                               }
!                       }
!                       if ($addr['org_name'])
!                       {
!                               $name = $addr['org_name'].': '.$name;
!                       }
!                       return $GLOBALS['phpgw']->strip_html($name);
!               }
! 
!               /*!
!               @function addressbook_query
!               @syntax addressbook_query(  $pattern  )
!               @author ralfbecker
!               @abstract query addressbook for $pattern, should be moved to 
boaddressbook.link_query
!               */
!               function addressbook_query( $pattern )
!               {
!                       if (!is_object($this->contacts))
!                       {
!                               $this->contacts = 
createobject('phpgwapi.contacts');
!                       }
!                       $addrs = $this->contacts->read( 
0,0,'',$pattern,'','DESC','org_name,n_family,n_given' );
!                       $content = array( );
!                       while ($addrs && list( $key,$addr ) = each( $addrs ))
!                       {
!                               $content[$addr['id']] = 
$this->addressbook_title( $addr );
!                       }
!                       return $content;
!               }
! 
!               /*!
!               @function projects_title
!               @syntax projects_title(  $id  )
!               @author ralfbecker
!               @abstract get title for a project, should be moved to 
boprojects.link_title
!               */
!               function projects_title( $proj )
!               {
!                       if (!is_object($this->boprojects))
!                       {
!                               if 
(!file_exists(PHPGW_SERVER_ROOT.'/projects'))        // check if projects 
installed
!                                       return '';
!                               $this->boprojects = 
createobject('projects.boprojects');
!                       }
!                       if (!is_array($proj))
!                       {
!                               $proj = $this->boprojects->read_single_project( 
$proj );
!                       }
!                       return $proj['title'];
!               }
! 
!               /*!
!               @function projects_query
!               @syntax projects_query(  $pattern  )
!               @author ralfbecker
!               @abstract query for projects matching $pattern, should be moved 
to boprojects.link_query
!               */
!               function projects_query( $pattern )
!               {
!                       if (!is_object($this->boprojects))
!                       {
!                               if 
(!file_exists(PHPGW_SERVER_ROOT.'/projects'))        // check if projects 
installed
!                                       return array();
!                               $this->boprojects = 
createobject('projects.boprojects');
!                       }
!                       $projs = $this->boprojects->list_projects( 
0,0,$pattern,'','','','',0,'mains','' );
!                       $content = array();
!                       while ($projs && list( $key,$proj ) = each( $projs ))
!                       {
!                               $content[$proj['project_id']] = 
$this->projects_title($proj);
!                       }
!                       return $content;
!               }
!       }
! 
! 
! 
! 
--- 1,438 ----
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - InfoLog Links                                          
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Ralf Becker <address@hidden>                  *
!       * --------------------------------------------                          
   *
!       *  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$ */
! 
!       include_once(PHPGW_INCLUDE_ROOT . '/infolog/inc/class.solink.inc.php');
! 
!       /*!
!       @class bolink
!       @author ralfbecker
!       @abstract generalized linking between entries of phpGroupware apps - BO 
layer
!       @discussion This class is the BO-layer of the links
!       @discussion Links have to ends each pointing to an entry, an entry is a 
double:
!       @discussion app   app-name or directory-name of an phpgw application, 
eg. 'infolog'
!       @discussion id    this is the id, eg. an integer or a tupple like 
'0:INBOX:1234'
!       */
!       class bolink extends solink
!       {
!               var $app_register = array(              // this should be 
setup/extended by setup
!                       'addressbook' => array(
!                               'query' => 'addressbook_query',
!                               'title' => 'addressbook_title',
!                               'view' => array(
!                                       'menuaction' => 
'addressbook.uiaddressbook.view'
!                               ),
!                               'view_id' => 'ab_id'
!                       ),
!                       'projects' => array(
!                               'query' => 'projects_query',
!                               'title' => 'projects_title',
!                               'view' => array (
!                                       'menuaction' => 
'projects.uiprocject.view_project'
!                               ),
!                               'view_id' => 'project_id'
!                       ),
!                       'calendar' => array(
!                               'query' => 'calendar_query',
!                               'title' => 'calendar_title',
!                               'view' => array (
!                                       'menuaction' => 
'calendar.uicalendar.view'
!                               ),
!                               'view_id' => 'cal_id'
!                       ), /*
!                       'email' => array(
!                               'view' => array(
!                                       'menuaction' => 
'email.uimessage.message'
!                               ),
!                               'view_id' => 'msgball[acctnum:folder:msgnum]'   
// id is a tupple/array, fields separated by ':'
!                       ), */
!                       'infolog' => array(
!                               'query' => 'infolog.boinfolog.link_query',
!                               'title' => 'infolog.boinfolog.link_title',
!                               'view' => array(
!                                       'menuaction' => 
'infolog.uiinfolog.get_list',
!                                       'action' => 'sp'
!                               ),
!                               'view_id' => 'info_id',
!                       )
!               );
! 
!               function bolink( )
!               {
!                       $this->solink( );                                       
                // call constructor of derived class
!                       $this->public_functions += array(       // extend the 
public_functions of solink
!                               'query' => True,
!                               'title' => True,
!                               'view'  => True
!                       );
!               }
! 
!               /*!
!               @function link
!               @syntax link(  $app1,$id1,$app2,$id2='',$remark='',$user=0  )
!               @author ralfbecker
!               @abstract creats a link between $app1,$id1 and $app2,$id2 - 
$id1 does NOT need to exist yet
!               @param $app1 app of $id1
!               @param $id1 id of item to linkto or 0 if item not yet created 
or array with links of not created item
!               @param $app2 app of 2.linkend or array with links ($id2 not 
used)
!               @param $remark Remark to be saved with the link (defaults to '')
!               @param $owner Owner of the link (defaults to user)
!               @discussion Does NOT check if link already exists
!               @result db-errno or -1 (for param-error) or 0 for success
!               @result if $id1==0 or already an array: $id1 is array with links
!               */
!               function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0 )
!               {
!                       if ($this->debug)
!                       {
!                               echo 
"<p>bolink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n";
!                       }
!                       if (!$app1 || !$app2 || !$id1 && is_array($id2) || 
$app1 == $app2 && $id1 == $id2)
!                       {
!                               return -1;
!                       }
!                       if (is_array($id1) || !$id1)            // create link 
only in $id1 array
!                       {
!                               if (!is_array($id1))
!                               {
!                                       $id1 = array( );
!                               }
!                               $id1["$app2:$id2"] = array(
!                                       'app' => $app2,
!                                       'id'  => $id2,
!                                       'remark' => $remark,
!                                       'owner'  => $owner,
!                                       'link_id' => "$app2:$id2"
!                               );
!                               return 0;
!                       }
!                       if (is_array($app2) && !$id2)
!                       {
!                               reset($app2);
!                               $err = 0;
!                               while (!$err && list(,$link) = each($app2))
!                               {
!                                       $err = 
solink::link($app1,$id1,$link['app'],$link['id'],$link['remark'],$link['owner']);
!                               }
!                               return $err;
!                       }
!                       return 
solink::link($app1,$id1,$app2,$id2,$remark,$owner);
!               }
! 
!               /*!
!               @function get_links
!               @syntax get_links(  
$app,$id,$only_app='',$only_name='',$order='link_lastmod DESC'  )
!               @author ralfbecker
!               @abstract returns array of links to $app,$id (reimplemented to 
deal with not yet created items)
!               @param $id id of entry in $app or array of links if entry not 
yet created
!               @param $only_app if set return only links from $only_app (eg. 
only addressbook-entries) or NOT from if $only_app[0]=='!'
!               @param $order defaults to newest links first
!               @result array of links or empty array if no matching links found
!               */
!               function get_links( $app,$id,$only_app='',$order='link_lastmod 
DESC' )
!               {
!                       if (is_array($id) || !$id)
!                       {
!                               $ids = array();
!                               if (is_array($id))
!                               {
!                                       if ($not_only = $only_app[0])
!                                       {
!                                               $only_app = substr(1,$only_app);
!                                       }
!                                       reset($id);
!                                       while (list($key,$link) = each($id))
!                                       {
!                                               if ($only_app && $not_only == 
($link['app'] == $only_app))
!                                               {
!                                                       continue;
!                                               }
!                                               $ids[$key] = $link;
!                                       }
!                               }
!                               return $ids;
!                       }
!                       return solink::get_links($app,$id,$only_app,$order);
!               }
! 
!               /*!
!       @function unlink
!       @syntax unlink( $link_id,$app='',$id='',$owner='' )
!       @author ralfbecker
!               @abstract Remove link with $link_id or all links matching given 
$app,$id
!               @param $link_id link-id to remove if > 0
!               @param $app,$id,$owner if $link_id <= 0: removes all links 
matching the non-empty params
!               @discussion Note: if $link_id != '' and $id is an array: unlink 
removes links from that array only
!               @discussion       unlink has to be called with &$id so see the 
result !!!
!               @result the number of links deleted
!               */
!               function unlink($link_id,$app='',$id='',$owner='')
!               {
!                       if ($link_id > 0 || !is_array($id))
!                       {
!                               return solink::unlink($link_id,$app,$id,$owner);
!                       }
!                       $result = isset($id[$link_id]);
! 
!                       unset($id[$link_id]);
! 
!                       return $result;
!               }
! 
!               /*!
!               @function app_list
!               @syntax app_list(   )
!               @author ralfbecker
!               @abstrac get list/array of link-aware apps
!               @result array( $app => lang($app), ... )
!               */
!               function app_list( )
!               {
!                       reset ($this->app_register);
!                       $apps = array();
!                       while (list($app,$reg) = each($this->app_register))
!                       {
!                               $apps[$app] = lang($app);
!                       }
!                       return $apps;
!               }
! 
!               function check_method($method,&$class,&$func)
!               {
!                       // Idea: check if method exist and cache the class
!               }
! 
!               /*!
!               @function query
!               @syntax query( $app,$pattern )
!               @author ralfbecker
!               @abstract Searches for a $pattern in the entries of $app
!               @result an array of $id => $title pairs
!               */
!               function query($app,$pattern)
!               {
!                       if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['query']))
!                       {
!                               return array();
!                       }
!                       $method = $reg['query'];
! 
!                       if ($this->debug)
!                       {
!                               echo "<p>bolink.query('$app','$pattern') => 
'$method'</p>\n";
!                       }
!                       return strchr($method,'.') ? 
ExecMethod($method,$pattern) : $this->$method($pattern);
!               }
! 
!               /*!
!               @function title
!               @syntax title( $app,$id )
!               @author ralfbecker
!               @abstract returns the title (short description) of entry $id 
and $app
!               @result the title
!               */
!               function title($app,$id)
!               {
!                       if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['title']))
!                       {
!                               return array();
!                       }
!                       $method = $reg['title'];
! 
!                       return strchr($method,'.') ? ExecMethod($method,$id) : 
$this->$method($id);
!               }
! 
!               /*!
!               @function view
!               @syntax view( $app,$id )
!               @author ralfbecker
!               @abstract view entry $id of $app
!               @result array with name-value pairs for link to view-methode of 
$app to view $id
!               */
!               function view($app,$id)
!               {
!                       if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['view']) || !isset($reg['view_id']))
!                       {
!                               return array();
!                       }
!                       $view = $reg['view'];
! 
!                       $names = explode(':',$reg['view_id']);
!                       if (count($names) > 1)
!                       {
!                               $id = explode(':',$id);
!                               while (list($n,$name) = each($names))
!                               {
!                                       $view[$name] = $id[$n];
!                               }
!                       }
!                       else
!                       {
!                               $view[$reg['view_id']] = $id;
!                       }
!                       return $view;
!               }
! 
!               /*!
!               @function calendar_title
!               @syntax calendar_title(  $id  )
!               @author ralfbecker
!               @abstract get title for an event, should be moved to 
bocalendar.link_title
!               */
!               function calendar_title( $event )
!               {
!                       if (!is_object($this->bocal))
!                       {
!                               $this->bocal = 
createobject('calendar.bocalendar');
!                       }
!                       if (!is_array($event) && (int) $event > 0)
!                       {
!                               $event = $this->bocal->read_entry($event);
!                       }
!                       if (!is_array($event))
!                       {
!                               return 'not an event !!!';
!                       }
!                       $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 calendar_query
!               @syntax calendar_query(  $pattern  )
!               @author ralfbecker
!               @abstract query calendar for an event $matching pattern, should 
be moved to bocalendar.link_query
!               */
!               function calendar_query($pattern)
!               {
!                       if (!is_object($this->bocal))
!                       {
!                               $this->bocal = 
createobject('calendar.bocalendar');
!                       }
!                       $event_ids = $this->bocal->search_keywords($pattern);
! 
!                       $content = array( );
!                       while (is_array($event_ids) && list( $key,$id ) = each( 
$event_ids ))
!                       {
!                               $content[$id] = $this->calendar_title( $id );
!                       }
!                       return $content;
!               }
! 
!               /*!
!               @function addressbook_title
!               @syntax addressbook_title(  $id  )
!               @author ralfbecker
!               @abstract get title for an address, should be moved to 
boaddressbook.link_title
!               */
!               function addressbook_title( $addr )
!               {
!                       if (!is_object($this->contacts))
!                       {
!                               $this->contacts = 
createobject('phpgwapi.contacts');
!                       }
!                       if (!is_array($addr))
!                       {
!                               list( $addr ) = 
$this->contacts->read_single_entry( $addr );
!                       }
!                       $name = $addr['n_family'];
!                       if ($addr['n_given'])
!                       {
!                               $name .= ', '.$addr['n_given'];
!                       }
!                       else
!                       {
!                               if ($addr['n_prefix'])
!                               {
!                                       $name .= ', '.$addr['n_prefix'];
!                               }
!                       }
!                       if ($addr['org_name'])
!                       {
!                               $name = $addr['org_name'].': '.$name;
!                       }
!                       return $GLOBALS['phpgw']->strip_html($name);
!               }
! 
!               /*!
!               @function addressbook_query
!               @syntax addressbook_query(  $pattern  )
!               @author ralfbecker
!               @abstract query addressbook for $pattern, should be moved to 
boaddressbook.link_query
!               */
!               function addressbook_query( $pattern )
!               {
!                       if (!is_object($this->contacts))
!                       {
!                               $this->contacts = 
createobject('phpgwapi.contacts');
!                       }
!                       $addrs = $this->contacts->read( 
0,0,'',$pattern,'','DESC','org_name,n_family,n_given' );
!                       $content = array( );
!                       while ($addrs && list( $key,$addr ) = each( $addrs ))
!                       {
!                               $content[$addr['id']] = 
$this->addressbook_title( $addr );
!                       }
!                       return $content;
!               }
! 
!               /*!
!               @function projects_title
!               @syntax projects_title(  $id  )
!               @author ralfbecker
!               @abstract get title for a project, should be moved to 
boprojects.link_title
!               */
!               function projects_title( $proj )
!               {
!                       if (!is_object($this->boprojects))
!                       {
!                               if 
(!file_exists(PHPGW_SERVER_ROOT.'/projects'))        // check if projects 
installed
!                                       return '';
!                               $this->boprojects = 
createobject('projects.boprojects');
!                       }
!                       if (!is_array($proj))
!                       {
!                               $proj = $this->boprojects->read_single_project( 
$proj );
!                       }
!                       return $proj['title'];
!               }
! 
!               /*!
!               @function projects_query
!               @syntax projects_query(  $pattern  )
!               @author ralfbecker
!               @abstract query for projects matching $pattern, should be moved 
to boprojects.link_query
!               */
!               function projects_query( $pattern )
!               {
!                       if (!is_object($this->boprojects))
!                       {
!                               if 
(!file_exists(PHPGW_SERVER_ROOT.'/projects'))        // check if projects 
installed
!                                       return array();
!                               $this->boprojects = 
createobject('projects.boprojects');
!                       }
!                       $projs = $this->boprojects->list_projects( 
0,0,$pattern,'','','','',0,'mains','' );
!                       $content = array();
!                       while ($projs && list( $key,$proj ) = each( $projs ))
!                       {
!                               $content[$proj['project_id']] = 
$this->projects_title($proj);
!                       }
!                       return $content;
!               }
!       }
! 
! 
! 
! 

Index: class.linklist_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.linklist_widget.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.linklist_widget.inc.php       24 Sep 2002 22:02:20 -0000      1.1
--- class.linklist_widget.inc.php       8 Oct 2002 00:10:02 -0000       1.2
***************
*** 32,50 ****
                }
  
!               function 
pre_process(&$cell,&$value,&$extension_data,&$readonlys)
                {
!                       $app = $value['app'] = 'addressbook';
!                       $id  = $value['id']  = 921;
                        //echo "<p>linklist_widget.preprocess: app='$app', 
id='$id', value="; _debug_array($value);
  
                        if (!$value['title'])
                        {
!                               $value['title'] = $this->link->title($app,$id);
                        }
                        $extension_data = $value;
  
                        $links = $this->link->get_links($app,$id);
! 
!                       for($row=1; list(,$link) = each($links); ++$row)
                        {
                                $value[$row] = $link;
--- 32,59 ----
                }
  
!               function 
pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
                {
!                       if (!is_array($value))
!                       {
!                               $value = array('to_id' => $value,'to_app' => 
$GLOBALS['phpgw_info']['flags']['currentapp']);
!                       }
!                       $app = $value['to_app'];
!                       $id  = $value['to_id'];
                        //echo "<p>linklist_widget.preprocess: app='$app', 
id='$id', value="; _debug_array($value);
  
                        if (!$value['title'])
                        {
!                               $value['title'] = 
$this->link->title($to_app,$to_id);
                        }
                        $extension_data = $value;
  
                        $links = $this->link->get_links($app,$id);
!                       if (!count($links))
!                       {
!                               $cell = $tmpl->empty_cell();
!                               return False;
!                       }
!                       $tpl = new etemplate('infolog.linklist_widget');
!                       for($row=$tpl->rows-1; list(,$link) = each($links); 
++$row)
                        {
                                $value[$row] = $link;
***************
*** 54,62 ****
                        $cell['type'] = 'template';
                        $cell['name'] = 'infolog.linklist_widget';
  
                        return True;    // extra Label is ok
                }
  
!               function post_process(&$cell,&$value,&$extension_data,&$loop)
                {
                        list($unlink) = @each($value['unlink']);
--- 63,72 ----
                        $cell['type'] = 'template';
                        $cell['name'] = 'infolog.linklist_widget';
+                       $cell['obj'] = &$tpl;
  
                        return True;    // extra Label is ok
                }
  
!               function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
                {
                        list($unlink) = @each($value['unlink']);
***************
*** 71,73 ****
                        }
                }
!       }
\ No newline at end of file
--- 81,83 ----
                        }
                }
!       }

Index: class.linkto_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.linkto_widget.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.linkto_widget.inc.php 24 Sep 2002 22:02:20 -0000      1.3
--- class.linkto_widget.inc.php 8 Oct 2002 00:10:02 -0000       1.4
***************
*** 32,42 ****
                }
  
!               function 
pre_process(&$cell,&$value,&$extension_data,&$readonlys)
                {
!                       $search = $value['search'] ? 1 : 0;
!                       $create = $value['create'] ? 1 : 0;
!                       //echo "<p>linkto_widget.preprocess: 
query='$value[query]',app='$value[app]',search=$search,create=$create</p>\n";
  
!                       if ($search && count($ids = 
$this->link->query($value['app'],$value['query'])))
                        {
                                $extension_data['app'] = $value['app'];
--- 32,44 ----
                }
  
!               function 
pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
                {
!                       if (!is_array($value))
!                       {
!                               $value = array('to_id' => $value,'to_app' => 
$GLOBALS['phpgw_info']['flags']['currentapp']);
!                       }
!                       //echo "<p>linkto_widget.preprocess: name='$name', 
query='$value[query]',app='$value[app]',button=$value[button]</p>\n";
  
!                       if ($value['button'] == 'search' && count($ids = 
$this->link->query($value['app'],$value['query'])))
                        {
                                $extension_data['app'] = $value['app'];
***************
*** 51,55 ****
                        else
                        {
!                               if (!$create)
                                {
                                        $extension_data = $value;
--- 53,57 ----
                        else
                        {
!                               if (!$value['button'])
                                {
                                        $extension_data = $value;
***************
*** 59,63 ****
                                        'options-app' => 
$this->link->app_list(),
                                        'query' => $value['query'],
!                                       'msg' => $search ? 'Nothing found - try 
again !!!' : ''
                                );
                                $next = 'search';
--- 61,65 ----
                                        'options-app' => 
$this->link->app_list(),
                                        'query' => $value['query'],
!                                       'msg' => $value['button'] == 'search' ? 
'Nothing found - try again !!!' : ''
                                );
                                $next = 'search';
***************
*** 70,82 ****
                }
  
!               function post_process(&$cell,&$value,&$extension_data,&$loop)
                {
!                       $search = $value['search'] ? 1 : 0;
!                       $create = $value['create'] ? 1 : 0;
!                       list($value['app']) = @$value['app'];   // no 
multiselection
!                       list($value['id'])  = @$value['id'];
!                       //echo "<p>linkto_widget.postprocess: 
query='$value[query]',app='$value[app]',id='$value[id]', 
search=$search,create=$create</p>\n";
  
!                       if ($create)
                        {
                                $value = array_merge($value,$extension_data);
--- 72,93 ----
                }
  
!               function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
                {
!                       if ($value['search'])
!                       {
!                               $button = 'search';
!                       }
!                       elseif ($value['create'])
!                       {
!                               $button = 'create';
!                       }
!                       elseif ($value['new'])
!                       {
!                               $button = 'new';
!                       }
!                       unset($value[$button]);
!                       //echo "<p>linkto_widget.postprocess: 
query='$value[query]',app='$value[app]',id='$value[id]', 
button='$button'</p>\n";
  
!                       if ($button == 'create')
                        {
                                $value = array_merge($value,$extension_data);
***************
*** 87,91 ****
                                }
                        }
!                       $loop = $search || $create;
                }
        }
--- 98,103 ----
                                }
                        }
!                       $value['button'] = $button;
!                       $loop = $button != '';
                }
        }

Index: class.soinfolog.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.soinfolog.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** class.soinfolog.inc.php     1 Sep 2002 20:41:14 -0000       1.13
--- class.soinfolog.inc.php     8 Oct 2002 00:10:02 -0000       1.14
***************
*** 1,337 ****
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - InfoLog                                                
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Ralf Becker <address@hidden>                  *
!       * originaly based on todo written by Joseph Engo <address@hidden>  *
!       * --------------------------------------------                          
   *
!       *  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 soinfolog                                 // DB-Layer
!       {
!               var $db,$db2;
!               var $grants;
!               var $data = array( );
!               var $filters = array( );
!               var $user;
!               var $maybe_slashes = array (
!                       
'info_des'=>1,'info_subject'=>1,'info_from'=>1,'info_addr'=>1
!               );
!               function soinfolog( $info_id = 0)
!               {
!                       $this->db     = $GLOBALS['phpgw']->db;
!                       $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('infolog');
!                       $this->user   = 
$GLOBALS['phpgw_info']['user']['account_id'];
! 
!                       $this->links = CreateObject('infolog.solink');
! 
!                       $this->read( $info_id );
!               }
!                               
! 
!               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;                      
!                               $info = $private_info->read($info_id);
!                       }
!                       else
!                       {
!                               $info = $this->data;
!                       }
!                       if (!$info || !$info_id)
!                       {
!                               return False;
!                       }
!                       $owner = $info['info_owner'];
! 
!                       $access_ok = $owner == $this->user ||                // 
user has all rights
!                                                        // ACL only on public 
entrys || $owner granted _PRIVATE
!                                                        
!!($this->grants[$owner] & $required_rights) &&
!                                                        ($info['info_access'] 
== 'public' ||
!                                                        
!!($this->grants[$owner] & PHPGW_ACL_PRIVATE));   
!                                                       
!                       // echo "check_access(info_id=$info_id (owner=$owner, 
user=$user),required_rights=$required_rights): 
access".($access_ok?"Ok":"Denied");
!                       
!                       return $access_ok;         
!               }
! 
!               // sql to be AND into a query to ensure ACL is respected (incl. 
_PRIVATE)
!               // filter: none|all    - list all entrys user have rights to see
!               //         private|own - list only his personal entrys
!               //                                                      (incl. 
those he is responsible for !!!)            
!               function aclFilter($filter = 'none')
!               {
!                       ereg('.*(own|privat|all|none).*',$filter,$vars);
!                       $filter = $vars[1];
! 
!                       if (isset($this->acl_filter[$filter]))
!                       {
!                               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>";
!                                       if ($grant & 
(PHPGW_ACL_READ|PHPGW_ACL_EDIT))
!                                       {
!                                               $public_user_list[] = $user;
!                                       }
!                                       if ($grant & PHPGW_ACL_PRIVATE)
!                                       {
!                                               $private_user_list[] = $user;
!                                       }
!                               }
!                               if (count($private_user_list))
!                               {               
!                                       $has_private_access = 'info_owner IN ('.
!                                                                               
                 implode(',',$private_user_list).')';
!                               }            
!                       }
!                       $filtermethod = " (info_owner=$this->user"; // user has 
all rights
! 
!                       // private: own entries plus the one user is 
responsible for 
!                       if ($filter == 'private' || $filter == 'own')
!                       {
!                               $filtermethod .= " OR 
(info_responsible=$this->user OR info_status = 'offer')".
!                                                " AND 
(info_access='public'".($has_private_access?" OR $has_private_access":'').')';
!                       }
!                       else                                    // none --> all 
entrys user has rights to see
!                       {
!                               if ($has_private_access)
!                               {
!                                       $filtermethod .= " OR 
$has_private_access";
!                               }
!                               if (count($public_user_list))
!                               { 
!                                       $filtermethod .= " OR 
(info_access='public' AND info_owner IN(" . implode(',',$public_user_list) . 
'))';
!                               }
!                       }
!                       $filtermethod .= ') ';
!                       
!                       return $this->acl_filter[$filter] = $filtermethod;  // 
cache the filter
!               }      
!       
!               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 '';
!               }
! 
!               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)
!                       {
!                               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')";
!                       }
!                       return '';
!               }
! 
!               function init()
!               {
!                       $this->data = array( 'info_owner' => $this->user,
!                                                                               
'info_pri'    => 'normal' );
!               }      
!                               
!               function read($info_id)         // did _not_ ensure ACL
!               {
!                       if ($info_id <= 0 || $info_id != $this->data['info_id'] 
&& 
!                                                                               
(!$this->db->query("select * FROM phpgw_infolog where info_id='$info_id'") ||   
!$this->db->next_record())) 
!                       {
!                               $this->init( );
!                               return False;
!                       }
!                       if ($info_id != $this->data['info_id'])      // data 
yet read in
!                       {
!                               $this->data = $this->db->Record;
!                               reset($this->maybe_slashes);
!                               while (list($key) = each($this->maybe_slashes))
!                               {
!                                       $this->data[$key] = 
stripslashes($this->data[$key]);
!                               }
!                               $links = 
$this->links->get_links('infolog',$this->data['info_id']);
!                               while (list($nul,$link) = each($links))
!                               {
!                                       if ($link['app'] == 'addressbook')
!                                               $this->data['info_addr_id'] = 
$link['id'];
!                                       if ($link['app'] == 'projects')
!                                               $this->data['info_proj_id'] = 
$link['id'];
!                                       if ($link['app'] == 'calendar')
!                                               $this->data['info_event_id'] = 
$link['id'];
!                               }
!                       }
!                       return $this->data;         
!               }
!               
!               function delete($info_id)  // did _not_ ensure ACL
!               {
!                       $this->db->query("delete FROM phpgw_infolog where 
info_id='$info_id' or info_id_parent='"
!                               . "$info_id' AND ((info_access='public' and 
info_owner != '$this->user')"
!                               . " or (info_owner='$this->user'))" 
,__LINE__,__FILE__);
!                               
!                       $this->links->unlink(0,'infolog',$info_id);
! 
!                       if ($this->data['info_id'] == $info_id)
!                       {
!                               $this->init( );            
!                       }
!               }
! 
!               function write($values)  // did _not_ ensure ACL
!               {
!                       while (list($key,$val) = each($values))
!                       {
!                               if ($key != 'info_id')
!                               {
!                                       $key = 'info_'.$key;
! 
!                                       $this->data[$key] = $val;   // update 
internal data
! 
!                                       if ($key == 'info_addr_id' || $key == 
'info_proj_id' || $key == 'info_event_id')
!                                               continue;       // not longer 
in infolog-table
! 
!                                       if ($this->maybe_slashes[$key])
!                                       {
!                                               $val = addslashes($val);
!                                       }
!                                       $cols .= ($cols ? ',' : '').$key;
!                                       $vals .= ($vals ? ',' : '')."'$val'";
!                                       $query .= ($query ? ',' : 
'')."$key='$val'";
!                               }
!                       }
!                       if (($this->data['info_id'] = $values['info_id']) > 0)
!                       {
!                               $query = "UPDATE phpgw_infolog SET $query where 
info_id='".$values['info_id']."'";
!                               $this->db->query($query,__LINE__,__FILE__);
! 
!                               
$this->links->unlink(0,'infolog',$values['info_id']);
!                       }
!                       else
!                       {
!                               $query = "INSERT INTO phpgw_infolog ($cols) 
VALUES ($vals)";
!                               $this->db->query($query,__LINE__,__FILE__);
!                               
$this->data['info_id']=$this->db->get_last_insert_id('phpgw_infolog','info_id');
!                       }
!                       // echo "<p>soinfolog.write values= "; 
_debug_array($values);
!                       // echo "<p>soinfolog.write this->data= "; 
_debug_array($this->data);
!                       if ($this->data['info_addr_id'])
!                               
$this->links->link('infolog',$this->data['info_id'],'addressbook',$this->data['info_addr_id']);
!                       if ($this->data['info_proj_id'])
!                               
$this->links->link('infolog',$this->data['info_id'],'projects',$this->data['info_proj_id']);
!                       if ($this->data['info_event_id'])
!                               
$this->links->link('infolog',$this->data['info_id'],'calendar',$this->data['info_event_id']);
!               }
! 
!               function anzSubs( $info_id )
!               {
!                       $this->db->query('select count(*) FROM phpgw_infolog 
where '.
!                                                                 
"info_id_parent=$info_id",__LINE__,__FILE__);
! 
!                       $this->db->next_record();
! 
!                       return $this->db->f(0);
!               }
! 
!               function 
readIdArray($order,$sort,$filter,$cat_id,$query,$action,$action_id,
!                                                                       
$ordermethod,&$start,&$total)
!               {
!                       //echo 
"<p>soinfolog.readIdArray(action='$action',action_id='$action_id')</p>\n";
!                       $action2app = array(
!                               'addr' => 'addressbook',
!                               'proj' => 'projects',
!                               'event' => 'calendar'
!                       );
!                       if ($action != '' && $action2app[$action] != '')
!                       {
!                               $links = 
$this->links->get_links($action2app[$action],$action_id);
!                               $ids = array();
!                               while (list($nul,$link) = each($links))
!                               {
!                                       $ids[''.$link['id']] = 0;
!                               }
!                               //echo 
"<p>soinfolog.readIdArray($action,$action_id) ids ="; _debug_array($ids);
!                               return $ids;
!                       }
!                       if ($order)
!                       {
!                         $ordermethod = 'order by ' . $order . ' ' . $sort;
!                       }
!                       else
!                       {
!                         $ordermethod = 'order by info_datemodified desc';   
// newest first
!                       }
!                       $filtermethod = $this->aclFilter($filter);
!                       $filtermethod .= $this->statusFilter($filter);
!                       $filtermethod .= $this->dateFilter($filter);
!                       // echo "<p>filtermethod='$filtermethod'</p>";
! 
!                       if ($cat_id)
!                       {
!                         $filtermethod .= " AND info_cat='$cat_id' ";
!                       }
!                       switch ($action)
!                       {
!                               case 'addr':    $filtermethod .= " AND 
info_addr_id=$action_id ";
!                                                                       break;
!                               case 'proj':    $filtermethod .= " AND 
info_proj_id=$action_id ";
!                                                                       break;
!                               case 'event':   $filtermethod .= " AND 
info_event_id=$action_id ";
!                                                                       break;
!                       }
!                       if ($query)                       // we search in 
_from, _subject and _des for $query
!                       {
!                               $sql_query = "AND (info_from like '%$query%' OR 
info_subject ".
!                                                                "like 
'%$query%' OR info_des like '%$query%') ";
!                       }
!                       $pid = 'AND info_id_parent='.($action == 'sp' ? 
$action_id : 0);
! 
!                       if 
(!$phpgw_info['user']['preferences']['infolog']['listNoSubs'] &&
!                                $action != 'sp')
!                       {
!                               $pid = '';
!                       }
!                       $this->db->query("SELECT COUNT(*) FROM phpgw_infolog 
WHERE $filtermethod $pid $sql_query",__LINE__,__FILE__);
! 
!                       $this->db->next_record();
!                       $total = $this->db->f(0);
! 
!                       if (!$start || $start > $total)
!                       {
!                               $start = 0;
!                       }
!                       $this->db->limit_query("SELECT info_id,info_id_parent 
FROM phpgw_infolog WHERE $filtermethod $pid $sql_query 
$ordermethod",$start,__LINE__,__FILE__);
! 
!                       $ids = array( );
!                       while ($this->db->next_record())
!                       {
!                               $ids[$this->db->f('info_id')] = 
$this->db->f('info_id_parent');
!                       }
!                       return $ids;
!               }
!       }
--- 1,339 ----
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - InfoLog                                                
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Ralf Becker <address@hidden>                  *
!       * originaly based on todo written by Joseph Engo <address@hidden>  *
!       * --------------------------------------------                          
   *
!       *  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 soinfolog                                 // DB-Layer
!       {
!               var $db,$db2;
!               var $grants;
!               var $data = array( );
!               var $filters = array( );
!               var $user;
!               var $maybe_slashes = array (
!                       
'info_des'=>1,'info_subject'=>1,'info_from'=>1,'info_addr'=>1
!               );
!               function soinfolog( $info_id = 0)
!               {
!                       $this->db     = $GLOBALS['phpgw']->db;
!                       $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('infolog');
!                       $this->user   = 
$GLOBALS['phpgw_info']['user']['account_id'];
! 
!                       $this->links = CreateObject('infolog.solink');
! 
!                       $this->read( $info_id );
!               }
!                               
! 
!               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;                      
!                               $info = $private_info->read($info_id);
!                       }
!                       else
!                       {
!                               $info = $this->data;
!                       }
!                       if (!$info || !$info_id)
!                       {
!                               return False;
!                       }
!                       $owner = $info['info_owner'];
! 
!                       $access_ok = $owner == $this->user ||                // 
user has all rights
!                                                        // ACL only on public 
entrys || $owner granted _PRIVATE
!                                                        
!!($this->grants[$owner] & $required_rights) &&
!                                                        ($info['info_access'] 
== 'public' ||
!                                                        
!!($this->grants[$owner] & PHPGW_ACL_PRIVATE));   
!                                                       
!                       // echo "check_access(info_id=$info_id (owner=$owner, 
user=$user),required_rights=$required_rights): 
access".($access_ok?"Ok":"Denied");
!                       
!                       return $access_ok;         
!               }
! 
!               // sql to be AND into a query to ensure ACL is respected (incl. 
_PRIVATE)
!               // filter: none|all    - list all entrys user have rights to see
!               //         private|own - list only his personal entrys
!               //                                                      (incl. 
those he is responsible for !!!)            
!               function aclFilter($filter = 'none')
!               {
!                       ereg('.*(own|privat|all|none).*',$filter,$vars);
!                       $filter = $vars[1];
! 
!                       if (isset($this->acl_filter[$filter]))
!                       {
!                               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>";
!                                       if ($grant & 
(PHPGW_ACL_READ|PHPGW_ACL_EDIT))
!                                       {
!                                               $public_user_list[] = $user;
!                                       }
!                                       if ($grant & PHPGW_ACL_PRIVATE)
!                                       {
!                                               $private_user_list[] = $user;
!                                       }
!                               }
!                               if (count($private_user_list))
!                               {               
!                                       $has_private_access = 'info_owner IN ('.
!                                                                               
                 implode(',',$private_user_list).')';
!                               }            
!                       }
!                       $filtermethod = " (info_owner=$this->user"; // user has 
all rights
! 
!                       // private: own entries plus the one user is 
responsible for 
!                       if ($filter == 'private' || $filter == 'own')
!                       {
!                               $filtermethod .= " OR 
(info_responsible=$this->user OR info_status = 'offer')".
!                                                " AND 
(info_access='public'".($has_private_access?" OR $has_private_access":'').')';
!                       }
!                       else                                    // none --> all 
entrys user has rights to see
!                       {
!                               if ($has_private_access)
!                               {
!                                       $filtermethod .= " OR 
$has_private_access";
!                               }
!                               if (count($public_user_list))
!                               { 
!                                       $filtermethod .= " OR 
(info_access='public' AND info_owner IN(" . implode(',',$public_user_list) . 
'))';
!                               }
!                       }
!                       $filtermethod .= ') ';
!                       
!                       return $this->acl_filter[$filter] = $filtermethod;  // 
cache the filter
!               }      
!       
!               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 '';
!               }
! 
!               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)
!                       {
!                               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')";
!                       }
!                       return '';
!               }
! 
!               function init()
!               {
!                       $this->data = array( 'info_owner' => $this->user,
!                                                                               
'info_pri'    => 'normal' );
!               }      
!                               
!               function read($info_id)         // did _not_ ensure ACL
!               {
!                       if ($info_id <= 0 || $info_id != $this->data['info_id'] 
&& 
!                                                                               
(!$this->db->query("select * FROM phpgw_infolog where info_id='$info_id'") ||   
!$this->db->next_record())) 
!                       {
!                               $this->init( );
!                               return False;
!                       }
!                       if ($info_id != $this->data['info_id'])      // data 
yet read in
!                       {
!                               $this->data = $this->db->Record;
!                               reset($this->maybe_slashes);
!                               while (list($key) = each($this->maybe_slashes))
!                               {
!                                       $this->data[$key] = 
stripslashes($this->data[$key]);
!                               }
!                               $links = 
$this->links->get_links('infolog',$this->data['info_id']);
!                               while (list($nul,$link) = each($links))
!                               {
!                                       if ($link['app'] == 'addressbook')
!                                               $this->data['info_addr_id'] = 
$link['id'];
!                                       if ($link['app'] == 'projects')
!                                               $this->data['info_proj_id'] = 
$link['id'];
!                                       if ($link['app'] == 'calendar')
!                                               $this->data['info_event_id'] = 
$link['id'];
!                               }
!                       }
!                       return $this->data;         
!               }
!               
!               function delete($info_id)  // did _not_ ensure ACL
!               {
!                       $this->db->query("delete FROM phpgw_infolog where 
info_id='$info_id' or info_id_parent='"
!                               . "$info_id' AND ((info_access='public' and 
info_owner != '$this->user')"
!                               . " or (info_owner='$this->user'))" 
,__LINE__,__FILE__);
!                               
!                       $this->links->unlink(0,'infolog',$info_id);
! 
!                       if ($this->data['info_id'] == $info_id)
!                       {
!                               $this->init( );            
!                       }
!               }
! 
!               function write($values)  // did _not_ ensure ACL
!               {
!                       
include(PHPGW_SERVER_ROOT.'/infolog/setup/tables_current.inc.php');
!                       $db_cols = $phpgw_baseline['phpgw_infolog']['fd'];
!                       unset($phpgw_baseline);
! 
!                       while (list($key,$val) = each($values))
!                       {
!                               if ($key != 'info_id')
!                               {
!                                       if (!isset($db_cols[$key]))
!                                       {
!                                               continue;       // not in 
infolog-table
!                                       }
!                                       $this->data[$key] = $val;   // update 
internal data
! 
!                                       if ($this->maybe_slashes[$key])
!                                       {
!                                               $val = addslashes($val);
!                                       }
!                                       $cols .= ($cols ? ',' : '').$key;
!                                       $vals .= ($vals ? ',' : '')."'$val'";
!                                       $query .= ($query ? ',' : 
'')."$key='$val'";
!                               }
!                       }
!                       if (($this->data['info_id'] = $values['info_id']) > 0)
!                       {
!                               $query = "UPDATE phpgw_infolog SET $query where 
info_id='".$values['info_id']."'";
!                               $this->db->query($query,__LINE__,__FILE__);
!                       }
!                       else
!                       {
!                               $query = "INSERT INTO phpgw_infolog ($cols) 
VALUES ($vals)";
!                               $this->db->query($query,__LINE__,__FILE__);
!                               
$this->data['info_id']=$this->db->get_last_insert_id('phpgw_infolog','info_id');
!                       }
!                       // echo "<p>soinfolog.write values= "; 
_debug_array($values);
!                       // echo "<p>soinfolog.write this->data= "; 
_debug_array($this->data);
!                       /*
!                       if ($this->data['info_addr_id'])
!                               
$this->links->link('infolog',$this->data['info_id'],'addressbook',$this->data['info_addr_id']);
!                       if ($this->data['info_proj_id'])
!                               
$this->links->link('infolog',$this->data['info_id'],'projects',$this->data['info_proj_id']);
!                       if ($this->data['info_event_id'])
!                               
$this->links->link('infolog',$this->data['info_id'],'calendar',$this->data['info_event_id']);
 */
!               }
! 
!               function anzSubs( $info_id )
!               {
!                       $this->db->query('select count(*) FROM phpgw_infolog 
where '.
!                                                                 
"info_id_parent=$info_id",__LINE__,__FILE__);
! 
!                       $this->db->next_record();
! 
!                       return $this->db->f(0);
!               }
! 
!               function 
readIdArray($order,$sort,$filter,$cat_id,$query,$action,$action_id,
!                                                                       
$ordermethod,&$start,&$total)
!               {
!                       //echo 
"<p>soinfolog.readIdArray(action='$action',action_id='$action_id')</p>\n";
!                       $action2app = array(
!                               'addr' => 'addressbook',
!                               'proj' => 'projects',
!                               'event' => 'calendar'
!                       );
!                       if ($action != '' && $action2app[$action] != '')
!                       {
!                               $links = 
$this->links->get_links($action2app[$action],$action_id);
!                               $ids = array();
!                               while (list($nul,$link) = each($links))
!                               {
!                                       $ids[''.$link['id']] = 0;
!                               }
!                               //echo 
"<p>soinfolog.readIdArray($action,$action_id) ids ="; _debug_array($ids);
!                               return $ids;
!                       }
!                       if ($order)
!                       {
!                         $ordermethod = 'order by ' . $order . ' ' . $sort;
!                       }
!                       else
!                       {
!                         $ordermethod = 'order by info_datemodified desc';   
// newest first
!                       }
!                       $filtermethod = $this->aclFilter($filter);
!                       $filtermethod .= $this->statusFilter($filter);
!                       $filtermethod .= $this->dateFilter($filter);
!                       // echo "<p>filtermethod='$filtermethod'</p>";
! 
!                       if ($cat_id)
!                       {
!                         $filtermethod .= " AND info_cat='$cat_id' ";
!                       }
!                       switch ($action)
!                       {
!                               case 'addr':    $filtermethod .= " AND 
info_addr_id=$action_id ";
!                                                                       break;
!                               case 'proj':    $filtermethod .= " AND 
info_proj_id=$action_id ";
!                                                                       break;
!                               case 'event':   $filtermethod .= " AND 
info_event_id=$action_id ";
!                                                                       break;
!                       }
!                       if ($query)                       // we search in 
_from, _subject and _des for $query
!                       {
!                               $sql_query = "AND (info_from like '%$query%' OR 
info_subject ".
!                                                                "like 
'%$query%' OR info_des like '%$query%') ";
!                       }
!                       $pid = 'AND info_id_parent='.($action == 'sp' ? 
$action_id : 0);
! 
!                       if 
(!$phpgw_info['user']['preferences']['infolog']['listNoSubs'] &&
!                                $action != 'sp')
!                       {
!                               $pid = '';
!                       }
!                       $this->db->query("SELECT COUNT(*) FROM phpgw_infolog 
WHERE $filtermethod $pid $sql_query",__LINE__,__FILE__);
! 
!                       $this->db->next_record();
!                       $total = $this->db->f(0);
! 
!                       if (!$start || $start > $total)
!                       {
!                               $start = 0;
!                       }
!                       $this->db->limit_query("SELECT info_id,info_id_parent 
FROM phpgw_infolog WHERE $filtermethod $pid $sql_query 
$ordermethod",$start,__LINE__,__FILE__);
! 
!                       $ids = array( );
!                       while ($this->db->next_record())
!                       {
!                               $ids[$this->db->f('info_id')] = 
$this->db->f('info_id_parent');
!                       }
!                       return $ids;
!               }
!       }

Index: class.uiinfolog.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.uiinfolog.inc.php,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -r1.45 -r1.46
*** class.uiinfolog.inc.php     29 Sep 2002 08:40:51 -0000      1.45
--- class.uiinfolog.inc.php     8 Oct 2002 00:10:02 -0000       1.46
***************
*** 1,1218 ****
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - InfoLog                                                
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Ralf Becker <address@hidden>                  *
!       * originaly based on todo written by Joseph Engo <address@hidden>  *
!       * --------------------------------------------                          
   *
!       *  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  *
[...2543 lines suppressed...]
!                                       
$GLOBALS['phpgw']->template->set_var('data',$this->html->checkbox($pref,
!                                                               
$GLOBALS['phpgw_info']['user']['preferences']['infolog'][$pref]));
!                               }
!                               
$GLOBALS['phpgw']->template->parse('pref_lines','pref_line',True);
!                       }
!                       
$GLOBALS['phpgw']->template->fp('phpgw_body','info_prefs');
!               }
!               
!               /*!
!               @function writeLangFile
!               @abstract writes langfile with all templates and messages 
registered here
!               @discussion can be called via 
http://domain/phpgroupware/index.php?infolog.uiinfolog.writeLangFile
!               */
!               function writeLangFile()
!               {
!                       $il = new uiinfolog(False);     // no lang on messages
! 
!                       
$this->tmpl->writeLangFile('et_media','en',$il->messages);
!               }
!       }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]