/** * Check the expiring orders. * * Only the orders where renewal option has been set as * false send an email to the client to inform him * that his order has been set as deleted. */ public static function checkExpiringOrders() { $orders = Orders::find_all_expired_orders(date('Y-m-d')); foreach ($orders as $order) { $customer = Customers::getAllInfo($order['customer_id']); $ISP = ISP::getActiveIspById($customer['isp_id']); // Get the fastlink attached $link_exist = Fastlinks::findlinks($order['order_id'], $order['customer_id'], 'orders'); if (count($link_exist) > 0) { $fastlink = $link_exist[0]['code']; } else { $fastlink = Fastlinks::CreateFastlink('orders', 'edit', json_encode(array('id' => $order['order_id'])), 'orders', $order['order_id'], $customer['customer_id']); } $customer_url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/{$fastlink}"; Shineisp_Commons_Utilities::sendEmailTemplate($customer['email'], 'order_expired', array('orderid' => $order['order_number'], ':shineisp:' => $customer, 'url' => $customer_url), null, null, null, $ISP, $customer['language_id'], Settings::findbyParam('cron_notify')); // Set the order as deleted Orders::set_status($order['order_id'], Statuses::id('deleted', 'orders')); } return true; }
/** * accountAction * Manage the Isp account settings. * @return void */ public function accountAction() { $form = $this->getForm('/admin/isp/process'); $this->view->form = $form; $this->view->mex = $this->getRequest()->getParam('mex'); $this->view->mexstatus = $this->getRequest()->getParam('status'); $this->view->title = $this->translator->translate("ISP Account"); $this->view->description = $this->translator->translate("Here you can edit your ISP account information"); $this->view->serversgrid = $this->serversGrid(); // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit'))); $isp = ISP::find($this->isp['isp_id'])->toArray(); // the password is a MD5 string so we need to empty it, because the software could save the MD5 value again. $isp['password'] = ""; $form->populate($isp); $this->view->srclogo = !empty($isp['logo']) ? "/documents/isp/" . $isp['logo'] : null; $this->view->srclogoemail = !empty($isp['logo_email']) ? "/documents/isp/" . $isp['logo_email'] : null; $this->render('applicantform'); }
/** * Send the email profile to the user */ public function sendMail($task) { $ISP = ISP::getByCustomerId($task['customer_id']); if (!$ISP || !isset($ISP['isp_id']) || !is_numeric($ISP['isp_id'])) { // ISP not found, can't send mail return false; } // Get the service details $service = OrdersItems::getAllInfo($task['orderitem_id']); // If the setup has been written by the task action then ... if (!empty($service['setup'])) { $setup = json_decode($service['setup'], true); // Get the service/product name $productname = !empty($service['Products']['ProductsData'][0]['name']) ? $service['Products']['ProductsData'][0]['name'] : ""; $welcome_mail = !empty($service['Products']['welcome_mail_id']) && intval($service['Products']['welcome_mail_id']) > 0 ? intval($service['Products']['welcome_mail_id']) : 'new_hosting'; // new_hosting = fallback to old method if no template is set // Check if the customer is present in the service and if there is a welcome_mail set for the bought product if (!empty($service['Orders']['Customers'])) { // Getting the customer $customer = $service['Orders']['Customers']; $strSetup = ""; foreach ($setup as $section => $details) { $strSetup .= strtoupper($section) . "<hr/>"; foreach ($details as $label => $detail) { $strSetup .= "{$label}: " . $detail . "<br/>"; } $strSetup .= "<br/>"; } Shineisp_Commons_Utilities::sendEmailTemplate($ISP['email'], $welcome_mail, array('setup' => $strSetup, 'fullname' => $customer['firstname'] . " " . $customer['lastname'], 'hostingplan' => $productname, 'controlpanel' => $ISP['website'] . ":8080", 'signature' => $ISP['company']), null, null, null, $ISP, $customer['language_id']); } } }
/** * Send an email template replacing all placeholders * * @param array|string $recipient * @param string $template * @param array $placeholders * @param array|string $inreplyto * @param array|string $attachments * @param array|string $replyto * @param array $ISP * @param integer $language_id * @param string $bcc */ public static function sendEmailTemplate($recipient = null, $template = '', $placeholders = array(), $inreplyto = null, $attachments = null, $replyto = null, $ISP = null, $language_id = null, $bcc = null) { // Get email template $arrTemplate = self::getEmailTemplate($template, $language_id); if (!is_array($arrTemplate)) { return false; } $arrReplaced = array(); // ISP missing from arguments, try to get automatically $ISP = isset($ISP) && is_array($ISP) ? $ISP : ISP::getCurrentISP(); // Add some mixed parameters $ISP['storename'] = $ISP['company']; // All placeholder prefixed with "isp_" will be replaced with ISP data foreach ($ISP as $k => $v) { $placeholders['isp_' . $k] = $v; } // Merge original placeholder with ISP value. This is done to override standard ISP values $placeholders = array_merge($ISP, $placeholders); // Creates a flat array $placeholders = self::flatplaceholders($placeholders); // Remove unneeded parameters unset($placeholders['active']); unset($placeholders['isppanel']); // Replace all placeholders in everything foreach ($placeholders as $placeholder => $emailcontent) { foreach ($arrTemplate as $k => $v) { // $placeholders contains the order header information if (is_string($emailcontent)) { $arrTemplate[$k] = str_replace('[' . $placeholder . ']', $emailcontent, $v); } } } // Send the email $arrBCC = array(); $arrCC = array(); $arrFrom = array('email' => $arrTemplate['fromemail'], 'name' => $arrTemplate['fromname']); if (isset($arrTemplate['bcc']) && !empty($arrTemplate['bcc'])) { if (is_array($arrTemplate['bcc']) && count($arrTemplate['bcc']) > 0) { $arrBCC = array_merge($arrBCC, $arrTemplate['bcc']); } else { $arrBCC[] = $arrTemplate['bcc']; } } // add hidden email address if (!empty($bcc)) { $arrBCC[] = $bcc; } // Get always-bcc from custom settings $always_send_to = Settings::findbyParam('always_send_to'); $always_send_to = trim($always_send_to); if (!empty($always_send_to)) { if (strpos($always_send_to, ',') !== false) { $_bcc = explode(',', $always_send_to); foreach ($_bcc as $_bccAddress) { $arrBCC[] = trim($_bccAddress); } } else { $arrBCC[] = $always_send_to; } } $arrBCC = array_unique($arrBCC); // Remove duplicate bcc addresses if (isset($arrTemplate['cc']) && !empty($arrTemplate['cc'])) { if (is_array($arrTemplate['cc']) && count($arrTemplate['cc']) > 0) { $arrCC = array_merge($arrCC, $arrTemplate['cc']); } else { $arrCC[] = $arrTemplate['cc']; } } // null recipient, send only to ISP $recipient = $recipient == null ? $ISP['email'] : $recipient; // Zend_Debug::dump($recipient); // Zend_Debug::dump($replyto); // Zend_Debug::dump($arrFrom); // Zend_Debug::dump($arrTemplate); // Zend_Debug::dump($arrBCC); // Zend_Debug::dump($arrTemplate['template']); // echo $arrTemplate['template']; // die; // SendEmail ( $from, $to, $bcc, $subject, $body, $html, $inreplyto, $attachments, $replyto, $cc ) self::SendEmail($arrFrom, $recipient, $arrBCC, $arrTemplate['subject'], $arrTemplate['template'], !$arrTemplate['plaintext'], $inreplyto, $attachments, $replyto, $arrCC); }