diff --git a/src/freeform_next/Controllers/MailingListsController.php b/src/freeform_next/Controllers/MailingListsController.php index 49a1f389..fc8af8c9 100644 --- a/src/freeform_next/Controllers/MailingListsController.php +++ b/src/freeform_next/Controllers/MailingListsController.php @@ -33,18 +33,22 @@ public function handle($id = null) return $this->index(); } - if ($id === 'check') { + if ($id === "check") { return $this->check(); } - if ($id === 'get') { + if ($id === "get") { return $this->getIntegrationsAjax(); } - if ($id === 'delete') { + if ($id === "delete") { return $this->batchDelete(); } + if ($id === "authorize") { + return $this->authorize(); + } + return $this->edit($id); } @@ -54,16 +58,16 @@ public function handle($id = null) public function index() { /** @var Table $table */ - $table = ee('CP/Table', ['sortable' => false, 'searchable' => false]); + $table = ee("CP/Table", ["sortable" => false, "searchable" => false]); $table->setColumns( [ - 'id' => ['type' => Table::COL_ID], - 'Name' => ['type' => Table::COL_TEXT], - 'Handle' => ['type' => Table::COL_TEXT], - 'Service Provider' => ['type' => Table::COL_TEXT], - 'manage' => ['type' => Table::COL_TOOLBAR], - ['type' => Table::COL_CHECKBOX, 'name' => 'selection'], + "id" => ["type" => Table::COL_ID], + "Name" => ["type" => Table::COL_TEXT], + "Handle" => ["type" => Table::COL_TEXT], + "Service Provider" => ["type" => Table::COL_TEXT], + "manage" => ["type" => Table::COL_TOOLBAR], + ["type" => Table::COL_CHECKBOX, "name" => "selection"], ] ); @@ -74,64 +78,64 @@ public function index() $tableData[] = [ $integration->id, [ - 'content' => $integration->name, - 'href' => $this->getLink('integrations/mailing_lists/' . $integration->id), + "content" => $integration->name, + "href" => $this->getLink("integrations/mailing_lists/" . $integration->id), ], $integration->handle, $integration->getIntegrationObject()->getServiceProvider(), [ - 'toolbar_items' => [ - 'edit' => [ - 'href' => UrlHelper::getLink('integrations/mailing_lists/' . $integration->id), - 'title' => lang('edit'), + "toolbar_items" => [ + "edit" => [ + "href" => UrlHelper::getLink("integrations/mailing_lists/" . $integration->id), + "title" => lang("edit"), ], ], ], [ - 'name' => 'id_list[]', - 'value' => $integration->id, - 'data' => [ - 'confirm' => lang('Integration') . ': ' . htmlentities( + "name" => "id_list[]", + "value" => $integration->id, + "data" => [ + "confirm" => lang("Integration") . ": " . htmlentities( $integration->name, ENT_QUOTES - ) . '', + ) . "", ], ], ]; } $table->setData($tableData); - $table->setNoResultsText('No results'); + $table->setNoResultsText("No results"); - $removeModal = new ConfirmRemoveModal($this->getLink('integrations/mailing_lists/delete')); - $removeModal->setKind('Mailing List Integrations'); + $removeModal = new ConfirmRemoveModal($this->getLink("integrations/mailing_lists/delete")); + $removeModal->setKind("Mailing List Integrations"); $serviceProviderTypes = $this->getMailingListService()->getAllMailingListServiceProviders(); if (count($serviceProviderTypes)) { $formRightLinks = [ [ - 'title' => lang('New Integration'), - 'link' => $this->getLink('integrations/mailing_lists/new'), + "title" => lang("New Integration"), + "link" => $this->getLink("integrations/mailing_lists/new"), ], ]; } else { $formRightLinks = [ [ - 'title' => lang('Upgrade to Pro to Enable'), - 'link' => 'https://docs.solspace.com/expressionengine/freeform/v3/', + "title" => lang("Upgrade to Pro to Enable"), + "link" => "https://docs.solspace.com/expressionengine/freeform/v3/", ], ]; } $view = new CpView( - 'integrations/table', + "integrations/table", [ - 'table' => $table->viewData(), - 'cp_page_title' => lang('Mailing List Integrations'), - 'form_right_links' => $formRightLinks, + "table" => $table->viewData(), + "cp_page_title" => lang("Mailing List Integrations"), + "form_right_links" => $formRightLinks, ] ); - $view->setHeading(lang('Mailing List Integrations')); + $view->setHeading(lang("Mailing List Integrations")); $view->addModal($removeModal); return $view; @@ -148,10 +152,10 @@ public function edit($id) $serviceProviderTypes = $this->getMailingListService()->getAllMailingListServiceProviders(); if (empty($serviceProviderTypes)) { - return new RedirectView('https://docs.solspace.com/expressionengine/freeform/v3/'); + return new RedirectView("https://docs.solspace.com/expressionengine/freeform/v3/"); } - if ($id === 'new') { + if ($id === "new") { $model = IntegrationModel::create(IntegrationModel::TYPE_MAILING_LIST); $model->class = array_keys($serviceProviderTypes)[0]; } else { @@ -159,21 +163,21 @@ public function edit($id) } if (!$model) { - throw new IntegrationException('Integration does not exist'); + throw new IntegrationException("Integration does not exist"); } $errors = null; - if (isset($_POST['class'])) { + if (isset($_POST["class"])) { $errors = $this->save($model); if (empty($errors)) { - $view = new RedirectView($this->getLink('integrations/mailing_lists/')); + $view = new RedirectView($this->getLink("integrations/mailing_lists/")); return $view; } } - if (ee()->input->get('code')) { + if (ee()->input->get("code")) { $this->handleAuthorization($model); } @@ -199,14 +203,15 @@ public function edit($id) $hash = md5($className); $settingGroups[] = [ - 'title' => $item->getLabel(), - 'desc' => $item->getInstructions(), - 'group' => $hash, - 'fields' => [ - $hash . '-' . $item->getHandle() => [ - 'type' => $item->getType() === SettingBlueprint::TYPE_BOOL ? 'yes_no' : 'text', - 'required' => $item->isRequired(), - 'value' => isset($settings[$item->getHandle()]) ? $settings[$item->getHandle()] : null, + "title" => $item->getLabel(), + "desc" => $item->getInstructions(), + "group" => $hash, + "fields" => [ + $hash . "-" . $item->getHandle() => [ + "type" => $item->getType() === SettingBlueprint::TYPE_BOOL ? "yes_no" : "text", + "required" => $item->isRequired(), + "value" => isset($settings[$item->getHandle()]) ? $settings[$item->getHandle()] : $item->getValue(), + "attrs" => $item->getAttributes(), ], ], ]; @@ -216,51 +221,51 @@ public function edit($id) $sectionData = [ [ [ - 'title' => lang('Service Provider'), - 'fields' => [ - 'class' => [ - 'type' => 'select', - 'value' => $model->class, - 'choices' => $types, - 'group_toggle' => $targets, + "title" => lang("Service Provider"), + "fields" => [ + "class" => [ + "type" => "select", + "value" => $model->class, + "choices" => $types, + "group_toggle" => $targets, ], ], ], [ - 'title' => 'Name', - 'desc' => 'What this integration will be called in the CP.', - 'fields' => [ - 'name' => [ - 'type' => 'text', - 'value' => $model->name, - 'attrs' => 'data-generator-base', + "title" => "Name", + "desc" => "What this integration will be called in the CP.", + "fields" => [ + "name" => [ + "type" => "text", + "value" => $model->name, + "attrs" => "data-generator-base", ], ], ], [ - 'title' => 'Handle', - 'desc' => 'The unique name used to identify this integration.', - 'fields' => [ - 'handle' => [ - 'type' => 'text', - 'value' => $model->handle, - 'attrs' => 'data-generator-target', + "title" => "Handle", + "desc" => "The unique name used to identify this integration.", + "fields" => [ + "handle" => [ + "type" => "text", + "value" => $model->handle, + "attrs" => "data-generator-target", ], ], ], ], - 'Settings' => $settingGroups, + "Settings" => $settingGroups, ]; if ($model->id) { - $link = $this->getLink('integrations/mailing_lists/check'); + $link = $this->getLink("integrations/mailing_lists/check"); $sectionData[0][] = [ - 'title' => 'Is Authorized?', - 'desc' => 'Is the connection authorized?', - 'fields' => [ - 'handle' => [ - 'type' => 'html', - 'content' => ' + "title" => "Is Authorized?", + "desc" => "Is the connection authorized?", + "fields" => [ + "handle" => [ + "type" => "html", + "content" => '