コード例 #1
0
ファイル: order.php プロジェクト: jeprodev/jeproshop
 public function update_message()
 {
     $app = JFactory::getApplication();
     $order_id = $app->input->get('order_id');
     $customer_id = $app->input->get('customer_id');
     $order = new JeproshopOrderModelOrder($order_id);
     if (isset($order)) {
         if ($this->viewAccess()) {
             $customer = new JeproshopCustomerModelCustomer($customer_id);
             if (!JeproshopTools::isLoadedObject($customer, 'customer_id')) {
                 JError::raiseError(JText::_('COM_JEPROSHOP_CUSTOMER_IS_INVALID_MESSAGE'));
             } elseif (!$inputMessage) {
                 JError::raiseError(JText::_('COM_JEPROSHOP_THE_MESSAGE_CANNOT_BE_BLANK_MESSAGE'));
             } else {
                 /** Get Message rules anf check fields validity */
                 $rules = JeproshopMessageModelMessage::getValidationRules();
                 foreach ($rules->required as $field) {
                     $value = $app->input->get($field) == false;
                     if ($value && (string) $value != '0') {
                         if ($order_id || $field != 'passwd') {
                             JError::raiseError($field . ' ' . JText::_('COM_JEPROSHOP_IS_REQUIRED_FIELD_MESSAGE'));
                         }
                     }
                 }
                 foreach ($rules->size as $field => $maxLength) {
                     if ($app->input->get($field) && strlen($field) > $maxLength) {
                         JError::raiseError($field . ' ' . JText::_('COM_JEPROSHOP_FIELD_IS_TOO_LONG_LABEL') . ' ' . $maxLength . ' ' . JText::_('COM_JEPROSHOP_MAX_CHARS_LABEL'));
                     }
                 }
                 foreach ($rules->validate as $field => $function) {
                     if ($app->input->get($field)) {
                         if (!JeproshopTools::$function()) {
                             JError::raiseError(JText::_('COm_JEPROSHOP_FIELD_IS_INVALID_LABEL'));
                         }
                     }
                 }
                 if (12) {
                     $customer_thread_id = JeproshopCustomerThreadModelCustomerThread::getCustomerThreadIdByEmailAndOrderId($customer->email, $order->order_id);
                     if (!$customer_thread_id) {
                         $customerThread = new JeproshopCustomerThreadModelCustomerThread();
                         $customerThread->contact_id = 0;
                         $customerThread->customer_id = (int) $order->customer_id;
                         $customerThread->shop_id = (int) $context->shop->shop_id;
                         $customerThread->order_id = (int) $order->order_id;
                         $customerThread->lang_id = (int) $context->language->lang_id;
                         $customerThread->email = $customer->email;
                         $customerThread->status = 'open';
                         $customerThread->token = JeproshopTools::passwdGen(12);
                         $customerThread->add();
                     } else {
                         $customerThread = new JeproshopCustomerThreadModelCustomerThread((int) $customer_thread_id);
                     }
                     $customerMessage = new JeproshopCustomerMessageModelCustomerMessage();
                     $customerMessage->customer_thread_id = $customerThread->customer_thread_id;
                     $customerMessage->employee_id = (int) $context->employee->employee_id;
                     $customerMessage->message = $app->input->get('message');
                     $customerMessage->private = $app->input->get('visibility');
                     if (!$customerMessage->add()) {
                         JError::raiseError(JText::_('COM_JEPROSHOP_AN_ERROR_WHILE_'));
                     } elseif ($customerMessage->private) {
                         $app->redirect('index.php?option=com_jeproshop&view=order&task=view&order_id=' . (int) $order->order_id);
                     } else {
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: customer.php プロジェクト: jeprodev/jeproshop
 public function transformToCustomer($lang_id, $password = null)
 {
     if (!$this->isGuest()) {
         return false;
     }
     if (empty($password)) {
         $password = JeproshopTools::passwdGen();
     }
     if (!JeproshopTools::isPasswd($password)) {
         return false;
     }
     $this->is_guest = 0;
     $this->passwd = JeproshopTools::encrypt($password);
     $this->cleanGroups();
     $this->addGroups(array(JeproshopSettingModelSetting::getValue('customer_group')));
     // add default customer group
     if ($this->update()) {
         $vars = array('{firstname}' => $this->firstname, '{lastname}' => $this->lastname, '{email}' => $this->email, '{passwd}' => $password);
         Mail::Send((int) $lang_id, 'guest_to_customer', Mail::l('Your guest account has been transformed into a customer account', (int) $lang_id), $vars, $this->email, $this->firstname . ' ' . $this->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $this->shop_id);
         return true;
     }
     return false;
 }