mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-04 14:13:52 +09:00
Removed / cleaned up deprecated functions (#755)
* Add PHPStan extension for deprecation function usage * Removed some deprecated functions * And a few more * Also remove the deprecated API calls * Fix references to deprecated API calls * Oh, and this too
This commit is contained in:
1 parent
03a8927b82
commit
4d7b341e03
28 files changed
+165
-800
No files matched your search
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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'];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{% block meta_title %}{{ 'Payment history'|trans }}{% endblock %}
|
||||
{% block breadcrumb %} <li class="active">{{ 'Payment history'|trans }}</li>{% endblock %}
|
||||
|
||||
{% set profile = client.client_get %}
|
||||
{% set profile = client.profile_get %}
|
||||
|
||||
{% block body_class %}client-balance{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
|
||||
Reference in new issue
Block a user