phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] tts/inc class.uitts.inc.php class.botts.inc.php


From: Dave Hall
Subject: [Phpgroupware-cvs] tts/inc class.uitts.inc.php class.botts.inc.php
Date: Wed, 27 Dec 2006 02:54:44 +0000

CVSROOT:        /cvsroot/phpgroupware
Module name:    tts
Changes by:     Dave Hall <skwashd>     06/12/27 02:54:44

Modified files:
        inc            : class.uitts.inc.php class.botts.inc.php 

Log message:
        added mailpipe handling backend code and switched to app prefix in 
class names

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/tts/inc/class.uitts.inc.php?cvsroot=phpgroupware&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/tts/inc/class.botts.inc.php?cvsroot=phpgroupware&r1=1.5&r2=1.6

Patches:
Index: class.uitts.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/inc/class.uitts.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- class.uitts.inc.php 21 Dec 2006 00:06:13 -0000      1.6
+++ class.uitts.inc.php 27 Dec 2006 02:54:44 -0000      1.7
@@ -5,10 +5,10 @@
        * @copyright Copyright (C) 2000-2006 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package tts
-       * @version $Id: class.uitts.inc.php,v 1.6 2006/12/21 00:06:13 skwashd 
Exp $
+       * @version $Id: class.uitts.inc.php,v 1.7 2006/12/27 02:54:44 skwashd 
Exp $
        */
        
-       class uitts
+       class tts_uitts
        {
                /**
                 * @var object $bo reference to the tts business logic class

Index: class.botts.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/inc/class.botts.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- class.botts.inc.php 21 Dec 2006 00:06:13 -0000      1.5
+++ class.botts.inc.php 27 Dec 2006 02:54:44 -0000      1.6
@@ -5,7 +5,7 @@
        * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package tts
-       * @version $Id: class.botts.inc.php,v 1.5 2006/12/21 00:06:13 skwashd 
Exp $
+       * @version $Id: class.botts.inc.php,v 1.6 2006/12/27 02:54:44 skwashd 
Exp $
        */
 
 
@@ -14,7 +14,7 @@
        * 
        * @package tts
        */      
-       class botts
+       class tts_botts
        {
                /**
                * @var object $cats reference to the categories object
@@ -191,9 +191,10 @@
                * Read a ticket from the database
                *
                * @param int $id the database id for the ticket
+               * @param bool $bypass_check bypass ACL check
                * @return array the ticket values, count(0) == invalid ticket
                */
-               function get_ticket($id)
+               function get_ticket($id, $bypass_check = false)
                {
                        $id = (int)$id;
                        if ( $id === 0 )
@@ -207,7 +208,7 @@
 
                        $cats = $this->get_user_cat_list(PHPGW_ACL_READ);
                        
-                       if ( $ttype === 0 || !isset($cats[$ttype]) ) //not 
found, invalid type or no rights
+                       if ( !$bypass_check && ($ttype === 0 || 
!isset($cats[$ttype]) ) ) //not found, invalid type or no rights
                        {
                                return array();
                        }
@@ -803,23 +804,57 @@
                /**
                 * Process the data provided by the mailpipe script
                 * 
+                * @todo implement attachment handling
                 * @param array $ticket the ticket data
+                * @param int $handler_id the mail handler id, used for lookups
                 * @return int the new ticket id, 0 = failure
                 */
-               function process_mail($ticket)
+               function process_mail($msg, $handler_id)
                {
-                       //we are dealing with a comment
-                       if ( isset($ticket['ticket_id']) )
+                       $sql = 'SELECT tts_cat_id FROM phpgw_tts_email_map 
WHERE is_active = 1 AND api_handler_id = ' . (int) $handler_id ;
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       if ( !$this->db->next_record() )
                        {
-                               $this->historylog->add('C', 
$ticket['ticket_id'], $ticket['body'],'');
-                               return $ticket['ticket_id'];
+                               return false; //invalid or inactive
                        }
+                       $cat_id = $this->db->f('tts_cat_id');
                        
-                       if ( $id = $this->save($ticket) )
+                       $matches = array();
+                       if ( !preg_match('/(\[ticket #(\d+)\])(.*)/', 
$msg->subject, $matches) ) //is it new?
+                       {
+                               if ( !$GLOBALS['phpgw']->acl->check('C' . 
$cat['id'], PHPGW_ACL_ADD, 'tts') )
                        {
-                               return $id; 
+                                       return false;
+                               }
+
+                               $ticket = array
+                               (
+                                       'ticket_group'          => 0,
+                                       'ticket_priority'       => 0,
+                                       'ticket_assignedto'     => 0,
+                                       'ticket_subject'        => 
trim($msg->subject),
+                                       'ticket_billable_hours' => 0.00,
+                                       'ticket_billable_rate'  => 0.00,
+                                       'ticket_deadline'       => time() + 
86400, // (60 * 60 * 24) or 1 day
+                                       'ticket_effort'         => '',
+                                       'ticket_type'           => $cat_id,
+                                       'ticket_details'        => 
trim($msg->body),
+                               );
+                               return !!$this->save_ticket($ticket);
+                       }
+                       else
+                       {
+                               $ticket = $this->get_ticket($matches[2], true);
+                               if ( $ticket['ticket_type'] != $cat_id // can't 
reassign cat via email - for now anyway
+                                       || !$GLOBALS['phpgw']->acl->check('C' . 
$cat['id'], PHPGW_ACL_EDIT, 'tts') )
+                               {
+                                       return false;
+                               }
+
+                               $ticket['ticket_subject'] = trim($matches[3]); 
// trust me :)
+                               $ticket['ticket_detail'] = trim($msg->body);
+                               return !!$this->edit($ticket['ticket_id'], 
$ticket);
                        }
-                       return 0;
                }
 
                /**
@@ -840,7 +875,6 @@
                                        . ' ticket_owner,'
                                        . ' ticket_assignedto,'
                                        . ' ticket_subject,'
-                                       . ' ticket_category,'
                                        . ' ticket_billable_hours,'
                                        . ' ticket_billable_rate,'
                                        . ' ticket_status,'
@@ -856,10 +890,9 @@
                        (
                                (int) $ticket['ticket_group'],
                                (int) $ticket['ticket_priority'],
-                               0, //(int) $ticket['ticket_reported_by'],
+                               (int) 
$GLOBALS['phpgw_info']['user']['account_id'],
                                (int) $ticket['ticket_assignedto'],
                                
$this->db->db_addslashes($ticket['ticket_subject']),
-                               0,//(int) $ticket['ticket_category'],
                                (float) $ticket['ticket_billable_hours'],
                                (float) $ticket['ticket_billable_rate'],
                                'O',




reply via email to

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