[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc/class.boactor.inc.php, 1.2
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/inc/class.boactor.inc.php, 1.2 |
Date: |
Wed, 2 Jun 2004 20:54:27 +0200 |
Update of /property/inc
Added Files:
Branch:
class.boactor.inc.php
date: 2004/06/02 18:54:27; author: sigurdne; state: Exp; lines: +390 -0
Log Message:
no message
=====================================================================
<?php
/**************************************************************************\
* phpGroupWare - property
*
* http://www.phpgroupware.org
*
*
*
* Facilities Management
*
* Written by Sigurd Nes [sigurdne at online.no]
*
*
------------------------------------------------------------------------ *
* Copyright 2000 - 2003 Free Software Foundation, Inc
*
* This program is part of the GNU project, see http://www.gnu.org/
*
*
------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\**************************************************************************/
/* $Id: class.boactor.inc.php,v 1.2 2004/06/02 18:54:27 sigurdne Exp $
*/
class boactor
{
var $start;
var $query;
var $filter;
var $sort;
var $order;
var $cat_id;
var $role;
var $member_id;
var $public_functions = array
(
'read' => True,
'read_single' => True,
'save' => True,
'delete' => True,
'check_perms' => True
);
function boactor($session=False)
{
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->so = CreateObject($this->currentapp.'.soactor');
$this->bocommon =
CreateObject($this->currentapp.'.bocommon');
if ($session)
{
$this->read_sessiondata();
$this->use_session = True;
}
$start = get_var('start',array('POST','GET'));
$query = get_var('query',array('POST','GET'));
$sort = get_var('sort',array('POST','GET'));
$order = get_var('order',array('POST','GET'));
$filter = get_var('filter',array('POST','GET'));
$cat_id = get_var('cat_id',array('POST','GET'));
$allrows =
get_var('allrows',array('POST','GET'));
$role = get_var('role',array('POST','GET'));
$member_id =
get_var('member_id',array('POST','GET'));
$this->role = $role;
$this->so->role = $role;
if ($start)
{
$this->start=$start;
}
else
{
$this->start=0;
}
if(isset($query))
{
$this->query = $query;
}
if(!empty($filter))
{
$this->filter = $filter;
}
if(isset($sort))
{
$this->sort = $sort;
}
if(isset($order))
{
$this->order = $order;
}
if(isset($cat_id) && !empty($cat_id))
{
$this->cat_id = $cat_id;
}
else
{
unset($this->cat_id);
}
if(isset($allrows))
{
$this->allrows = $allrows;
}
if(isset($member_id))
{
$this->member_id = $member_id;
}
}
function save_sessiondata($data)
{
if ($this->use_session)
{
$GLOBALS['phpgw']->session->appsession('session_data','actor_' .
$this->role,$data);
}
}
function read_sessiondata()
{
$data =
$GLOBALS['phpgw']->session->appsession('session_data','actor_' . $this->role);
//_debug_array($data);
$this->start = $data['start'];
$this->query = $data['query'];
$this->filter = $data['filter'];
$this->sort = $data['sort'];
$this->order = $data['order'];
$this->cat_id = $data['cat_id'];
$this->member_id= $data['member_id'];
$this->allrows = $data['allrows'];
}
function check_perms($has, $needed)
{
return (!!($has & $needed) == True);
}
function select_category_list($format='',$selected='')
{
switch($format)
{
case 'select':
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
break;
case 'filter':
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
break;
}
$categories= $this->so->select_category_list();
while (is_array($categories) && list(,$category) =
each($categories))
{
$sel_category = '';
if ($category['id']==$selected)
{
$sel_category = 'selected';
}
$category_list[] = array
(
'cat_id' => $category['id'],
'name' => $category['name'],
'selected' => $sel_category
);
}
for ($i=0;$i<count($category_list);$i++)
{
if ($category_list[$i]['selected'] !=
'selected')
{
unset($category_list[$i]['selected']);
}
}
return $category_list;
}
function read()
{
$actor = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id));
$this->total_records = $this->so->total_records;
$this->uicols = $this->so->uicols;
for ($i=0; $i<count($actor); $i++)
{
$actor[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($actor[$i]['date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
}
return $actor;
}
function read_single($data)
{
$contacts =
CreateObject('phpgwapi.contacts');
$actor = $this->so->read_single($data);
$dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
$input_type_array = array(
'R' => 'radio',
'CH' => 'checkbox',
'LB' => 'listbox'
);
$sep = '/';
$dlarr[strpos($dateformat,'Y')] = 'Y';
$dlarr[strpos($dateformat,'m')] = 'm';
$dlarr[strpos($dateformat,'d')] = 'd';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
//html_print_r($actor);
$m=0;
for ($i=0;$i<count($actor['attributes']);$i++)
{
if($actor['attributes'][$i]['datatype']=='D' &&
$actor['attributes'][$i]['value'])
{
$timestamp_date=
mktime(0,0,0,date(m,strtotime($actor['attributes'][$i]['value'])),date(d,strtotime($actor['attributes'][$i]['value'])),date(y,strtotime($actor['attributes'][$i]['value'])));
$actor['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
}
if($actor['attributes'][$i]['datatype']=='AB')
{
if($actor['attributes'][$i]['value'])
{
$contact_data =
$contacts->read_single_entry($actor['attributes'][$i]['value'],array('org_name'=>'org_name','email'=>'email'));
$actor['attributes'][$i]['org_name'] = $contact_data[0]['org_name'];
}
$insert_record_actor[] =
$actor['attributes'][$i]['name'];
$lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $actor['attributes'][$i]['name']);
$lookup_functions[$m]['name'] =
'lookup_'. $actor['attributes'][$i]['name'] .'()';
$lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
$m++;
}
if($actor['attributes'][$i]['datatype']=='R' ||
$actor['attributes'][$i]['datatype']=='CH' ||
$actor['attributes'][$i]['datatype']=='LB')
{
$actor['attributes'][$i]['choice']
= $this->so->read_attrib_choice($actor['attributes'][$i]['attrib_id']);
$input_type=$input_type_array[$actor['attributes'][$i]['datatype']];
if($actor['attributes'][$i]['datatype']=='CH')
{
$actor['attributes'][$i]['value']=unserialize($actor['attributes'][$i]['value']);
$actor['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($actor['attributes'][$i]['value'],$actor['attributes'][$i]['choice'],$input_type);
}
else
{
for
($j=0;$j<count($actor['attributes'][$i]['choice']);$j++)
{
$actor['attributes'][$i]['choice'][$j]['input_type']=$input_type;
if($actor['attributes'][$i]['choice'][$j]['id']==$actor['attributes'][$i]['value'])
{
$actor['attributes'][$i]['choice'][$j]['checked']='checked';
}
}
}
}
$actor['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($actor['attributes'][$i]['datatype']);
$actor['attributes'][$i]['counter'] = $i;
$actor['attributes'][$i]['type_id'] =
$data['type_id'];
}
for ($j=0;$j<count($lookup_functions);$j++)
{
$actor['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
$actor['lookup_functions'] .= '{'."\r\n";
$actor['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
$actor['lookup_functions'] .= '}'."\r\n";
}
$GLOBALS['phpgw']->session->appsession('insert_record_actor',$this->currentapp,$insert_record_actor);
//html_print_r($actor);
return $actor;
}
function save($actor,$values_attribute='')
{
for ($i=0;$i<count($values_attribute);$i++)
{
if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
{
$values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
}
if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
{
$values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
}
if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
{
$values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
}
if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
{
$values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
}
}
if ($actor['actor_id'])
{
if ($actor['actor_id'] != 0)
{
$actor_id = $actor['actor_id'];
$receipt=$this->so->edit($actor,$values_attribute);
}
}
else
{
$receipt =
$this->so->add($actor,$values_attribute);
}
return $receipt;
}
function delete($actor_id='',$id='',$attrib='')
{
if ($attrib)
{
$this->so->delete_attrib($id);
}
else
{
$this->so->delete($actor_id);
}
}
function read_attrib($type_id='')
{
$attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
'allrows'=>$this->allrows));
for ($i=0; $i<count($attrib); $i++)
{
$attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
}
$this->total_records = $this->so->total_records;
return $attrib;
}
function read_single_attrib($id)
{
return $this->so->read_single_attrib($id);
}
function resort_attrib($data)
{
$this->so->resort_attrib($data);
}
function save_attrib($attrib,$action='')
{
if ($action=='edit')
{
if ($attrib['id'] != '')
{
$receipt =
$this->so->edit_attrib($attrib);
}
}
else
{
$receipt = $this->so->add_attrib($attrib);
}
return $receipt;
}
function column_list($selected='',$allrows='')
{
if(!$selected)
{
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["actor_columns_"
. $this->role];
}
$columns =
$this->so->read_attrib(array('allrows'=>$allrows,'column_list'=>True));
$column_list=$this->bocommon->select_multi_list($selected,$columns);
return $column_list;
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc/class.boactor.inc.php, 1.2,
nomail <=