diff --git a/src/composer.json b/src/composer.json index 0eb7364cb..57270a2c3 100644 --- a/src/composer.json +++ b/src/composer.json @@ -41,7 +41,9 @@ "phpunit/phpunit": "^9.0", "friendsofphp/php-cs-fixer": "^3.8", "symfony/deprecation-contracts": "^3.0.0", - "rector/rector": "^0.15.4" + "rector/rector": "^0.15.4", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.1" }, "suggest": { "ext-gettext": "*", @@ -53,5 +55,10 @@ }, "autoload-dev": { "psr-0": { "": "../tests/library" } + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } } } diff --git a/src/composer.lock b/src/composer.lock index 7d12caaea..4006d7009 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a82451ba23e9ac8f2921c25024628dbb", + "content-hash": "a02c67624fb2477ae667587578cabf08", "packages": [ { "name": "composer/ca-bundle", @@ -4372,6 +4372,50 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f06dbb052ddc394e7896fcd1cfcd533f9f6ace40", + "reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.8.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.2.0" + }, + "time": "2022-10-17T12:59:16+00:00" + }, { "name": "phpstan/phpstan", "version": "1.9.12", @@ -4431,6 +4475,54 @@ ], "time": "2023-01-17T10:44:04+00:00" }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "2c6792eda026d9c474c14aa018aed312686714db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/2c6792eda026d9c474c14aa018aed312686714db", + "reference": "2c6792eda026d9c474c14aa018aed312686714db", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.3" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-php-parser": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.1.1" + }, + "time": "2022-12-13T14:26:20+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.23", diff --git a/src/library/Api/Abstract.php b/src/library/Api/Abstract.php index 18415d84d..49342e5b5 100644 --- a/src/library/Api/Abstract.php +++ b/src/library/Api/Abstract.php @@ -123,31 +123,4 @@ class Api_Abstract implements InjectionAwareInterface { return $this->ip; } - - /** - * @deprecated use DI - */ - public function getApiAdmin() - { - if($this->identity instanceof \Model_Admin) { - return $this->di['api_admin']; - } - return $this->di['api_system']; - } - - /** - * @deprecated use DI - */ - public function getApiGuest() - { - return $this->di['api_guest']; - } - - /** - * @deprecated use DI - */ - public function getApiClient() - { - return $this->di['api_client']; - } } \ No newline at end of file diff --git a/src/library/Box/App.php b/src/library/Box/App.php index e3b919b0a..8e7346e72 100644 --- a/src/library/Box/App.php +++ b/src/library/Box/App.php @@ -385,28 +385,4 @@ class Box_App return $this->show404($e); } - - /** - * @deprecated - */ - public function getApiAdmin() - { - return $this->di['api_admin']; - } - - /** - * @deprecated - */ - public function getApiClient() - { - return $this->di['api_client']; - } - - /** - * @deprecated - */ - public function getApiGuest() - { - return $this->di['api_guest']; - } } diff --git a/src/library/Box/Tools.php b/src/library/Box/Tools.php index 2e2910c53..16d9c8baf 100644 --- a/src/library/Box/Tools.php +++ b/src/library/Box/Tools.php @@ -245,86 +245,6 @@ class Box_Tools return stripslashes($string); } - /** - * @Deprecated not used anywhere - * @param $filename - * @return mixed|string - */ - public function get_mime_content_type($filename) - { - $mime_types = array( - - 'txt' => 'text/plain', - 'htm' => 'text/html', - 'html' => 'text/html', - 'php' => 'text/html', - 'css' => 'text/css', - 'js' => 'application/javascript', - 'json' => 'application/json', - 'xml' => 'application/xml', - 'swf' => 'application/x-shockwave-flash', - 'flv' => 'video/x-flv', - - // images - 'png' => 'image/png', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'gif' => 'image/gif', - 'bmp' => 'image/bmp', - 'ico' => 'image/vnd.microsoft.icon', - 'tiff' => 'image/tiff', - 'tif' => 'image/tiff', - 'svg' => 'image/svg+xml', - 'svgz' => 'image/svg+xml', - - // archives - 'zip' => 'application/zip', - 'rar' => 'application/x-rar-compressed', - 'exe' => 'application/x-msdownload', - 'msi' => 'application/x-msdownload', - 'cab' => 'application/vnd.ms-cab-compressed', - - // audio/video - 'mp3' => 'audio/mpeg', - 'qt' => 'video/quicktime', - 'mov' => 'video/quicktime', - - // adobe - 'pdf' => 'application/pdf', - 'psd' => 'image/vnd.adobe.photoshop', - 'ai' => 'application/postscript', - 'eps' => 'application/postscript', - 'ps' => 'application/postscript', - - // ms office - 'doc' => 'application/msword', - 'rtf' => 'application/rtf', - 'xls' => 'application/vnd.ms-excel', - 'ppt' => 'application/vnd.ms-powerpoint', - - // open office - 'odt' => 'application/vnd.oasis.opendocument.text', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - ); - - $ext = explode('.',$filename); - $ext = array_pop($ext); - $ext = strtolower($ext); - if (array_key_exists($ext, $mime_types)) { - return $mime_types[$ext]; - } - elseif (function_exists('finfo_open')) { - $finfo = finfo_open(FILEINFO_MIME); - $mimetype = finfo_file($finfo, $filename); - finfo_close($finfo); - return $mimetype; - } - else { - return 'application/octet-stream'; - } - } - public function to_camel_case($str, $capitalise_first_char = false) { if($capitalise_first_char) { $str[0] = strtoupper($str[0]); diff --git a/src/library/Model/ProductTable.php b/src/library/Model/ProductTable.php index 2f354cb57..c6219d268 100644 --- a/src/library/Model/ProductTable.php +++ b/src/library/Model/ProductTable.php @@ -1,4 +1,5 @@ getCode(); - switch ($code) { - case '1W': - return 'w'; - - case '1M': - return 'm'; - - case '3M': - return 'q'; - - case '6M': - return 'b'; - - case '12M': - case '1Y': - return 'a'; - - case '2Y': - return 'bia'; - - case '3Y': - return 'tria'; - - default: - throw new Box_Exception('Unknown period selected ' . $code); + try { + return match ($$code) { + '1W' => 'w', + '1M' => 'm', + '3M' => 'q', + '6M' => 'b', + '12M' => 'a', + '1Y' => 'a', + '2Y' => 'bia', + '3Y' => 'tria' + }; + } catch (\UnhandledMatchError) { + throw new Box_Exception('Unknown period selected ' . $code); } } public function getPricingArray(Model_Product $model) { - if($model->product_payment_id) { + if ($model->product_payment_id) { $service = $this->di['mod_service']('product'); $productPayment = $this->di['db']->load('ProductPayment', $model->product_payment_id); return $service->toProductPaymentApiArray($productPayment); } - throw new \Box_Exception('Product pricing could not be determined. '.get_class($this)); + throw new \Box_Exception('Product pricing could not be determined. ' . get_class($this)); } /** @@ -109,21 +97,21 @@ class Model_ProductTable implements \Box\InjectionAwareInterface { $pp = $this->di['db']->load('ProductPayment', $product->product_payment_id); - if($pp->type == Model_ProductPayment::FREE) { + if ($pp->type == Model_ProductPayment::FREE) { $price = 0; } - if($pp->type == Model_ProductPayment::ONCE) { + if ($pp->type == Model_ProductPayment::ONCE) { $price = (float)$pp->once_setup_price; } - if($pp->type == Model_ProductPayment::RECURRENT) { + if ($pp->type == Model_ProductPayment::RECURRENT) { $period = new Box_Period($config['period']); $key = $this->_getPeriodKey($period); - $price = (float)$pp->{$key.'_setup_price'}; + $price = (float)$pp->{$key . '_setup_price'}; } - if(isset($price)) { + if (isset($price)) { return $price; } @@ -141,28 +129,28 @@ class Model_ProductTable implements \Box\InjectionAwareInterface { $pp = $this->di['db']->load('ProductPayment', $product->product_payment_id); - if($pp->type == Model_ProductPayment::FREE) { + if ($pp->type == Model_ProductPayment::FREE) { $price = 0; } - if($pp->type == Model_ProductPayment::ONCE) { + if ($pp->type == Model_ProductPayment::ONCE) { $price = $pp->once_price; } - if($pp->type == Model_ProductPayment::RECURRENT) { - if(!isset($config['period'])) { - throw new \Box_Exception('Product :id payment type is recurrent, but period was not selected', array(':id'=>$product->id)); + if ($pp->type == Model_ProductPayment::RECURRENT) { + if (!isset($config['period'])) { + throw new \Box_Exception('Product :id payment type is recurrent, but period was not selected', array(':id' => $product->id)); } $period = new Box_Period($config['period']); $key = $this->_getPeriodKey($period); - $price =$pp->{$key.'_price'}; + $price = $pp->{$key . '_price'}; } - if(isset($price)) { + if (isset($price)) { return $price; } throw new \Box_Exception('Unknown Period selected for price'); } -} \ No newline at end of file +} diff --git a/src/modules/Api/Service.php b/src/modules/Api/Service.php index c6c3b8849..37e8f0e7e 100644 --- a/src/modules/Api/Service.php +++ b/src/modules/Api/Service.php @@ -90,28 +90,4 @@ class Service implements \Box\InjectionAwareInterface return (int) $this->di['db']->getCell($sql, $values); } - - /** - * @deprecated use DI - */ - public function getApiGuest() - { - return $this->di['api_guest']; - } - - /** - * @deprecated use DI - */ - public function getApiClient($id) - { - return $this->di['api_client']; - } - - /** - * @deprecated use DI - */ - public function getApiAdmin($id = null) - { - return $this->di['api_admin']; - } } diff --git a/src/modules/Cart/Service.php b/src/modules/Cart/Service.php index d5ccc58ab..369813eee 100644 --- a/src/modules/Cart/Service.php +++ b/src/modules/Cart/Service.php @@ -148,11 +148,6 @@ class Service implements InjectionAwareInterface $productServiceFromList = $productFromList->getService(); - // @deprecated logic - if (method_exists($productServiceFromList, 'prependOrderConfig')) { - $productFromListConfig = $productServiceFromList->prependOrderConfig($productFromList, $productFromListConfig); - } - if (method_exists($productServiceFromList, 'attachOrderConfig')) { $model = $this->di['db']->load('Product', $productFromList->id); $productFromListConfig = $productServiceFromList->attachOrderConfig($model, $productFromListConfig); @@ -438,7 +433,8 @@ class Service implements InjectionAwareInterface 'params' => [ 'ip' => $this->di['request']->getClientAddress(), 'client_id' => $client->id, - 'cart_id' => $cart->id, ], + 'cart_id' => $cart->id, + ], ] ); diff --git a/src/modules/Client/Api/Client.php b/src/modules/Client/Api/Client.php index 98aa11729..83adb7dc3 100644 --- a/src/modules/Client/Api/Client.php +++ b/src/modules/Client/Api/Client.php @@ -22,205 +22,6 @@ namespace Box\Mod\Client\Api; class Client extends \Api_Abstract { - /** - * Get currently logged in client details. - * - * @deprecated moved to profile module - */ - public function get() - { - return $this->getService()->toApiArray($this->getIdentity(), true, $this->getIdentity()); - } - - /** - * Update currently logged in client details. - * - * @optional string $email - new client email. Must not exist on system - * @optional string $last_name - last name - * @optional string $aid - Alternative id. Usually used by import tools. - * @optional string $gender - Gender - values: male|female|nonbinary|other - * @optional string $country - Country - * @optional string $city - city - * @optional string $birthday - Birthday - * @optional string $company - Company - * @optional string $company_vat - Company VAT number - * @optional string $company_number - Company number - * @optional string $type - Identifies client type: company or individual - * @optional string $address_1 - Address line 1 - * @optional string $address_2 - Address line 2 - * @optional string $postcode - zip or postcode - * @optional string $state - country state - * @optional string $phone - Phone number - * @optional string $phone_cc - Phone country code - * @optional string $document_type - Related document type, ie: passport, driving license - * @optional string $document_nr - Related document number, ie: passport number: LC45698122 - * @optional string $notes - Notes about client. Visible for admin only - * @optional string $custom_1 - Custom field 1 - * @optional string $custom_2 - Custom field 2 - * @optional string $custom_3 - Custom field 3 - * @optional string $custom_4 - Custom field 4 - * @optional string $custom_5 - Custom field 5 - * @optional string $custom_6 - Custom field 6 - * @optional string $custom_7 - Custom field 7 - * @optional string $custom_8 - Custom field 8 - * @optional string $custom_9 - Custom field 9 - * @optional string $custom_10 - Custom field 10 - * - * @return bool - * - * @throws Exception - * - * @deprecated moved to profile module - */ - public function update($data = []) - { - $client = $this->getIdentity(); - - $event_params = $data; - $event_params['id'] = $client->id; - $this->di['events_manager']->fire(['event' => 'onBeforeClientProfileUpdate', 'params' => $event_params]); - - $email = $this->di['array_get']($data, 'email', ''); - if (!empty($email)) { - $email = $this->di['tools']->validateAndSanitizeEmail($email); - - $this->getService()->canChangeEmail($client, $email); - - if ($this->getService()->emailAlreadyRegistered($email, $client)) { - throw new \Box_Exception('Can not change email. It is already registered.'); - } - $client->email = strtolower(trim($email)); - } - - $phoneCC = $this->di['array_get']($data, 'phone_cc', $client->phone_cc); - if (!empty($phoneCC)) { - $client->phone_cc = intval($phoneCC); - } - - $client->first_name = $this->di['array_get']($data, 'first_name', $client->first_name); - $client->last_name = $this->di['array_get']($data, 'last_name', $client->last_name); - $client->gender = $this->di['array_get']($data, 'gender', $client->gender); - $client->birthday = $this->di['array_get']($data, 'birthday', $client->birthday); - $client->company = $this->di['array_get']($data, 'company', $client->company); - $client->company_vat = $this->di['array_get']($data, 'company_vat', $client->company_vat); - $client->company_number = $this->di['array_get']($data, 'company_number', $client->company_number); - $client->type = $this->di['array_get']($data, 'type', $client->type); - $client->address_1 = $this->di['array_get']($data, 'address_1', $client->address_1); - $client->address_2 = $this->di['array_get']($data, 'address_2', $client->address_2); - $client->phone = $this->di['array_get']($data, 'phone', $client->phone); - $client->country = $this->di['array_get']($data, 'country', $client->country); - $client->postcode = $this->di['array_get']($data, 'postcode', $client->postcode); - $client->city = $this->di['array_get']($data, 'city', $client->city); - $client->state = $this->di['array_get']($data, 'state', $client->state); - $client->document_type = $this->di['array_get']($data, 'document_type', 'passport'); - $client->document_nr = $this->di['array_get']($data, 'document_nr', ''); - $client->notes = $this->di['array_get']($data, 'notes', $client->notes); - - $client->custom_1 = $this->di['array_get']($data, 'custom_1', $client->custom_1); - $client->custom_2 = $this->di['array_get']($data, 'custom_2', $client->custom_2); - $client->custom_3 = $this->di['array_get']($data, 'custom_3', $client->custom_3); - $client->custom_4 = $this->di['array_get']($data, 'custom_4', $client->custom_4); - $client->custom_5 = $this->di['array_get']($data, 'custom_5', $client->custom_5); - $client->custom_6 = $this->di['array_get']($data, 'custom_6', $client->custom_6); - $client->custom_7 = $this->di['array_get']($data, 'custom_7', $client->custom_7); - $client->custom_8 = $this->di['array_get']($data, 'custom_8', $client->custom_8); - $client->custom_9 = $this->di['array_get']($data, 'custom_9', $client->custom_9); - $client->custom_10 = $this->di['array_get']($data, 'custom_10', $client->custom_10); - - $client->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($client); - - $this->di['events_manager']->fire(['event' => 'onAfterClientProfileUpdate', 'params' => ['id' => $client->id]]); - - $this->di['logger']->info('Updated profile'); - - return true; - } - - /** - * Retrieve current API key. - * - * @deprecated moved to profile module - */ - public function api_key_get($data) - { - $client = $this->getIdentity(); - - return $client->api_token; - } - - /** - * Generate new API key. - * - * @deprecated moved to profile module - */ - public function api_key_reset($data) - { - $client = $this->getIdentity(); - - $client->api_token = $this->di['tools']->generatePassword(32); - $client->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($client); - - $this->di['logger']->info('Generated new API key'); - - return $client->api_token; - } - - /** - * Change client area password. - * - * @deprecated moved to profile module - */ - public function change_password($data) - { - $required = [ - 'password' => 'Password required', - 'password_confirm' => 'Password confirmation required', - ]; - $this->di['validator']->checkRequiredParamsForArray($required, $data); - $this->di['validator']->isPasswordStrong($data['password']); - - if ($data['password'] != $data['password_confirm']) { - throw new \Box_Exception('Passwords do not match.'); - } - - $event_params = $data; - $event_params['id'] = $this->getIdentity()->id; - $this->di['events_manager']->fire(['event' => 'onBeforeClientProfilePasswordChange', 'params' => $event_params]); - - $this->di['validator']->isPasswordStrong($data['password']); - - $client = $this->getIdentity(); - $client->pass = $this->di['password']->hashIt($data['password']); - $this->di['db']->store($client); - - $this->di['events_manager']->fire(['event' => 'onAfterClientProfilePasswordChange', 'params' => ['id' => $client->id]]); - - $this->di['logger']->info('Changed profile password'); - - return true; - } - - /** - * Clear session and logout. - * - * @return bool - * - * @deprecated moved to profile module - */ - public function logout() - { - if ($_COOKIE) { // testing env fix - $this->di['cookie']->set('BOXCLR', '', time() - 3600, '/'); - } - $this->di['session']->delete('client'); - $this->di['session']->delete('client_id'); - $this->di['logger']->info('Logged out'); - - return true; - } - /** * Get payments information. * diff --git a/src/modules/Client/Controller/Client.php b/src/modules/Client/Controller/Client.php index e2d8ce08f..3f63fc83b 100644 --- a/src/modules/Client/Controller/Client.php +++ b/src/modules/Client/Controller/Client.php @@ -38,9 +38,6 @@ class Client implements \Box\InjectionAwareInterface public function register(\Box_App &$app) { - // @deprecated - $app->get('/client/me', 'get_profile', [], static::class); - $app->get('/client/reset-password-confirm/:hash', 'get_reset_password_confirm', ['hash' => '[a-z0-9]+'], static::class); $app->get('/client', 'get_client_index', [], static::class); $app->get('/client/logout', 'get_client_logout', [], static::class); @@ -48,22 +45,6 @@ class Client implements \Box\InjectionAwareInterface $app->get('/client/confirm-email/:hash', 'get_client_confirmation', ['page' => '[a-z0-9-]+'], static::class); } - /** - * @deprecated - */ - public function get_profile(\Box_App $app) - { - return $app->redirect('/client/profile'); - } - - /** - * @deprecated - */ - public function get_balance(\Box_App $app) - { - return $app->redirect('/client/balance'); - } - public function get_client_index(\Box_App $app) { $this->di['is_client_logged']; diff --git a/src/modules/Client/html_client/mod_client_balance.html.twig b/src/modules/Client/html_client/mod_client_balance.html.twig index 0d107170a..1cbf00575 100644 --- a/src/modules/Client/html_client/mod_client_balance.html.twig +++ b/src/modules/Client/html_client/mod_client_balance.html.twig @@ -5,7 +5,7 @@ {% block meta_title %}{{ 'Payment history'|trans }}{% endblock %} {% block breadcrumb %}
  • {{ 'Payment history'|trans }}
  • {% endblock %} -{% set profile = client.client_get %} +{% set profile = client.profile_get %} {% block body_class %}client-balance{% endblock %} {% block content %} diff --git a/src/modules/Client/html_client/mod_client_profile.html.twig b/src/modules/Client/html_client/mod_client_profile.html.twig index b1f3cb06a..4a1faf43e 100644 --- a/src/modules/Client/html_client/mod_client_profile.html.twig +++ b/src/modules/Client/html_client/mod_client_profile.html.twig @@ -268,7 +268,7 @@ $(function() { $('#change-password').bind('submit', function(event) { bb.post( - 'client/client/change_password', + 'client/profile/change_password', $(this).serialize(), function(result) { bb.msg('Password was changed'); diff --git a/src/modules/Client/html_email/mod_client_confirm.html.twig b/src/modules/Client/html_email/mod_client_confirm.html.twig index 4b3aacd44..96cacd52c 100644 --- a/src/modules/Client/html_email/mod_client_confirm.html.twig +++ b/src/modules/Client/html_email/mod_client_confirm.html.twig @@ -8,7 +8,7 @@ Please verify your email by clicking on the link below: {{email_confirmation_link}} To login, visit {{'login'|link({'email' : c.email }) }} -Edit your profile at {{'client/me'|link}} +Edit your profile at {{'client/profile'|link}} {{ guest.system_company.signature }} diff --git a/src/modules/Client/html_email/mod_client_password_reset_approve.html.twig b/src/modules/Client/html_email/mod_client_password_reset_approve.html.twig index 666c42a16..a3da1e78e 100644 --- a/src/modules/Client/html_email/mod_client_password_reset_approve.html.twig +++ b/src/modules/Client/html_email/mod_client_password_reset_approve.html.twig @@ -14,7 +14,7 @@ Password: {{ password }} To change your password to something more memorable, after logging in go to Profile > Change Password. -Edit your profile at {{ 'client/me'|link }} +Edit your profile at {{ 'client/profile'|link }} {{ guest.system_company.signature }} diff --git a/src/modules/Client/html_email/mod_client_password_reset_request.html.twig b/src/modules/Client/html_email/mod_client_password_reset_request.html.twig index df2688b9a..f4e360754 100644 --- a/src/modules/Client/html_email/mod_client_password_reset_request.html.twig +++ b/src/modules/Client/html_email/mod_client_password_reset_request.html.twig @@ -15,7 +15,7 @@ When you visit the link above, your password will be reset and a new password will be emailed to you. To login, visit {{'login'|link({'email' : c.email }) }} -Edit your profile at {{'client/me'|link}} +Edit your profile at {{'client/profile'|link}} {{ guest.system_company.signature }} diff --git a/src/modules/Client/html_email/mod_client_signup.html.twig b/src/modules/Client/html_email/mod_client_signup.html.twig index dc88928b1..aa3416d0b 100644 --- a/src/modules/Client/html_email/mod_client_signup.html.twig +++ b/src/modules/Client/html_email/mod_client_signup.html.twig @@ -18,7 +18,7 @@ Approve your email by clicking on the link below: {% endif %} To login, visit {{'login'|link({'email' : c.email }) }} -Edit your profile at {{'client/me'|link}} +Edit your profile at {{'client/profile'|link}} {{ guest.system_company.signature }} diff --git a/src/modules/Dashboard/html_client/mod_dashboard_index.html.twig b/src/modules/Dashboard/html_client/mod_dashboard_index.html.twig index dc5ace37a..c2b1f2be2 100644 --- a/src/modules/Dashboard/html_client/mod_dashboard_index.html.twig +++ b/src/modules/Dashboard/html_client/mod_dashboard_index.html.twig @@ -71,14 +71,14 @@ {% endif %}
    -{% set profile = client.client_get %} +{% set profile = client.profile_get %}

    {{ 'Profile'|trans }}

    diff --git a/src/modules/Example/html_client/mod_example_index.html.twig b/src/modules/Example/html_client/mod_example_index.html.twig index 3e00da2ec..d2c067015 100644 --- a/src/modules/Example/html_client/mod_example_index.html.twig +++ b/src/modules/Example/html_client/mod_example_index.html.twig @@ -40,7 +40,7 @@

    {{ 'Your protected content'|trans }}

    -

    {{ 'Manage profile'|trans }}

    +

    {{ 'Manage profile'|trans }}

    diff --git a/src/modules/Index/html_client/mod_index_dashboard.html.twig b/src/modules/Index/html_client/mod_index_dashboard.html.twig index 5bd59202e..86169b87a 100644 --- a/src/modules/Index/html_client/mod_index_dashboard.html.twig +++ b/src/modules/Index/html_client/mod_index_dashboard.html.twig @@ -76,14 +76,14 @@ {% endif %}
    -{% set profile = client.client_get %} +{% set profile = client.profile_get %}

    {{ 'Profile'|trans }}

    diff --git a/src/modules/Invoice/Service.php b/src/modules/Invoice/Service.php index ef91e05b0..6d9ee7da1 100644 --- a/src/modules/Invoice/Service.php +++ b/src/modules/Invoice/Service.php @@ -739,29 +739,6 @@ class Service implements InjectionAwareInterface $result = (int) $new->id; break; - // @todo undocumented - // @deprecated - case 'same_invoice': - $amount = $this->getTotalWithTax($invoice); - $invoice->refund = empty($amount) ? null : $amount; - $invoice->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($invoice); - - if (!empty($note)) { - $this->addNote($invoice, $note); - } - - // mark invoice as refunded if refund amount is equal or greater - // than refund amount - $total = $this->getTotalWithTax($invoice); - if ($invoice->refund >= $total) { - $invoice->status = \Model_Invoice::STATUS_REFUNDED; - $this->di['db']->store($invoice); - } - - $this->countIncome($invoice); - break; - case 'manual': if ($this->di['config']['debug']) { error_log('Refunds are managed manually. No actions performed'); diff --git a/src/modules/Order/Service.php b/src/modules/Order/Service.php index 93355dea7..1024febbb 100644 --- a/src/modules/Order/Service.php +++ b/src/modules/Order/Service.php @@ -238,39 +238,18 @@ class Service implements InjectionAwareInterface public function getOrderService(\Model_ClientOrder $order) { if (null !== $order->service_id) { - // @deprecated - // @todo remove this when doctrine is removed - $core_services = [ - \Model_ProductTable::CUSTOM, - \Model_ProductTable::LICENSE, - \Model_ProductTable::DOWNLOADABLE, - \Model_ProductTable::HOSTING, - \Model_ProductTable::MEMBERSHIP, - \Model_ProductTable::DOMAIN, - ]; - if (in_array($order->service_type, $core_services)) { - $repo_class = $this->_getServiceClassName($order); + $service = $this->di['db']->findOne( + 'service_' . $order->service_type, + 'id = :id', + [':id' => $order->service_id] + ); - return $this->di['db']->load($repo_class, $order->service_id); - } else { - $service = $this->di['db']->findOne('service_' . $order->service_type, - 'id = :id', - [':id' => $order->service_id]); - - return $service; - } + return $service; } return null; } - protected function _getServiceClassName(\Model_ClientOrder $order) - { - $s = $this->di['tools']->to_camel_case($order->service_type, true); - - return 'Service' . ucfirst($s); - } - public function getServiceOrder($service) { $type = $this->di['tools']->from_camel_case(str_replace('Model_Service', '', $service::class)); @@ -564,10 +543,6 @@ class Service implements InjectionAwareInterface $config['period'] = $period; } $se = $this->di['mod_service']('service' . $product->type); - // @deprecated logic - if (method_exists($se, 'prependOrderConfig')) { - $config = $se->prependOrderConfig($product, $config); - } // @migration script $se = $this->di['mod_service']('service' . $product->type); @@ -788,38 +763,21 @@ class Service implements InjectionAwareInterface protected function _callOnService(\Model_ClientOrder $order, $action) { $repo = $this->di['mod_service']('service' . $order->service_type); - // @deprecated - // @todo remove this when doctrine is removed - $core_services = [ - \Model_ProductTable::CUSTOM, - \Model_ProductTable::LICENSE, - \Model_ProductTable::DOWNLOADABLE, - \Model_ProductTable::HOSTING, - \Model_ProductTable::MEMBERSHIP, - \Model_ProductTable::DOMAIN, - ]; - - if (in_array($order->service_type, $core_services)) { - $m = 'action_' . $action; - if (!method_exists($repo, $m) || !is_callable([$repo, $m])) { - throw new \Box_Exception('Service ' . $order->service_type . ' do not support ' . $m); - } - - return $repo->$m($order); - } else { - // @new logic for services - $o = $this->di['db']->findOne('client_order', - 'id = :id', - [':id' => $order->id]); - $service = null; - $sdbname = 'service_' . $order->service_type; - if ($order->service_id) { - $service = $this->di['db']->load($sdbname, $order->service_id); - } - if (method_exists($repo, $action) && is_callable([$repo, $action])) { - return $repo->$action($o, $service); - } + // @new logic for services + $o = $this->di['db']->findOne( + 'client_order', + 'id = :id', + [':id' => $order->id] + ); + $service = null; + $sdbname = 'service_' . $order->service_type; + if ($order->service_id) { + $service = $this->di['db']->load($sdbname, $order->service_id); } + if (method_exists($repo, $action) && is_callable([$repo, $action])) { + return $repo->$action($o, $service); + } + error_log(sprintf('Service %s does not support action %s', $order->service_type, $action)); return null; diff --git a/src/modules/Servicelicense/Server.php b/src/modules/Servicelicense/Server.php index c7e40601a..17d5de1ae 100644 --- a/src/modules/Servicelicense/Server.php +++ b/src/modules/Servicelicense/Server.php @@ -41,31 +41,6 @@ class Server implements \Box\InjectionAwareInterface { } - /** - * @deprecated - * - * @param type $data - * - * @return type - */ - public function handle_deprecated($data) - { - try { - $this->process($data); - } catch (\LogicException $e) { - $this->_log->info($e->getMessage() . ' ' . $e->getCode()); - $this->_result['error'] = $e->getMessage(); - $this->_result['error_code'] = $e->getCode(); - } catch (\Exception $e) { - error_log($e); - $this->_log->info($e->getMessage() . ' ' . $e->getCode()); - $this->_result['error'] = 'Licensing server is temporary unavailable'; - $this->_result['error_code'] = $e->getCode(); - } - - return $this->_result; - } - /** * @param string $key */ diff --git a/src/modules/Servicelicense/Service.php b/src/modules/Servicelicense/Service.php index 507921d62..ce0e7b0fb 100644 --- a/src/modules/Servicelicense/Service.php +++ b/src/modules/Servicelicense/Service.php @@ -477,25 +477,6 @@ class Service implements InjectionAwareInterface return $result; } - /* - * Old style api format return. - * - * @deprecated - */ - if (isset($data['legacy']) && $data['legacy']) { - $server = $this->di['license_server']; - $array = $server->handle_deprecated($data); - if (APPLICATION_ENV == 'testing') { - return $array; - } - - header('Cache-Control: no-cache, must-revalidate'); - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); - header('Content-type: application/json; charset=utf-8'); - echo json_encode($array); - exit; - } - $server = $this->di['license_server']; return $server->process($data); diff --git a/src/modules/Staff/Api/Admin.php b/src/modules/Staff/Api/Admin.php index fe55b47a8..08d96c85f 100644 --- a/src/modules/Staff/Api/Admin.php +++ b/src/modules/Staff/Api/Admin.php @@ -395,175 +395,6 @@ class Admin extends \Api_Abstract return $this->getService()->deleteLoginHistory($model); } - /** - * Returns currently logged in staff member information. - * - * @return array - * - * @deprecated moved to profile module - * - * @codeCoverageIgnore - * - * @example - * - * Array - * ( - * [id] => 1 - * [role] => staff - * [admin_group_id] => 1 - * [email] => demo@boxbilling.org - * [pass] => 89e495e7941cf9e40e6980d14a16bf023ccd4c91 - * [name] => Demo Administrator - * [signature] => Sincerely Yours, Demo Administrator - * [status] => active - * [api_token] => 29baba87f1c120f1b7fc6b0139167003 - * [created_at] => 1310024416 - * [updated_at] => 1310024416 - * ) - * - */ - public function profile_get() - { - return $this->di['db']->toArray($this->getIdentity()); - } - - /** - * Clear session data and logout from system. - * - * @deprecated moved to profile module - * - * @codeCoverageIgnore - * - * @return bool - */ - public function profile_logout() - { - if ($_COOKIE) { // testing env fix - $this->di['cookie']->set('BOXADMR', '', time() - 3600, '/'); - } - $this->di['session']->delete('admin'); - $this->di['logger']->info('Logged out'); - - return true; - } - - /** - * Update currently logged in staff member details. - * - * @optional string $email - new email - * @optional string $name - new name - * @optional string $signature - new signature - * - * @deprecated moved to profile module - * - * @return bool - * - * @throws Exception - * - * @codeCoverageIgnore - */ - public function profile_update($data) - { - $event_params = $data; - $event_params['id'] = $this->getIdentity()->id; - $this->di['events_manager']->fire(['event' => 'onBeforeAdminStaffProfileUpdate', 'params' => $event_params]); - - $admin = $this->getIdentity(); - - if (!is_null($data['email'])) { - $data['email'] = $this->di['tools']->validateAndSanitizeEmail($data['email']); - } - - $admin->email = $this->di['array_get']($data, 'email', $admin->email); - $admin->name = $this->di['array_get']($data, 'name', $admin->name); - $admin->signature = $this->di['array_get']($data, 'signature', $admin->signature); - $admin->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($admin); - - $event_params = []; - $event_params['id'] = $this->getIdentity()->id; - $this->di['events_manager']->fire(['event' => 'onAfterAdminStaffProfileUpdate', 'params' => $event_params]); - - $this->di['logger']->info('Updated profile'); - - return true; - } - - /** - * Generates new API token for currently logged in staff member. - * - * @deprecated moved to profile module - * - * @return bool - * - * @codeCoverageIgnore - */ - public function profile_generate_api_key($data) - { - $admin = $this->getIdentity(); - - $event_params = []; - $event_params['id'] = $this->getIdentity()->id; - $this->di['events_manager']->fire(['event' => 'onBeforeAdminStaffApiKeyChange', 'params' => $event_params]); - - $admin->api_token = $this->di['tools']->generatePassword(32); - $admin->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($admin); - - $this->di['events_manager']->fire(['event' => 'onAfterAdminStaffApiKeyChange', 'params' => $event_params]); - - $this->di['logger']->info('Generated new API key'); - - return true; - } - - /** - * Change password for currently logged in staff member. - * - * @param string $password - new password - * @param string $password_confirm - repeat new password - * - * @return bool - * - * @deprecated moved to profile module - * - * @throws Exception - * - * @codeCoverageIgnore - */ - public function profile_change_password($data) - { - $required = [ - 'password' => 'Password required', - 'password_confirm' => 'Password confirmation required', - ]; - $this->di['validator']->checkRequiredParamsForArray($required, $data); - - if ($data['password'] != $data['password_confirm']) { - throw new \Box_Exception('Passwords do not match'); - } - - $this->di['validator']->isPasswordStrong($data['password']); - - $event_params = $data; - $event_params['id'] = $this->getIdentity()->id; - $this->di['events_manager']->fire(['event' => 'onBeforeAdminStaffProfilePasswordChange', 'params' => $event_params]); - - $admin = $this->getIdentity(); - - $admin->pass = $data['password']; - $admin->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($admin); - - $event_params = []; - $event_params['id'] = $this->getIdentity()->id; - $this->di['events_manager']->fire(['event' => 'onAfterAdminStaffProfilePasswordChange', 'params' => $event_params]); - - $this->di['logger']->info('Changed profile password'); - - return true; - } - /** * Deletes admin login logs with given IDs. * diff --git a/src/modules/System/Api/Admin.php b/src/modules/System/Api/Admin.php index f9c96392d..8edcad5f0 100644 --- a/src/modules/System/Api/Admin.php +++ b/src/modules/System/Api/Admin.php @@ -22,25 +22,6 @@ namespace Box\Mod\System\Api; class Admin extends \Api_Abstract { - /** - * Return system setting param. - * - * @deprecated - * - * @param string $key - parameter key name - * - * @return string - */ - public function param($data) - { - $required = [ - 'key' => 'Parameter key is missing', - ]; - $this->di['validator']->checkRequiredParamsForArray($required, $data); - - return $this->getService()->getParamValue($data['key']); - } - /** * Get all defined system params. * diff --git a/src/themes/huraga/html/layout_default.html.twig b/src/themes/huraga/html/layout_default.html.twig index b99a58bff..bd5124b5d 100644 --- a/src/themes/huraga/html/layout_default.html.twig +++ b/src/themes/huraga/html/layout_default.html.twig @@ -58,7 +58,7 @@ {% endif %} {% if client %} - {% set profile = client.client_get %} + {% set profile = client.profile_get %} {% endif %} {% set company = guest.system_company %} @@ -108,7 +108,7 @@ {% if settings.top_menu_profile %}
  • {% if client %} - {{ 'Profile'|trans }} + {{ 'Profile'|trans }} {% else %} {{ 'Login'|trans }} {% endif %} diff --git a/tests/modules/System/Api/AdminTest.php b/tests/modules/System/Api/AdminTest.php index 4a98f5018..c4fdb0e67 100644 --- a/tests/modules/System/Api/AdminTest.php +++ b/tests/modules/System/Api/AdminTest.php @@ -23,30 +23,6 @@ class AdminTest extends \BBTestCase { $this->assertEquals($di, $getDi); } - public function testparam() - { - $data = array( - 'key' => 'key_parameter', - ); - $serviceMock = $this->getMockBuilder('\Box\Mod\System\Service')->getMock(); - $serviceMock->expects($this->atLeastOnce()) - ->method('getParamValue') - ->will($this->returnValue('paramValue')); - - $validatorMock = $this->getMockBuilder('\Box_Validate')->disableOriginalConstructor()->getMock(); - $validatorMock->expects($this->atLeastOnce()) - ->method('checkRequiredParamsForArray') - ->will($this->returnValue(null)); - - $di = new \Box_Di(); - $di['validator'] = $validatorMock; - $this->api->setDi($di); - $this->api->setService($serviceMock); - - $result = $this->api->param($data); - $this->assertIsString($result); - } - public function testget_params() { $data = array( diff --git a/tests/modules/System/Api/GuestTest.php b/tests/modules/System/Api/GuestTest.php index b94a0c03d..ec39bceed 100644 --- a/tests/modules/System/Api/GuestTest.php +++ b/tests/modules/System/Api/GuestTest.php @@ -107,30 +107,6 @@ class GuestTest extends \BBTestCase { $this->assertIsArray($result); } - public function testparam() - { - $data = array('key' => 'keyValue'); - - $servuceMock = $this->getMockBuilder('\Box\Mod\System\Service')->getMock(); - $servuceMock->expects($this->atLeastOnce()) - ->method('getPublicParamValue') - ->will($this->returnValue('paramValue')); - - $validatorMock = $this->getMockBuilder('\Box_Validate')->disableOriginalConstructor()->getMock(); - $validatorMock->expects($this->atLeastOnce()) - ->method('checkRequiredParamsForArray') - ->will($this->returnValue(null)); - - $di = new \Box_Di(); - $di['validator'] = $validatorMock; - $this->api->setDi($di); - - $this->api->setService($servuceMock); - - $result = $this->api->param($data); - $this->assertIsString($result); - } - public function testPeriods() { $result = $this->api->periods();