phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc/class.bostandard_entity.inc.php, 1.2


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.bostandard_entity.inc.php, 1.2
Date: Wed, 2 Jun 2004 20:54:28 +0200

Update of /property/inc
Added Files:
        Branch: 
          class.bostandard_entity.inc.php

date: 2004/06/02 18:54:28;  author: sigurdne;  state: Exp;  lines: +283 -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.                                            
   *
        
\**************************************************************************/

        class bostandard_entity
        {
                var $start;
                var $query;
                var $filter;
                var $sort;
                var $order;
                var $cat_id;

                var $public_functions = array
                (
                        'read'                          => True,
                        'read_single'           => True,
                        'save'                          => True,
                        'delete'                        => True,
                        'check_perms'           => True
                );

                var $soap_functions = array(
                        'list' => array(
                                'in'  => 
array('int','int','struct','string','int'),
                                'out' => array('array')
                        ),
                        'read' => array(
                                'in'  => array('int','struct'),
                                'out' => array('array')
                        ),
                        'save' => array(
                                'in'  => array('int','struct'),
                                'out' => array()
                        ),
                        'delete' => array(
                                'in'  => array('int','struct'),
                                'out' => array()
                        )
                );

                function bostandard_entity($session=False)
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so               = 
CreateObject($this->currentapp.'.sostandard_entity');
                        $this->socommon = 
CreateObject($this->currentapp.'.socommon');
                        $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'));

                        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))
                        {
                                $this->cat_id = $cat_id;
                        }
                }


                function save_sessiondata($data)
                {
                        if ($this->use_session)
                        {
                                
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
                        }
                }

                function read_sessiondata()
                {
                        $data = 
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');


                        $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'];
                }


                function read($type='')
                {
                        $standard = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                                                                
        'type' => $type));

                        $this->total_records = $this->so->total_records;


                        return $standard;
                }

                function read_single($id,$type)
                {
                        return $this->so->read_single($id,$type);
                }

                function save($standard,$action='',$type ='')
                {
                        if ($action=='edit')
                        {
                                if ($standard['id'] != '')
                                {

                                        $receipt = 
$this->so->edit($standard,$type);
                                }
                        }
                        else
                        {
                                $receipt = $this->so->add($standard,$type);
                        }
                        return $receipt;

                }

                function delete($id,$type,$attrib)
                {
                        $this->so->delete($id,$type,$attrib);
                }

                function read_attrib($type='',$type_id='',$allrows='')
                {
                        $attrib = $this->so->read_attrib(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                                                                
        'type' => $type,'type_id' => $type_id,'allrows' => $allrows));

                        $this->total_records = $this->so->total_records;

                        for ($i=0; $i<count($attrib); $i++)
                        {
                                $attrib[$i]['datatype'] = 
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
                        }

                        return $attrib;
                }

                function read_single_attrib($id,$type)
                {
                        return $this->so->read_single_attrib($id,$type);
                }

                function save_attrib($attrib,$action='',$type ='')
                {
                        if ($action=='edit')
                        {
                                if ($attrib['id'] != '')
                                {

                                        $receipt = 
$this->so->edit_attrib($attrib,$type);
                                }
                        }
                        else
                        {
                                $receipt = $this->so->add_attrib($attrib,$type);
                        }
                        return $receipt;
                }


                function select_entity_type($type='',$selected='')
                {
                        $entity_types= $this->so->select_entity_type($type);

                        while (is_array($entity_types) && list(,$type) = 
each($entity_types))
                        {
                                $sel_type = '';
                                if ($type['id']==$selected)
                                {
                                        $sel_type = 'selected';
                                }

                                $entity_type_list[] = array
                                (
                                        'id'    => $type['id'],
                                        'name'          => $type['name'],
                                        'selected'      => $sel_type
                                );
                        }

                        for ($i=0;$i<count($entity_type_list);$i++)
                        {
                                if ($entity_type_list[$i]['selected'] != 
'selected')
                                {
                                        
unset($entity_type_list[$i]['selected']);
                                }
                        }

                        return $entity_type_list;
                }

                function select_datatype($selected='')
                {
                        $datatypes[0]['id']= 'C';
                        $datatypes[0]['name']= lang('Character');
                        $datatypes[1]['id']= 'I';
                        $datatypes[1]['name']= lang('Integer');
                        $datatypes[2]['id']= 'N';
                        $datatypes[2]['name']= lang('Decimal');
                        $datatypes[3]['id']= 'D';
                        $datatypes[3]['name']= lang('Date');
                        $datatypes[4]['id']= 'T';
                        $datatypes[4]['name']= lang('Memo');
                        $datatypes[5]['id']= 'R';
                        $datatypes[5]['name']= lang('Multiple radio');
                        $datatypes[6]['id']= 'CH';
                        $datatypes[6]['name']= lang('Multiple Checkbox');

                        while (is_array($datatypes) && list(,$type) = 
each($datatypes))
                        {
                                $sel_type = '';
                                if ($type['id']==$selected)
                                {
                                        $sel_type = 'selected';
                                }

                                $datatype_list[] = array
                                (
                                        'id'    => $type['id'],
                                        'name'          => $type['name'],
                                        'selected'      => $sel_type
                                );
                        }

                        for ($i=0;$i<count($datatype_list);$i++)
                        {
                                if ($datatype_list[$i]['selected'] != 
'selected')
                                {
                                        unset($datatype_list[$i]['selected']);
                                }
                        }

                        return $datatype_list;
                }


        }
?>




reply via email to

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