phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] tts/inc/class.bo.inc.php, 1.7


From: nomail
Subject: [Phpgroupware-cvs] tts/inc/class.bo.inc.php, 1.7
Date: Tue, 14 Dec 2004 21:02:17 +0100

Update of /tts/inc
Modified Files:
        Branch: 
          class.bo.inc.php

date: 2004/12/14 20:02:17;  author: fipsfuchs;  state: Exp;  lines: +78 -6

Log Message:
new methods for ipc
=====================================================================
Index: tts/inc/class.bo.inc.php
diff -u tts/inc/class.bo.inc.php:1.6 tts/inc/class.bo.inc.php:1.7
--- tts/inc/class.bo.inc.php:1.6        Mon Oct 11 09:43:14 2004
+++ tts/inc/class.bo.inc.php    Tue Dec 14 20:02:17 2004
@@ -165,6 +165,69 @@
                        return $r;
                }
 
+               function exists($id) {
+                       $myid = (int) $id;
+                       $this->db->query(
+                               "select 1 from phpgw_tts_tickets where 
ticket_id='". $myid . "'",
+                               __LINE__,
+                               __FILE__
+                       );
+                       return $this->db->next_record();
+               }
+
+               function delete($id) {
+                       $ret = true;
+                       $ret &= (! is_null($this->db->query(
+                               "DELETE from phpgw_tts_tickets where 
ticket_id='". $myid . "'",
+                               __LINE__,
+                               __FILE__
+                       )));
+                       $ret &= (! is_null($this->db->query(
+                               "DELETE from phpgw_tts_views where view_id='". 
$myid . "'",
+                               __LINE__,
+                               __FILE__
+                       )));
+                       return $ret;
+               }
+
+               function getIDList($lastmod = -1) {
+                       $sel = "SELECT ticket_id FROM phpgw_tts_tickets";
+                       $mylastmod = (int) $lastmod;
+                       if ($mylastmod >= 0) {
+                               $sel .= " WHERE ticket_lastmod>='" . $mylastmod 
. "'";
+                       }
+                       $this->db->query($sel, __LINE__, __FILE__);
+                       $ret = array();
+                       while ($this->db->next_record()) {
+                               $ret[] = $this->db->f("ticket_id");
+                       }
+                       error_log("bo_tts:getIDList: ".print_r($ret, true));
+                       return $ret;
+               }
+
+               // created getter without view-creation or reading it
+               function retrieve($id) {
+                       $myid = (int) $id;
+                       $this->db->query("select * from phpgw_tts_tickets where 
ticket_id='" . $myid . "'",__LINE__,__FILE__);
+                       if (! $this->db->next_record()) {
+                               return false;
+                       }
+                       $ret = array(
+                               'id'             => (int) $id,
+                               'group'          => 
$this->db->f('ticket_group'),
+                               'priority'       => 
$this->db->f('ticket_priority'),
+                               'owner'          => 
$this->db->f('ticket_owner'),
+                               'assignedto'     => 
$this->db->f('ticket_assignedto'),
+                               'subject'        => 
$this->db->f('ticket_subject'),
+                               'category'       => 
$this->db->f('ticket_category'),
+                               'billable_hours' => 
$this->db->f('ticket_billable_hours'),
+                               'billable_rate'  => 
$this->db->f('ticket_billable_rate'),
+                               'status'         => 
$this->db->f('ticket_status'),
+                               'details'        => 
$this->db->f('ticket_details')
+                       );
+                       return $ret;
+               }
+
                function _read($params = '')
                {
                        $cat = createobject('phpgwapi.categories');
@@ -281,11 +344,14 @@
                        return $r;
                }
 
-               function save($params)
+               //added optional parameter to avoid historylog-entries due 
sync-addition
+               function save($params, $dohistorylog = true)
                {
-                       $this->db->query("insert into phpgw_tts_tickets 
(ticket_group,ticket_priority,ticket_owner,"
+                       //added lastmod-support for ipc-layer
+                       $lastmod = array_key_exists('lastmod', $params) ? (int) 
$params['lastmod'] : time();
+                       $statement = "insert into phpgw_tts_tickets 
(ticket_group,ticket_priority,ticket_owner,"
                                . 
"ticket_assignedto,ticket_subject,ticket_category,ticket_billable_hours,"
-                               . 
"ticket_billable_rate,ticket_status,ticket_details) values ('0','"
+                               . 
"ticket_billable_rate,ticket_status,ticket_details,ticket_lastmod) values 
('0','"
                                . $params['priority'] . "','"
                                . $GLOBALS['phpgw_info']['user']['account_id'] 
. "','"
                                . $params['assignedto'] . "','"
@@ -293,10 +359,16 @@
                                . $params['category'] . "','"
                                . $params['billable_hours'] . "','"
                                . $params['billable_rate'] . "','O','"
-                               . addslashes($params['details']) . 
"')",__LINE__,__FILE__);
-
+                               . addslashes($params['details']) . "','"
+                               . $lastmod . "')";
+                       error_log("bo_tts:save: statement='" . $statement . 
"'");
+                       $this->db->query($statement,__LINE__,__FILE__);
                        $ticket_id = 
$this->db->get_last_insert_id('phpgw_tts_tickets','ticket_id');
-                       $this->historylog->add('O',$ticket_id,'');
+                       error_log("bo_tts:save: saved -> $ticket_id");
+                       //added optional parameter to avoid historylog-entries 
due sync-addition
+                       if ($dohistorylog) {
+                               $this->historylog->add('O',$ticket_id,'');
+                       }
                        return $ticket_id;
                }
 




reply via email to

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