예제 #1
0
 /**
  * importAcetion
  * Import all templates from disks
  * @return unknown_type
  */
 public function importAction()
 {
     $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
     $importOK = 0;
     $arrDeleted = array();
     /*
      * Cycle all template and all languages
      */
     $arrLanguages = Languages::getActiveLanguageList();
     if (is_array($arrLanguages) && !empty($arrLanguages)) {
         foreach ($arrLanguages as $lang) {
             if (empty($lang['locale'])) {
                 continue;
             }
             $dir = PUBLIC_PATH . "/languages/emails/" . $lang['locale'];
             foreach (scandir($dir) as $file) {
                 if (!preg_match('/^([a-z0-9A-Z\\-\\_]+)\\.htm$/', $file, $out)) {
                     continue;
                 }
                 if (empty($out[1])) {
                     continue;
                 }
                 // Import
                 $outArray = Shineisp_Commons_Utilities::getEmailTemplate($out[1], $lang['language_id']);
                 if (!empty($outArray)) {
                     $importOK++;
                 }
             }
         }
     }
     if ($importOK > 0) {
         $this->_helper->redirector('list', $controller, 'admin', array('mex' => $this->translator->translate('Template imported successfully'), 'status' => 'success'));
     }
     $this->_helper->redirector('list', $controller, 'admin', array('mex' => $this->translator->translate('An error occurred'), 'status' => 'success'));
 }
