diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df4e7314997026d0e8ba577b3c49b014ade8bfeb..3c31ba5c8016b69d7b34f522a7e3227b737a3ce4 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ services: - - postgres:latest + - postgres:9.4 variables: POSTGRES_DB: "MaarchCourrier" @@ -11,19 +11,21 @@ stages: before_script: - apt-get update > /dev/null - - apt-get install apt-utils -yqq > /dev/null + - mkdir -p /usr/share/man/man1 + - mkdir -p /usr/share/man/man7 + #- apt-get install apt-utils -yqq > /dev/null - apt-get install cron -yqq > /dev/null - - apt-get install tar -yqq > /dev/null - - apt-get install wkhtmltopdf -yqq > /dev/null - - apt-get install wget -yqq > /dev/null - - wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz - - tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz - - mv wkhtmltox/bin/wkhtmlto* /usr/bin - - chmod +x /usr/bin/wkhtmlto* + #- apt-get install tar -yqq > /dev/null + #- apt-get install wkhtmltopdf -yqq > /dev/null + #- apt-get install wget -yqq > /dev/null + #- wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz + #- tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz + #- mv wkhtmltox/bin/wkhtmlto* /usr/bin + #- chmod +x /usr/bin/wkhtmlto* #- apt-get install libreoffice -yqq > /dev/null - - apt-get install xpdf-utils -yqq > /dev/null - - apt-get install imagemagick -yqq > /dev/null - - apt-get install npm -yqq > /dev/null + #- apt-get install xpdf-utils -yqq > /dev/null + #- apt-get install imagemagick -yqq > /dev/null + #- apt-get install npm -yqq > /dev/null - apt-get install git -yqq > /dev/null - bash ci/docker_install_php.sh > /dev/null - bash ci/docker_install_database.sh > /dev/null @@ -41,11 +43,11 @@ job_php-7.1: - cp -R /builds/maarch/MaarchCourrier/ /var/www/html/ - cd /var/www/html/MaarchCourrier - mkdir -p /var/www/html/MaarchCourrier - - curl -sL https://deb.nodesource.com/setup_7.x | bash - - - apt-get install -yqq nodejs - - npm install npm@latest -g - - npm set registry https://registry.npmjs.org/ - - npm install + #- curl -sL https://deb.nodesource.com/setup_7.x | bash - + #- apt-get install -yqq nodejs + #- npm install npm@latest -g + #- npm set registry https://registry.npmjs.org/ + #- npm install - sed 's/<databaseserver>.*<\/databaseserver>/<databaseserver>postgres<\/databaseserver>/;s/<databasepassword>.*<\/databasepassword>/<databasepassword><\/databasepassword>/;s/<databasename>.*<\/databasename>/<databasename>MaarchCourrier<\/databasename>/;s/<databaseuser>.*<\/databaseuser>/<databaseuser>maarch<\/databaseuser>/' apps/maarch_entreprise/xml/config.xml.default > apps/maarch_entreprise/xml/config.xml - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar - chmod +x /usr/local/bin/phpunit @@ -67,11 +69,11 @@ job_php-7.0: - cp -R /builds/maarch/MaarchCourrier/ /var/www/html/ - cd /var/www/html/MaarchCourrier - mkdir -p /var/www/html/MaarchCourrier - - curl -sL https://deb.nodesource.com/setup_7.x | bash - - - apt-get install -yqq nodejs - - npm install npm@latest -g - - npm set registry https://registry.npmjs.org/ - - npm install + #- curl -sL https://deb.nodesource.com/setup_7.x | bash - + #- apt-get install -yqq nodejs + #- npm install npm@latest -g + #- npm set registry https://registry.npmjs.org/ + #- npm install - sed 's/<databaseserver>.*<\/databaseserver>/<databaseserver>postgres<\/databaseserver>/;s/<databasepassword>.*<\/databasepassword>/<databasepassword><\/databasepassword>/;s/<databasename>.*<\/databasename>/<databasename>MaarchCourrier<\/databasename>/;s/<databaseuser>.*<\/databaseuser>/<databaseuser>maarch<\/databaseuser>/' apps/maarch_entreprise/xml/config.xml.default > apps/maarch_entreprise/xml/config.xml - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-6.phar - chmod +x /usr/local/bin/phpunit @@ -80,3 +82,4 @@ job_php-7.0: only: - develop + diff --git a/ci/docker_install_php.sh b/ci/docker_install_php.sh index 1d8b2a6b971897611310a5c99ec311bc21ed2f77..9acacbe21278c231bd19f0eba7db7aede312d941 100755 --- a/ci/docker_install_php.sh +++ b/ci/docker_install_php.sh @@ -7,8 +7,9 @@ set -xe apt-get install -y libpq-dev libxml2-dev libxslt1-dev \ && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ -&& docker-php-ext-install pdo_pgsql pgsql xsl zip \ +&& docker-php-ext-install pdo_pgsql pgsql xsl \ && pecl install xdebug \ && docker-php-ext-enable xdebug +#&& docker-php-ext-install pdo_pgsql pgsql xsl zip \ diff --git a/src/app/basket/controllers/BasketController.php b/src/app/basket/controllers/BasketController.php index b15034c7124bb94683f845017d211bb8e7a01a7b..b6757b7b9e46baea7384ac2e1bf77ae54ac393c1 100644 --- a/src/app/basket/controllers/BasketController.php +++ b/src/app/basket/controllers/BasketController.php @@ -70,7 +70,7 @@ class BasketController $existingBasket = BasketModel::getById(['id' => $data['id'], 'select' => ['1']]); if (!empty($existingBasket)) { - return $response->withStatus(400)->withJson(['errors' => _ID.' '._ALREADY_EXISTS]); + return $response->withStatus(400)->withJson(['errors' => _ID. ' ' . _ALREADY_EXISTS]); } if (!PreparedClauseController::isRequestValid(['clause' => $data['clause'], 'userId' => $GLOBALS['userId']])) { @@ -83,11 +83,11 @@ class BasketController BasketModel::create($data); HistoryController::add([ 'tableName' => 'baskets', - 'recordId' => $data['id'], + 'recordId' => $data['id'], 'eventType' => 'ADD', - 'info' => _BASKET_CREATION." : {$data['id']}", - 'moduleId' => 'basket', - 'eventId' => 'basketCreation', + 'info' => _BASKET_CREATION . " : {$data['id']}", + 'moduleId' => 'basket', + 'eventId' => 'basketCreation', ]); return $response->withJson(['basket' => $data['id']]); @@ -125,11 +125,11 @@ class BasketController BasketModel::update($data); HistoryController::add([ 'tableName' => 'baskets', - 'recordId' => $aArgs['id'], + 'recordId' => $aArgs['id'], 'eventType' => 'UP', - 'info' => _BASKET_MODIFICATION." : {$aArgs['id']}", - 'moduleId' => 'basket', - 'eventId' => 'basketModification', + 'info' => _BASKET_MODIFICATION . " : {$aArgs['id']}", + 'moduleId' => 'basket', + 'eventId' => 'basketModification', ]); return $response->withJson(['success' => 'success']); @@ -149,11 +149,11 @@ class BasketController BasketModel::delete(['id' => $aArgs['id']]); HistoryController::add([ 'tableName' => 'baskets', - 'recordId' => $aArgs['id'], + 'recordId' => $aArgs['id'], 'eventType' => 'DEL', - 'info' => _BASKET_SUPPRESSION." : {$aArgs['id']}", - 'moduleId' => 'basket', - 'eventId' => 'basketSuppression', + 'info' => _BASKET_SUPPRESSION . " : {$aArgs['id']}", + 'moduleId' => 'basket', + 'eventId' => 'basketSuppression', ]); return $response->withJson(['baskets' => BasketModel::get()]); @@ -166,10 +166,10 @@ class BasketController } $baskets = BasketModel::get([ - 'select' => ['basket_id', 'basket_name', 'basket_desc', 'basket_order'], - 'where' => ['is_visible = ?'], - 'data' => ['Y'], - 'orderBy' => ['basket_order'], + 'select' => ['basket_id', 'basket_name', 'basket_desc', 'basket_order'], + 'where' => ['is_visible = ?'], + 'data' => ['Y'], + 'orderBy' => ['basket_order'] ]); return $response->withJson(['baskets' => $baskets]); @@ -191,18 +191,18 @@ class BasketController HistoryController::add([ 'tableName' => 'baskets', - 'recordId' => $aArgs['id'], + 'recordId' => $aArgs['id'], 'eventType' => 'UP', - 'info' => _BASKETS_SORT_MODIFICATION, - 'moduleId' => 'basket', - 'eventId' => 'basketModification', + 'info' => _BASKETS_SORT_MODIFICATION, + 'moduleId' => 'basket', + 'eventId' => 'basketModification', ]); $baskets = BasketModel::get([ - 'select' => ['basket_id', 'basket_name', 'basket_desc', 'basket_order'], - 'where' => ['is_visible = ?'], - 'data' => ['Y'], - 'orderBy' => ['basket_order'], + 'select' => ['basket_id', 'basket_name', 'basket_desc', 'basket_order'], + 'where' => ['is_visible = ?'], + 'data' => ['Y'], + 'orderBy' => ['basket_order'] ]); return $response->withJson(['baskets' => $baskets]); @@ -232,9 +232,9 @@ class BasketController } $actionsForGroup = $allActions; $actions = BasketModel::getActionsForGroupById([ - 'id' => $aArgs['id'], - 'groupId' => $group['group_id'], - 'select' => ['id_action', 'where_clause', 'used_in_basketlist', 'used_in_action_page', 'default_action_list'], + 'id' => $aArgs['id'], + 'groupId' => $group['group_id'], + 'select' => ['id_action', 'where_clause', 'used_in_basketlist', 'used_in_action_page', 'default_action_list'] ]); $actionIds = []; foreach ($actions as $action) { @@ -244,14 +244,14 @@ class BasketController $redirects = []; if (!empty($actionIds)) { $statuses = BasketModel::getGroupActionStatus([ - 'select' => ['status_id', 'action_id'], - 'where' => ['basket_id = ?', 'group_id = ?', 'action_id in (?)'], - 'data' => [$aArgs['id'], $group['group_id'], $actionIds], + 'select' => ['status_id', 'action_id'], + 'where' => ['basket_id = ?', 'group_id = ?', 'action_id in (?)'], + 'data' => [$aArgs['id'], $group['group_id'], $actionIds] ]); $redirects = BasketModel::getGroupActionRedirect([ - 'select' => ['entity_id', 'action_id', 'keyword', 'redirect_mode'], - 'where' => ['basket_id = ?', 'group_id = ?', 'action_id in (?)'], - 'data' => [$aArgs['id'], $group['group_id'], $actionIds], + 'select' => ['entity_id', 'action_id', 'keyword', 'redirect_mode'], + 'where' => ['basket_id = ?', 'group_id = ?', 'action_id in (?)'], + 'data' => [$aArgs['id'], $group['group_id'], $actionIds] ]); } foreach ($actions as $actionKey => $action) { @@ -318,7 +318,7 @@ class BasketController if (!$check) { return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); } - $data['groupActions'] = self::checkGroupActions(['groupActions' => $data['groupActions'], 'userId' => $GLOBALS['userId']]); + $data['groupActions'] = BasketController::checkGroupActions(['groupActions' => $data['groupActions'], 'userId' => $GLOBALS['userId']]); if (!empty($data['groupActions']['errors'])) { return $response->withStatus(400)->withJson(['errors' => $data['groupActions']['errors']]); } @@ -331,34 +331,34 @@ class BasketController foreach ($data['groupActions'] as $groupAction) { if ($groupAction['checked']) { BasketModel::createGroupAction([ - 'id' => $aArgs['id'], - 'groupId' => $data['group_id'], - 'actionId' => $groupAction['id'], - 'whereClause' => $groupAction['where_clause'], - 'usedInBasketlist' => $groupAction['used_in_basketlist'], - 'usedInActionPage' => $groupAction['used_in_action_page'], - 'defaultActionList' => $groupAction['default_action_list'], + 'id' => $aArgs['id'], + 'groupId' => $data['group_id'], + 'actionId' => $groupAction['id'], + 'whereClause' => $groupAction['where_clause'], + 'usedInBasketlist' => $groupAction['used_in_basketlist'], + 'usedInActionPage' => $groupAction['used_in_action_page'], + 'defaultActionList' => $groupAction['default_action_list'] ]); if (!empty($groupAction['statuses'])) { foreach ($groupAction['statuses'] as $status) { BasketModel::createGroupActionStatus([ - 'id' => $aArgs['id'], - 'groupId' => $data['group_id'], - 'actionId' => $groupAction['id'], - 'statusId' => $status, + 'id' => $aArgs['id'], + 'groupId' => $data['group_id'], + 'actionId' => $groupAction['id'], + 'statusId' => $status ]); } } if (!empty($groupAction['redirects'])) { foreach ($groupAction['redirects'] as $redirect) { BasketModel::createGroupActionRedirect([ - 'id' => $aArgs['id'], - 'groupId' => $data['group_id'], - 'actionId' => $groupAction['id'], - 'entityId' => $redirect['entity_id'], - 'keyword' => $redirect['keyword'], - 'redirectMode' => $redirect['redirect_mode'], + 'id' => $aArgs['id'], + 'groupId' => $data['group_id'], + 'actionId' => $groupAction['id'], + 'entityId' => $redirect['entity_id'], + 'keyword' => $redirect['keyword'], + 'redirectMode' => $redirect['redirect_mode'] ]); } } @@ -369,20 +369,20 @@ class BasketController $group = GroupModel::getByGroupId(['select' => ['id'], 'groupId' => $data['group_id']]); foreach ($users as $user) { UserBasketPreferenceModel::create([ - 'userSerialId' => $user['id'], + 'userSerialId' => $user['id'], 'groupSerialId' => $group['id'], - 'basketId' => $aArgs['id'], - 'display' => 'true', + 'basketId' => $aArgs['id'], + 'display' => 'true', ]); } HistoryController::add([ 'tableName' => 'baskets', - 'recordId' => $aArgs['id'], + 'recordId' => $aArgs['id'], 'eventType' => 'UP', - 'info' => _BASKET_GROUP_CREATION." : {$aArgs['id']}", - 'moduleId' => 'basket', - 'eventId' => 'basketModification', + 'info' => _BASKET_GROUP_CREATION . " : {$aArgs['id']}", + 'moduleId' => 'basket', + 'eventId' => 'basketModification', ]); return $response->withJson(['success' => 'success']); @@ -406,7 +406,7 @@ class BasketController if (!$check) { return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); } - $data['groupActions'] = self::checkGroupActions(['groupActions' => $data['groupActions'], 'userId' => $GLOBALS['userId']]); + $data['groupActions'] = BasketController::checkGroupActions(['groupActions' => $data['groupActions'], 'userId' => $GLOBALS['userId']]); if (!empty($data['groupActions']['errors'])) { return $response->withStatus(400)->withJson(['errors' => $data['groupActions']['errors']]); } @@ -415,40 +415,40 @@ class BasketController return $response->withStatus(400)->withJson(['errors' => 'Group does not exist for this basket']); } - GroupBasketModel::deleteGroupBasketWithoutUserPref(['basketId' => $aArgs['id'], 'groupId' => $aArgs['groupId']]); + GroupBasketModel::deleteGroupBasket(['basketId' => $aArgs['id'], 'groupId' => $aArgs['groupId'], 'preferences' => false]); GroupBasketModel::createGroupBasket(['basketId' => $aArgs['id'], 'groupId' => $aArgs['groupId'], 'resultPage' => $data['result_page']]); foreach ($data['groupActions'] as $groupAction) { if ($groupAction['checked']) { BasketModel::createGroupAction([ - 'id' => $aArgs['id'], - 'groupId' => $aArgs['groupId'], - 'actionId' => $groupAction['id'], - 'whereClause' => $groupAction['where_clause'], - 'usedInBasketlist' => $groupAction['used_in_basketlist'], - 'usedInActionPage' => $groupAction['used_in_action_page'], - 'defaultActionList' => $groupAction['default_action_list'], + 'id' => $aArgs['id'], + 'groupId' => $aArgs['groupId'], + 'actionId' => $groupAction['id'], + 'whereClause' => $groupAction['where_clause'], + 'usedInBasketlist' => $groupAction['used_in_basketlist'], + 'usedInActionPage' => $groupAction['used_in_action_page'], + 'defaultActionList' => $groupAction['default_action_list'] ]); if (!empty($groupAction['statuses'])) { foreach ($groupAction['statuses'] as $status) { BasketModel::createGroupActionStatus([ - 'id' => $aArgs['id'], - 'groupId' => $aArgs['groupId'], - 'actionId' => $groupAction['id'], - 'statusId' => $status, + 'id' => $aArgs['id'], + 'groupId' => $aArgs['groupId'], + 'actionId' => $groupAction['id'], + 'statusId' => $status ]); } } if (!empty($groupAction['redirects'])) { foreach ($groupAction['redirects'] as $redirect) { BasketModel::createGroupActionRedirect([ - 'id' => $aArgs['id'], - 'groupId' => $aArgs['groupId'], - 'actionId' => $groupAction['id'], - 'entityId' => $redirect['entity_id'], - 'keyword' => $redirect['keyword'], - 'redirectMode' => $redirect['redirect_mode'], + 'id' => $aArgs['id'], + 'groupId' => $aArgs['groupId'], + 'actionId' => $groupAction['id'], + 'entityId' => $redirect['entity_id'], + 'keyword' => $redirect['keyword'], + 'redirectMode' => $redirect['redirect_mode'] ]); } } @@ -456,11 +456,11 @@ class BasketController } HistoryController::add([ 'tableName' => 'baskets', - 'recordId' => $aArgs['id'], + 'recordId' => $aArgs['id'], 'eventType' => 'UP', - 'info' => _BASKET_GROUP_MODIFICATION." : {$aArgs['id']}", - 'moduleId' => 'basket', - 'eventId' => 'basketModification', + 'info' => _BASKET_GROUP_MODIFICATION . " : {$aArgs['id']}", + 'moduleId' => 'basket', + 'eventId' => 'basketModification', ]); return $response->withJson(['success' => 'success']); @@ -477,14 +477,14 @@ class BasketController return $response->withStatus(400)->withJson(['errors' => 'Basket not found']); } - GroupBasketModel::deleteGroupBasket(['basketId' => $aArgs['id'], 'groupId' => $aArgs['groupId']]); + GroupBasketModel::deleteGroupBasket(['basketId' => $aArgs['id'], 'groupId' => $aArgs['groupId'], 'preferences' => true]); HistoryController::add([ 'tableName' => 'baskets', - 'recordId' => $aArgs['id'], + 'recordId' => $aArgs['id'], 'eventType' => 'UP', - 'info' => _BASKET_GROUP_SUPPRESSION." : {$aArgs['id']}", - 'moduleId' => 'basket', - 'eventId' => 'basketModification', + 'info' => _BASKET_GROUP_SUPPRESSION . " : {$aArgs['id']}", + 'moduleId' => 'basket', + 'eventId' => 'basketModification', ]); return $response->withJson(['success' => 'success']); diff --git a/src/app/basket/models/GroupBasketModelAbstract.php b/src/app/basket/models/GroupBasketModelAbstract.php index 41c72c1876d654489bcb4a403ec061989aa6fd69..4d5e2e0e0a89ce6146c3d9d2c131f9362a861749 100644 --- a/src/app/basket/models/GroupBasketModelAbstract.php +++ b/src/app/basket/models/GroupBasketModelAbstract.php @@ -4,11 +4,11 @@ * Copyright Maarch since 2008 under licence GPLv3. * See LICENCE.txt file at the root folder for more details. * This file is part of Maarch software. + * */ /** * @brief GroupBasket Model Abstract - * * @author dev@maarch.org */ @@ -25,11 +25,11 @@ abstract class GroupBasketModelAbstract ValidatorModel::arrayType($aArgs, ['select', 'where', 'data', 'orderBy']); $aGroupsBaskets = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['groupbasket'], - 'where' => $aArgs['where'], - 'data' => $aArgs['data'], - 'order_by' => $aArgs['orderBy'], + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['groupbasket'], + 'where' => $aArgs['where'], + 'data' => $aArgs['data'], + 'order_by' => $aArgs['orderBy'] ]); return $aGroupsBaskets; @@ -41,12 +41,12 @@ abstract class GroupBasketModelAbstract ValidatorModel::stringType($aArgs, ['basketId', 'groupId', 'resultPage']); DatabaseModel::insert([ - 'table' => 'groupbasket', + 'table' => 'groupbasket', 'columnsValues' => [ - 'basket_id' => $aArgs['basketId'], - 'group_id' => $aArgs['groupId'], - 'result_page' => $aArgs['resultPage'], - ], + 'basket_id' => $aArgs['basketId'], + 'group_id' => $aArgs['groupId'], + 'result_page' => $aArgs['resultPage'] + ] ]); return true; @@ -56,65 +56,38 @@ abstract class GroupBasketModelAbstract { ValidatorModel::notEmpty($aArgs, ['basketId', 'groupId']); ValidatorModel::stringType($aArgs, ['basketId', 'groupId']); + ValidatorModel::boolType($aArgs, ['preferences']); $group = GroupModel::getByGroupId(['select' => ['id'], 'groupId' => $aArgs['groupId']]); DatabaseModel::delete([ 'table' => 'groupbasket', 'where' => ['basket_id = ?', 'group_id = ?'], - 'data' => [$aArgs['basketId'], $aArgs['groupId']], + 'data' => [$aArgs['basketId'], $aArgs['groupId']] ]); DatabaseModel::delete([ 'table' => 'actions_groupbaskets', 'where' => ['basket_id = ?', 'group_id = ?'], - 'data' => [$aArgs['basketId'], $aArgs['groupId']], + 'data' => [$aArgs['basketId'], $aArgs['groupId']] ]); DatabaseModel::delete([ 'table' => 'groupbasket_redirect', 'where' => ['basket_id = ?', 'group_id = ?'], - 'data' => [$aArgs['basketId'], $aArgs['groupId']], + 'data' => [$aArgs['basketId'], $aArgs['groupId']] ]); DatabaseModel::delete([ 'table' => 'groupbasket_status', 'where' => ['basket_id = ?', 'group_id = ?'], - 'data' => [$aArgs['basketId'], $aArgs['groupId']], - ]); - DatabaseModel::delete([ - 'table' => 'users_baskets_preferences', - 'where' => ['basket_id = ?', 'group_serial_id = ?'], - 'data' => [$aArgs['basketId'], $group['id']], + 'data' => [$aArgs['basketId'], $aArgs['groupId']] ]); - return true; - } - - public static function deleteGroupBasketWithoutUserPref(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['basketId', 'groupId']); - ValidatorModel::stringType($aArgs, ['basketId', 'groupId']); - - $group = GroupModel::getByGroupId(['select' => ['id'], 'groupId' => $aArgs['groupId']]); - - DatabaseModel::delete([ - 'table' => 'groupbasket', - 'where' => ['basket_id = ?', 'group_id = ?'], - 'data' => [$aArgs['basketId'], $aArgs['groupId']], - ]); - DatabaseModel::delete([ - 'table' => 'actions_groupbaskets', - 'where' => ['basket_id = ?', 'group_id = ?'], - 'data' => [$aArgs['basketId'], $aArgs['groupId']], - ]); - DatabaseModel::delete([ - 'table' => 'groupbasket_redirect', - 'where' => ['basket_id = ?', 'group_id = ?'], - 'data' => [$aArgs['basketId'], $aArgs['groupId']], - ]); - DatabaseModel::delete([ - 'table' => 'groupbasket_status', - 'where' => ['basket_id = ?', 'group_id = ?'], - 'data' => [$aArgs['basketId'], $aArgs['groupId']], - ]); + if (!empty($aArgs['preferences'])) { + DatabaseModel::delete([ + 'table' => 'users_baskets_preferences', + 'where' => ['basket_id = ?', 'group_serial_id = ?'], + 'data' => [$aArgs['basketId'], $group['id']] + ]); + } return true; }