Skip to content

Commit

Permalink
magento2 version 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
amarpanday committed Dec 7, 2020
1 parent c5ee086 commit 6c703d9
Show file tree
Hide file tree
Showing 66 changed files with 2,400 additions and 3,114 deletions.
Empty file modified Block/Adminhtml/SendinblueBlock.php
100644 → 100755
Empty file.
Empty file modified Block/Sib.php
100644 → 100755
Empty file.
Empty file modified Controller/Adminhtml/Sib/Index.php
100644 → 100755
Empty file.
310 changes: 107 additions & 203 deletions Controller/Adminhtml/index/Ajax.php
100644 → 100755

Large diffs are not rendered by default.

94 changes: 42 additions & 52 deletions Controller/Adminhtml/index/Post.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function execute()
}
try {
$model = $this->sibObject();

if (isset($post['submitUpdate']) && !empty($post['submitUpdate'])) {
$this->apiKeyPostProcessConfiguration();
}
Expand Down Expand Up @@ -154,39 +155,29 @@ public function apiKeyPostProcessConfiguration()
$scopeInerface = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
if ($status == 1) {
$apikey = trim($post['apikey']);
$rowList = $model->checkApikey($apikey);

if (isset($rowList) && $rowList['code'] == 'success' && $rowList['message'] == 'Data retrieved') {
//If a user enters a new API key, we remove all records that belongs to the
//old API key.
$oldApiKey = trim($model->_getValueDefault->getValue('sendinblue/api_key', $scopeInerface));

// Old key
if ($apikey != $oldApiKey) {
// Reset data for old key
$model->resetDataBaseValue();
$model->resetSmtpDetail();
}

if (isset($apikey)) {
$model->_resourceConfig->saveConfig('sendinblue/api_key', $apikey, $model->_scopeTypeDefault, $model->_storeId);
}

if (isset($status)) {
$model->_resourceConfig->saveConfig('sendinblue/api_key_status', $status, $model->_scopeTypeDefault, $model->_storeId);
}

$sendinListdata = $model->_getValueDefault->getValue('sendinblue/selected_list_data', $scopeInerface);
$sendinFirstrequest = $model->_getValueDefault->getValue('sendinblue/first_request', $scopeInerface);
//We remove all records that belongs to the old API
$oldApiKey = trim($model->_getValueDefault->getValue('sendinblue/api_key_v3', $scopeInerface));
if ($apikey != $oldApiKey) {
$model->resetDataBaseValue();
$model->resetSmtpDetail();
}
$model->_resourceConfig->saveConfig('sendinblue/api_key_v3', $apikey, $model->_scopeTypeDefault, $model->_storeId);
$model->_resourceConfig->saveConfig('sendinblue/api_key_status', $status, $model->_scopeTypeDefault, $model->_storeId);
$sendinListdata = $model->_getValueDefault->getValue('sendinblue/selected_list_data', $scopeInerface);
$sendinFirstrequest = $model->_getValueDefault->getValue('sendinblue/first_request', $scopeInerface);

if (empty($sendinListdata) && empty($sendinFirstrequest)) {
$model->_resourceConfig->saveConfig('sendinblue/first_request', 1, $model->_scopeTypeDefault, $model->_storeId);
$model->_resourceConfig->saveConfig('sendinblue/subscribe_setting', 1, $model->_scopeTypeDefault, $model->_storeId);
$model->_resourceConfig->saveConfig('sendinblue/notify_cron_executed', 0, $model->_scopeTypeDefault, $model->_storeId);
$model->_resourceConfig->saveConfig('sendinblue/syncronize', 1, $model->_scopeTypeDefault, $model->_storeId);
if (empty($sendinListdata) && empty($sendinFirstrequest)) {
$model->_resourceConfig->saveConfig('sendinblue/first_request', 1, $model->_scopeTypeDefault, $model->_storeId);
$model->_resourceConfig->saveConfig('sendinblue/subscribe_setting', 1, $model->_scopeTypeDefault, $model->_storeId);
$model->_resourceConfig->saveConfig('sendinblue/notify_cron_executed', 0, $model->_scopeTypeDefault, $model->_storeId);
$model->_resourceConfig->saveConfig('sendinblue/syncronize', 1, $model->_scopeTypeDefault, $model->_storeId);
}

$model->createFolderName($apikey);
}
$response = $model->checkApikey($apikey);

if ($response) {
$model->createAttributesName($apikey, $response);
$model->createFolderName($apikey);
$this->messageManager->addSuccess(
__('Sendiblue configuration setting Successfully updated')
);
Expand All @@ -204,6 +195,8 @@ public function apiKeyPostProcessConfiguration()
}
}
} catch (\Exception $e) {
$model->_resourceConfig->saveConfig('sendinblue/api_key_status', 0, $model->_scopeTypeDefault, $model->_storeId);
$model->resetDataBaseValue();
$this->messageManager->addError(
__('API key is invalid.')
);
Expand Down Expand Up @@ -239,56 +232,53 @@ public function saveTemplateValue()
$doubleoptinRedirectUrl = !empty($post['doubleoptin_redirect_url']) ? $post['doubleoptin_redirect_url'] : '';
$finalConfirmEmail = !empty($post['final_confirm_email']) ? $post['final_confirm_email'] : '';
$finalTempId = !empty($post['template_final']) ? $post['template_final'] : '';
$shopApiKey = $model->getDbData('api_key');
$manageSubscribe = !empty($post['managesubscribe']) ? $post['managesubscribe'] : 0;
$shopApiKeyStatus = $model->getDbData('api_key_status');

$model->updateDbData('doubleoptin_template_id', $doubleOptinTempId);
$model->updateDbData('template_id', $valueTemplateId);
$model->updateDbData('optin_url_check', $optinRedirectUrlCheck);
$model->updateDbData('doubleoptin_redirect', $doubleoptinRedirectUrl);
$model->updateDbData('final_confirm_email', $finalConfirmEmail);
$model->updateDbData('subscribe_setting', $manageSubscribe);
if (!empty($finalTempId)) {
$model->updateDbData('final_template_id', $finalTempId);
}
$model->updateSender();
if (!empty($subscribeConfirmType)) {
$model->updateDbData('confirm_type', $subscribeConfirmType);
if ($subscribeConfirmType == 'doubleoptin') {
$resOptin = $model->checkFolderListDoubleoptin($shopApiKey);
if ($subscribeConfirmType == 'doubleoptin') {
$resOptin = $model->checkFolderListDoubleoptin();
if (!empty($resOptin['optin_id'])) {
$model->updateDbData('optin_list_id', $resOptin['optin_id']);
}

if ($resOptin === false) {
$mailin = $model->createObjMailin($shopApiKey);
if (!empty($shopApiKey)) {
$data = [];
$data = ["name"=> "FORM"];
$folderRes = $mailin->createFolder($data);
$folderId = $folderRes['data']['id'];
}

if (!empty($shopApiKey)) {
if ( $resOptin === false && !empty($shopApiKeyStatus) ) {
$mailin = $model->createObjSibClient();
$data = [];
$data = ["name"=> "FORM"];
$folderRes = $mailin->createFolder($data);
if (201 === $mailin->getLastResponseCode()) {
$data = [];
$data = [
"list_name" => 'Temp - DOUBLE OPTIN',
"list_parent" => $folderId
"name" => 'Temp - DOUBLE OPTIN',
"folderId" => $folderRes["id"]
];
$listResp = $mailin->createList($data);
$listId = $listResp['data']['id'];
$model->updateDbData('optin_list_id', $listId);
if (201 === $mailin->getLastResponseCode()) {
$listId = $listResp['id'];
$model->updateDbData('optin_list_id', $listId);
}
}
}
}
}
$displayList = $post['display_list'];
if (!empty($displayList)) {
if ($model->getDbData('subscribe_setting') == 1) {
$listValue = implode('|', $displayList);
$model->updateDbData('selected_list_data', $listValue);
} else {
$model->updateDbData('subscribe_setting', 0);
}
}

$this->messageManager->addSuccess(__('Sendiblue configuration setting Successfully updated'));
$this->_redirect('sendinblue/sib/index');
return true;
Expand Down
Empty file modified Controller/Adminhtml/index/Sync.php
100644 → 100755
Empty file.
23 changes: 12 additions & 11 deletions Controller/Index/Index.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,25 @@ public function dubleoptinProcess($userEmail)
{
$nlStatus = $this->_model->checkNlStatus($userEmail);
if (!empty($userEmail) && $nlStatus = 1) {
$apiKey = $this->_model->getDbData('api_key');
$optinListId = $this->_model->getDbData('optin_list_id');
$listId = $this->_model->getDbData('selected_list_data');

$mailin = $this->_model->createObjMailin($apiKey);
$mailin = $this->_model->createObjSibClient();

$data = array( "email" => $userEmail,
"attributes" => array("DOUBLE_OPT-IN"=>1),
"blacklisted" => 0,
"listid" => array($listId),
"listid_unlink" => array($optinListId),
"blacklisted_sms" => 0
$data = array(
"attributes" => array("DOUBLE_OPT-IN"=>'1'),
"emailBlacklisted" => false,
"listIds" => array_map('intval', explode('|', $listId)),
"unlinkListIds" => array_map('intval', explode('|', $optinListId)),
"smsBlacklisted" => false
);
$mailin->createUpdateUser($data);

$mailin->updateUser($userEmail, $data);

$confirmEmail = $this->_model->getDbData('final_confirm_email');
if ($confirmEmail === 'yes') {
$finalId = $this->_model->getDbData('final_template_id');
$this->_model->sendOptinConfirmMailResponce($userEmail, $finalId, $apiKey);
$this->_model->sendOptinConfirmMailResponce($userEmail, $finalId);
}
}
$doubleoptinRedirect = $this->_model->getDbData('doubleoptin_redirect');
Expand All @@ -67,7 +68,7 @@ public function dubleoptinProcess($userEmail)
header("Location: ".$doubleoptinRedirect);
ob_flush_end();
} else {
$shopName = $_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
$shopName = $this->_model->_getValueDefault->getValue('web/unsecure/base_url', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
header("Location: ".$shopName);
ob_flush_end();
}
Expand Down
Empty file modified Helper/ConfigHelper.php
100644 → 100755
Empty file.
Loading

0 comments on commit 6c703d9

Please sign in to comment.