phpgroupware-cvs
[Top][All Lists]
Advanced

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

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


From: Dave Hall
Subject: [Phpgroupware-cvs] tts/inc class.botts.inc.php
Date: Wed, 27 Dec 2006 12:26:04 +0000

CVSROOT:        /cvsroot/phpgroupware
Module name:    tts
Changes by:     Dave Hall <skwashd>     06/12/27 12:26:04

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

Log message:
        make it work with mailpipe, there are still some outstanding issues 
here and we need a gui for managing the queues

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

Patches:
Index: class.botts.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/inc/class.botts.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- class.botts.inc.php 27 Dec 2006 04:26:38 -0000      1.7
+++ class.botts.inc.php 27 Dec 2006 12:26:04 -0000      1.8
@@ -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.7 2006/12/27 04:26:38 skwashd 
Exp $
+       * @version $Id: class.botts.inc.php,v 1.8 2006/12/27 12:26:04 skwashd 
Exp $
        */
 
 
@@ -667,16 +667,23 @@
                * @param array $values the ticket values as an associative array
                * @return bool any errors?
                */
-               function validate($values)
+               function validate($values, $ignore_custom)
                {
-                       $ticket_fields = 
$this->get_fields($values['ticket_type']);
+                       $ttype = $values['ticket_type'];
+                       if ( $ignore_custom )
+                       {
+                               $ttype = 0;
+                       }
+                       $ticket_fields = $this->get_fields($ttype);
                        foreach ( $ticket_fields as $field )
                        {
-                               if ( !$field['nullable'] && 
!$values[$field['id']] )
+                               if ( !$field['nullable'] && 
!(isset($values[$field['id']]) && $values[$field['id']]) )
                                {
+                                       echo "{$field['id']} == 
{$values[$field['id']]}\n";
                                        $this->errors[$field['id']] = lang('%1 
must not be empty', $field['label']);
                                }
                        }
+                       print_r($this->errors);
                        return !count($this->errors);
                }
                
@@ -809,9 +816,9 @@
                 * @param int $handler_id the mail handler id, used for lookups
                 * @return int the new ticket id, 0 = failure
                 */
-               function process_mail($msg, $handler_id)
+               function process_mail($msg)
                {
-                       $sql = 'SELECT tts_cat_id FROM phpgw_tts_email_map 
WHERE is_active = 1 AND api_handler_id = ' . (int) $handler_id ;
+                       $sql = 'SELECT tts_cat_id FROM phpgw_tts_email_map 
WHERE is_active = 1 AND api_handler_id = ' . (int) $msg->handler_id;
                        $this->db->query($sql, __LINE__, __FILE__);
                        if ( !$this->db->next_record() )
                        {
@@ -822,7 +829,7 @@
                        $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') )
+                               if ( !$GLOBALS['phpgw']->acl->check('C' . 
$cat_id, PHPGW_ACL_ADD, 'tts') )
                                {
                                        return false;
                                }
@@ -838,21 +845,22 @@
                                        'ticket_deadline'       => time() + 
86400, // (60 * 60 * 24) or 1 day
                                        'ticket_effort'         => '',
                                        'ticket_type'           => $cat_id,
-                                       'ticket_details'        => 
trim($msg->body),
+                                       'ticket_details'        => $msg->body,
                                );
-                               return !!$this->save_ticket($ticket);
+                               return !!$this->save($ticket, true, true);
                        }
                        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') )
+                                       || (!$GLOBALS['phpgw']->acl->check('C' 
. $cat_id, PHPGW_ACL_EDIT, 'tts') && $ticket['ticket_owner'] != 
$GLOBALS['phpgw-info']['user']['account_id'] ) )
                                {
                                        return false;
                                }
 
                                $ticket['ticket_subject'] = trim($matches[3]); 
// trust me :)
                                $ticket['ticket_detail'] = trim($msg->body);
+                               $ticket['ticket_status'] = 'O';//reopen it as 
someone has posted to it
                                return !!$this->edit($ticket['ticket_id'], 
$ticket);
                        }
                }
@@ -860,9 +868,9 @@
                /**
                 * Save a ticket to the database
                 */
-               function save($ticket, $dohistorylog = true)
+               function save($ticket, $dohistorylog = true, $ignore_custom = 
false)
                {
-                       if ( !$this->validate($ticket) )
+                       if ( !$this->validate($ticket, $ignore_custom) )
                        {
                                return 0;
                        }
@@ -884,7 +892,7 @@
                                        . ' ticket_details,'
                                        . ' ticket_lastmod,'
                                        . ' ticket_lastmod_user)'
-                               . ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?)');
+                               . ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?)');
                        
                        $params = array
                        (
@@ -911,7 +919,7 @@
 
                                $this->_save_custom($ticket['ticket_type'], 
$ticket);
 
-                               error_log("bo_tts:save: saved -> $ticket_id");
+                               //error_log("bo_tts::save - saved $ticket_id");
                                //added optional parameter to avoid 
historylog-entries due sync-addition
                                if ($dohistorylog)
                                {




reply via email to

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