/**
  * Step 2: Save the data
  */
 public function saveAction()
 {
     $session = new Zend_Session_Namespace('setup');
     $request = $this->getRequest();
     $form = new Setup_Form_PreferencesForm(array('action' => '/setup/preferences/save', 'method' => 'post'));
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index', 'preferences', 'setup');
     }
     try {
         if ($form->isValid($request->getPost())) {
             // Get the values posted
             $params = $form->getValues();
             $session->preferences = $params;
             // Create the main xml config file
             if (Settings::saveConfig($session->db)) {
                 // Start the creation of the database tables
                 Settings::createDb();
                 // Get the default ISP company
                 $isp_id = Isp::getActiveISPID();
                 // Save the company information
                 Isp::saveAll($params, $isp_id);
                 // TODO: Bind ISP to the current URL
                 $IspUrls = new IspUrls();
                 $IspUrls->isp_id = $isp_id;
                 $IspUrls->url = $_SERVER['HTTP_HOST'];
                 $IspUrls->save();
                 // Adding the user as administrator
                 AdminUser::addUser($params['firstname'], $params['lastname'], $params['email'], $params['password'], $isp_id);
                 // Redirect the user to the homepage
                 $this->_helper->redirector('index', 'summary', 'setup');
             }
             // There was a problem the setup restarts
             $this->_helper->redirector('index', 'index', 'setup');
         }
     } catch (Exception $e) {
         die($e->getMessage());
     }
     $this->view->form = $form;
     return $this->_helper->viewRenderer('form');
 }
Example #2
0
 public static function getDnsserver()
 {
     $dq = Doctrine_Query::create()->from('Servers i')->leftJoin('i.Servers_Types st ON st.type_id = i.type_id')->where("type_id = ?", 4)->andWhere("isp_id = ?", Isp::getActiveISPID());
     return $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
 }
Example #3
0
 /**
  * Get the config panel variables 
  * @param string $panelvar
  * @return ArrayObject
  */
 public static function getActivePanel()
 {
     // Get the Active ISP Panel set at the Isp Profile page
     $strpanel = Isp::getPanel(Isp::getActiveISPID());
     if (!empty($strpanel)) {
         $panel = Doctrine_Query::create()->from('Panels')->where("name = ?", $strpanel)->limit(1)->execute(array(), Doctrine::HYDRATE_ARRAY);
         return !empty($panel[0]) ? $panel[0] : array();
     }
     return false;
 }
Example #4
0
 /**
  * getExpiringDomainsByDays
  * Get the list of all the expiring domains  
  * @param $days
  * @param $status [default: 4 is active]
  * @param $autorenew [0, 1]
  * @return array()
  */
 public static function getExpiringDomainsByDays($days = 7, $statusId = null, $autorenew = null)
 {
     if (!is_numeric($statusId)) {
         $statusId = Statuses::id("active", "domains");
     }
     $dq = Doctrine_Query::create()->select("domain_id, \r\n\t\t\t\t\t\t\t\t\t\t\t        CONCAT(domain, '.', ws.tld) as domain, \r\n\t\t\t\t\t\t\t\t\t\t\t        d.autorenew as renew, \r\n\t\t\t\t\t\t\t\t\t\t\t        oi.parameters as parameters, \r\n\t\t\t\t\t\t\t\t\t\t\t        d.expiring_date as expiringdate, \r\n\t\t\t\t\t\t\t\t\t\t\t        d.customer_id as customer_id, \r\n\t\t\t\t\t\t\t\t\t\t\t        Concat(c.firstname, ' ', c.lastname, ' ', c.company) as fullname, \r\n\t\t\t\t\t\t\t\t\t\t\t        c.email as email, \r\n\t\t\t\t\t\t\t\t\t\t\t        c.language_id as language_id, \r\n\t\t\t\t\t\t\t\t\t\t\t        c.parent_id as reseller,\r\n\t\t\t\t\t\t\t\t\t\t\t        DATEDIFF(d.expiring_date, CURRENT_DATE) as days\r\n        \t\t\t\t\t\t\t\t\t")->from('Domains d')->leftJoin('d.Customers c')->leftJoin('d.OrdersItems oi')->leftJoin('d.DomainsTlds dt')->leftJoin('dt.WhoisServers ws')->addWhere("c.isp_id = ?", Isp::getActiveISPID())->orderBy('d.expiring_date asc, d.customer_id');
     if (is_numeric($days)) {
         $dq->andWhere('DATEDIFF(d.expiring_date, CURRENT_DATE) = ?', $days);
     }
     if (is_numeric($statusId)) {
         $dq->andWhere('d.status_id = ?', $statusId);
     }
     if (is_numeric($autorenew)) {
         $dq->andWhere('d.autorenew = ?', $autorenew);
     }
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $logged_user = $auth->getIdentity();
         $dq->whereIn("c.isp_id", $logged_user['isp_id']);
     }
     $records = $dq->execute(null, Doctrine::HYDRATE_ARRAY);
     for ($i = 0; $i < count($records); $i++) {
         $records[$i]['oldorders'] = OrdersItemsDomains::findOrdersByDomainID($records[$i]['domain_id']);
     }
     return $records;
 }
