当前位置: 首页>>代码示例>>PHP>>正文


PHP CustomerThread::getIdCustomerThreadByEmailAndIdOrder方法代码示例

本文整理汇总了PHP中CustomerThread::getIdCustomerThreadByEmailAndIdOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomerThread::getIdCustomerThreadByEmailAndIdOrder方法的具体用法?PHP CustomerThread::getIdCustomerThreadByEmailAndIdOrder怎么用?PHP CustomerThread::getIdCustomerThreadByEmailAndIdOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CustomerThread的用法示例。


在下文中一共展示了CustomerThread::getIdCustomerThreadByEmailAndIdOrder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 /**
  * Start forms process
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     if (Tools::isSubmit('submitMessage')) {
         $idOrder = (int) Tools::getValue('id_order');
         $msgText = Tools::getValue('msgText');
         if (!$idOrder || !Validate::isUnsignedId($idOrder)) {
             $this->errors[] = Tools::displayError('The order is no longer valid.');
         } elseif (empty($msgText)) {
             $this->errors[] = Tools::displayError('The message cannot be blank.');
         } elseif (!Validate::isMessage($msgText)) {
             $this->errors[] = Tools::displayError('This message is invalid (HTML is not allowed).');
         }
         if (!count($this->errors)) {
             $order = new Order($idOrder);
             if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
                 //check if a thread already exist
                 $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($this->context->customer->email, $order->id);
                 $cm = new CustomerMessage();
                 if (!$id_customer_thread) {
                     $ct = new CustomerThread();
                     $ct->id_contact = 0;
                     $ct->id_customer = (int) $order->id_customer;
                     $ct->id_shop = (int) $this->context->shop->id;
                     if (($id_product = (int) Tools::getValue('id_product')) && $order->orderContainProduct((int) $id_product)) {
                         $ct->id_product = $id_product;
                     }
                     $ct->id_order = (int) $order->id;
                     $ct->id_lang = (int) $this->context->language->id;
                     $ct->email = $this->context->customer->email;
                     $ct->status = 'open';
                     $ct->token = Tools::passwdGen(12);
                     $ct->add();
                 } else {
                     $ct = new CustomerThread((int) $id_customer_thread);
                 }
                 $cm->id_customer_thread = $ct->id;
                 $cm->message = $msgText;
                 $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
                 $cm->add();
                 if (!Configuration::get('PS_MAIL_EMAIL_MESSAGE')) {
                     $to = strval(Configuration::get('PS_SHOP_EMAIL'));
                 } else {
                     $to = new Contact((int) Configuration::get('PS_MAIL_EMAIL_MESSAGE'));
                     $to = strval($to->email);
                 }
                 $toName = strval(Configuration::get('PS_SHOP_NAME'));
                 $customer = $this->context->customer;
                 if (Validate::isLoadedObject($customer)) {
                     Mail::Send($this->context->language->id, 'order_customer_comment', Mail::l('Message from a customer'), array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{email}' => $customer->email, '{id_order}' => (int) $order->id, '{order_name}' => $order->getUniqReference(), '{message}' => Tools::nl2br($msgText)), $to, $toName, $customer->email, $customer->firstname . ' ' . $customer->lastname);
                 }
                 if (Tools::getValue('ajax') != 'true') {
                     Tools::redirect('index.php?controller=order-detail&id_order=' . (int) $idOrder);
                 }
                 $this->context->smarty->assign('message_confirmation', true);
             } else {
                 $this->errors[] = Tools::displayError('Order not found');
             }
         }
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:64,代码来源:OrderDetailController.php

示例2: postProcess

    /**
     * Start forms process
     * @see FrontController::postProcess()
     */
    public function postProcess()
    {
        if (Tools::isSubmit('submitMessage')) {
            $fileAttachment = null;
            if (isset($_FILES['fileUpload']['name']) && !empty($_FILES['fileUpload']['name']) && !empty($_FILES['fileUpload']['tmp_name'])) {
                $extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
                $filename = uniqid() . substr($_FILES['fileUpload']['name'], -5);
                $fileAttachment['content'] = file_get_contents($_FILES['fileUpload']['tmp_name']);
                $fileAttachment['name'] = $_FILES['fileUpload']['name'];
                $fileAttachment['mime'] = $_FILES['fileUpload']['type'];
            }
            $message = Tools::getValue('message');
            // Html entities is not usefull, iscleanHtml check there is no bad html tags.
            if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from)) {
                $this->errors[] = Tools::displayError('Invalid e-mail address');
            } else {
                if (!$message) {
                    $this->errors[] = Tools::displayError('Message cannot be blank');
                } else {
                    if (!Validate::isCleanHtml($message)) {
                        $this->errors[] = Tools::displayError('Invalid message');
                    } else {
                        if (!($id_contact = (int) Tools::getValue('id_contact')) || !Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))) {
                            $this->errors[] = Tools::displayError('Please select a subject from the list.');
                        } else {
                            if (!empty($_FILES['fileUpload']['name']) && $_FILES['fileUpload']['error'] != 0) {
                                $this->errors[] = Tools::displayError('An error occurred during the file upload');
                            } else {
                                if (!empty($_FILES['fileUpload']['name']) && !in_array(substr($_FILES['fileUpload']['name'], -4), $extension) && !in_array(substr($_FILES['fileUpload']['name'], -5), $extension)) {
                                    $this->errors[] = Tools::displayError('Bad file extension');
                                } else {
                                    $customer = $this->context->customer;
                                    if (!$customer->id) {
                                        $customer->getByEmail($from);
                                    }
                                    $contact = new Contact($id_contact, $this->context->language->id);
                                    if (!(($id_customer_thread = (int) Tools::getValue('id_customer_thread')) && (int) Db::getInstance()->getValue('
						SELECT cm.id_customer_thread FROM ' . _DB_PREFIX_ . 'customer_thread cm
						WHERE cm.id_customer_thread = ' . (int) $id_customer_thread . ' AND cm.id_shop = ' . (int) $this->context->shop->id . ' AND token = \'' . pSQL(Tools::getValue('token')) . '\'') || ($id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, (int) Tools::getValue('id_order'))))) {
                                        $fields = Db::getInstance()->executeS('
					SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
					FROM ' . _DB_PREFIX_ . 'customer_thread cm
					WHERE email = \'' . pSQL($from) . '\' AND cm.id_shop = ' . (int) $this->context->shop->id . ' AND (' . ($customer->id ? 'id_customer = ' . (int) $customer->id . ' OR ' : '') . '
						id_order = ' . (int) Tools::getValue('id_order') . ')');
                                        $score = 0;
                                        foreach ($fields as $key => $row) {
                                            $tmp = 0;
                                            if ((int) $row['id_customer'] && $row['id_customer'] != $customer->id && $row['email'] != $from) {
                                                continue;
                                            }
                                            if ($row['id_order'] != 0 && Tools::getValue('id_order') != $row['id_order']) {
                                                continue;
                                            }
                                            if ($row['email'] == $from) {
                                                $tmp += 4;
                                            }
                                            if ($row['id_contact'] == $id_contact) {
                                                $tmp++;
                                            }
                                            if (Tools::getValue('id_product') != 0 && $row['id_product'] == Tools::getValue('id_product')) {
                                                $tmp += 2;
                                            }
                                            if ($tmp >= 5 && $tmp >= $score) {
                                                $score = $tmp;
                                                $id_customer_thread = $row['id_customer_thread'];
                                            }
                                        }
                                    }
                                    $old_message = Db::getInstance()->getValue('
					SELECT cm.message FROM ' . _DB_PREFIX_ . 'customer_message cm
					LEFT JOIN ' . _DB_PREFIX_ . 'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
					WHERE cc.id_customer_thread = ' . (int) $id_customer_thread . ' AND cc.id_shop = ' . (int) $this->context->shop->id . '
					ORDER BY cm.date_add DESC');
                                    if ($old_message == $message) {
                                        $this->context->smarty->assign('alreadySent', 1);
                                        $contact->email = '';
                                        $contact->customer_service = 0;
                                    }
                                    if (!empty($contact->email)) {
                                        $id_order = (int) Tools::getValue('id_order', 0);
                                        $order = new Order($id_order);
                                        $mail_var_list = array('{email}' => $from, '{message}' => Tools::nl2br(stripslashes($message)), '{id_order}' => $id_order, '{order_name}' => $order->getUniqReference(), '{attached_file}' => isset($_FILES['fileUpload'], $_FILES['fileUpload']['name']) ? $_FILES['fileUpload']['name'] : '');
                                        if (Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form'), $mail_var_list, $contact->email, $contact->name, $from, $customer->id ? $customer->firstname . ' ' . $customer->lastname : '', $fileAttachment) && Mail::Send($this->context->language->id, 'contact_form', Mail::l('Your message has been correctly sent'), $mail_var_list, $from)) {
                                            $this->context->smarty->assign('confirmation', 1);
                                        } else {
                                            $this->errors[] = Tools::displayError('An error occurred while sending message.');
                                        }
                                    }
                                    if ($contact->customer_service) {
                                        if ((int) $id_customer_thread) {
                                            $ct = new CustomerThread($id_customer_thread);
                                            $ct->status = 'open';
                                            $ct->id_lang = (int) $this->context->language->id;
                                            $ct->id_contact = (int) $id_contact;
                                            if ($id_order = (int) Tools::getValue('id_order')) {
                                                $ct->id_order = $id_order;
//.........这里部分代码省略.........
开发者ID:jicheng17,项目名称:pengwine,代码行数:101,代码来源:ContactController.php

示例3: postProcess

    /**
     * Start forms process
     * @see FrontController::postProcess()
     */
    public function postProcess()
    {
        if (Tools::isSubmit('submitMessage')) {
            $extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
            $file_attachment = Tools::fileAttachment('fileUpload');
            $message = Tools::getValue('message');
            // Html entities is not usefull, iscleanHtml check there is no bad html tags.
            if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from)) {
                $this->errors[] = Tools::displayError('Invalid email address.');
            } elseif (!$message) {
                $this->errors[] = Tools::displayError('The message cannot be blank.');
            } elseif (!Validate::isCleanHtml($message)) {
                $this->errors[] = Tools::displayError('Invalid message');
            } elseif (!($id_contact = (int) Tools::getValue('id_contact')) || !Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))) {
                $this->errors[] = Tools::displayError('Please select a subject from the list provided. ');
            } elseif (!empty($file_attachment['name']) && $file_attachment['error'] != 0) {
                $this->errors[] = Tools::displayError('An error occurred during the file-upload process.');
            } elseif (!empty($file_attachment['name']) && !in_array(Tools::strtolower(substr($file_attachment['name'], -4)), $extension) && !in_array(Tools::strtolower(substr($file_attachment['name'], -5)), $extension)) {
                $this->errors[] = Tools::displayError('Bad file extension');
            } else {
                $customer = $this->context->customer;
                if (!$customer->id) {
                    $customer->getByEmail($from);
                }
                $id_order = (int) $this->getOrder();
                if (!(($id_customer_thread = (int) Tools::getValue('id_customer_thread')) && (int) Db::getInstance()->getValue('
						SELECT cm.id_customer_thread FROM ' . _DB_PREFIX_ . 'customer_thread cm
						WHERE cm.id_customer_thread = ' . (int) $id_customer_thread . ' AND cm.id_shop = ' . (int) $this->context->shop->id . ' AND token = \'' . pSQL(Tools::getValue('token')) . '\'') || ($id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, $id_order)))) {
                    $fields = Db::getInstance()->executeS('
					SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
					FROM ' . _DB_PREFIX_ . 'customer_thread cm
					WHERE email = \'' . pSQL($from) . '\' AND cm.id_shop = ' . (int) $this->context->shop->id . ' AND (' . ($customer->id ? 'id_customer = ' . (int) $customer->id . ' OR ' : '') . '
						id_order = ' . (int) $id_order . ')');
                    $score = 0;
                    foreach ($fields as $key => $row) {
                        $tmp = 0;
                        if ((int) $row['id_customer'] && $row['id_customer'] != $customer->id && $row['email'] != $from) {
                            continue;
                        }
                        if ($row['id_order'] != 0 && $id_order != $row['id_order']) {
                            continue;
                        }
                        if ($row['email'] == $from) {
                            $tmp += 4;
                        }
                        if ($row['id_contact'] == $id_contact) {
                            $tmp++;
                        }
                        if (Tools::getValue('id_product') != 0 && $row['id_product'] == Tools::getValue('id_product')) {
                            $tmp += 2;
                        }
                        if ($tmp >= 5 && $tmp >= $score) {
                            $score = $tmp;
                            $id_customer_thread = $row['id_customer_thread'];
                        }
                    }
                }
                $old_message = Db::getInstance()->getValue('
					SELECT cm.message FROM ' . _DB_PREFIX_ . 'customer_message cm
					LEFT JOIN ' . _DB_PREFIX_ . 'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
					WHERE cc.id_customer_thread = ' . (int) $id_customer_thread . ' AND cc.id_shop = ' . (int) $this->context->shop->id . '
					ORDER BY cm.date_add DESC');
                if ($old_message == $message) {
                    $this->context->smarty->assign('alreadySent', 1);
                    $contact->email = '';
                    $contact->customer_service = 0;
                }
                if ($contact->customer_service) {
                    if ((int) $id_customer_thread) {
                        $ct = new CustomerThread($id_customer_thread);
                        $ct->status = 'open';
                        $ct->id_lang = (int) $this->context->language->id;
                        $ct->id_contact = (int) $id_contact;
                        $ct->id_order = (int) $id_order;
                        if ($id_product = (int) Tools::getValue('id_product')) {
                            $ct->id_product = $id_product;
                        }
                        $ct->update();
                    } else {
                        $ct = new CustomerThread();
                        if (isset($customer->id)) {
                            $ct->id_customer = (int) $customer->id;
                        }
                        $ct->id_shop = (int) $this->context->shop->id;
                        $ct->id_order = (int) $id_order;
                        if ($id_product = (int) Tools::getValue('id_product')) {
                            $ct->id_product = $id_product;
                        }
                        $ct->id_contact = (int) $id_contact;
                        $ct->id_lang = (int) $this->context->language->id;
                        $ct->email = $from;
                        $ct->status = 'open';
                        $ct->token = Tools::passwdGen(12);
                        $ct->add();
                    }
                    if ($ct->id) {
//.........这里部分代码省略.........
开发者ID:Rohit-jn,项目名称:hotelcommerce,代码行数:101,代码来源:ContactController.php

示例4: postProcess

 public function postProcess()
 {
     if (Tools::isSubmit('submitMessage')) {
         $idOrder = (int) Tools::getValue('id_order');
         $msgText = Tools::getValue('msgText');
         if (!$idOrder || !Validate::isUnsignedId($idOrder)) {
             $this->errors[] = Tools::displayError('The order is no longer valid.');
         } elseif (empty($msgText)) {
             $this->errors[] = Tools::displayError('The message cannot be blank.');
         } elseif (!Validate::isMessage($msgText)) {
             $this->errors[] = Tools::displayError('This message is invalid (HTML is not allowed).');
         }
         if (!count($this->errors)) {
             $order = new Order($idOrder);
             if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
                 //check if a thread already exist
                 $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($this->context->customer->email, $order->id);
                 $id_product = (int) Tools::getValue('id_product');
                 $cm = new CustomerMessage();
                 if (!$id_customer_thread) {
                     $ct = new CustomerThread();
                     $ct->id_contact = 0;
                     $ct->id_customer = (int) $order->id_customer;
                     $ct->id_shop = (int) $this->context->shop->id;
                     if ($id_product && $order->orderContainProduct((int) $id_product)) {
                         $ct->id_product = $id_product;
                     }
                     $ct->id_order = (int) $order->id;
                     $ct->id_lang = (int) $this->context->language->id;
                     $ct->email = $this->context->customer->email;
                     $ct->status = 'open';
                     $ct->token = Tools::passwdGen(12);
                     $ct->add();
                 } else {
                     $ct = new CustomerThread((int) $id_customer_thread);
                 }
                 $cm->id_customer_thread = $ct->id;
                 if ($id_product && $order->orderContainProduct((int) $id_product)) {
                     $cm->id_product = $id_product;
                 }
                 $cm->message = $msgText;
                 $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
                 $cm->add();
                 if (!Configuration::get('PS_MAIL_EMAIL_MESSAGE')) {
                     $to = strval(Configuration::get('PS_SHOP_EMAIL'));
                 } else {
                     $to = new Contact((int) Configuration::get('PS_MAIL_EMAIL_MESSAGE'));
                     $to = strval($to->email);
                 }
                 $toName = strval(Configuration::get('PS_SHOP_NAME'));
                 $customer = $this->context->customer;
                 $product = new Product($id_product);
                 $product_name = '';
                 if (Validate::isLoadedObject($product) && isset($product->name[(int) $this->context->language->id])) {
                     $product_name = $product->name[(int) $this->context->language->id];
                 }
                 if (Validate::isLoadedObject($customer)) {
                     Mail::Send($this->context->language->id, 'order_customer_comment', Mail::l('Message from a customer'), array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{email}' => $customer->email, '{id_order}' => (int) $order->id, '{order_name}' => $order->getUniqReference(), '{message}' => Tools::nl2br($msgText), '{product_name}' => $product_name), $to, $toName, $customer->email, $customer->firstname . ' ' . $customer->lastname);
                 }
                 if (Tools::getValue('ajax') != 'true') {
                     Tools::redirect('index.php?controller=order-detail&id_order=' . (int) $idOrder);
                 }
                 $this->context->smarty->assign('message_confirmation', true);
             } else {
                 $this->errors[] = Tools::displayError('Order not found');
             }
         }
     }
     if (Tools::isSubmit('markAsReceived')) {
         $idOrder = (int) Tools::getValue('id_order');
         $order = new Order($idOrder);
         if (Validate::isLoadedObject($order)) {
             if ($order->getCurrentState() == 15) {
                 $new_history = new OrderHistory();
                 $new_history->id_order = (int) $order->id;
                 $new_history->changeIdOrderState(3, $order);
                 // 16: Ready for Production
                 //var_dump($order,$new_history);
                 $myfile = fopen(PS_PRODUCT_IMG_PATH . "/orders/" . $order->reference . ".txt", "w") or die("Unable to open file!");
                 $txt = "Order Confirmed\n Order Reference: " . $order->reference;
                 fwrite($myfile, $txt);
                 fclose($myfile);
                 $new_history->addWithemail(true);
             }
             $this->context->smarty->assign('receipt_confirmation', true);
         } else {
             $this->_errors[] = Tools::displayError('Error: Invalid order number');
         }
     }
 }
开发者ID:Eximagen,项目名称:3m,代码行数:90,代码来源:OrderDetailController.php

示例5: postProcess


//.........这里部分代码省略.........
                 ${$heccerkhiwt} = new OrderHistory();
                 ${"GLOBALS"}["uynetoegv"] = "templateVars";
                 $vriwvgqg = "templateVars";
                 $history->id_order = $order->id;
                 $history->id_employee = 1;
                 $history->changeIdOrderState($order_state->id, $order->id);
                 ${${"GLOBALS"}["tvqrewgc"]} = new Carrier($order->id_carrier, $order->id_lang);
                 ${$vriwvgqg} = array();
                 if ($history->id_order_state == Configuration::get("PS_OS_SHIPPING") && $order->shipping_number) {
                     ${${"GLOBALS"}["nkwobosfw"]} = array("{followup}" => str_replace("@", $order->shipping_number, $carrier->url));
                 } elseif ($history->id_order_state == Configuration::get("PS_OS_CHEQUE")) {
                     ${${"GLOBALS"}["nkwobosfw"]} = array("{cheque_name}" => Configuration::get("CHEQUE_NAME") ? Configuration::get("CHEQUE_NAME") : "", "{cheque_address_html}" => Configuration::get("CHEQUE_ADDRESS") ? nl2br(Configuration::get("CHEQUE_ADDRESS")) : "");
                 } elseif ($history->id_order_state == Configuration::get("PS_OS_BANKWIRE")) {
                     ${${"GLOBALS"}["nkwobosfw"]} = array("{bankwire_owner}" => Configuration::get("BANK_WIRE_OWNER") ? Configuration::get("BANK_WIRE_OWNER") : "", "{bankwire_details}" => Configuration::get("BANK_WIRE_DETAILS") ? nl2br(Configuration::get("BANK_WIRE_DETAILS")) : "", "{bankwire_address}" => Configuration::get("BANK_WIRE_ADDRESS") ? nl2br(Configuration::get("BANK_WIRE_ADDRESS")) : "");
                 }
                 if (!$history->addWithemail(true, ${${"GLOBALS"}["uynetoegv"]})) {
                     $this->errors[] = Tools::displayError("An error occurred while changing the status or was unable to send e-mail to the customer.");
                 }
             } else {
                 $this->errors[] = Tools::displayError("This order is already assigned this status");
             }
         }
         if (empty($this->errors)) {
             self::$smarty->assign("cfmmsg_flag", 1);
         }
     }
     if (Tools::isSubmit("submitMessage")) {
         $ipovlstkh = "idOrder";
         ${${"GLOBALS"}["pfwbejwlah"]} = (int) Tools::getValue("id_order");
         ${${"GLOBALS"}["nioumgdgj"]} = Tools::getValue("msgText");
         ${"GLOBALS"}["tumvnnp"] = "msgText";
         if (!${${"GLOBALS"}["pfwbejwlah"]} || !Validate::isUnsignedId(${$ipovlstkh})) {
             $this->errors[] = Tools::displayError("Order is no longer valid");
         } else {
             if (empty(${${"GLOBALS"}["nioumgdgj"]})) {
                 $this->errors[] = Tools::displayError("Message cannot be blank");
             } else {
                 if (!Validate::isMessage(${${"GLOBALS"}["tumvnnp"]})) {
                     $this->errors[] = Tools::displayError("Message is invalid (HTML is not allowed)");
                 }
             }
         }
         if (!count($this->errors)) {
             $svycwjflohh = "idOrder";
             ${${"GLOBALS"}["thtbvco"]} = new Order(${$svycwjflohh});
             if (Validate::isLoadedObject(${${"GLOBALS"}["thtbvco"]})) {
                 ${"GLOBALS"}["pcdbkuo"] = "cm";
                 ${"GLOBALS"}["qejrcjwlidu"] = "to";
                 ${${"GLOBALS"}["nbpumdloal"]} = new Employee();
                 $iilmenu = "seller";
                 ${$iilmenu} = $emp->getbyEmail($this->context->customer->email);
                 $ucwaikq = "customer";
                 ${$ucwaikq} = new Customer($order->id_customer);
                 ${${"GLOBALS"}["ryhapbx"]} = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($customer->email, $order->id);
                 ${"GLOBALS"}["pnxcso"] = "id_customer_thread";
                 ${${"GLOBALS"}["pcdbkuo"]} = new CustomerMessage();
                 ${"GLOBALS"}["csptele"] = "ct";
                 $pykymotfmtq = "fromName";
                 if (!${${"GLOBALS"}["pnxcso"]}) {
                     ${"GLOBALS"}["azdvluwhw"] = "id_product";
                     ${"GLOBALS"}["fpmtmpmcoy"] = "id_product";
                     $vckfnym = "id_product";
                     ${${"GLOBALS"}["docrub"]} = new CustomerThread();
                     $ct->id_contact = 2;
                     $ct->id_customer = (int) $order->id_customer;
                     $ct->id_shop = (int) $this->context->shop->id;
                     ${$vckfnym} = (int) Tools::getValue("id_product");
                     if (${${"GLOBALS"}["fxogbxc"]} && $order->orderContainProduct(${${"GLOBALS"}["azdvluwhw"]})) {
                         $ct->id_product = ${${"GLOBALS"}["fpmtmpmcoy"]};
                     }
                     $ct->id_order = (int) $order->id;
                     $ct->id_lang = (int) $this->context->language->id;
                     $ct->email = $customer->email;
                     $ct->status = "open";
                     $ct->token = Tools::passwdGen(12);
                     $ct->add();
                 } else {
                     ${${"GLOBALS"}["csptele"]} = new CustomerThread((int) ${${"GLOBALS"}["ryhapbx"]});
                 }
                 $qlkkcochivs = "msgText";
                 $cm->id_customer_thread = $ct->id;
                 $cm->message = ${${"GLOBALS"}["nioumgdgj"]};
                 $cm->ip_address = ip2long($_SERVER["REMOTE_ADDR"]);
                 $cm->id_employee = $seller->id;
                 $cm->add();
                 $mwsicth = "fromName";
                 ${"GLOBALS"}["lhbflpuhi"] = "customer";
                 ${${"GLOBALS"}["oatuem"]} = $customer->email;
                 ${${"GLOBALS"}["xtxkthxeqll"]} = $customer->firstname . " " . $customer->lastname;
                 ${${"GLOBALS"}["sormbzxw"]} = $seller->email;
                 ${$mwsicth} = $seller->firstname . " " . $seller->lastname;
                 if (Validate::isLoadedObject(${${"GLOBALS"}["lhbflpuhi"]})) {
                     Mail::Send($this->context->language->id, "order_merchant_comment", Mail::l('Message from a seller'), array("{lastname}" => $customer->lastname, "{firstname}" => $customer->firstname, "{email}" => $customer->email, "{id_order}" => (int) $order->id, "{order_name}" => $order->getUniqReference(), "{message}" => Tools::nl2br(${$qlkkcochivs})), ${${"GLOBALS"}["qejrcjwlidu"]}, ${${"GLOBALS"}["xtxkthxeqll"]}, ${${"GLOBALS"}["sormbzxw"]}, ${$pykymotfmtq});
                 }
             } else {
                 $this->errors[] = Tools::displayError("Order not found");
             }
         }
     }
 }
开发者ID:sho5kubota,项目名称:guidingyou2,代码行数:101,代码来源:sellerorderdetail.php

示例6: saveContact

    public function saveContact()
    {
        $message = Tools::getValue('message');
        // Html entities is not usefull, iscleanHtml check there is no bad html tags.
        if (!($from = trim(Tools::getValue('email'))) || !Validate::isEmail($from)) {
            $this->errors[] = Tools::displayError('Invalid email address.');
        } elseif (!$message) {
            $this->errors[] = Tools::displayError('The message cannot be blank.');
        } elseif (!Validate::isCleanHtml($message)) {
            $this->errors[] = Tools::displayError('Invalid message');
        } elseif (!($id_contact = (int) Tools::getValue('id_contact')) || !Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))) {
            $this->errors[] = Tools::displayError('Please select a subject from the list provided. ');
        } else {
            $customer = $this->context->customer;
            if (!$customer->id) {
                $customer->getByEmail($from);
            }
            $id_order = (int) $this->getOrder();
            if (!(($id_customer_thread = (int) Tools::getValue('id_customer_thread')) && (int) Db::getInstance()->getValue('
						SELECT cm.id_customer_thread FROM ' . _DB_PREFIX_ . 'customer_thread cm
						WHERE cm.id_customer_thread = ' . (int) $id_customer_thread . ' AND cm.id_shop = ' . (int) $this->context->shop->id . ' AND token = \'' . pSQL(Tools::getValue('token')) . '\'') || ($id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, $id_order)))) {
                $fields = Db::getInstance()->executeS('
					SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
					FROM ' . _DB_PREFIX_ . 'customer_thread cm
					WHERE email = \'' . pSQL($from) . '\' AND cm.id_shop = ' . (int) $this->context->shop->id . ' AND (' . ($customer->id ? 'id_customer = ' . (int) $customer->id . ' OR ' : '') . '
						id_order = ' . (int) $id_order . ')');
                $score = 0;
                foreach ($fields as $key => $row) {
                    $tmp = 0;
                    if ((int) $row['id_customer'] && $row['id_customer'] != $customer->id && $row['email'] != $from) {
                        continue;
                    }
                    if ($row['id_order'] != 0 && $id_order != $row['id_order']) {
                        continue;
                    }
                    if ($row['email'] == $from) {
                        $tmp += 4;
                    }
                    if ($row['id_contact'] == $id_contact) {
                        $tmp++;
                    }
                    if (Tools::getValue('id_product') != 0 && $row['id_product'] == Tools::getValue('id_product')) {
                        $tmp += 2;
                    }
                    if ($tmp >= 5 && $tmp >= $score) {
                        $score = $tmp;
                        $id_customer_thread = $row['id_customer_thread'];
                    }
                }
            }
            $old_message = Db::getInstance()->getValue('
					SELECT cm.message FROM ' . _DB_PREFIX_ . 'customer_message cm
					LEFT JOIN ' . _DB_PREFIX_ . 'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
					WHERE cc.id_customer_thread = ' . (int) $id_customer_thread . ' AND cc.id_shop = ' . (int) $this->context->shop->id . '
					ORDER BY cm.date_add DESC');
            if ($old_message == $message) {
                $this->context->smarty->assign('alreadySent', 1);
                $contact->email = '';
                $contact->customer_service = 0;
            }
            if ($contact->customer_service) {
                if ((int) $id_customer_thread) {
                    $ct = new CustomerThread($id_customer_thread);
                    $ct->status = 'open';
                    $ct->id_lang = (int) $this->context->language->id;
                    $ct->id_contact = (int) $id_contact;
                    $ct->id_order = (int) $id_order;
                    if ($id_product = (int) Tools::getValue('id_product')) {
                        $ct->id_product = $id_product;
                    }
                    $ct->update();
                } else {
                    $ct = new CustomerThread();
                    if (isset($customer->id)) {
                        $ct->id_customer = (int) $customer->id;
                    }
                    $ct->id_shop = (int) $this->context->shop->id;
                    $ct->id_order = (int) $id_order;
                    if ($id_product = (int) Tools::getValue('id_product')) {
                        $ct->id_product = $id_product;
                    }
                    $ct->id_contact = (int) $id_contact;
                    $ct->id_lang = (int) $this->context->language->id;
                    $ct->email = $from;
                    $ct->status = 'open';
                    $ct->token = Tools::passwdGen(12);
                    $ct->add();
                }
                if ($ct->id) {
                    $cm = new CustomerMessage();
                    $cm->id_customer_thread = $ct->id;
                    $cm->message = $message;
                    $cm->ip_address = (int) ip2long(Tools::getRemoteAddr());
                    $cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
                    if (!$cm->add()) {
                        $this->errors[] = Tools::displayError('An error occurred while sending the message.');
                    }
                } else {
                    $this->errors[] = Tools::displayError('An error occurred while sending the message.');
                }
//.........这里部分代码省略.........
开发者ID:zangles,项目名称:lennyba,代码行数:101,代码来源:megaboxsAjax.php

示例7: sendMessage

 public function sendMessage()
 {
     $extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
     $file_attachment = Tools::fileAttachment('fileUpload');
     $message = Tools::getValue('message');
     if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from)) {
         $this->context->controller->errors[] = $this->l('Invalid email address.');
     } elseif (!$message) {
         $this->context->controller->errors[] = $this->l('The message cannot be blank.');
     } elseif (!Validate::isCleanHtml($message)) {
         $this->context->controller->errors[] = $this->l('Invalid message');
     } elseif (!($id_contact = (int) Tools::getValue('id_contact')) || !Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))) {
         $this->context->controller->errors[] = $this->l('Please select a subject from the list provided. ');
     } elseif (!empty($file_attachment['name']) && $file_attachment['error'] != 0) {
         $this->context->controller->errors[] = $this->l('An error occurred during the file-upload process.');
     } elseif (!empty($file_attachment['name']) && !in_array(Tools::strtolower(substr($file_attachment['name'], -4)), $extension) && !in_array(Tools::strtolower(substr($file_attachment['name'], -5)), $extension)) {
         $this->context->controller->errors[] = $this->l('Bad file extension');
     } else {
         $customer = $this->context->customer;
         if (!$customer->id) {
             $customer->getByEmail($from);
         }
         $id_order = (int) Tools::getValue('id_order');
         $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, $id_order);
         if ($contact->customer_service) {
             if ((int) $id_customer_thread) {
                 $ct = new CustomerThread($id_customer_thread);
                 $ct->status = 'open';
                 $ct->id_lang = (int) $this->context->language->id;
                 $ct->id_contact = (int) $id_contact;
                 $ct->id_order = (int) $id_order;
                 if ($id_product = (int) Tools::getValue('id_product')) {
                     $ct->id_product = $id_product;
                 }
                 $ct->update();
             } else {
                 $ct = new CustomerThread();
                 if (isset($customer->id)) {
                     $ct->id_customer = (int) $customer->id;
                 }
                 $ct->id_shop = (int) $this->context->shop->id;
                 $ct->id_order = (int) $id_order;
                 if ($id_product = (int) Tools::getValue('id_product')) {
                     $ct->id_product = $id_product;
                 }
                 $ct->id_contact = (int) $id_contact;
                 $ct->id_lang = (int) $this->context->language->id;
                 $ct->email = $from;
                 $ct->status = 'open';
                 $ct->token = Tools::passwdGen(12);
                 $ct->add();
             }
             if ($ct->id) {
                 $lastMessage = CustomerMessage::getLastMessageForCustomerThread($ct->id);
                 $testFileUpload = isset($file_attachment['rename']) && !empty($file_attachment['rename']);
                 // if last message is the same as new message (and no file upload), do not consider this contact
                 if ($lastMessage != $message || $testFileUpload) {
                     $cm = new CustomerMessage();
                     $cm->id_customer_thread = $ct->id;
                     $cm->message = $message;
                     if ($testFileUpload && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_ . basename($file_attachment['rename']))) {
                         $cm->file_name = $file_attachment['rename'];
                         @chmod(_PS_UPLOAD_DIR_ . basename($file_attachment['rename']), 0664);
                     }
                     $cm->ip_address = (int) ip2long(Tools::getRemoteAddr());
                     $cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
                     if (!$cm->add()) {
                         $this->context->controller->errors[] = $this->l('An error occurred while sending the message.');
                     }
                 } else {
                     $mailAlreadySend = true;
                 }
             } else {
                 $this->context->controller->errors[] = $this->l('An error occurred while sending the message.');
             }
         }
         if (!count($this->context->controller->errors) && empty($mailAlreadySend)) {
             $var_list = ['{order_name}' => '-', '{attached_file}' => '-', '{message}' => Tools::nl2br(stripslashes($message)), '{email}' => $from, '{product_name}' => ''];
             if (isset($file_attachment['name'])) {
                 $var_list['{attached_file}'] = $file_attachment['name'];
             }
             $id_product = (int) Tools::getValue('id_product');
             if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) {
                 $order = new Order((int) $ct->id_order);
                 $var_list['{order_name}'] = $order->getUniqReference();
                 $var_list['{id_order}'] = (int) $order->id;
             }
             if ($id_product) {
                 $product = new Product((int) $id_product);
                 if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id])) {
                     $var_list['{product_name}'] = $product->name[Context::getContext()->language->id];
                 }
             }
             if (empty($contact->email)) {
                 Mail::Send($this->context->language->id, 'contact_form', isset($ct) && Validate::isLoadedObject($ct) ? $this->trans('Your message has been correctly sent #ct%thread_id% #tc%thread_token%', array('%thread_id%' => $ct->id, '%thread_token%' => $ct->token), 'Emails.Subject') : $this->trans('Your message has been correctly sent', array(), 'Emails.Subject'), $var_list, $from, null, null, null, $file_attachment);
             } else {
                 if (!Mail::Send($this->context->language->id, 'contact', $this->trans('Message from contact form', array(), 'Emails.Subject') . ' [no_sync]', $var_list, $contact->email, $contact->name, null, null, $file_attachment, null, _PS_MAIL_DIR_, false, null, null, $from) || !Mail::Send($this->context->language->id, 'contact_form', isset($ct) && Validate::isLoadedObject($ct) ? $this->trans('Your message has been correctly sent #ct%thread_id% #tc%thread_token%', array('%thread_id%' => $ct->id, '%thread_token%' => $ct->token), 'Emails.Subject') : $this->trans('Your message has been correctly sent', array(), 'Emails.Subject'), $var_list, $from, null, null, null, $file_attachment, null, _PS_MAIL_DIR_, false, null, null, $contact->email)) {
                     $this->context->controller->errors[] = $this->l('An error occurred while sending the message.');
                 }
             }
//.........这里部分代码省略.........
开发者ID:prestashop,项目名称:contactform,代码行数:101,代码来源:contactform.php


注:本文中的CustomerThread::getIdCustomerThreadByEmailAndIdOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。