Пример #1
0
 private function onCreate()
 {
     $form = $this->getForm();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateCT();
     }
     $options = GWF_HelpdeskTicket::USER_READ;
     $options |= isset($_POST['faq']) ? GWF_HelpdeskTicket::ALLOW_FAQ : 0;
     $options |= isset($_POST['email']) ? GWF_HelpdeskTicket::EMAIL_ME : 0;
     $ticket = new GWF_HelpdeskTicket(array('hdt_id' => '0', 'hdt_uid' => GWF_Session::getUserID(), 'hdt_worker' => '0', 'hdt_date' => GWF_Time::getDate(GWF_Time::LEN_SECOND), 'hdt_title' => $form->getVar('title'), 'hdt_other' => $form->getVar('other'), 'hdt_priority' => '0', 'hdt_status' => 'open', 'hdt_options' => $options));
     if (false === $ticket->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateCT();
     }
     $ticket->setVar('hdt_uid', GWF_Session::getUser());
     $message = new GWF_HelpdeskMsg(array('hdm_id' => '0', 'hdm_tid' => $ticket->getID(), 'hdm_uid' => GWF_Session::getUserID(), 'hdm_date' => GWF_Time::getDate(GWF_Time::LEN_SECOND), 'hdm_message' => $form->getVar('message'), 'hdm_options' => '0'));
     if (false === $message->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateCT();
     }
     $message->setVar('hdm_uid', GWF_Session::getUser());
     $this->onMailTicket($ticket, $message);
     return $this->module->message('msg_created');
 }