diff --git a/RELEASE b/RELEASE index 17f59ddbd..6ee560ca4 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -0.7.9 rev 5171 +0.7.9 rev 5174 diff --git a/api/libs/api.userside.php b/api/libs/api.userside.php index 0de6c18a1..dbd6f7dd6 100644 --- a/api/libs/api.userside.php +++ b/api/libs/api.userside.php @@ -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 @@ -96,6 +96,13 @@ class UserSideApi { */ protected $supportedChangeMethods = array(); + /** + * Contains supported user states to change + * + * @var array + */ + protected $supportedChageUserState = array(); + /** * Contains localised error notices * @@ -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( @@ -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'), @@ -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 * @@ -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 * @@ -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)) { @@ -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)); diff --git a/config/globalmenu.ini b/config/globalmenu.ini index 6b7393ef4..1e4ad09bd 100644 --- a/config/globalmenu.ini +++ b/config/globalmenu.ini @@ -678,7 +678,7 @@ NAME="Administrators permissions" URL="?module=permissions" ICON="permissions.png" CATEGORY=4 -NEED_RIGHT=ROOT +NEED_RIGHT=PERMISSIONS NEED_OPTION= diff --git a/config/modules.d/system/b_permissions.php b/config/modules.d/system/b_permissions.php index e333ce2df..edef73cd6 100755 --- a/config/modules.d/system/b_permissions.php +++ b/config/modules.d/system/b_permissions.php @@ -1 +1 @@ -$taskbar.=build_task('ROOT','?module=permissions','coffin.jpg',__('Administrators permissions')); +$taskbar.=build_task('PERMISSIONS','?module=permissions','coffin.jpg',__('Administrators permissions')); diff --git a/languages/russian/billing.php b/languages/russian/billing.php index 74f2113f1..a1d310d09 100755 --- a/languages/russian/billing.php +++ b/languages/russian/billing.php @@ -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'][''] = ''; diff --git a/languages/ukrainian/billing.php b/languages/ukrainian/billing.php index 724aa89b5..34c926ae5 100755 --- a/languages/ukrainian/billing.php +++ b/languages/ukrainian/billing.php @@ -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'] = 'Користувача не авторизовано'; ?>