Skip to content
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

some fixes #139

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions classes/MailJetEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ public function getScheme($name)

$file = __DIR__ . '/../xml/events.xml';
$scheme = array();
//...$log = 'Scheme not found';

if (file_exists($file) && ($xml = simplexml_load_file($file))) {
if (file_exists($file) && ($xml = simplexml_load_string(file_get_contents($file)))) {
foreach ($xml->event as $event) {
if ((string) $event['name'] == $name) {
// Will set GET / POST Data if exist
Expand All @@ -100,15 +99,10 @@ public function getScheme($name)
$scheme[(string) $key] = array('value' => (string) $key, 'type' => (string) $key['type']);
}
}
//...$log = 'Scheme found';
}
}
}


// Not used for ajax query, then no need to log it
/* if ($name != MailJetEvents::ALL_EVENTS_KEYS)
MailJetLog::write(MailJetLog::$file, $log.': '.$name); */
return $scheme;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/MailJetLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MailJetLog
*/
public static function init()
{
MailJetLog::$file = dirname(__FILE__) . '/../logs/ajax.log';
MailJetLog::$file = __DIR__ . '/../logs/ajax.log';
}

private static function lockWrite($handle, $msg)
Expand Down
2 changes: 1 addition & 1 deletion classes/MailJetPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function initPagesTranslation()
public function initTemplatesAccess()
{
$file = __DIR__ . '/../xml/template.xml';
if (file_exists($file) && ($xml = simplexml_load_file($file))) {
if (file_exists($file) && ($xml = simplexml_load_string(file_get_contents($file)))) {
$this->default_page = ($this->current_authentication ?
(string) $xml->tabs->tab->default_page['name'] :
(string) $xml->pages->default_page['name']);
Expand Down
21 changes: 6 additions & 15 deletions classes/MailJetTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* International Registered Trademark & Property of PrestaShop SA
*/

include_once(dirname(__FILE__) . '/../libraries/Mailjet.Api.class.php');
include_once(dirname(__FILE__) . '/../libraries/Mailjet.Overlay.class.php');
include_once(__DIR__ . '/../libraries/Mailjet.Api.class.php');
include_once(__DIR__ . '/../libraries/Mailjet.Overlay.class.php');

class MailjetTemplate
{
Expand Down Expand Up @@ -125,8 +125,8 @@ public static function getDataApi()
*/
public function initIframeLink()
{
$file = dirname(__FILE__) . '/../xml/iframes.xml';
if (file_exists($file) && ($xml = simplexml_load_file($file))) {
$file = __DIR__ . '/../xml/iframes.xml';
if (file_exists($file) && ($xml = simplexml_load_string(file_get_contents($file)))) {
foreach ($xml->iframe as $iframe) {
$this->iframes_url[(string) $iframe['name']] = (string) str_replace('{lang}', $this->lang, $iframe);
}
Expand All @@ -144,7 +144,7 @@ public function initIframeLink()
public function fetchTemplate($name)
{
if (isset($this->templates[$name])) {
$file = dirname(__FILE__) . '/../translations/templates/' . $this->lang . '/' . $name . '.txt';
$file = __DIR__ . '/../translations/templates/' . $this->lang . '/' . $name . '.txt';
if (file_exists($file)) {
$template = Tools::file_get_contents($file);
$this->templates[$name]['html'] = $template;
Expand Down Expand Up @@ -173,21 +173,16 @@ public function getSignupURL($name = 'SETUP_STEP_1')

public function getCampaignURL($name = 'CAMPAIGN', $token = null)
{
// $ps_shop_domain = Context::getContext()->shop->getBaseUrl(true, true);
// $cb = urlencode($ps_shop_domain . 'modules/mailjet/callback_campaign.php');

// Let cb parameter in official version
$url = $this->mjWebsite . '/campaigns?t=' . $token . '&r=Prestashop-3.0&show_menu=none&sp=display&f=am&locale=' . $this->locale;

// Remove cb parameter while fix issue
// $url = $this->mjWebsite . '/campaigns?t=' . $token . '&r=Prestashop-3.0&show_menu=none&sp=display&locale=' . $this->locale;
$this->iframes_url[$name] = $url;
}

public function getPricingURL($name = 'PRICING', $token = null)
{
// $ps_shop_domain = Context::getContext()->shop->getBaseUrl(true, true);
// $cb = urlencode($ps_shop_domain . '/modules/mailjet/callback_campaign.php');
if ($token) {
$url = $this->mjWebsite .
'/reseller/pricing?t=' . $token . '&r=Prestashop-3.0&show_menu=none&sp=display&locale=' .
Expand All @@ -202,8 +197,6 @@ public function getPricingURL($name = 'PRICING', $token = null)

public function getStatsURL($name = 'STATS', $token = null)
{
// $ps_shop_domain = Context::getContext()->shop->getBaseUrl(true, true);
// $cb = urlencode($ps_shop_domain . '/modules/mailjet/callback_campaign.php');
$url = $this->mjWebsite .
'/stats?t=' . $token . '&r=Prestashop-3.0&show_menu=none&f=am&locale=' .
$this->locale;
Expand All @@ -212,8 +205,6 @@ public function getStatsURL($name = 'STATS', $token = null)

public function getContactsURL($name = 'CONTACTS', $token = null)
{
// $ps_shop_domain = Context::getContext()->shop->getBaseUrl(true, true);
// $cb = urlencode($ps_shop_domain . '/modules/mailjet/callback_campaign.php');
$url = $this->mjWebsite .
'/contacts?t=' . $token . '&r=Prestashop-3.0&show_menu=none&sp=display&f=am&locale=' .
$this->locale;
Expand Down
2 changes: 1 addition & 1 deletion classes/MailJetTranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function getTranslationsByName($name, $iso = false)
$translations = array();
$default_translation = array();

if (file_exists($file) && ($xml = simplexml_load_file($file))) {
if (file_exists($file) && ($xml = simplexml_load_string(file_get_contents($file)))) {
$iso = ($iso) ? $iso : Context::getContext()->language->iso_code;

if (isset($xml->{$name})) {
Expand Down