Beispiel #1
0
 public function insert($params)
 {
     $this->authenticate();
     $form = new Api_Form_CustomerForm(array('action' => '#', 'method' => 'post'));
     #Add email validator
     $mailValidator = new Shineisp_Validate_Email();
     $form->getElement('email')->addValidator($mailValidator);
     $form->addElement('password', 'password', array('filters' => array('StringTrim'), 'required' => true, 'decorators' => array('Composite'), 'validators' => array(array('regex', false, '/^[a-zA-Z0-9\\-\\_\\.\\%\\!\\$]{6,20}$/')), 'description' => 'Write here your password. (min.6 chars - max.20 chars)', 'label' => 'Password', 'class' => 'text-input large-input'));
     if (array_key_exists('countrycode', $params)) {
         $country_id = Countries::getIDbyCode($params['countrycode']);
         if ($country_id == null) {
             throw new Shineisp_Api_Exceptions(400005, ":: 'countrycode' not valid");
             exit;
         }
         unset($params['coutrycode']);
         $params['country_id'] = $country_id;
     }
     if (array_key_exists('provincecode', $params) && $params['provincecode'] != "") {
         $params['area'] = $params['provincecode'];
         unset($params['provincecode']);
     }
     if ($form->isValid($params)) {
         if ($params['status'] == false) {
             $params['status'] = 'disabled';
         }
         $idcustomers = Customers::Create($params);
         $customer = Customers::find($idcustomers);
         return $customer['uuid'];
     } else {
         $errors = $form->getMessages();
         $message = "";
         foreach ($errors as $field => $errorsField) {
             $message .= "Field '{$field}'<br/>";
             foreach ($errorsField as $error => $describe) {
                 $message .= " => {$error} ({$describe})";
             }
         }
         throw new Shineisp_Api_Exceptions(400004, ":\n{$message}");
         exit;
     }
 }
Beispiel #2
0
 public function insert($params)
 {
     $this->authenticate();
     $form = new Api_Form_CustomerForm(array('action' => '#', 'method' => 'post'));
     if (array_key_exists('countrycode', $params)) {
         $country_id = Countries::getIDbyCode($params['countrycode']);
         if ($country_id == null) {
             throw new Shineisp_Api_Exceptions(400005, ":: 'countrycode' not valid");
             exit;
         }
         unset($params['coutrycode']);
         $params['country_id'] = $country_id;
     }
     if (array_key_exists('provincecode', $params) && $params['provincecode'] != "") {
         $params['area'] = $params['provincecode'];
         unset($params['provincecode']);
     }
     if ($form->isValid($params)) {
         if ($params['status'] == false) {
             $params['status'] = 'disabled';
         }
         $idcustomers = Customers::Create($params);
         $customer = Customers::find($idcustomers);
         return $customer['uuid'];
     } else {
         $errors = $form->getMessages();
         $message = "";
         foreach ($errors as $field => $errorsField) {
             $message .= "Field '{$field}'<br/>";
             foreach ($errorsField as $error => $describe) {
                 $message .= " => {$error} ({$describe})";
             }
         }
         throw new Shineisp_Api_Exceptions(400004, ":\n{$message}");
         exit;
     }
 }
Beispiel #3
0
 /**
  * Create a customer using the cart information and it creates 
  * the Nic Handle in order to communicate with the default registrars 
  */
 private function CreateCustomer($params, $createNicHandle = false)
 {
     $params['contacttypes'] = 1;
     // Telephone
     $params['contact'] = $params['telephone'];
     $customerID = Customers::Create($params);
     return $customerID;
 }
Beispiel #4
0
 /**
  * Signup Action Controller
  */
 public function dosignupAction()
 {
     $request = $this->getRequest();
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = new Default_Form_SignupForm(array('action' => '/customer/dosignup', 'method' => 'post'));
     $this->view->form = $form;
     $post = $request->getPost();
     if (is_array($post)) {
         if (!$form->isValid($request->getPost())) {
             // Invalid entries
             $this->view->form = $form;
             return $this->_helper->viewRenderer('signup');
             // re-render the signup form
         }
         // Get the values posted
         $params = $form->getValues();
         // Create the user
         Customers::Create($params);
         // Send the user to the auto login page
         $url = '/default/index/fastlogin/id/' . Shineisp_Commons_Hasher::hash_string($params['email']);
         $redirector->gotoUrl($url);
     }
 }