Skip to content

Commit 9c83cfd

Browse files
author
Leonid Vakulenko
committed
Webasyst Framework v.3.7.0
* See full changelog here: https://developers.webasyst.com/updates/ https://developers.webasyst.ru/updates/
1 parent 65ff0ed commit 9c83cfd

File tree

111 files changed

+1901
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1901
-211
lines changed

wa-apps/installer/lib/actions/plugins/installerPluginsEnable.controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function execute()
1212
$result = installerHelper::pluginSetStatus($app_id, waRequest::post('plugin_id'), true);
1313
$this->response['message'] = _w('Cache cleared');
1414
if ($result !== true) {
15-
$this->response['message'] .= "<br>"._w('But with errors:')."<br>".implode("<br>", $result);
15+
$this->response['message'] .= "<br>"._w('But with errors:')."<br>".implode("<br>", (array)$result);
1616
}
1717

1818
/**

wa-apps/installer/lib/classes/installerAnnouncementList.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class installerAnnouncementList
2020
*/
2121
const PLACE_PROMOTION = 'promotion';
2222

23+
const PLACE_FRONT = 'front';
24+
2325
public function withFilteredByApp($app_id)
2426
{
2527
if ($app_id) {
@@ -87,12 +89,19 @@ public function getNotificationList()
8789
return isset($list[self::PLACE_NOTIFICATION]) ? $list[self::PLACE_NOTIFICATION] : [];
8890
}
8991

92+
public function getFrontList()
93+
{
94+
$list = $this->getList();
95+
return isset($list[self::PLACE_FRONT]) ? $list[self::PLACE_FRONT] : [];
96+
}
97+
9098
private function groupByPlace(array $list = [])
9199
{
92100
$result = [
93101
self::PLACE_HEADER_TOP => [],
94102
self::PLACE_NOTIFICATION => [],
95103
self::PLACE_PROMOTION => [],
104+
self::PLACE_FRONT => [],
96105
];
97106
foreach ($list as $key => $announcement) {
98107
if(empty($announcement['html'])) {

wa-apps/installer/lib/classes/installerHelper.class.php

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,42 @@ public static function checkLicense($slug, $force_renew = false)
416416

417417
try {
418418
$config->loadLicenses();
419+
$cache = new waVarExportCache('licenses', installerConfig::LICENSE_CACHE_TTL, 'installer');
420+
$cache_data = $cache->get();
419421
} catch (Exception $e) {
422+
// Get the last successfully saved licenses data
423+
$app_settings_model = new waAppSettingsModel();
424+
$cache_data = json_decode($app_settings_model->get('installer', 'licenses_data', '{}'), true);
425+
$now_ts = time();
426+
if (!empty($cache_data['timestamp']) && $cache_data['timestamp'] > $now_ts) {
427+
// License data is in the future, so it can't be valid
428+
$cache_data = null;
429+
}
430+
if (!empty($cache_data['timestamp'])) {
431+
// Check the fall counter
432+
$fall_counter = json_decode($app_settings_model->get('installer', 'licenses_fall_counter', '{}'), true);
433+
if (ifset($fall_counter, 'timestamp', 0) < $cache_data['timestamp']) {
434+
// Reset old fall counter
435+
$fall_counter = [];
436+
}
437+
if (ifset($fall_counter, 'count', 0) < installerConfig::LICENSE_FALL_LIMIT
438+
|| $now_ts - $cache_data['timestamp'] < installerConfig::LICENSE_LONG_CACHE_TTL
439+
) {
440+
// Count the fall
441+
$app_settings_model->set('installer', 'licenses_fall_counter', json_encode([
442+
'count' => ifset($fall_counter, 'count', 0) + 1,
443+
'timestamp' => $now_ts,
444+
]));
445+
} else {
446+
// Exceeded the falls limit
447+
$cache_data = null;
448+
}
449+
}
420450
}
421-
$cache = new waVarExportCache('licenses', installerConfig::LICENSE_CACHE_TTL, 'installer');
422-
423-
$cache_data = $cache->get();
424451
}
452+
425453
$license = [
426-
'status' => false,
454+
'status' => empty($cache_data['data']),
427455
'ts' => isset($cache_data['timestamp']) ? $cache_data['timestamp'] : time()
428456
];
429457
if (isset($cache_data['data']['baza'][$slug])) {

wa-apps/installer/lib/classes/installerServicesApi.class.php

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ class installerServicesApi extends waWebasystIDApi
88
const SMS_SERVICE = 'SMS';
99
const CRON_SERVICE = 'CRON';
1010

11+
private static $is_connected = null;
12+
private static $is_valid_connection = null;
13+
private static $system_token = null;
14+
private static $user_token = null;
15+
1116
public function __construct(array $options = [])
1217
{
1318
$config = new waServicesApiUrlConfig();
@@ -18,12 +23,27 @@ public function __construct(array $options = [])
1823

1924
public function isConnected()
2025
{
21-
static $result = null;
22-
if ($result === null) {
23-
$cm = new waWebasystIDClientManager();
24-
$result = !!$cm->isConnected();
26+
if (self::$is_connected !== null) return self::$is_connected;
27+
28+
$cm = new waWebasystIDClientManager();
29+
self::$is_connected = !!$cm->isConnected();
30+
if (self::$is_connected) {
31+
try {
32+
$this->getToken(false);
33+
} catch (waWebasystIDApiAuthException $e) {
34+
self::$is_connected = false;
35+
self::$is_valid_connection = false;
36+
}
2537
}
26-
return $result;
38+
39+
return self::$is_connected;
40+
}
41+
42+
public function isBrokenConnection()
43+
{
44+
if ($this->isConnected()) return false;
45+
if (self::$is_valid_connection === false) return true;
46+
return false;
2747
}
2848

2949
public function billingCall($api_method, array $params = [], $http_method = waNet::METHOD_GET, array $net_options = [])
@@ -305,28 +325,30 @@ public function sendWebsocketMessage(array $message, $channel_id, $app_id = null
305325

306326
public function getSystemToken($force_refresh = false)
307327
{
308-
static $token = null;
309-
if ($token === null || $force_refresh) {
310-
$token = (new waWebasystIDClientManager)->getSystemAccessToken($force_refresh);
328+
if (self::$system_token === null || $force_refresh) {
329+
self::$system_token = (new waWebasystIDClientManager)->getSystemAccessToken($force_refresh);
311330
}
312-
return $token;
331+
return self::$system_token;
313332
}
314333

315334
public function getUserToken($force_refresh = false)
316335
{
317-
$token_params = wa()->getUser()->getWebasystTokenParams();
318-
if (empty($token_params)) {
319-
return null;
320-
}
321-
if ($force_refresh) {
322-
$ok = $this->refreshedTokenParams($token_params, wa()->getUser()->getId());
323-
} else {
324-
$ok = $this->refreshTokenWhenExpired($token_params, wa()->getUser()->getId());
325-
}
326-
if (!$ok) {
327-
return null;
336+
if (self::$user_token === null || $force_refresh) {
337+
$token_params = wa()->getUser()->getWebasystTokenParams();
338+
if (empty($token_params)) {
339+
return null;
340+
}
341+
if ($force_refresh) {
342+
$ok = $this->refreshedTokenParams($token_params, wa()->getUser()->getId());
343+
} else {
344+
$ok = $this->refreshTokenWhenExpired($token_params, wa()->getUser()->getId());
345+
}
346+
if (!$ok) {
347+
return null;
348+
}
349+
self::$user_token = $token_params['access_token'];
328350
}
329-
return $token_params['access_token'];
351+
return self::$user_token;
330352
}
331353

332354
private function getToken($use_system_token, $force_refresh = false)

wa-apps/installer/lib/config/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
'description' => 'Install new apps from the Webasyst Store',
55
'icon' => 'img/installer.svg',
66
'mobile' => false,
7-
'version' => '3.6.0',
8-
'critical' => '3.6.0',
7+
'version' => '3.7.0',
8+
'critical' => '3.7.0',
99
'system' => true,
1010
'vendor' => 'webasyst',
1111
'csrf' => true,

wa-apps/installer/lib/config/installerConfig.class.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class installerConfig extends waAppConfig
1616
{
1717
const ANNOUNCE_CACHE_TTL = 3600; // sec
1818
const LICENSE_CACHE_TTL = 3600; // 1 hour
19+
const LICENSE_LONG_CACHE_TTL = 86400; // 1 day
20+
const LICENSE_FALL_LIMIT = 3;
1921

2022
const INIT_DATA_CACHE_TTL = 10800; // 3 hours
2123
const INIT_DATA_CACHE_TTL_DEBUG = 900; // 15 mins
@@ -398,7 +400,8 @@ public function loadLicenses()
398400
if ($previous_hash = $wa_installer->getGenericConfig('previous_hash')) {
399401
$init_url_params['previous_hash'] = $previous_hash;
400402
}
401-
$token_data = (new waAppSettingsModel())->get('installer', 'token_data', false);
403+
$app_settings_model = new waAppSettingsModel();
404+
$token_data = $app_settings_model->get('installer', 'token_data', false);
402405
if ($token_data) {
403406
$token_data = waUtils::jsonDecode($token_data, true);
404407
$init_url_params['token'] = ifset($token_data, 'token', null);
@@ -409,10 +412,12 @@ public function loadLicenses()
409412
$res = $net->query($init_url);
410413

411414
if (!empty($res['data'])) {
412-
$cache->set([
415+
$data = [
413416
'data' => $res['data'],
414417
'timestamp' => time()
415-
]);
418+
];
419+
$cache->set($data);
420+
$app_settings_model->set('installer', 'licenses_data', json_encode($data));
416421
}
417422

418423
return $res;

wa-apps/installer/templates/actions/services/Services.html

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,32 @@ <h1>[s`Webasyst Services`]</h1>
1313
{/foreach}
1414
{else}
1515

16-
<div class="flexbox space-24 wrap-mobile full-width">
17-
<figure class="card" style="width: 400px;">
16+
<figure class="card custom-mb-24" style="container-type: inline-size;">
17+
<div class="details width-70">
18+
<h4 class="custom-mb-8">
19+
[s`Webasyst AI`]
20+
</h4>
21+
<p class="small gray custom-mt-8 cust1om-mb-8">
22+
[s`Transactional AI service for promo text generation, spell check, and other kinds of text job handled by Webasyst apps.`]
23+
<a href="[s`https://www.webasyst.com/ai/`]" target="_blank" class="nowrap text-blue"><u>[s`How AI works`]</u> <i class="fas fa-external-link-alt fa-xs opacity-70"></i></a>
24+
</p>
25+
</div>
26+
<div class="details width-70">
27+
{$ai_params = webasystHelper::getAiParams()}
28+
29+
<p class="small">
30+
<span>{sprintf_wp('Remaining Webasyst AI prompts: %s', '<strong>'|cat:$ai_params.remaining_count|cat:'</strong>')}</span>
31+
</p>
32+
33+
<p class="custom-mt-8 custom-mb-4">
34+
<a href="javascript:void(0)" data-service="AI" class="button green small js-balance-button">[s`Add credit`]</a>
35+
</p>
36+
</div>
37+
<span class="icon webasyst-magic-wand-ai" style="font-size:clamp(4rem, 12cqw, 7rem);position:absolute;top:0;right:7cqw;bottom:0;margin:auto;"></span>
38+
</figure>
39+
40+
<div class="flexbox space-24 wrap-mobile fixed full-width">
41+
<figure class="card">
1842
<div class="details">
1943
<h4 class="custom-mb-8">
2044
<i class="fas fa-at text-light-gray"></i>
@@ -70,7 +94,7 @@ <h4 class="custom-mb-8">
7094
</div>
7195
</figure>
7296

73-
<figure class="card" style="width: 400px;">
97+
<figure class="card">
7498
<div class="details">
7599
<h4 class="custom-mb-8">
76100
<i class="fas fa-sms text-light-gray"></i>

wa-apps/installer/templates/layouts/BackendStoreSidebar.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@
2121
{$_href = ($_type == 'SERVICES') ? "`$wa_app_url``$_data_href`" : "`$wa_app_url`store`$_sidebar_item.TOP.base_url|escape`"}
2222

2323
<a href="{$_href}" data-href="{$_data_href}" data-type-link="{$_sidebar_item@key}" class="{if $_type != 'SERVICES'}js-installer-toggle-link{/if}{if $store_sidebar_type == $_type} selected{/if}">
24-
<span class="icon"><i class="{$_brick_icons[$_type]}"></i></span>
24+
<span class="icon">
25+
{if $_type == 'SERVICES'}
26+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
27+
<path fill="currentColor" d="M8.326 7.703a.912.912 0 0 0-1.272-.018L.47 13.82a1.233 1.233 0 1 0 1.74 1.742l6.134-6.584a.913.913 0 0 0-.017-1.274ZM2.55 3.992a.126.126 0 0 1 .242 0l.457 1.614a.44.44 0 0 0 .303.304l1.615.456c.122.035.122.208 0 .242l-1.615.457a.44.44 0 0 0-.303.304l-.457 1.614a.126.126 0 0 1-.242 0l-.457-1.614a.44.44 0 0 0-.303-.304L.175 6.608c-.122-.034-.122-.207 0-.242L1.79 5.91a.44.44 0 0 0 .303-.304l.457-1.614ZM5 .122c.027-.092.16-.092.187 0l.351 1.217c.032.11.12.197.234.229l1.241.344a.094.094 0 0 1 0 .183l-1.241.344a.335.335 0 0 0-.234.229l-.351 1.217c-.027.092-.16.092-.186 0l-.352-1.217a.335.335 0 0 0-.233-.229l-1.242-.344a.094.094 0 0 1 0-.183l1.242-.344a.335.335 0 0 0 .233-.229L5.001.122ZM8.732 11.85c.026-.092.156-.092.182 0l.345 1.217c.031.11.118.197.229.229l1.217.344c.091.026.091.157 0 .183l-1.217.344a.332.332 0 0 0-.23.229l-.344 1.217c-.026.092-.156.092-.182 0l-.344-1.217a.332.332 0 0 0-.23-.229l-1.216-.344c-.092-.026-.092-.157 0-.183l1.217-.344a.332.332 0 0 0 .229-.229l.344-1.217Zm4.616-2.688c.033-.116.198-.116.231 0l.436 1.54c.04.14.15.25.29.29l1.54.435c.115.033.115.198 0 .23l-1.54.437a.42.42 0 0 0-.29.29l-.436 1.539c-.033.116-.198.116-.23 0l-.437-1.54a.42.42 0 0 0-.289-.29l-1.54-.435c-.116-.033-.116-.198 0-.231l1.54-.436a.42.42 0 0 0 .29-.29l.435-1.539ZM10.729.229c.066-.234.398-.234.465 0l.878 3.102c.08.282.3.503.583.583l3.102.878c.234.066.234.398 0 .465l-3.102.878a.845.845 0 0 0-.583.583l-.878 3.102c-.067.234-.399.234-.465 0L9.85 6.718a.845.845 0 0 0-.583-.583l-3.102-.878c-.234-.067-.234-.399 0-.465l3.102-.878c.282-.08.503-.3.583-.583l.878-3.102Z"></path>
28+
</svg>
29+
{else}
30+
<i class="{$_brick_icons[$_type]}"></i>
31+
{/if}
32+
</span>
2533
{$_sidebar_item.name}
2634
</a>
2735
{/foreach}

wa-content/css/dashboard/dashboard.css

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,8 @@
10141014
@media screen and (min-width: 1120px) {
10151015
#wa-app .content .wa-dashboard-page #wa_announcement,
10161016
#wa-app .content #dashboard-wrapper #wa_announcement,
1017-
#wa-app .content .wa-dashboard-page #wa_apps,
1018-
#wa-app .content #dashboard-wrapper #wa_apps,
1017+
#wa-app .content .wa-dashboard-page #wa_apps:not(:has(> .wa-onboarding-overlay-text)),
1018+
#wa-app .content #dashboard-wrapper #wa_apps:not(:has(> .wa-onboarding-overlay-text)),
10191019
#wa-app .content .wa-dashboard-page #wa_activity,
10201020
#wa-app .content #dashboard-wrapper #wa_activity {
10211021
background-color: var(--background-color-blank);
@@ -1918,6 +1918,40 @@
19181918
padding-right: 1.75rem;
19191919
}
19201920
}
1921+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.nobutton {
1922+
color: var(--text-color-input);
1923+
}
1924+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button {
1925+
transition: background-color 0.3s ease, color 0.3s ease, width 0.3s ease, max-width 0.3s ease, min-width 0.3s ease;
1926+
}
1927+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button .icon-loading,
1928+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button .icon-success,
1929+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button .icon-error {
1930+
display: none;
1931+
color: var(--white);
1932+
}
1933+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-submit {
1934+
height: 35px;
1935+
padding: 0;
1936+
}
1937+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-submit .text {
1938+
display: none;
1939+
}
1940+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-submit:not(.is-success):not(.is-error) .icon-loading {
1941+
display: inline-block;
1942+
}
1943+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-success {
1944+
background: var(--green);
1945+
}
1946+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-success .icon-success {
1947+
display: inline-block;
1948+
}
1949+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-error {
1950+
background: var(--red);
1951+
}
1952+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-error .icon-error {
1953+
display: inline-block;
1954+
}
19211955
#wa_announcement .wa-announcement-wrapper > .wa-announcement-list-wrapper {
19221956
padding-left: 28px;
19231957
padding-right: 28px;

wa-content/css/dashboard/mobile.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,40 @@
1717
padding-right: 1.75rem;
1818
}
1919
}
20+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.nobutton {
21+
color: var(--text-color-input);
22+
}
23+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button {
24+
transition: background-color 0.3s ease, color 0.3s ease, width 0.3s ease, max-width 0.3s ease, min-width 0.3s ease;
25+
}
26+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button .icon-loading,
27+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button .icon-success,
28+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button .icon-error {
29+
display: none;
30+
color: var(--white);
31+
}
32+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-submit {
33+
height: 35px;
34+
padding: 0;
35+
}
36+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-submit .text {
37+
display: none;
38+
}
39+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-submit:not(.is-success):not(.is-error) .icon-loading {
40+
display: inline-block;
41+
}
42+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-success {
43+
background: var(--green);
44+
}
45+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-success .icon-success {
46+
display: inline-block;
47+
}
48+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-error {
49+
background: var(--red);
50+
}
51+
#wa_announcement .wa-announcement-wrapper > .wa-announcement-form .button.ai-button.is-error .icon-error {
52+
display: inline-block;
53+
}
2054
#wa_announcement .wa-announcement-wrapper > .wa-announcement-list-wrapper {
2155
padding-left: 28px;
2256
padding-right: 28px;

0 commit comments

Comments
 (0)