예제 #2
0
파일: Cronjobs.php 프로젝트: moay/shineisp
 /**
  * Send the newsletter to the queue
  */
 public static function send_queue($test = FALSE, $id = NULL)
 {
     $queue = NewslettersHistory::get_active_queue($test, $id);
     $isp = Isp::getActiveISP();
     try {
         // Get the template from the main email template folder
         $retval = Shineisp_Commons_Utilities::getEmailTemplate('newsletter');
         if (!empty($retval) && !empty($queue)) {
             $contents = Newsletters::fill_content();
             $subject = $retval['subject'];
             $template = $retval['template'];
             $subject = str_replace("[subject]", $queue[0]['Newsletters']['subject'], $subject);
             $template = str_replace("[subject]", $queue[0]['Newsletters']['subject'], $template);
             $template = str_replace("[body]", $queue[0]['Newsletters']['message'], $template);
             foreach ($contents as $name => $content) {
                 $template = str_replace("[" . $name . "]", $content, $template);
             }
             foreach ($isp as $field => $value) {
                 $template = str_replace("[" . $field . "]", $value, $template);
             }
             $template = str_replace("[url]", "http://" . $_SERVER['HTTP_HOST'] . "/media/newsletter/", $template);
             foreach ($queue as $item) {
                 // Send a test of the newsletter to the default isp email otherwise send an email to the queue
                 if ($test) {
                     $body = str_replace("[optout]", "#", $template);
                     Shineisp_Commons_Utilities::SendEmail($isp['email'], $isp['email'], null, "<!--TEST --> " . $subject, $body, true);
                     break;
                 } else {
                     // Create the optout link to be added in the email
                     $body = str_replace("[optout]", '<a href="http://' . $_SERVER['HTTP_HOST'] . "/newsletter/optout/id/" . MD5($item['NewslettersSubscribers']['email']) . '" >Unsubscribe</a>', $template);
                     $result = Shineisp_Commons_Utilities::SendEmail($isp['email'], $item['NewslettersSubscribers']['email'], null, $subject, $body, true);
                     if ($result === true) {
                         NewslettersHistory::set_status($item['subscriber_id'], $item['newsletter_id'], 1, "Mail Sent");
                     } else {
                         NewslettersHistory::set_status($item['subscriber_id'], $item['newsletter_id'], 0, $result['message']);
                     }
                     Newsletters::set_sending_date($item['news_id']);
                 }
             }
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         return false;
     }
     return true;
 }
예제 #3
0
파일: Orders.php 프로젝트: kokkez/shineisp
 /**
  * saveAll
  * Save all the data in the database
  * @param array $params
  * @param integer $id
  */
 public static function saveAll($params, $id = "")
 {
     $orders = new Orders();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $currentStatus = "";
     try {
         // Set the new values
         if (is_numeric($id)) {
             $orders = Doctrine::getTable('Orders')->find($id);
             $currentStatus = $orders->status_id;
             // used to detect status changes
         }
         if (!empty($params) && is_array($params)) {
             $params['date_start'] = !empty($params['date_start']) ? $params['date_start'] : new Zend_Date();
             $params['order_date'] = !empty($params['order_date']) ? $params['order_date'] : new Zend_Date();
             $customer = Customers::getAllInfo($params['customer_id']);
             $isp_id = $customer['isp_id'];
             $orders->order_date = Shineisp_Commons_Utilities::formatDateIn($params['order_date']);
             $orders->customer_id = $params['customer_id'];
             $orders->isp_id = $isp_id;
             $orders->status_id = $params['status_id'];
             $orders->invoice_id = !empty($params['invoice_id']) ? $params['invoice_id'] : null;
             $orders->note = $params['note'];
             $orders->is_renewal = $params['is_renewal'] == 1 ? 1 : 0;
             $orders->expiring_date = Shineisp_Commons_Utilities::formatDateIn($params['expiring_date']);
             $orders->vat = $params['vat'];
             $orders->total = $params['total'];
             $orders->grandtotal = $params['total'] + $params['vat'];
             // Save the data
             $orders->save();
             $id = is_numeric($id) ? $id : $orders->getIncremented();
             // Status changed? Let's call set_status. This is needed to properly log all status change.
             if (isset($params['status_id']) && $params['status_id'] != $currentStatus) {
                 self::logStatusChange($id, $params['status_id']);
             }
             // Add a fastlink to a order
             $link_exist = Fastlinks::findlinks($id, 'orders');
             $link = new Fastlinks();
             if (count($link_exist) == 0) {
                 $link->controller = "orders";
                 $link->action = "edit";
                 $link->params = json_encode(array('id' => $id));
                 $link->customer_id = $params['customer_id'];
                 $link->sqltable = "orders";
                 $link->id = $id;
                 $link->code = Shineisp_Commons_Utilities::GenerateRandomString();
             } else {
                 $link = Doctrine::getTable('Fastlinks')->find($link_exist[0]['fastlink_id']);
                 $link->code = $params['fastlink'];
             }
             $link->save();
             // Save the message note and send an alert
             if (!empty($params['message'])) {
                 $order = self::getAllInfo($id, null, true);
                 $link = Fastlinks::findlinks($id, $params['customer_id'], 'orders');
                 $isp = Isp::find($isp_id);
                 $retval = Shineisp_Commons_Utilities::getEmailTemplate('order_message');
                 if ($retval) {
                     $in_reply_to = md5($id);
                     // Save the message written by the ISP owner
                     Messages::addMessage($params['message'], null, null, $id, null, $isp_id);
                     // Create the array with all the placeholders
                     $placeholders['fullname'] = $order[0]['Customers']['firstname'] . " " . $order[0]['Customers']['lastname'];
                     $placeholders['url'] = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $link[0]['code'];
                     $placeholders['orderid'] = sprintf("%03s", $id) . " - " . Shineisp_Commons_Utilities::formatDateOut($order[0]['order_date']);
                     $placeholders['messagetype'] = $translator->translate('Order Details');
                     $placeholders['message'] = $params['message'];
                     Shineisp_Commons_Utilities::sendEmailTemplate(Contacts::getEmails($order[0]['Customers']['customer_id']), 'order_message', $placeholders, $in_reply_to, null, null, null, $order[0]['Customers']['language_id']);
                     // Change the URL for the administrator
                     $placeholders['url'] = "http://" . $_SERVER['HTTP_HOST'] . "/admin/login/link/id/" . $link[0]['code'] . "/keypass/" . Shineisp_Commons_Hasher::hash_string($isp->email);
                     // Send a message to the administrator
                     Shineisp_Commons_Utilities::sendEmailTemplate($isp->email, 'order_message_admin', $placeholders, $in_reply_to);
                 }
             }
             // Saving the domain
             if (!empty($params['domains_selected'])) {
                 self::SaveDomainsDetails($params, $id);
             } else {
                 if (!empty($params['products'])) {
                     $date_end = null;
                     // Get the product information
                     $product = Products::getAllInfo($params['products']);
                     // Manage the details of the order
                     if (!empty($params['billingcycle_id'])) {
                         $months = BillingCycle::getMonthsNumber($params['billingcycle_id']);
                         // Add months to the starting date
                         if ($months > 0) {
                             $params['date_end'] = Shineisp_Commons_Utilities::add_date($params['date_start'], null, $months);
                         }
                     }
                     // Format the dates before to save them in the database
                     $params['date_end'] = Shineisp_Commons_Utilities::formatDateIn($params['date_end']);
                     $params['date_start'] = Shineisp_Commons_Utilities::formatDateIn($params['date_start']);
                     if (!empty($product['Taxes']['tax_id'])) {
                         $vat = $params['price'] * $product['Taxes']['percentage'] / 100;
                         $subtotal = $params['price'] * ($product['Taxes']['percentage'] + 100) / 100;
                         $percentage = $product['Taxes']['percentage'];
                     } else {
                         $vat = 0;
                         $subtotal = $params['price'];
                         $percentage = 0;
                     }
                     $details = new OrdersItems();
                     $details->order_id = $id;
                     $details->quantity = $params['quantity'];
                     $details->cost = Products::getCost($params['products']);
                     $details->price = $params['price'];
                     $details->date_start = $params['date_start'];
                     $details->date_end = $params['date_end'];
                     $details->billing_cycle_id = !empty($params['billingcycle_id']) ? $params['billingcycle_id'] : null;
                     $details->product_id = $params['products'];
                     $details->description = $params['description'];
                     $details->status_id = $params['status_id'];
                     $details->vat = $vat;
                     $details->percentage = $percentage;
                     $details->subtotal = $subtotal;
                     if ($product['type'] == "hosting") {
                         // Get all the product attributes
                         $attrs = ProductsAttributes::getAttributebyProductID($params['products']);
                         // Create the system attributes parameters
                         foreach ($attrs as $attr) {
                             if ($attr['system'] && !empty($attr['ProductsAttributesIndexes'][0]['value'])) {
                                 $hostingplan[$attr['code']] = $attr['ProductsAttributesIndexes'][0]['value'];
                             }
                         }
                         $details->parameters = json_encode($hostingplan);
                     }
                     $details->save();
                     $detail_id = $details->getIncremented();
                     // Attaching of the service a particular domain. It's not a mandatory field because the services and the products can be bought also without a domain
                     if (is_numeric($params['referdomain']) && $params['referdomain'] > 0) {
                         $ordersitemsdomains = new OrdersItemsDomains();
                         $ordersitemsdomains->domain_id = $params['referdomain'];
                         $ordersitemsdomains->order_id = $id;
                         $ordersitemsdomains->orderitem_id = $detail_id;
                         $ordersitemsdomains->save();
                     }
                 }
             }
             // Handle the payment transaction
             if (!empty($params['paymentdate'])) {
                 Payments::addPayment($id, $params['reference'], $params['bank_id'], $params['confirmed'], $params['income'], $params['paymentdate'], $params['customer_id'], $params['payment_description']);
             }
             // Set the status of the order
             OrdersItems::setNewStatus($id, $params['status_id']);
             // Update the totals of the order selected
             self::updateTotalsOrder($id);
             return $id;
         }
     } catch (Exception $e) {
         die($e->getMessage());
     }
     return false;
 }
예제 #4
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/profile/process");
     $request = $this->getRequest();
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index', 'index', 'default');
     }
     if ($form->isValid($request->getPost())) {
         // Get the id
         $id = $this->getRequest()->getParam('customer_id');
         try {
             // Set the new values
             if (is_numeric($id)) {
                 $customer = Doctrine::getTable('Customers')->find($id);
                 $oldCustomer = $customer->toArray();
                 // Get the values posted
                 $params = $form->getValues();
                 $customer->company = $params['company'];
                 $customer->firstname = $params['firstname'];
                 $customer->lastname = $params['lastname'];
                 $customer->email = $params['email'];
                 $customer->birthdate = Shineisp_Commons_Utilities::formatDateIn($params['birthdate']);
                 if (!empty($params['password'])) {
                     $customer->password = MD5($params['password']);
                 }
                 $customer->birthplace = $params['birthplace'];
                 $customer->birthdistrict = $params['birthdistrict'];
                 $customer->birthcountry = $params['birthcountry'];
                 $customer->birthnationality = $params['birthnationality'];
                 $customer->vat = $params['vat'];
                 $customer->taxpayernumber = $params['taxpayernumber'];
                 $customer->type_id = !empty($params['company_type_id']) ? $params['company_type_id'] : NULL;
                 $customer->legalform_id = $params['legalform'];
                 $customer->gender = $params['gender'];
                 // Save the data
                 $customer->save();
                 $id = is_numeric($id) ? $id : $customer->getIncremented();
                 // Manage the address of the customer
                 $address = new Addresses();
                 $mainAddress = $address->findOneByUserId($id);
                 if ($mainAddress) {
                     $address = $mainAddress;
                 }
                 $address->address = $params['address'];
                 $address->city = $params['city'];
                 $address->code = $params['code'];
                 $address->country_id = $params['country_id'];
                 $address->area = $params['area'];
                 $address->customer_id = $id;
                 $address->save();
                 if (!empty($params['contact'])) {
                     $contacts = new Contacts();
                     $contacts->contact = $params['contact'];
                     $contacts->type_id = $params['contacttypes'];
                     $contacts->customer_id = $id;
                     $contacts->save();
                 }
                 // Add or Remove the customer email in the newsletter list
                 Customers::newsletter_subscription($id, $params['newsletter']);
                 $retval = Shineisp_Commons_Utilities::getEmailTemplate('profile_changed');
                 if ($retval) {
                     $subject = $retval['subject'];
                     $subject = str_replace("[user]", $params['firstname'] . " " . $params['lastname'], $retval['subject']);
                     // Alert the administrator about the changing of the customer information
                     $body = $retval['template'];
                     $body = str_replace("[user]", $params['firstname'] . " " . $params['lastname'], $body);
                     $body = str_replace("[old]", print_r($oldCustomer, true), $body);
                     $body = str_replace("[new]", print_r($customer->toArray(), true), $body);
                     $isp = Shineisp_Registry::get('ISP');
                     Shineisp_Commons_Utilities::SendEmail($isp->email, $isp->email, null, $subject, $body);
                 }
             }
         } catch (Exception $e) {
             echo $e->getMessage();
             die;
         }
         return $this->_helper->redirector('account', 'profile', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success'));
     } else {
         $this->view->form = $form;
         $this->view->title = $this->translator->translate("Profile details");
         $this->view->description = $this->translator->translate("Update here your details filling the applicant form with all the information about you.");
         return $this->_helper->viewRenderer('applicantform');
     }
 }
