-
Notifications
You must be signed in to change notification settings - Fork 6
add support for local edit #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1479,6 +1479,43 @@ public function addService($package, array $vars=null, $parent_package=null, $pa | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Edits the service on the remote server. Sets Input errors on failure, | ||
| * preventing the service from being edited. | ||
| * | ||
| * @param stdClass $package A stdClass object representing the current package | ||
| * @param stdClass $service A stdClass object representing the current service | ||
| * @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 edited (if the current service is an addon service) | ||
| * @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 editService($package, $service, array $vars = null, $parent_package = null, $parent_service = null) | ||
| { | ||
| // Set fields to update locally | ||
| $service_fields = ['thesslstore_token', 'thesslstore_order_id', 'thesslstore_fqdn']; | ||
| foreach ($service_fields as $field) { | ||
| // check if the field is set and is not empty | ||
| if (isset($vars[$field]) && $vars[$field] != '') { | ||
| $service_fields[$field] = trim($vars[$field]); | ||
| } | ||
| } | ||
|
|
||
| $fields = []; | ||
| foreach ($service_fields as $key => $value) { | ||
| $fields[] = ['key' => $key, 'value' => $value]; | ||
| } | ||
|
|
||
| return $fields; | ||
| } | ||
|
|
||
| /** | ||
| * Allows the module to perform an action when the service is ready to renew. | ||
| * Sets Input errors on failure, preventing the service from renewing. | ||
|
|
@@ -1793,6 +1830,50 @@ private function getProducts() { | |
| return $productsArray; | ||
| } | ||
|
|
||
| /** | ||
| * Returns all fields to display to an admin attempting to edit a service with the module | ||
| * | ||
| * @param stdClass $package A stdClass object representing the selected package | ||
| * @param $vars stdClass A stdClass object representing a set of post fields | ||
| * @return ModuleFields A ModuleFields object, containg the fields to render as | ||
| * well as any additional HTML markup to include | ||
| */ | ||
| public function getAdminEditFields($package, $vars = null) | ||
| { | ||
| Loader::loadHelpers($this, ['Html']); | ||
|
|
||
| $fields = new ModuleFields(); | ||
|
|
||
| // Create domain label | ||
| $thesslstore_fqdn = $fields->label(Language::_('ThesslstoreModule.tab_client_cert_details.domains', true), 'thesslstore_fqdn'); | ||
| // Create domain field and attach to domain label | ||
| $thesslstore_fqdn->attach( | ||
| $fields->fieldText('thesslstore_fqdn', $this->Html->ifSet($vars->thesslstore_fqdn), ['id'=>'thesslstore_fqdn']) | ||
| ); | ||
| // Set the label as a field | ||
| $fields->setField($thesslstore_fqdn); | ||
|
|
||
| // Create order id label | ||
| $thesslstore_order_id = $fields->label(Language::_('ThesslstoreModule.tab_client_cert_details.store_order_id', true), 'thesslstore_order_id'); | ||
| // Create order id field and attach to order id label | ||
| $thesslstore_order_id->attach( | ||
| $fields->fieldText('thesslstore_order_id', $this->Html->ifSet($vars->thesslstore_order_id), ['id'=>'thesslstore_order_id']) | ||
| ); | ||
| // Set the label as a field | ||
| $fields->setField($thesslstore_order_id); | ||
|
|
||
| // Create token label | ||
| $thesslstore_token = $fields->label(Language::_('ThesslstoreModule.tab_client_cert_details.token', true), 'thesslstore_token'); | ||
| // Create token field and attach to token label | ||
| $thesslstore_token->attach( | ||
| $fields->fieldText('thesslstore_token', $this->Html->ifSet($vars->thesslstore_token), ['id'=>'thesslstore_token']) | ||
| ); | ||
| // Set the label as a field | ||
| $fields->setField($thesslstore_token); | ||
|
|
||
| return $fields; | ||
| } | ||
|
|
||
| /** | ||
| * Returns all tabs to display to a client when managing a service whose | ||
| * package uses this module | ||
|
|
@@ -3719,8 +3800,86 @@ private function parseResponse($response, $ignore_error = false) { | |
| return $response; | ||
| } | ||
|
|
||
| /** | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have added the same methods twice. |
||
| * Returns all fields to display to an admin attempting to edit a service with the module | ||
| * | ||
| * @param stdClass $package A stdClass object representing the selected package | ||
| * @param $vars stdClass A stdClass object representing a set of post fields | ||
| * @return ModuleFields A ModuleFields object, containg the fields to render as | ||
| * well as any additional HTML markup to include | ||
| */ | ||
| public function getAdminEditFields($package, $vars = null) | ||
| { | ||
| Loader::loadHelpers($this, ['Html']); | ||
|
|
||
| $fields = new ModuleFields(); | ||
|
|
||
| // Create domain label | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know the rest of this file does not adhere to it, but we try to have a maximum line length of 120 characters. |
||
| $thesslstore_fqdn = $fields->label(Language::_('ThesslstoreModule.tab_client_cert_details.domains', true), 'thesslstore_fqdn'); | ||
| // Create domain field and attach to domain label | ||
| $thesslstore_fqdn->attach( | ||
| $fields->fieldText('thesslstore_fqdn', $this->Html->ifSet($vars->thesslstore_fqdn), ['id'=>'thesslstore_fqdn']) | ||
| ); | ||
| // Set the label as a field | ||
| $fields->setField($thesslstore_fqdn); | ||
|
|
||
| // Create order id label | ||
| $thesslstore_order_id = $fields->label(Language::_('ThesslstoreModule.tab_client_cert_details.store_order_id', true), 'thesslstore_order_id'); | ||
| // Create order id field and attach to order id label | ||
| $thesslstore_order_id->attach( | ||
| $fields->fieldText('thesslstore_order_id', $this->Html->ifSet($vars->thesslstore_order_id), ['id'=>'thesslstore_order_id']) | ||
| ); | ||
| // Set the label as a field | ||
| $fields->setField($thesslstore_order_id); | ||
|
|
||
| // Create token label | ||
| $thesslstore_token = $fields->label(Language::_('ThesslstoreModule.tab_client_cert_details.token', true), 'thesslstore_token'); | ||
| // Create token field and attach to token label | ||
| $thesslstore_token->attach( | ||
| $fields->fieldText('thesslstore_token', $this->Html->ifSet($vars->thesslstore_token), ['id'=>'thesslstore_token']) | ||
| ); | ||
| // Set the label as a field | ||
| $fields->setField($thesslstore_token); | ||
|
|
||
| return $fields; | ||
| } | ||
|
|
||
| /** | ||
| * Edits the service on the remote server. Sets Input errors on failure, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is inaccurate. You only edit fields locally and you never set errors. Careful with copy paste. |
||
| * preventing the service from being edited. | ||
| * | ||
| * @param stdClass $package A stdClass object representing the current package | ||
| * @param stdClass $service A stdClass object representing the current service | ||
| * @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 edited (if the current service is an addon service) | ||
| * @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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While 'encrypted' is a valid index to set, so do not set it so this comment is inaccurate. |
||
| * @see Module::getModule() | ||
| * @see Module::getModuleRow() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You never use these two functions you are referencing. |
||
| */ | ||
| public function editService($package, $service, array $vars = null, $parent_package = null, $parent_service = null) | ||
| { | ||
| // Set fields to update locally | ||
| $service_fields = ['thesslstore_token', 'thesslstore_order_id', 'thesslstore_fqdn']; | ||
| foreach ($service_fields as $field) { | ||
| // check if the field is set and is not empty | ||
| if (isset($vars[$field]) && $vars[$field] != '') { | ||
| $service_fields[$field] = trim($vars[$field]); | ||
| } | ||
| } | ||
|
|
||
| $fields = []; | ||
| foreach ($service_fields as $key => $value) { | ||
| $fields[] = ['key' => $key, 'value' => $value]; | ||
| } | ||
|
|
||
| return $fields; | ||
| } | ||
|
|
||
| } | ||
| ?> | ||
| ?> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting is off here with white space usage. You should use spaces rather than tabs (1 tab = 4 spaces).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed .