Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/28/2016 in all areas

  1. Hi all, Just sharing an approach that can be used in a custom module to check whether a service field value is unique or already in use (e.g. to enforce unique domain names). public function validateService($package, array $vars=null, $edit=false) { if ($package) $module_row_id = $package->module_row; else $module_row_id = isset($vars['module_row']) ? $vars['module_row'] : null; $row = $this->getModuleRow($module_row_id); //get the service id using a known and guaranteed unique field. this is needed to perform a unique validation of service fields without having the same service that may already have the field to cause validation to fail (e.g. when activating a pending service). $service_id = $this->getServiceIDUsingUniqueServiceField('myUniqueServiceUID', $params['myUniqueServiceUID']); $rules = array( 'domain' => array( 'unique' => array( 'final' => true, 'rule' => array(array($this, "checkUniqueDomain"), $service_id), 'negate' => true, 'message' => Language::_("ModuleName.!error.domain_valid.unique", true) ) ) ); $this->Input->setRules($rules); return $this->Input->validates($params); } // check any service field value exists private function checkServiceFieldValueExists($key, $value, $service_id = null) { Loader::loadComponents($this, array("Record")); $exists = false; if (is_null($service_id)) { $service_id = -1; } $this->Record->select() ->from("service_fields") ->where("service_fields.key", "=", $key) ->where("service_fields.value", "=", $value) ->where("service_fields.service_id", "!=", $service_id); if($this->Record->numResults() > 0) { $exists = true; } $this->Record->reset(); return $exists; } // check domain is unique public function checkUniqueDomain($value, $service_id = null) { return $this->checkServiceFieldValueExists('domain', $value, $service_id); }
    1 point
  2. NETLINK

    Enom Module - Nameservers

    The following change will prevent an error if, for some reason, Enom is only returning one nameserver, which happened me today. if ($response->status() == "OK") { $data = $response->response(); if ( isset( $data->dns ) && is_array( $data->dns ) ) { foreach ($data->dns as $ns) $vars->ns[] = $ns; } } Blesta Version 3.6.1 Enom (ver 2.2.1) File: components/modules/enom/enom.php Line: 1151
    1 point
  3. Just wondering if this plugin is safe to use with Blesta ?
    1 point
  4. NETLINK

    Enom Module - Nameservers

    The expected output returned by the module is a list of nameservers associated with the domain, which is converted into a PHP array: https://reseller.enom.com/interface.asp <?xml version="1.0" encoding="utf-8"?> <interface-response> <dns>ns1.example.com</dns> <dns>ns2.example.com</dns> <UseDNS></UseDNS> However, the actual result I got was just 1 nameserver, which resulted in a fatal PHP error: Invalid argument supplied for foreach() https://reseller.enom.com/interface.asp <?xml version="1.0" encoding="utf-8"?> <interface-response> <dns>ns1.example.com</dns> <UseDNS></UseDNS> I added "&& is_array( $data->dns )", which checks if $data->dns is an array, and prevents a fatal error in this scenario.
    1 point
×
×
  • Create New...