Ejemplo n.º 1
0
 /**
  * Validate an User
  *
  * Verifies that the user exists.
  *
  * @param string $data Field data
  * @return UserDBO User DBO for this User ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $userDBO = load_UserDBO($data);
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("User");
     }
     return $userDBO;
 }
Ejemplo n.º 2
0
 /**
  * Validate an Account ID
  *
  * Verifies that the account exists.
  *
  * @param string $data Field data
  * @return AccountDBO Account DBO for this Account ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $accountDBO = load_AccountDBO(intval($data));
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("Account");
     }
     return $accountDBO;
 }
 /**
  * Validate a Registrar Module
  *
  * Verifies that the Registrar Module exists and is enabled
  *
  * @param string $data Field data
  * @return ModuleDBO Module DBO for this Registrar
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $moduleDBO = load_ModuleDBO($data);
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("RegistrarModule");
     }
     return $moduleDBO;
 }
Ejemplo n.º 4
0
 /**
  * Validate an Invoice ID
  *
  * Verifies that the invoice exists.
  *
  * @param array $config Field configuration
  * @param string $data Field data
  * @return InvoiceDBO Invoice DBO for this Invoice ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $invoiceDBO = load_InvoiceDBO(intval($data));
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("Invoice");
     }
     return $invoiceDBO;
 }
 /**
  * Validate a IPAddress Field
  *
  * Verifies that an IP address is in the form: 255.255.255.255.
  *
  * @param string $data Field data
  * @return string This function may alter data before validating it, if so this is the result
  * @throws FieldException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     $ip = ip2long($data);
     if ($ip === false || $ip == -1) {
         // Not a valid IP address
         throw new FieldException("[PLEASE_ENTER_A_VALID_IP_ADDRESS]");
     }
     return $data;
 }
 /**
  * Validate a Domain Service Price
  *
  * Verifies that the domain service price exists.
  *
  * @param string $data Field data
  * @return DomainServiceDBO DomainService DBO for this DomainService ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     $id = explode("-", $data);
     try {
         $priceDBO = load_DomainServicePriceDBO($id[0], $id[1], intval($id[2]));
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("DomainServicePrice");
     }
     return $priceDBO;
 }
 /**
  * Validate an OrderItem ID
  *
  * Verifies that the order exists.
  *
  * @param string $data Field data
  * @return OrderItemDBO OrderItem DBO for this OrderItem ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     if ($this->order == null) {
         // Can not validate an order item without an order property
         throw new SWException("Attempted to validate an OrderItem without giving an OrderDBO!");
     }
     if (null == ($orderItemDBO = $this->order->getItem(intval($data)))) {
         // Order Item does not exist
         throw new RecordNotFoundException("OrderItem");
     }
     return $orderItemDBO;
 }
Ejemplo n.º 8
0
 /**
  * Validate a Hosting Service ID
  *
  * Verifies that the hosting service exists.
  *
  * @param string $data Field data
  * @return HostingServiceDBO HostingService DBO for this HostingService ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $hostingDBO = load_HostingServiceDBO(intval($data));
     } catch (DBRowNotFoundException $e) {
         throw new RecordNotFoundException("HostingService");
     }
     if ($this->fieldConfig['publicitemsonly'] && !$hostingDBO->isPublic()) {
         throw new RecordNotFoundException("HostingService");
     }
     return $hostingDBO;
 }
 /**
  * Validate a Domain Service TLD
  *
  * Verifies that the domain service exists.
  *
  * @param string $data Field data
  * @return DomainServiceDBO Domain Service DBO for this TLD
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $domainDBO = load_DomainServiceDBO($data);
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("DomainService");
     }
     if ($this->fieldConfig['publicitemsonly'] && !$domainDBO->isPublic()) {
         throw new RecordNotFoundException("DomainService");
     }
     return $domainDBO;
 }
Ejemplo n.º 10
0
 /**
  * Validate a Payment ID
  *
  * Verifies that the payment exists.
  *
  * @param string $data Field data
  * @return PaymentDBO Payment DBO for this Payment ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $paymentDBO = load_PaymentDBO(intval($data));
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("Payment");
     }
     // Verify that this payment belongs to the invocie specified
     if (isset($this->invoiceID) && $paymentDBO->getInvoiceID() != $this->invoiceID) {
         throw new FieldException("Invoice/Payment mismatch");
     }
     return $paymentDBO;
 }
 /**
  * Validate a Product  Purchase ID
  *
  * Verifies that the server exists.
  *
  * @param string $data Field data
  * @return ProductPurchaseDBO Purchase DBO for this ProductPurchase ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $purchaseDBO = load_ProductPurchaseDBO(intval($data));
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("ProductPurchase");
     }
     // Verify that this purchase is for a specific account
     if (isset($this->accountID) && $purchaseDBO->getAccountID() != $this->accountID) {
         throw new FieldException("Purchase/Account mismatch");
     }
     return $purchaseDBO;
 }
Ejemplo n.º 12
0
 /**
  * Validate a Module
  *
  * Verifies that a module exists.
  *
  * @param string $data Field data
  * @return ModuleDBO Module DBO for this Module ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     global $conf;
     $data = parent::validate($data);
     try {
         $module = ModuleRegistry::getModuleRegistry()->getModule($data);
         if (isset($this->type) && $module->getType() != $this->type) {
             throw new FieldException("Invalid module type");
         }
     } catch (ModuleDoesNotExistException $e) {
         throw new RecordNotFoundException("Module");
     }
     return $module;
 }
Ejemplo n.º 13
0
 /**
  * Returns the validation error message for a field.
  *
  * @param Field $field A field.
  *
  * @return string (X)HTML.
  */
 protected function validateField(Field $field)
 {
     $fieldValidator = new FieldValidator($this->form->getName(), $field);
     return $fieldValidator->validate();
 }