phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc/class.bocustom.inc.php, 1.1.2.1


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.bocustom.inc.php, 1.1.2.1
Date: Fri, 28 May 2004 15:06:40 +0200

Update of /property/inc
Added Files:
        Branch: sigurd-2
          class.bocustom.inc.php

date: 2004/05/28 13:06:40;  author: sigurdne;  state: Exp;  lines: +195 -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.bocustom.inc.php,v 1.1.2.1 2004/05/28 13:06:40 sigurdne 
Exp $ */

        class bocustom
        {
                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
                );

                function bocustom($session=False)
                {
                        $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so = CreateObject($this->currentapp.'.socustom');

                        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'));

                        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;
                        }
                }


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

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

                        $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 check_perms($has, $needed)
                {
                        return (!!($has & $needed) == True);
                }


                function read()
                {
                        $custom = $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));
                        $this->total_records = $this->so->total_records;

                        for ($i=0; $i<count($custom); $i++)
                        {
                                $custom[$i]['entry_date']  = 
$GLOBALS['phpgw']->common->show_date($custom[$i]['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
                        }
                        return $custom;
                }

                function read_single($custom_id)
                {
                        return $this->so->read_single($custom_id);
                }

                function read_custom_name($custom_id)
                {
                        return $this->so->read_custom_name($custom_id);
                }

                function save($custom)
                {

                        if ($custom['custom_id'])
                        {
                                if ($custom['custom_id'] != 0)
                                {
                                        $custom_id = $custom['custom_id'];
                                        $receipt=$this->so->edit($custom);
                                }
                        }
                        else
                        {
                                $receipt = $this->so->add($custom);
                        }
                        return $receipt;
                }

                function delete($params)
                {
                        if (is_array($params))
                        {
                                $this->so->delete($params[0]);
                        }
                        else
                        {
                                $this->so->delete($params);
                        }
                }

                function resort($data)
                {
                        $this->so->resort($data);
                }


                function read_custom($custom_id,$allrows='')
                {
                        if($allrows)
                        {
                                $this->allrows=$allrows;
                        }
                        $custom = $this->so->read_custom(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                                                                
        'filter' => $this->filter,'custom_id' => 
$custom_id,'allrows'=>$this->allrows));
                        $this->uicols = $this->so->uicols;
                        $this->total_records = $this->so->total_records;
                        return $custom;
                }

        }
?>




reply via email to

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