Пример #1
0
 public function sendProductConversationMail($product_details = array(), $thread_id = 0, $key = 'NewComment', $message_id = 0, $reference_id = 0)
 {
     $thread_details_arr = MpProductComments::whereRaw("id = ?", array($thread_id))->first();
     if (count($product_details) == 0 || count($thread_details_arr) == 0) {
         return '';
     }
     $email_template = 'emails.mp_product.productCommentAddedNotify';
     /*
     switch($key)
     {
     	case 'NewComment':
     		$email_template .= 'requestNewMessage';
     		break;
     
     	case 'MessageOwnerReply':
     		$email_template .= 'requestMessageOwnerReply';
     		break;
     
     	case 'MessageUserReply':
     		$email_template .= 'requestMessageUserReply';
     		break;
     
     	case 'deleteThread':
     		$email_template .= 'requestDeleteThread';
     		break;
     
     	case 'deleteThreadReply':
     		$email_template .= 'requestDeleteThreadReply';
     		break;
     
     	default:
     		return '';
     }
     */
     $view_product_link = $this->getProductViewURL($product_details->id, $product_details);
     $thread_link = $view_product_link . '?thread=' . $thread_id;
     $message_details_arr = array();
     //To get user information
     $from_id = $this->logged_user_id;
     $to_id = $product_details['product_user_id'] == $from_id ? $thread_details_arr['user_id'] : $thread_details_arr['seller_id'];
     $from_user_details = CUtil::getUserDetails($from_id, 'all');
     $to_user_details = CUtil::getUserDetails($to_id, 'all');
     //To get seller details
     $owner_details = array();
     if ($from_id == $product_details['product_user_id']) {
         $owner_details = $from_user_details;
     } elseif ($to_id == $product_details['product_user_id']) {
         $owner_details = $to_user_details;
     } else {
         $owner_details = CUtil::getUserDetails($product_details['product_user_id'], 'all');
     }
     //To get commenter details
     $commenter_details = array();
     if ($from_id == $thread_details_arr['user_id']) {
         $commenter_details = $from_user_details;
     } elseif ($to_id == $thread_details_arr['user_id']) {
         $commenter_details = $to_user_details;
     } else {
         $commenter_details = CUtil::getUserDetails($thread_details_arr['user_id'], 'all');
     }
     $visibility_text = $thread_details_arr['visibility'] == "Public" ? "Public" : "Private";
     //Get replied message details
     $notes = $thread_details_arr['message'];
     if ($message_id > 0) {
         //To get message details if already not fetched..
         if (count($message_details_arr) == 0) {
             $message_details_arr = MpProductCommentReplies::whereRaw("id = ?", array($message_id))->first();
             if (count($message_details_arr) > 0) {
                 $notes = $message_details_arr['notes'];
                 if ($message_details_arr['visibility_status'] == 'Private') {
                     $visibility_text = trans('mp_product/viewProduct.private_msg_for');
                     $visibility_text .= $to_user_details['display_name'];
                     $visibility_text .= " By." . $from_user_details['display_name'];
                 }
             }
         }
     }
     //To assign mail data's..
     $mail_subject_lang = 'email.product_' . snake_case($key);
     $user_mail_sub = trans($mail_subject_lang . '_notify_user');
     $admin_mail_sub = trans($mail_subject_lang . '_notify_admin');
     //	$ack_mail_sub = trans($mail_subject_lang.'NotifyACK');
     $data_arr = array('product_title' => $product_details['product_name'], 'from_user_name' => $from_user_details['display_name'], 'to_user_name' => $to_user_details['display_name'], 'from_profile_url' => $from_user_details['profile_url'], 'to_profile_url' => $to_user_details['profile_url'], 'view_product_link' => $view_product_link, 'thread_link' => $thread_link, 'notes' => $notes, 'visibility' => $visibility_text, 'product_details' => $product_details, 'owner_details' => $owner_details, 'commenter_details' => $commenter_details, 'user_subject' => str_replace('VAR_PRODUCT_TITLE', $product_details['product_name'], $user_mail_sub), 'to_user_mail' => $to_user_details['email'], 'admin_subject' => str_replace('VAR_PRODUCT_TITLE', $product_details['product_name'], $admin_mail_sub), 'admin_email_template' => $email_template . 'ForAdmin', 'user_email_template' => $email_template . 'ForUser', 'key' => $key);
     //Mail to admin
     $mailer = new AgMailer();
     $data_arr['subject'] = $data_arr['admin_subject'];
     $mailer->sendAlertMail('product_comment', $data_arr['admin_email_template'], $data_arr);
     if (isset($to_user_details['email']) && $to_user_details['email'] != "" && $from_id != $to_id) {
         $data_arr['subject'] = $data_arr['user_subject'];
         $data_arr['to_email'] = $to_user_details['email'];
         $mailer->sendUserMail('product_comment', $data_arr['user_email_template'], $data_arr);
     }
 }
 public function listReplyComment()
 {
     $thread_id = Input::get('thread_id', 0);
     $thread_details_arr = MpProductCommentReplies::whereRaw("id = ? AND is_deleted = ?", array($thread_id, 0))->first();
     if (count($thread_details_arr) > 0) {
         $d_arr = array();
         $message_replies = $this->ViewProductService->getProductReplies($thread_id);
         $thread_added_by = $thread_details_arr['seller_id'];
         $product_added_by = $thread_details_arr['user_id'];
         $thread_id = $thread_details_arr['id'];
         $return_arr = $this->chkIsAllowConversation($thread_details_arr['request_id'], array(), $thread_id);
         $d_arr['allow_to_suggestion'] = $return_arr['allow_to_suggestion'];
         $d_arr['allow_to_message'] = $return_arr['allow_to_message'];
         $d_arr['allow_to_conversation'] = $return_arr['allow_to_conversation'];
         $d_arr['allow_to_reply'] = $return_arr['allow_to_reply'];
         $total_replies = $thread_details_arr['total_replies'];
         return View::make('mp_product/productThreadReply', compact('message_replies', 'thread_added_by', 'product_added_by', 'thread_id', 'd_arr', 'total_replies'));
     }
     return;
 }