Exemplo n.º 1
0
 /**
  * 得到留言的信息状态以及留言者的信息,回复信息以及回复者的信息
  *
  * @param Array $query_struct
  * @return Array
  */
 public function get_message_reply_by_site_manage_role($query_struct = array())
 {
     $list = array();
     $results = self::messages($query_struct);
     if (!empty($results)) {
         foreach ($results as $result) {
             $request_struct = array('where' => array('message_id' => $result['id']));
             if (!empty($result['is_reply'])) {
                 $replies = Message_replyService::get_instance()->index($request_struct);
                 foreach ($replies as $key => $val) {
                     $replies[$key]['manager_name'] = Mymanager::instance($val['manager_id'])->get('name');
                     $replies[$key]['manager_email'] = Mymanager::instance($val['manager_id'])->get('email');
                 }
                 $result['replies'] = $replies;
             }
             $list[] = $result;
         }
     }
     return $list;
 }
Exemplo n.º 2
0
 /**
  * 留言回复
  */
 public function do_edit()
 {
     $request_data = $this->input->post();
     if ($_POST) {
         //数据验证
         $validation = Validation::factory($request_data)->add_rules('message_id', 'required', 'digit')->add_rules('content', 'required', 'length[0,65535]');
         if (!$validation->validate()) {
             remind::set(Kohana::lang('o_global.input_error'), request::referrer());
         }
         $message = MessageService::get_instance()->get($request_data['message_id']);
         if (empty($message['id'])) {
             remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
         }
         $set_data = array('message_id' => $message['id'], 'manager_id' => $this->manager_id, 'content' => $request_data['content'], 'update_timestamp' => date('Y-m-d H:i:s'));
         //判断此管理员是否已经回复过
         $message_reply_service = Message_replyService::get_instance();
         $manager_reply = $message_reply_service->get_reply_by_manager_id($this->manager_id, $message['id']);
         if (isset($manager_reply) && !empty($manager_reply['id'])) {
             $message_reply_service->set($manager_reply['id'], $set_data);
         } else {
             $set_data['create_timestamp'] = date('Y-m-d H:i:s');
             $message_reply_service->add($set_data);
             //把留言的回复状态改为已回复
             $message_data['is_reply'] = MessageService::IS_MANAGER_REPLY;
             MessageService::get_instance()->set($message['id'], $message_data);
         }
         //发送邮件
         if ($request_data['send_mail'] == '1') {
             $email_flag = 'the answer of your question';
             $email = $message['email'];
             $name = Mymanager::instance($message['manager_id'])->get('name');
             $content = '';
             $content .= 'Dear ' . $name . ' :<br>';
             $content .= $request_data['content'];
             if (mail::send($email, $email_flag, $content)) {
                 remind::set(Kohana::lang('o_global.mail_send_success'));
             } else {
                 remind::set(Kohana::lang('o_global.mail_send_error'), 'manage/message/edit?id=' . $message['id']);
             }
         }
         remind::set(Kohana::lang('o_manage.message_success'), 'manage/message', 'success');
     } else {
         remind::set(Kohana::lang('o_manage.message_error'), 'manage/message/edit?id=' . $message['id']);
     }
 }