예제 #5
0
 /**
  * renewdomainAction
  * Renew a group of domains selected
  * @param $items
  * @return void
  */
 private function renewdomains($items)
 {
     $mex = "";
     if (is_array($items)) {
         try {
             $Orderid = Orders::createOrderWithMultiProducts($items, $this->customer['customer_id']);
             $isp = Shineisp_Registry::get('ISP');
             $order = Orders::getAllInfo($Orderid, null, true);
             $link = Fastlinks::findlinks($Orderid, $this->customer['customer_id'], 'orders');
             $retval = Shineisp_Commons_Utilities::getEmailTemplate('new_order');
             if ($retval) {
                 $subject = $retval['subject'];
                 $subject = str_replace("[orderid]", sprintf("%03s", $Orderid) . " - " . Shineisp_Commons_Utilities::formatDateOut($order[0]['order_date']), $subject);
                 $orderbody = $retval['template'];
                 $orderbody = str_replace("[fullname]", $order[0]['Customers']['firstname'] . " " . $order[0]['Customers']['lastname'], $orderbody);
                 $orderbody = str_replace("[bank]", $isp->bankname . "\nc/c:" . $isp->bankaccount . "\nIBAN: " . $isp->iban . "\nBIC: " . $isp->bic, $orderbody);
                 $orderbody = str_replace("[orderid]", $Orderid . "/" . date('Y'), $orderbody);
                 $orderbody = str_replace("[email]", $isp->email, $orderbody);
                 $orderbody = str_replace("[signature]", $isp->company . "\n" . $isp->email, $orderbody);
                 if (!empty($link[0])) {
                     $orderbody = str_replace("[url]", "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $link[0]['code'], $orderbody);
                 } else {
                     $orderbody = str_replace("[url]", "http://" . $_SERVER['HTTP_HOST'], $orderbody);
                 }
                 if (!empty($order[0]['Customers']['email'])) {
                     Shineisp_Commons_Utilities::SendEmail($isp->email, $order[0]['Customers']['email'], $isp->email, $subject, $orderbody);
                 }
             }
             die(json_encode(array('reload' => '/orders/edit/id/' . $Orderid)));
         } catch (Exception $e) {
             die(json_encode(array('mex' => $e->getMessage())));
         }
     }
     return false;
 }
예제 #6
0
 /**
  * Execute the request of the admin user to change the password
  */
 public function dopasswordAction()
 {
     $code = $this->getRequest()->getParam('id');
     $user = AdminUser::checkMD5CredencialsByIspEmail($code);
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $form = new Admin_Form_PasswordForm(array('action' => '/admin/login/password', 'method' => 'post'));
     if (!empty($user)) {
         $isp = Isp::getActiveISP();
         // Get the template from the main email template folder
         $retval = Shineisp_Commons_Utilities::getEmailTemplate('isp_password_changed');
         $newpassword = AdminUser::resetPassword($user['user_id']);
         if (!empty($retval)) {
             $subject = $retval['subject'];
             $template = $retval['template'];
             $subject = str_replace("[lastname]", $user['lastname'], $subject);
             $template = str_replace("[lastname]", $user['lastname'], $template);
             $template = str_replace("[admin_url]", "http://" . $_SERVER['HTTP_HOST'] . "/admin/", $template);
             $template = str_replace("[email]", $user['email'], $template);
             $template = str_replace("[password]", $newpassword, $template);
             $template = str_replace("[signature]", $isp['company'], $template);
             Shineisp_Commons_Utilities::SendEmail($user['email'], $user['email'], null, $subject, $template);
             $this->view->message = $translator->translate('An email has been sent with the new login credentials');
         }
     }
     $this->view->passwordform = $form;
     return $this->render('password');
     // re-render the login form
 }
예제 #7
0
파일: Tickets.php 프로젝트: kokkez/shineisp
 /**
  * This batch has been created in order to remind customers
  * that one or more tickets are still open.
  */
 public static function checkTickets()
 {
     $isp = Isp::getActiveISP();
     $tickets = Tickets::getWaitingReply();
     // Get the template from the main email template folder
     $retval = Shineisp_Commons_Utilities::getEmailTemplate('ticket_waitreply');
     foreach ($tickets as $ticket) {
         $customer = $ticket['Customers'];
         // Get the fastlink attached
         $link_exist = Fastlinks::findlinks($ticket['ticket_id'], $customer['customer_id'], 'tickets');
         if (count($link_exist) > 0) {
             $fastlink = $link_exist[0]['code'];
         } else {
             $fastlink = Fastlinks::CreateFastlink('tickets', 'edit', json_encode(array('id' => $ticket['ticket_id'])), 'tickets', $ticket['ticket_id'], $customer['customer_id']);
         }
         $customer_url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/{$fastlink}";
         if ($retval) {
             $subject = $retval['subject'];
             $Template = nl2br($retval['template']);
             $subject = str_replace("[subject]", $ticket['subject'], $subject);
             $Template = str_replace("[subject]", $ticket['subject'], $Template);
             $Template = str_replace("[lastname]", $customer['lastname'], $Template);
             $Template = str_replace("[issue_number]", $ticket['ticket_id'], $Template);
             $Template = str_replace("[date_open]", Shineisp_Commons_Utilities::formatDateOut($ticket['date_open']), $Template);
             $Template = str_replace("[link]", $customer_url, $Template);
             $Template = str_replace("[signature]", $isp['company'] . "<br/>" . $isp['website'], $Template);
             Shineisp_Commons_Utilities::SendEmail($isp['email'], Contacts::getEmails($customer['customer_id']), null, $subject, $Template, true);
         }
     }
     return true;
 }
예제 #8
0
 public static function optIn($email)
 {
     if (Shineisp_Commons_Utilities::isEmail($email)) {
         // Check if the email is already registered
         $retval = Doctrine::getTable('NewslettersSubscribers')->findOneBy('email', $email);
         if (empty($retval)) {
             // Save the new email address
             $subscriber = new NewslettersSubscribers();
             $subscriber->email = $email;
             $subscriber->subscriptiondate = date('Y-m-d H:i:s');
             if ($subscriber->trySave()) {
                 // Send the email to confirm the subscription
                 $retval = Shineisp_Commons_Utilities::getEmailTemplate('new_subscriber');
                 if ($retval) {
                     $subject = $retval['subject'];
                     $template = $retval['template'];
                     $isp = Isp::getActiveISP();
                     $template = str_replace("[signature]", $isp['company'], $template);
                     Shineisp_Commons_Utilities::SendEmail($isp['email'], $email, null, $subject, $template);
                 }
                 return true;
             }
         }
     }
     return false;
 }