phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc/class.soalarm.inc.php, 1.1


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.soalarm.inc.php, 1.1
Date: Wed, 21 Jul 2004 21:00:12 +0200

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

date: 2004/07/21 19:00:12;  author: sigurdne;  state: Exp;

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.soalarm.inc.php,v 1.1 2004/07/21 19:00:12 sigurdne Exp $ 
*/

        class soalarm
        {

                function soalarm()
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->db               = $GLOBALS['phpgw']->db;
                        $this->db2              = $this->db;
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->socommon         = 
CreateObject($this->currentapp.'.socommon');

                        $this->join                     = $this->socommon->join;
                }

                function select_method_list()
                {
                        $this->db->query("SELECT id,name,data FROM 
fm_async_method ORDER BY name ");

                        $i = 0;
                        while ($this->db->next_record())
                        {
                                if($this->db->f('data'))
                                {
                                        $data_set = 
unserialize($this->db->f('data'));
                                        while (is_array($data_set) && 
list($key,$value) = each($data_set))
                                        {
                                                $method_data[] = $key . '=' . 
$value;
                                        }

                                        $method_data= @implode 
(',',$method_data);
                                }

                                $categories[$i]['id']                           
= $this->db->f('id');
                                $categories[$i]['name']                         
= stripslashes($this->db->f('name')) . '(' . $method_data . ')';
                                $i++;
                        }
                        return $categories;
                }

                function read_single_method($id)
                {
                        $this->db->query("SELECT name FROM fm_async_method  
where id='$id'");
                        $this->db->next_record();
                        return $this->db->f('name');
                }

                function read($data)
                {
                        if(is_array($data))
                        {
                                $id     = (isset($data['id'])?$data['id']:0);
                                $start  = 
(isset($data['start'])?$data['start']:0);
                                $filter = 
(isset($data['filter'])?$data['filter']:'');
                                $query = 
(isset($data['query'])?$data['query']:'');
                                $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
                                $order = 
(isset($data['order'])?$data['order']:'');
                                $allrows                = 
(isset($data['allrows'])?$data['allrows']:'');
                        }

                        if ($order)
                        {
                                $ordermethod = " order by $order $sort";
                        }
                        else
                        {
                                $ordermethod = ' order by id DESC';
                        }


                        $where = 'WHERE';
                        if ($filter > 0)
                        {
                                $filtermethod .= " $where owner='$filter' ";
                                $where = 'AND';

                        }

/*                      if($query)
                        {
                                $query = ereg_replace("'",'',$query);
                                $query = ereg_replace('"','',$query);

                                $querymethod = " $where ( abid = '$query' or 
org_name LIKE '%$query%')";
                        }
*/
                        $id = $this->db->db_addslashes($id);
                        if (strpos($id,'%') !== False || strpos($id,'_') !== 
False)
                        {
                                $filtermethod = "$where id LIKE '%$id%' AND 
id!='##last-check-run##'";
                        }
                        elseif (!$id)
                        {
                                $filtermethod = $where . ' next<='.time()." AND 
id!='##last-check-run##'";
                        }
                        else
                        {
                                $filtermethod = "$where id='$id'";
                        }

                        $sql = "SELECT * FROM phpgw_async $filtermethod 
$querymethod";

                        $this->db2->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db2->num_rows();

                        if(!$allrows)
                        {
                                $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
                        }
                        else
                        {
                                $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
                        }

                        $jobs = array();
                        while ($this->db->next_record())
                        {
                                $id = $this->db->f('id');
                                $data   = unserialize($this->db->f('data'));

                                $jobs[$id] = array(
                                        'id'     => $id,
                                        'next'   => $this->db->f('next'),
                                        'times'  => 
unserialize($this->db->f('times')),
                                        'method' => $this->db->f('method'),
                                        'data'   => $data,
                                        'enabled'   => (int)$data['enabled'],
                                        'account_id'   => 
$this->db->f('account_id')
                                );
                        }
                        if (!count($jobs))
                        {
                                return False;
                        }
                        return $jobs;
                }

                function read_org($id=0)
                {
                        $id = $this->db->db_addslashes($id);
                        if (strpos($id,'%') !== False || strpos($id,'_') !== 
False)
                        {
                                $where = "id LIKE '%$id%' AND 
id!='##last-check-run##'";
                        }
                        elseif (!$id)
                        {
                                $where = 'next<='.time()." AND 
id!='##last-check-run##'";
                        }
                        else
                        {
                                $where = "id='$id'";
                        }
                        $this->db->query($sql="SELECT * FROM $this->db_table 
WHERE $where",__LINE__,__FILE__);

                        $jobs = array();
                        while ($this->db->next_record())
                        {
                                $id = $this->db->f('id');

                                $jobs[$id] = array(
                                        'id'     => $id,
                                        'next'   => $this->db->f('next'),
                                        'times'  => 
unserialize($this->db->f('times')),
                                        'method' => $this->db->f('method'),
                                        'data'   => 
unserialize($this->db->f('data')),
                                        'account_id'   => 
$this->db->f('account_id')
                                );
                                //echo "job id='$id'<pre>"; 
print_r($jobs[$id]); echo "</pre>\n";
                        }
                        if (!count($jobs))
                        {
                                return False;
                        }
                        return $jobs;
                }


                function read_single($owner_id)
                {
                        $this->db->query("select * from fm_owner where 
owner_id='$owner_id'",__LINE__,__FILE__);

                        if ($this->db->next_record())
                        {
                                $owner['id']                    = 
(int)$this->db->f('owner_id');
                                $owner['abid']                  = 
$this->db->f('abid');
                                $owner['org_name']              = 
stripslashes($this->db->f('org_name'));
                                $owner['remark']                = 
stripslashes($this->db->f('remark'));
                                $owner['entry_date']            = 
$this->db->f('entry_date');
                                $owner['cat_id']                        = 
(int)$this->db->f('category');

                                return $owner;
                        }
                }

                function add($owner)
                {
                        $owner['name'] = 
$this->db->db_addslashes($owner['name']);

                        $this->db->query("INSERT INTO fm_owner 
(entry_date,remark,abid,org_name,category) "
                                . "VALUES ('" . time() . "','" . 
$owner['remark'] . "','" . $owner['abid'] . "','" . $owner['org_name']
                                . "','" . $owner['cat_id'] . 
"')",__LINE__,__FILE__);

                        $receipt['owner_id']= 
$this->db->get_last_insert_id('fm_owner','owner_id');
                        $receipt['message'][] = array('msg'=>lang('owner %1 has 
been saved',$receipt['owner_id']));
                        return $receipt;
                }

                function edit($owner)
                {
                        $owner['name'] = 
$this->db->db_addslashes($owner['name']);

                        $this->db->query("UPDATE fm_owner set remark='" . 
$owner['remark'] . "', entry_date='" . time() . "', abid='" . $owner['abid'] . 
"', org_name='" . $owner['org_name'] . "', category='"
                                                        . $owner['cat_id'] . "' 
WHERE owner_id=" . intval($owner['owner_id']),__LINE__,__FILE__);

                        $receipt['owner_id']= $owner['owner_id'];
                        $receipt['message'][] = array('msg'=>lang('owner %1 has 
been edited',$owner['owner_id']));
                        return $receipt;
                }

                function delete($owner_id)
                {
                        $this->db->query('DELETE FROM fm_owner WHERE owner_id=' 
. intval($owner_id),__LINE__,__FILE__);
                }
        }
?>




reply via email to

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