* @package WB * @subpackage ITS */ WBClass::load('WBEvent_Handler' , 'WBEvent_Handler_ITS' , 'WBException_Config'); /** * WBEvent_Handler_ITS_Update * * Update ticket * * @version 0.1.0 * @package Wombat * @subpackage ITS */ class WBEvent_Handler_ITS_Update extends WBEvent_Handler_ITS { /** * Handler config * * For parameter list see parent class, additional parameter: * - loadticket: index of id to load ticket * - data: values to update ticket with * - deletecomment: original comment, default 1 (yes) * - triggerevent: default 1 (yes) * * @see WBEvent_Handler_Mail * @var array */ protected $config = array( 'loadticket' => '', 'data' => array(), 'deletecomment' => 1, 'triggerevent' => 1 ); /** * Comment object * @var WBDatasource_Comment */ private $comment; /** * Process event * * Send e-mail to customer * - Load ticket data using id given in event data * * @param WBEvent $e * @return bool true to continue, false to stop processing * @throws Exception in case of error */ public function process(WBEvent $e) { try { $this->loadTicket($e); } catch (WBException_Config $e) { return true; } $save = $this->config['data']; $save['comment'] = $e->get('commentbody', ''); $this->ticket->save($save); // update event data as well foreach ($save as $k => $v) { $e->set($k, $v); } $this->deleteComment($e); return true; } /** * Remove origin comment * * @param WBEvent $e */ private function deleteComment($e) { if (!$this->config['deletecomment']) { return; } $id = $e->get('id'); if (empty($id)) { return; } $this->comment = WBClass::create('WBDatasource_Comment'); $this->comment->useEventTrigger(false); $this->comment->forceDelete($id); } }