Skip to content

Commit

Permalink
0.7.9 rev 5174
Browse files Browse the repository at this point in the history
  • Loading branch information
nightflyza committed Nov 21, 2016
1 parent 392491e commit f6a94b3
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 5 deletions.
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.9 rev 5171
0.7.9 rev 5174
106 changes: 104 additions & 2 deletions api/libs/api.userside.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class UserSideApi {

const API_VER = '1.4';
const API_DATE = '12.10.2016';
const API_DATE = '21.11.2016';

/**
* Stores system alter config as key=>value
Expand Down Expand Up @@ -96,6 +96,13 @@ class UserSideApi {
*/
protected $supportedChangeMethods = array();

/**
* Contains supported user states to change
*
* @var array
*/
protected $supportedChageUserState = array();

/**
* Contains localised error notices
*
Expand Down Expand Up @@ -200,7 +207,8 @@ protected function setOptions() {
'get_services_list' => __('Returns available user services'),
'get_user_history' => __('Returns user financial operations history'),
'change_user_data' => __('Do some changes with user data'),
'get_supported_change_user_data_list' => __('Returns list of supported change user data methods')
'get_supported_change_user_data_list' => __('Returns list of supported change user data methods'),
'get_supported_change_user_state' => __('Returns list of supported change user states'),
);

$this->supportedChangeMethods = array(
Expand All @@ -211,6 +219,15 @@ protected function setOptions() {
'state' => __('User state operations'),
);

$this->supportedChageUserState = array(
'frozen' => __('Frozen user'),
'unfrozen' => __('Not frozen user'),
'down' => __('User down'),
'notdown' => __('User not down'),
'ao' => __('User AlwaysOnline'),
'notao' => __('User not AlwaysOnline')
);

$this->errorNotices = array(
'EX_NO_PARAMS' => __('No request parameters set'),
'EX_USER_NOT_EXISTS' => __('No such user available'),
Expand Down Expand Up @@ -633,6 +650,21 @@ protected function getChangeMethodsList() {
return ($result);
}

/**
* Returns supported change user state options
*
* @return array
*/
protected function getChangeStateMethodsList() {
$result = array();
if (!empty($this->supportedChageUserState)) {
foreach ($this->supportedChageUserState as $io => $each) {
$result[$io] = $each;
}
}
return ($result);
}

/**
* Returns Userside API information
*
Expand Down Expand Up @@ -1207,6 +1239,70 @@ protected function changeUserTariff($changeParams) {
return ($result);
}

/**
* Changes user basic state
*
* @global object $billing
* @param array $changeParams
*
* @return array
*/
protected function changeUserState($changeParams) {
global $billing;
$result = array();

if (isset($changeParams['customerid'])) {
if (isset($this->allUserData[$changeParams['customerid']])) {
if (isset($changeParams['value'])) {
$newState = $changeParams['value'];
if (isset($this->supportedChageUserState[$newState])) {
switch ($newState) {
case 'frozen':
$billing->setpassive($changeParams['customerid'], 1);
log_register('CHANGE Passive (' . $changeParams['customerid'] . ') ON 1');
$result = array('result' => 'ok');
break;
case 'unfrozen':
$billing->setpassive($changeParams['customerid'], 0);
log_register('CHANGE Passive (' . $changeParams['customerid'] . ') ON 0');
$result = array('result' => 'ok');
break;
case 'down':
$billing->setdown($changeParams['customerid'], 1);
log_register('CHANGE Down (' . $changeParams['customerid'] . ') ON 1');
$result = array('result' => 'ok');
break;
case 'notdown':
$billing->setdown($changeParams['customerid'], 0);
log_register('CHANGE Down (' . $changeParams['customerid'] . ') ON 0');
$result = array('result' => 'ok');
break;
case 'ao':
$billing->setao($changeParams['customerid'], 1);
log_register('CHANGE AlwaysOnline (' . $changeParams['customerid'] . ') ON 1');
$result = array('result' => 'ok');
break;
case 'notao':
$billing->setao($changeParams['customerid'], 0);
log_register('CHANGE AlwaysOnline (' . $changeParams['customerid'] . ') ON 0');
$result = array('result' => 'ok');
break;
}
} else {
$result = array('result' => 'error', 'error' => $this->errorNotices['EX_METHOD_NOT_SUPPORTED'] . ': ' . $newState);
}
} else {
$result = array('result' => 'error', 'error' => $this->errorNotices['EX_PARAM_MISSED'] . ': value');
}
} else {
$result = array('result' => 'error', 'error' => $this->errorNotices['EX_USER_NOT_EXISTS'] . ': ' . $changeParams['customerid']);
}
} else {
$result = array('result' => 'error', 'error' => $this->errorNotices['EX_PARAM_MISSED'] . ': customer_id');
}
return ($result);
}

/**
* Listens API requests and renders replies for it
*
Expand Down Expand Up @@ -1271,6 +1367,9 @@ public function catchRequest() {
case 'get_supported_change_user_data_list':
$this->renderReply($this->getChangeMethodsList());
break;
case 'get_supported_change_user_state':
$this->renderReply($this->getChangeStateMethodsList());
break;
case 'change_user_data':
$changeParams = $this->catchChangeParams();
if (!empty($changeParams)) {
Expand All @@ -1290,6 +1389,9 @@ public function catchRequest() {
case 'tariff':
$this->renderReply($this->changeUserTariff($changeParams));
break;
case 'state':
$this->renderReply($this->changeUserState($changeParams));
break;
}
} else {
$this->renderReply(array('result' => 'error', 'error' => $this->errorNotices['EX_METHOD_NOT_SUPPORTED'] . ': ' . $changeOperationType));
Expand Down
2 changes: 1 addition & 1 deletion config/globalmenu.ini
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ NAME="Administrators permissions"
URL="?module=permissions"
ICON="permissions.png"
CATEGORY=4
NEED_RIGHT=ROOT
NEED_RIGHT=PERMISSIONS
NEED_OPTION=


Expand Down
2 changes: 1 addition & 1 deletion config/modules.d/system/b_permissions.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$taskbar.=build_task('ROOT','?module=permissions','coffin.jpg',__('Administrators permissions'));
$taskbar.=build_task('PERMISSIONS','?module=permissions','coffin.jpg',__('Administrators permissions'));
5 changes: 5 additions & 0 deletions languages/russian/billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,11 @@
$lang['def']['Restart DHCP server'] = 'Перезапустить DHCP сервер';
$lang['def']['Local ARP table'] = 'Локальная ARP таблица';
$lang['def']['Host'] = 'Хост';
$lang['def']['Frozen user'] = 'Пользователь заморожен';
$lang['def']['Not frozen user'] = 'Пользователь разморожен';
$lang['def']['User not down'] = 'Пользователь включен';
$lang['def']['User AlwaysOnline'] = 'Пользователь авторизован';
$lang['def']['User not AlwaysOnline'] = 'Пользователь не авторизован';
$lang['def'][''] = '';
$lang['def'][''] = '';

Expand Down
5 changes: 5 additions & 0 deletions languages/ukrainian/billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2323,5 +2323,10 @@
$lang['def']['Restart DHCP server'] = 'Перезапустити DHCP сервер';
$lang['def']['Local ARP table'] = 'Локальна ARP таблиця';
$lang['def']['Host'] = 'Хост';
$lang['def']['Frozen user'] = 'Користувача заморожено';
$lang['def']['Not frozen user'] = 'Користувача розморожено';
$lang['def']['User not down'] = 'Користувача увімкнено';
$lang['def']['User AlwaysOnline'] = 'Користувача авторизовано';
$lang['def']['User not AlwaysOnline'] = 'Користувача не авторизовано';

?>

0 comments on commit f6a94b3

Please sign in to comment.