* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBEvent_Handler' , 'WBEvent_Handler_ITS'); /** * WBEvent_Handler_ITS_Update * * Update ticket * * @version 0.1.0 * @package Wombat * @subpackage base */ 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) * * @see WBEvent_Handler_Mail * @var array */ protected $config = array( 'loadticket' => '', 'data' => array(), 'deletecomment' => 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) { $this->loadTicket($e); $save = $this->config['data']; $save['comment'] = $e->get('commentbody', ''); $this->ticket->save($save); $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); } }