* @copyright 2005 by http://wombat.exit0.net * @package wombatSite * @subpackage event */ /** * Create a ticket on event * * * @version 0.1.0 * @package wombatSite * @subpackage event */ class wbEventHandler_Ticket extends wbEventHandler { /** * handler default parameter * @var array $_params */ var $_paramsDefault = array( 'status' => 'assigned', 'type' => 'task', 'title' => 'task event', 'owner' => '1', 'rcpts' => '', ); /** * handle event * * @access public * @param object $e event object * @return string $msg */ function process( &$e ) { $tm =& wbFactory::singleton( 'wbTicket' ); if( patErrorManager::isError( $tm ) ) { return $tm; } // create ticket information $tData = $e->getData(); $tData['type'] = $this->_params['type']; $tData['title'] = $this->_params['title']; $tData['link'] = $e->getLink(); $tData['message'] = $e->getMsg(); $tic = $tm->create( $tData ); if( patErrorManager::isError( $tic ) ) { return $tic; } // apply ticket status switch( strtolower( $this->_params['status'] ) ) { case 'assigned': $owner = (int) $this->_params['owner']; $result = $tm->assign( $owner ); if( patErrorManager::isError( $result ) ) { return $result; } break; default: break; } // add other recipients if( empty( $this->_params['rpcts'] ) ) { return true; } $rcpts = explode( ',', $this->_params['rpcts'] ); foreach( $rcpts as $rcpt ) { $result = $tm->addRcpt( $rcpt ); if( patErrorManager::isError( $result ) ) { return $result; } } return true; } } ?>