Example #5
0
 /**
  * Get all highligted tlds records
  * 
  * 
  * @return Array
  */
 public static function getHighlighted($locale = 1)
 {
     $isp = Shineisp_Registry::get('ISP');
     try {
         $dq = Doctrine_Query::create()->from('DomainsTlds dt')->leftJoin("dt.DomainsTldsData dtd WITH dtd.language_id = {$locale}")->leftJoin('dt.Registrars r')->leftJoin('dt.Taxes t')->where('dt.ishighlighted = ?', true);
         if (!empty($isp)) {
             $dq->addWhere('dt.isp_id = ?', $isp->isp_id);
         } else {
             $dq->addWhere('dt.isp_id = ?', Isp::getActiveISPID());
         }
         return $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Example #6
0
 /**
  * Save the ticket
  * 
  * @param integer $id
  * @param integer $customer
  * @param string $subject
  * @param string $description
  * @param integer $category
  * @param integer $status
  * @param integer $domain
  * @return Boolean or integer
  */
 public static function saveIt($id = null, $customer, $subject, $description, $category, $status = null, $domain = null)
 {
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $isUpdate = false;
     if (is_numeric($id)) {
         $ticket = self::find($id);
         $isUpdate = true;
     } else {
         $ticket = new Tickets();
     }
     $operatorId = Settings::findbyParam('tickets_operator', 'admin', Isp::getActiveISPID());
     if (!is_numeric($operatorId)) {
         $operator = AdminUser::getFirstAdminUser();
     } else {
         $operator = AdminUser::getAllInfo($operatorId);
     }
     if (is_numeric($customer)) {
         $ticket->subject = !empty($subject) ? $subject : $translator->translate('Generic Issue');
         $ticket->description = !empty($description) ? $description : null;
         $ticket->category_id = !empty($category) ? $category : null;
         $ticket->customer_id = $customer;
         $ticket->user_id = $operator['user_id'];
         $ticket->date_open = date('Y-m-d H:i:s');
         $ticket->date_updated = date('Y-m-d H:i:s');
         $ticket->domain_id = is_numeric($domain) && $domain > 0 ? $domain : NULL;
         $ticket->status_id = !empty($status) ? $status : Statuses::id("expectingreply", "tickets");
         // Expecting a reply as default
         $ticket->save();
         $id = $ticket->getIncremented();
         // Save the upload file
         $attachment = self::UploadDocument($id, $customer);
         // Check if the request is an update
         if ($isUpdate == false) {
             // Create for the first time the fast link
             Fastlinks::CreateFastlink('tickets', 'edit', json_encode(array('id' => $id)), 'tickets', $id, $customer);
             // Send ticket by email
             self::send($id, true, $attachment);
         }
         return $id;
     }
     return false;
 }
 /**
  * OptIn MailChimp
  * @param array
  * @return Boolean
  */
 public static function bulk_mailchimp_optin($items, $parameters)
 {
     $errors = array();
     if (!empty($items)) {
         $key = Settings::findbyParam("MailChimp_key", "Admin", Isp::getActiveISPID());
         $confirm = Settings::findbyParam("MailChimp_confirm", "admin", Isp::getActiveISPID());
         if (empty($key)) {
             die('MailChimp Api Key has been not set yet. Go to Configuration > MailChimp');
         }
         $list_id = $parameters['list'];
         $api = new Shineisp_Plugins_Newsletters_Mailchimp_Main();
         $api->setApi_key($key);
         foreach ($items as $id) {
             $email = self::getSubscriberEmail($id);
             $result = $api->listSubscribe($list_id, $email, NULL, true, $confirm);
             if (!empty($api->errorCode)) {
                 $errors[] = $api->errorMessage;
             }
         }
         if (!empty($errors)) {
             die(json_encode(array('mex' => implode("<br/>", $errors))));
         }
         return true;
     }
     return false;
 }
Example #8
0
 public function init()
 {
     // Set the custom decorator
     $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator');
     $translate = Shineisp_Registry::get('Zend_Translate');
     $this->addElement('text', 'firstname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Firstname'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'lastname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Lastname'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('select', 'gender', array('label' => $translate->_('Gender'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('gender')->setAllowEmpty(true)->setMultiOptions(array('M' => 'Man', 'F' => 'Female'));
     $this->addElement('select', 'taxfree', array('label' => $translate->_('Tax free'), 'description' => $translate->_('If it is set as Yes all the taxes will be not added in the orders'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('taxfree')->setAllowEmpty(true)->setMultiOptions(array('0' => 'No', '1' => 'Yes'));
     $this->addElement('select', 'ignore_latefee', array('label' => $translate->_('Ignore late fee'), 'description' => $translate->_('If it is set as Yes this customers is not subject to late fee'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('ignore_latefee')->setAllowEmpty(true)->setMultiOptions(array('0' => 'No', '1' => 'Yes'));
     $this->addElement('select', 'language_id', array('label' => $translate->_('Default Language'), 'description' => $translate->_('All the messages sent to the customer will be send using the default language selected'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('language_id')->setAllowEmpty(true)->setMultiOptions(Languages::getList());
     $this->addElement('select', 'issubscriber', array('label' => $translate->_('Newsletter Subscription'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('issubscriber')->setAllowEmpty(true)->setMultiOptions(array('0' => 'No', '1' => 'Yes'));
     $this->addElement('select', 'isreseller', array('label' => $translate->_('Is Reseller'), 'description' => 'Set the user as reseller', 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('isreseller')->setAllowEmpty(true)->setMultiOptions(array('0' => 'No', '1' => 'Yes'));
     $this->addElement('text', 'birthdate', array('filters' => array('StringTrim'), 'label' => $translate->_('Birth date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date'));
     $this->addElement('text', 'birthplace', array('filters' => array('StringTrim'), 'label' => $translate->_('Birth place'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'birthdistrict', array('filters' => array('StringTrim'), 'label' => $translate->_('Birth district'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'birthcountry', array('filters' => array('StringTrim'), 'label' => $translate->_('Birth country'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'birthnationality', array('filters' => array('StringTrim'), 'label' => $translate->_('Birth nationality'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('select', 'group_id', array('label' => $translate->_('Group'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('group_id')->setAllowEmpty(true)->setMultiOptions(CustomersGroups::getList());
     $this->addElement('select', 'type_id', array('label' => $translate->_('Company Type'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('type_id')->setAllowEmpty(true)->setMultiOptions(CompanyTypes::getList(true));
     $this->addElement('select', 'legalform_id', array('label' => 'Legal form', 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('legalform_id')->setAllowEmpty(true)->setMultiOptions(Legalforms::getList());
     $this->addElement('text', 'company', array('filters' => array('StringTrim'), 'label' => $translate->_('Company Name'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('button', 'customerupdate', array('label' => 'Customer Update', 'description' => 'Update the customer information retrieving the data from the registrar database.', 'decorators' => array('Bootstrap'), 'class' => 'button red customerupdate'));
     $this->addElement('text', 'vat', array('filters' => array('StringTrim'), 'label' => $translate->_('VAT Number'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'taxpayernumber', array('filters' => array('StringTrim'), 'label' => $translate->_('Taxpayer Number'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     // If the browser client is an Apple client hide the file upload html object
     if (false == Shineisp_Commons_Utilities::isAppleClient()) {
         $MBlimit = Settings::findbyParam('adminuploadlimit', 'admin', Isp::getActiveISPID());
         $filetypes = Settings::findbyParam('adminuploadfiletypes', 'Admin');
         $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit);
         $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'decorators' => array('File', array('ViewScript', array('viewScript' => 'partials/file.phtml', 'placement' => false))), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $filetypes, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)), 'data-classButton' => 'btn btn-primary', 'data-input' => 'false', 'class' => 'filestyle'));
         if ($filetypes) {
             $file->addValidator('Extension', false, $filetypes);
         }
         if ($Byteslimit) {
             $file->addValidator('Size', false, $Byteslimit);
         }
         $file->addValidator('Count', false, 1);
         $this->addElement($file);
         $this->addElement('select', 'filecategory', array('label' => $translate->_('File Category'), 'decorators' => array('Bootstrap'), 'class' => 'text-input'));
         $this->getElement('filecategory')->setAllowEmpty(true)->setMultiOptions(FilesCategories::getList());
     }
     $this->addElement('text', 'address', array('filters' => array('StringTrim'), 'label' => $translate->_('Address'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'code', array('filters' => array('StringTrim'), 'label' => $translate->_('Zip code'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'area', array('filters' => array('StringTrim'), 'label' => $translate->_('Area'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'city', array('filters' => array('StringTrim'), 'label' => $translate->_('City'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('select', 'country_id', array('label' => $translate->_('Country'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'onchange' => 'onChangeCountry( this );'));
     $this->getElement('country_id')->setAllowEmpty(false)->setMultiOptions(Countries::getList(true));
     $this->addElement('select', 'region_id', array('label' => $translate->_('Region'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'onchange' => 'onChangeRegions( this );'));
     $this->getElement('region_id')->setRegisterInArrayValidator(false)->addValidator(new Shineisp_Validate_Regions());
     $this->addElement('select', 'contacttypes', array('label' => $translate->_('Contact Types'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('contacttypes')->setAllowEmpty(false)->setMultiOptions(ContactsTypes::getList());
     $this->addElement('text', 'contact', array('filters' => array('StringTrim'), 'label' => $translate->_('Contact'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'email', array('filters' => array('StringTrim', 'StringToLower'), 'decorators' => array('Bootstrap'), 'validators' => array('EmailAddress'), 'required' => true, 'label' => $translate->_('Email'), 'class' => 'form-control'));
     $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Private Notes'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control wysiwyg'));
     $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'validators' => array(array('regex', false, '/^[a-zA-Z0-9\\-\\_\\.\\%\\!\\$]{6,20}$/')), 'description' => 'Write here at least 6 characters.', 'label' => $translate->_('Password'), 'class' => 'form-control'));
     $this->addElement('select', 'status_id', array('label' => $translate->_('Status'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('status_id')->setAllowEmpty(false)->setMultiOptions(Statuses::getList('customers'));
     $this->addElement('select', 'parent_id', array('label' => 'Reseller', 'decorators' => array('Bootstrap'), 'description' => 'Select the client who you want to join with the selected customer.', 'class' => 'form-control'));
     $criterias = array(array('where' => 'isreseller = ?', 'params' => '1'));
     $this->getElement('parent_id')->setAllowEmpty(true)->setMultiOptions(Customers::getList(true, $criterias));
     $this->addElement('submit', 'save', array('label' => $translate->_('Save'), 'decorators' => array('Bootstrap'), 'class' => 'btn'));
     $this->addElement('hidden', 'customer_id');
 }