/**
  * Adds the service to the remote server. Sets Input errors on failure,
  * preventing the service from being added.
  *
  * @param stdClass $package A stdClass object representing the selected package
  * @param array $vars An array of user supplied info to satisfy the request
  * @param stdClass $parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service)
  * @param stdClass $parent_service A stdClass object representing the parent service of the service being added (if the current service is an addon service service and parent service has already been provisioned)
  * @param string $status The status of the service being added. These include:
  * 	- active
  * 	- canceled
  * 	- pending
  * 	- suspended
  * @return array A numerically indexed array of meta fields to be stored for this service containing:
  * 	- key The key for this meta field
  * 	- value The value for this key
  * 	- encrypted Whether or not this field should be encrypted (default 0, not encrypted)
  * @see Module::getModule()
  * @see Module::getModuleRow()
  */
 public function addService($package, array $vars = null, $parent_package = null, $parent_service = null, $status = "pending")
 {
     $row = $this->getModuleRow();
     $api = $this->getApiByMeta($row->meta);
     // If no username given, generate a username
     if (!$this->getFromVars($vars, 'cpanel_username') and $this->getFromVars($vars, 'cpanel_domain')) {
         $vars['cpanel_username'] = $this->generateUsername($vars['cpanel_domain']);
     }
     $params = $this->getInputFieldsToCreate((array) $vars, $package);
     $this->validateService($package, $vars);
     if ($this->Input->errors()) {
         return;
     }
     // Generate Password if the Field is Hidden
     if ($package->meta->passwordfield != 'true') {
         $params['password'] = $this->generatePassword();
     }
     // Only provision the service if 'use_module' is true
     if ($vars['use_module'] == "true") {
         $masked_params = $params;
         $masked_params['password'] = "******";
         $this->log($row->meta->host_name . "|createacct", serialize($masked_params), "input", true);
         unset($masked_params);
         $result = $api->createacct($params);
         $this->parseResponse($result->getCleanResponse());
         if ($this->Input->errors()) {
             return;
         }
         // If reseller and we have an ACL set, update the reseller's ACL
         if ($package->meta->type == "reseller") {
             if ($package->meta->acl != "") {
                 $api->setacls(array('reseller' => $params['username'], 'acllist' => $package->meta->acl));
             }
             // Set Space Limit for Resellers
             if (!empty($package->meta->diskreseller) && !empty($package->meta->bandreseller)) {
                 Loader::load(dirname(__FILE__) . DS . "api" . DS . "xmlapi.php");
                 $xmlapi = new xmlapi($row->meta->host_name, $row->meta->user_name, $row->meta->password);
                 $params = array('user' => $vars['cpanel_username'], 'enable_resource_limits' => 1, 'diskspace_limit' => $package->meta->diskreseller, 'bandwidth_limit' => $package->meta->bandreseller);
                 $this->log($row->meta->host_name . "|setresellerlimits", serialize($params), "input", true);
                 $response = $xmlapi->setresellerlimits($params);
             }
         }
     }
     // Return service fields
     return array(array('key' => "cpanel_domain", 'value' => $params['domain'], 'encrypted' => 0), array('key' => "cpanel_username", 'value' => $params['username'], 'encrypted' => 0), array('key' => "cpanel_password", 'value' => $params['password'], 'encrypted' => 1), array('key' => "cpanel_confirm_password", 'value' => $params['password'], 'encrypted' => 1));
 }