@@ -11,20 +11,20 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class GeneralSettingsController extends BaseController { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Построение формы настроек |
|
| 16 | - */ |
|
| 17 | - public function modifyAction() |
|
| 18 | - { |
|
| 19 | - $pbxSettings = PbxSettings::getAllPbxSettings(); |
|
| 20 | - $this->view->form = new GeneralSettingsEditForm(null,$pbxSettings); |
|
| 21 | - $this->view->submitMode = NULL; |
|
| 22 | - } |
|
| 14 | + /** |
|
| 15 | + * Построение формы настроек |
|
| 16 | + */ |
|
| 17 | + public function modifyAction() |
|
| 18 | + { |
|
| 19 | + $pbxSettings = PbxSettings::getAllPbxSettings(); |
|
| 20 | + $this->view->form = new GeneralSettingsEditForm(null,$pbxSettings); |
|
| 21 | + $this->view->submitMode = NULL; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Сохранение настроек системы |
|
| 26 | - */ |
|
| 27 | - public function saveAction() |
|
| 24 | + /** |
|
| 25 | + * Сохранение настроек системы |
|
| 26 | + */ |
|
| 27 | + public function saveAction() |
|
| 28 | 28 | { |
| 29 | 29 | if (!$this->request->isPost()) { |
| 30 | 30 | return; |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | foreach ($pbxSettings as $key=>$value){ |
| 36 | 36 | $record = PbxSettings::findFirstByKey($key); |
| 37 | 37 | if (!$record) { |
| 38 | - $record = new PbxSettings(); |
|
| 39 | - $record->key = $key; |
|
| 40 | - $record->value = $value; |
|
| 38 | + $record = new PbxSettings(); |
|
| 39 | + $record->key = $key; |
|
| 40 | + $record->value = $value; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | switch($key) { |
@@ -49,32 +49,32 @@ discard block |
||
| 49 | 49 | case '***ALL CHECK BOXES ABOVE***': |
| 50 | 50 | $record->value = ($data[$key] === 'on') ? '1' : '0'; |
| 51 | 51 | break; |
| 52 | - case 'SSHPassword': |
|
| 53 | - //Если отправили пароль по-умолчанию, то сделаем его равным паролю WEB |
|
| 54 | - if ( $data[ $key ] === $pbxSettings[ $key ] ) { |
|
| 55 | - $record->value = $data['WebAdminPassword']; |
|
| 56 | - } else { |
|
| 57 | - $record->value = $data[ $key ]; |
|
| 58 | - } |
|
| 59 | - break; |
|
| 60 | - case 'PBXLanguage': |
|
| 61 | - $record->value = $data[$key]; |
|
| 62 | - if ($this->language !==$data[$key]){ |
|
| 63 | - $sessionParams = $this->session->get('auth'); |
|
| 64 | - $sessionParams['lang'] = substr($data[$key],0,2); |
|
| 65 | - $this->session->set('auth', $sessionParams); |
|
| 66 | - $this->session->set('PBXLanguage',$data[$key]); |
|
| 67 | - $this->view->reload = 'general-settings/modify/'; |
|
| 68 | - } |
|
| 69 | - break; |
|
| 52 | + case 'SSHPassword': |
|
| 53 | + //Если отправили пароль по-умолчанию, то сделаем его равным паролю WEB |
|
| 54 | + if ( $data[ $key ] === $pbxSettings[ $key ] ) { |
|
| 55 | + $record->value = $data['WebAdminPassword']; |
|
| 56 | + } else { |
|
| 57 | + $record->value = $data[ $key ]; |
|
| 58 | + } |
|
| 59 | + break; |
|
| 60 | + case 'PBXLanguage': |
|
| 61 | + $record->value = $data[$key]; |
|
| 62 | + if ($this->language !==$data[$key]){ |
|
| 63 | + $sessionParams = $this->session->get('auth'); |
|
| 64 | + $sessionParams['lang'] = substr($data[$key],0,2); |
|
| 65 | + $this->session->set('auth', $sessionParams); |
|
| 66 | + $this->session->set('PBXLanguage',$data[$key]); |
|
| 67 | + $this->view->reload = 'general-settings/modify/'; |
|
| 68 | + } |
|
| 69 | + break; |
|
| 70 | 70 | case 'SendMetrics': |
| 71 | 71 | $record->value = ($data[$key] === 'on') ? '1' : '0'; |
| 72 | 72 | $this->session->set('SendMetrics', $record->value); |
| 73 | 73 | break; |
| 74 | 74 | default: |
| 75 | 75 | if (array_key_exists($key, $data)){ |
| 76 | - $record->value = $data[$key]; |
|
| 77 | - } |
|
| 76 | + $record->value = $data[$key]; |
|
| 77 | + } |
|
| 78 | 78 | } |
| 79 | 79 | if ($record->save()=== false){ |
| 80 | 80 | $errors = $record->getMessages(); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | public function modifyAction() |
| 18 | 18 | { |
| 19 | 19 | $pbxSettings = PbxSettings::getAllPbxSettings(); |
| 20 | - $this->view->form = new GeneralSettingsEditForm(null,$pbxSettings); |
|
| 20 | + $this->view->form = new GeneralSettingsEditForm(null, $pbxSettings); |
|
| 21 | 21 | $this->view->submitMode = NULL; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | 32 | $data = $this->request->getPost(); |
| 33 | - $pbxSettings=PbxSettings::getDefaultArrayValues(); |
|
| 33 | + $pbxSettings = PbxSettings::getDefaultArrayValues(); |
|
| 34 | 34 | $this->db->begin(); |
| 35 | - foreach ($pbxSettings as $key=>$value){ |
|
| 35 | + foreach ($pbxSettings as $key=>$value) { |
|
| 36 | 36 | $record = PbxSettings::findFirstByKey($key); |
| 37 | 37 | if (!$record) { |
| 38 | 38 | $record = new PbxSettings(); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $record->value = $value; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - switch($key) { |
|
| 43 | + switch ($key) { |
|
| 44 | 44 | case 'PBXRecordCalls': |
| 45 | 45 | case 'AJAMEnabled': |
| 46 | 46 | case 'AMIEnabled': |
@@ -51,19 +51,19 @@ discard block |
||
| 51 | 51 | break; |
| 52 | 52 | case 'SSHPassword': |
| 53 | 53 | //Если отправили пароль по-умолчанию, то сделаем его равным паролю WEB |
| 54 | - if ( $data[ $key ] === $pbxSettings[ $key ] ) { |
|
| 54 | + if ($data[$key] === $pbxSettings[$key]) { |
|
| 55 | 55 | $record->value = $data['WebAdminPassword']; |
| 56 | 56 | } else { |
| 57 | - $record->value = $data[ $key ]; |
|
| 57 | + $record->value = $data[$key]; |
|
| 58 | 58 | } |
| 59 | 59 | break; |
| 60 | 60 | case 'PBXLanguage': |
| 61 | 61 | $record->value = $data[$key]; |
| 62 | - if ($this->language !==$data[$key]){ |
|
| 62 | + if ($this->language !== $data[$key]) { |
|
| 63 | 63 | $sessionParams = $this->session->get('auth'); |
| 64 | - $sessionParams['lang'] = substr($data[$key],0,2); |
|
| 64 | + $sessionParams['lang'] = substr($data[$key], 0, 2); |
|
| 65 | 65 | $this->session->set('auth', $sessionParams); |
| 66 | - $this->session->set('PBXLanguage',$data[$key]); |
|
| 66 | + $this->session->set('PBXLanguage', $data[$key]); |
|
| 67 | 67 | $this->view->reload = 'general-settings/modify/'; |
| 68 | 68 | } |
| 69 | 69 | break; |
@@ -72,21 +72,21 @@ discard block |
||
| 72 | 72 | $this->session->set('SendMetrics', $record->value); |
| 73 | 73 | break; |
| 74 | 74 | default: |
| 75 | - if (array_key_exists($key, $data)){ |
|
| 75 | + if (array_key_exists($key, $data)) { |
|
| 76 | 76 | $record->value = $data[$key]; |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | - if ($record->save()=== false){ |
|
| 79 | + if ($record->save() === false) { |
|
| 80 | 80 | $errors = $record->getMessages(); |
| 81 | 81 | $this->flash->warning(implode('<br>', $errors)); |
| 82 | - $this->view->success=false; |
|
| 82 | + $this->view->success = false; |
|
| 83 | 83 | $this->db->rollback(); |
| 84 | 84 | return; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $this->flash->success($this->translation->_('ms_SuccessfulSaved')); |
| 89 | - $this->view->success=true; |
|
| 89 | + $this->view->success = true; |
|
| 90 | 90 | $this->db->commit(); |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | \ No newline at end of file |
@@ -9,7 +9,8 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | use Models\PbxSettings; |
| 11 | 11 | |
| 12 | -class GeneralSettingsController extends BaseController { |
|
| 12 | +class GeneralSettingsController extends BaseController |
|
| 13 | +{ |
|
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Построение формы настроек |
@@ -25,7 +26,7 @@ discard block |
||
| 25 | 26 | * Сохранение настроек системы |
| 26 | 27 | */ |
| 27 | 28 | public function saveAction() |
| 28 | - { |
|
| 29 | + { |
|
| 29 | 30 | if (!$this->request->isPost()) { |
| 30 | 31 | return; |
| 31 | 32 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $pbxSettings = PbxSettings::getAllPbxSettings(); |
| 20 | 20 | $this->view->form = new GeneralSettingsEditForm(null,$pbxSettings); |
| 21 | - $this->view->submitMode = NULL; |
|
| 21 | + $this->view->submitMode = null; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -26,9 +26,9 @@ |
||
| 26 | 26 | { |
| 27 | 27 | $form = new LoginForm(); |
| 28 | 28 | $this->view->NameFromSettings |
| 29 | - = PbxSettings::getValueByKey('Name'); |
|
| 29 | + = PbxSettings::getValueByKey('Name'); |
|
| 30 | 30 | $this->view->DescriptionFromSettings |
| 31 | - = PbxSettings::getValueByKey('Description'); |
|
| 31 | + = PbxSettings::getValueByKey('Description'); |
|
| 32 | 32 | |
| 33 | 33 | $this->view->form = $form; |
| 34 | 34 | } |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | */ |
| 54 | 54 | public function startAction() |
| 55 | 55 | { |
| 56 | - if ( ! $this->request->isPost()) { |
|
| 56 | + if (!$this->request->isPost()) { |
|
| 57 | 57 | return $this->forward('session/index'); |
| 58 | 58 | } |
| 59 | 59 | $loginFromUser = $this->request->getPost('login'); |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | public function modifyAction(string $uniqid = null): void |
| 34 | 34 | { |
| 35 | 35 | $app = DialplanApplications::findFirstByUniqid($uniqid); |
| 36 | - if ( ! $app) { |
|
| 36 | + if (!$app) { |
|
| 37 | 37 | $app = new DialplanApplications(); |
| 38 | - $app->uniqid = strtoupper('DIALPLAN-APP-' . md5($app->id . time())); |
|
| 38 | + $app->uniqid = strtoupper('DIALPLAN-APP-'.md5($app->id.time())); |
|
| 39 | 39 | $app->type = 'php'; |
| 40 | 40 | $app->extension = Extensions::getNextFreeApplicationNumber(); |
| 41 | 41 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function saveAction() |
| 55 | 55 | { |
| 56 | - if ( ! $this->request->isPost()) { |
|
| 56 | + if (!$this->request->isPost()) { |
|
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // Заполним параметры внутреннего номера |
| 80 | - if ( ! $this->updateExtension($extension, $data)) { |
|
| 80 | + if (!$this->updateExtension($extension, $data)) { |
|
| 81 | 81 | $this->view->success = false; |
| 82 | 82 | $this->db->rollback(); |
| 83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // Заполним параметры пользователя |
| 88 | - if ( ! $this->updateDialplanApplication($appRecord, $data)) { |
|
| 88 | + if (!$this->updateDialplanApplication($appRecord, $data)) { |
|
| 89 | 89 | $this->view->success = false; |
| 90 | 90 | $this->db->rollback(); |
| 91 | 91 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $appRecord = DialplanApplications::findFirstByUniqid($uniqid); |
| 114 | 114 | |
| 115 | 115 | $errors = false; |
| 116 | - if ($appRecord->Extensions && ! $appRecord->Extensions->delete()) { |
|
| 116 | + if ($appRecord->Extensions && !$appRecord->Extensions->delete()) { |
|
| 117 | 117 | $errors = $appRecord->Extensions->getMessages(); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * |
| 21 | 21 | * @param int $currentPage текущая страница пажинации |
| 22 | 22 | */ |
| 23 | - public function indexAction( $currentPage = 0, $parameters = NULL ) |
|
| 23 | + public function indexAction($currentPage = 0, $parameters = NULL) |
|
| 24 | 24 | { |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -13,7 +13,8 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * SSH консоль |
| 15 | 15 | */ |
| 16 | -class ConsoleController extends BaseController { |
|
| 16 | +class ConsoleController extends BaseController |
|
| 17 | +{ |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Заглушка |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * |
| 21 | 21 | * @param int $currentPage текущая страница пажинации |
| 22 | 22 | */ |
| 23 | - public function indexAction( $currentPage = 0, $parameters = NULL ) |
|
| 23 | + public function indexAction( $currentPage = 0, $parameters = null ) |
|
| 24 | 24 | { |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $this->view->avatar = ''; |
| 146 | 146 | } else { |
| 147 | 147 | $extension->Sip->manualattributes |
| 148 | - = $extension->Sip->getManualAttributes(); |
|
| 148 | + = $extension->Sip->getManualAttributes(); |
|
| 149 | 149 | $enabledCodecs = $extension->Sip->Codecs; |
| 150 | 150 | foreach ($enabledCodecs as $codec) { |
| 151 | 151 | $codecs[$codec->codec]['enabled'] = true; |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | } |
| 797 | 797 | $result = (int)$query + 1; |
| 798 | 798 | $extensionsLength |
| 799 | - = PbxSettings::getValueByKey('PBXInternalExtensionLength'); |
|
| 799 | + = PbxSettings::getValueByKey('PBXInternalExtensionLength'); |
|
| 800 | 800 | $maxExtension = (10 ** $extensionsLength) - 1; |
| 801 | 801 | |
| 802 | 802 | return ($result <= $maxExtension) ? $result : ''; |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | $extensionTable[$extension->userid]['email'] = $extension->email; |
| 78 | 78 | $extensionTable[$extension->userid]['secret'] = $extension->secret; |
| 79 | 79 | |
| 80 | - if ( ! array_key_exists('mobile', $extensionTable[$extension->userid])) { |
|
| 80 | + if (!array_key_exists('mobile', $extensionTable[$extension->userid])) { |
|
| 81 | 81 | $extensionTable[$extension->userid]['mobile'] = ''; |
| 82 | 82 | } |
| 83 | 83 | if ($extension->avatar) { |
| 84 | 84 | $filename = md5($extension->avatar); |
| 85 | 85 | $imgFile = "{$this->config->application->imgCacheDir}$filename.jpg"; |
| 86 | - if ( ! file_exists($imgFile)) { |
|
| 86 | + if (!file_exists($imgFile)) { |
|
| 87 | 87 | $this->base64ToJpeg($extension->avatar, $imgFile); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | $extension = Extensions::findFirstById($id); |
| 122 | 122 | |
| 123 | - if ( ! $extension) { |
|
| 123 | + if (!$extension) { |
|
| 124 | 124 | $extension = new Extensions(); |
| 125 | 125 | $extension->show_in_phonebook = '1'; |
| 126 | 126 | $extension->public_access = '0'; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $extension->Sip = new Sip(); |
| 130 | 130 | $extension->Sip->disabled = 0; |
| 131 | 131 | $extension->Sip->type = 'peer'; |
| 132 | - $extension->Sip->uniqid = strtoupper('SIP-PHONE-' . md5(time())); |
|
| 132 | + $extension->Sip->uniqid = strtoupper('SIP-PHONE-'.md5(time())); |
|
| 133 | 133 | $extension->Sip->busylevel = 1; |
| 134 | 134 | $extension->Sip->qualify = '1'; |
| 135 | 135 | $extension->Sip->qualifyfreq = 60; |
@@ -160,20 +160,20 @@ discard block |
||
| 160 | 160 | $arrNetworkFilters[$filter->id] = $filter->getRepresent(); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $parameters = [ |
|
| 163 | + $parameters = [ |
|
| 164 | 164 | 'conditions' => 'type = "EXTERNAL" AND is_general_user_number = 1 AND userid=:userid:', |
| 165 | 165 | 'bind' => [ |
| 166 | 166 | 'userid' => $extension->userid, |
| 167 | 167 | ], |
| 168 | 168 | ]; |
| 169 | 169 | $externalExtension = Extensions::findFirst($parameters); |
| 170 | - if ( ! $externalExtension) { |
|
| 170 | + if (!$externalExtension) { |
|
| 171 | 171 | $externalExtension = new Extensions(); |
| 172 | 172 | $externalExtension->userid = $extension->userid; |
| 173 | 173 | $externalExtension->type = 'EXTERNAL'; |
| 174 | 174 | $externalExtension->is_general_user_number = '1'; |
| 175 | 175 | $externalExtension->ExternalPhones = new ExternalPhones(); |
| 176 | - $externalExtension->ExternalPhones->uniqid = strtoupper('EXTERNAL-' . md5(time())); |
|
| 176 | + $externalExtension->ExternalPhones->uniqid = strtoupper('EXTERNAL-'.md5(time())); |
|
| 177 | 177 | $externalExtension->ExternalPhones->disabled = '0'; |
| 178 | 178 | |
| 179 | 179 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | // Ограничим длинну внутреннего номера согласно настройкам |
| 200 | 200 | $extensionsLength = PbxSettings::getValueByKey('PBXInternalExtensionLength'); |
| 201 | - $internalExtensionMask = '9{' . $extensionsLength . '}'; |
|
| 201 | + $internalExtensionMask = '9{'.$extensionsLength.'}'; |
|
| 202 | 202 | |
| 203 | 203 | $form = new ExtensionEditForm($extension, [ |
| 204 | 204 | 'network_filters' => $arrNetworkFilters, |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public function saveAction(): void |
| 222 | 222 | { |
| 223 | - if ( ! $this->request->isPost()) { |
|
| 223 | + if (!$this->request->isPost()) { |
|
| 224 | 224 | return; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -243,21 +243,21 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | } else { |
| 245 | 245 | $extension = $sipEntity->Extensions; |
| 246 | - if ( ! $extension) { |
|
| 246 | + if (!$extension) { |
|
| 247 | 247 | $extension = new Extensions(); |
| 248 | 248 | } |
| 249 | 249 | $userEntity = $extension->Users; |
| 250 | - if ( ! $userEntity) { |
|
| 250 | + if (!$userEntity) { |
|
| 251 | 251 | $userEntity = new Users(); |
| 252 | 252 | } |
| 253 | 253 | $fwdEntity = $extension->ExtensionForwardingRights; |
| 254 | - if ( ! $fwdEntity) { |
|
| 254 | + if (!$fwdEntity) { |
|
| 255 | 255 | $fwdEntity = new ExtensionForwardingRights(); |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // Заполним параметры пользователя |
| 260 | - if ( ! $this->saveUser($userEntity, $data)) { |
|
| 260 | + if (!$this->saveUser($userEntity, $data)) { |
|
| 261 | 261 | $this->view->success = false; |
| 262 | 262 | $this->db->rollback(); |
| 263 | 263 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Заполним параметры внутреннего номера |
| 268 | - if ( ! $this->saveExtension($extension, $userEntity, $data, false)) { |
|
| 268 | + if (!$this->saveExtension($extension, $userEntity, $data, false)) { |
|
| 269 | 269 | $this->view->success = false; |
| 270 | 270 | $this->db->rollback(); |
| 271 | 271 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // Заполним параметры SIP учетки |
| 276 | - if ( ! $this->saveSip($sipEntity, $data)) { |
|
| 276 | + if (!$this->saveSip($sipEntity, $data)) { |
|
| 277 | 277 | $this->view->success = false; |
| 278 | 278 | $this->db->rollback(); |
| 279 | 279 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // Заполним параметры Кодеков |
| 284 | - if ( ! $this->saveSipCodecs($data)) { |
|
| 284 | + if (!$this->saveSipCodecs($data)) { |
|
| 285 | 285 | $this->view->success = false; |
| 286 | 286 | $this->db->rollback(); |
| 287 | 287 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Заполним параметры маршрутизации |
| 292 | - if ( ! $this->saveForwardingRights($fwdEntity, $data)) { |
|
| 292 | + if (!$this->saveForwardingRights($fwdEntity, $data)) { |
|
| 293 | 293 | $this->view->success = false; |
| 294 | 294 | $this->db->rollback(); |
| 295 | 295 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Если мобильный не указан, то не будем его добавлять в базу |
| 300 | - if ( ! empty($data['mobile_number'])) { |
|
| 300 | + if (!empty($data['mobile_number'])) { |
|
| 301 | 301 | $externalPhone = ExternalPhones::findFirstByUniqid($data['mobile_uniqid']); |
| 302 | 302 | if ($externalPhone === false) { |
| 303 | 303 | $externalPhone = new ExternalPhones(); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // Заполним параметры Extension для мобильного |
| 310 | - if ( ! $this->saveExtension($mobileExtension, $userEntity, $data, true)) { |
|
| 310 | + if (!$this->saveExtension($mobileExtension, $userEntity, $data, true)) { |
|
| 311 | 311 | $this->view->success = false; |
| 312 | 312 | $this->db->rollback(); |
| 313 | 313 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // Заполним параметры ExternalPhones для мобильного |
| 318 | - if ( ! $this->saveExternalPhones($externalPhone, $data)) { |
|
| 318 | + if (!$this->saveExternalPhones($externalPhone, $data)) { |
|
| 319 | 319 | $this->view->success = false; |
| 320 | 320 | $this->db->rollback(); |
| 321 | 321 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | } else { |
| 325 | 325 | // Удалить номер мобильного если он был привязан к пользователю |
| 326 | - $parameters = [ |
|
| 326 | + $parameters = [ |
|
| 327 | 327 | 'conditions' => 'type="EXTERNAL" AND is_general_user_number = 1 AND userid=:userid:', |
| 328 | 328 | 'bind' => [ |
| 329 | 329 | 'userid' => $userEntity->id, |
@@ -367,12 +367,12 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | $errors = false; |
| 369 | 369 | if ($extension && $extension->ExtensionForwardingRights |
| 370 | - && ! $extension->ExtensionForwardingRights->delete()) { |
|
| 370 | + && !$extension->ExtensionForwardingRights->delete()) { |
|
| 371 | 371 | $errors = $extension->ExtensionForwardingRights->getMessages(); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | |
| 375 | - if ( ! $errors && $extension && ! $extension->Users->delete()) { |
|
| 375 | + if (!$errors && $extension && !$extension->Users->delete()) { |
|
| 376 | 376 | $errors = $extension->Users->getMessages(); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -502,13 +502,13 @@ discard block |
||
| 502 | 502 | foreach ($userEntity as $name => $value) { |
| 503 | 503 | switch ($name) { |
| 504 | 504 | case 'role': |
| 505 | - if (array_key_exists('user_' . $name, $data)) { |
|
| 506 | - $userEntity->$name = ($userEntity->$name === 'user') ? 'user' : $data['user_' . $name]; // не повышаем роль |
|
| 505 | + if (array_key_exists('user_'.$name, $data)) { |
|
| 506 | + $userEntity->$name = ($userEntity->$name === 'user') ? 'user' : $data['user_'.$name]; // не повышаем роль |
|
| 507 | 507 | } |
| 508 | 508 | break; |
| 509 | 509 | default: |
| 510 | - if (array_key_exists('user_' . $name, $data)) { |
|
| 511 | - $userEntity->$name = $data['user_' . $name]; |
|
| 510 | + if (array_key_exists('user_'.$name, $data)) { |
|
| 511 | + $userEntity->$name = $data['user_'.$name]; |
|
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | } |
@@ -610,20 +610,20 @@ discard block |
||
| 610 | 610 | break; |
| 611 | 611 | case 'disabled': |
| 612 | 612 | case 'disablefromuser': |
| 613 | - if (array_key_exists('sip_' . $name, $data)) { |
|
| 614 | - $sipEntity->$name = ($data['sip_' . $name] === 'on') ? '1' : '0'; |
|
| 613 | + if (array_key_exists('sip_'.$name, $data)) { |
|
| 614 | + $sipEntity->$name = ($data['sip_'.$name] === 'on') ? '1' : '0'; |
|
| 615 | 615 | } else { |
| 616 | 616 | $sipEntity->$name = "0"; |
| 617 | 617 | } |
| 618 | 618 | break; |
| 619 | 619 | case 'networkfilterid': |
| 620 | - if ( ! array_key_exists('sip_' . $name, $data)) { |
|
| 620 | + if (!array_key_exists('sip_'.$name, $data)) { |
|
| 621 | 621 | continue 2; |
| 622 | 622 | } |
| 623 | - if ($data['sip_' . $name] === 'none') { |
|
| 623 | + if ($data['sip_'.$name] === 'none') { |
|
| 624 | 624 | $sipEntity->$name = null; |
| 625 | 625 | } else { |
| 626 | - $sipEntity->$name = $data['sip_' . $name]; |
|
| 626 | + $sipEntity->$name = $data['sip_'.$name]; |
|
| 627 | 627 | } |
| 628 | 628 | break; |
| 629 | 629 | case 'extension': |
@@ -636,8 +636,8 @@ discard block |
||
| 636 | 636 | $sipEntity->setManualAttributes($data['sip_manualattributes']); |
| 637 | 637 | break; |
| 638 | 638 | default: |
| 639 | - if (array_key_exists('sip_' . $name, $data)) { |
|
| 640 | - $sipEntity->$name = $data['sip_' . $name]; |
|
| 639 | + if (array_key_exists('sip_'.$name, $data)) { |
|
| 640 | + $sipEntity->$name = $data['sip_'.$name]; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | } |
@@ -672,9 +672,9 @@ discard block |
||
| 672 | 672 | 'codec' => $key, |
| 673 | 673 | ], |
| 674 | 674 | ]; |
| 675 | - if (array_key_exists('codec_' . $key, $data) && $data['codec_' . $key] === 'on') { |
|
| 675 | + if (array_key_exists('codec_'.$key, $data) && $data['codec_'.$key] === 'on') { |
|
| 676 | 676 | $newCodec = SipCodecs::findFirst($parameters); |
| 677 | - if ( ! $newCodec) { |
|
| 677 | + if (!$newCodec) { |
|
| 678 | 678 | $newCodec = new SipCodecs(); |
| 679 | 679 | } |
| 680 | 680 | $newCodec->sipuid = $data['sip_uniqid']; |
@@ -723,16 +723,16 @@ discard block |
||
| 723 | 723 | $externalPhone->$name = $data['user_username']; |
| 724 | 724 | break; |
| 725 | 725 | case 'disabled': |
| 726 | - if (array_key_exists('mobile_' . $name, $data)) { |
|
| 727 | - $externalPhone->$name = ($data['mobile_' . $name] === 'on') ? '1' : '0'; |
|
| 726 | + if (array_key_exists('mobile_'.$name, $data)) { |
|
| 727 | + $externalPhone->$name = ($data['mobile_'.$name] === 'on') ? '1' : '0'; |
|
| 728 | 728 | |
| 729 | 729 | } else { |
| 730 | 730 | $externalPhone->$name = '0'; |
| 731 | 731 | } |
| 732 | 732 | break; |
| 733 | 733 | default: |
| 734 | - if (array_key_exists('mobile_' . $name, $data)) { |
|
| 735 | - $externalPhone->$name = $data['mobile_' . $name]; |
|
| 734 | + if (array_key_exists('mobile_'.$name, $data)) { |
|
| 735 | + $externalPhone->$name = $data['mobile_'.$name]; |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | } |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | $forwardingRight->$name = $data['number']; |
| 765 | 765 | break; |
| 766 | 766 | default: |
| 767 | - if (array_key_exists('fwd_' . $name, $data)) { |
|
| 768 | - $forwardingRight->$name = ($data['fwd_' . $name] === -1) ? '' : $data['fwd_' . $name]; |
|
| 767 | + if (array_key_exists('fwd_'.$name, $data)) { |
|
| 768 | + $forwardingRight->$name = ($data['fwd_'.$name] === -1) ? '' : $data['fwd_'.$name]; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | } |
@@ -790,11 +790,11 @@ discard block |
||
| 790 | 790 | 'conditions' => 'type = "SIP"', |
| 791 | 791 | 'column' => 'number', |
| 792 | 792 | ]; |
| 793 | - $query = Extensions::maximum($parameters); |
|
| 793 | + $query = Extensions::maximum($parameters); |
|
| 794 | 794 | if ($query === null) { |
| 795 | 795 | $query = 200; |
| 796 | 796 | } |
| 797 | - $result = (int)$query + 1; |
|
| 797 | + $result = (int) $query + 1; |
|
| 798 | 798 | $extensionsLength |
| 799 | 799 | = PbxSettings::getValueByKey('PBXInternalExtensionLength'); |
| 800 | 800 | $maxExtension = (10 ** $extensionsLength) - 1; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | */ |
| 879 | 879 | public function GetPhonesRepresentAction(): void |
| 880 | 880 | { |
| 881 | - if ( ! $this->request->isPost()) { |
|
| 881 | + if (!$this->request->isPost()) { |
|
| 882 | 882 | return; |
| 883 | 883 | } |
| 884 | 884 | $numbers = $this->request->getPost('numbers'); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | 'hostname' => $provByType->host, |
| 33 | 33 | 'type' => $provider->type, |
| 34 | 34 | 'status' => $provByType->disabled ? 'disabled' : '', |
| 35 | - 'existLinks'=>$provider->OutgoingRouting->count()>0?'true':'false' |
|
| 35 | + 'existLinks'=>$provider->OutgoingRouting->count() > 0 ? 'true' : 'false' |
|
| 36 | 36 | |
| 37 | 37 | ]; |
| 38 | 38 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | } else { |
| 69 | - $uniqid = strtoupper('SIP-' . time()); |
|
| 69 | + $uniqid = strtoupper('SIP-'.time()); |
|
| 70 | 70 | $provider = new Providers(); |
| 71 | 71 | $provider->type = 'SIP'; |
| 72 | 72 | $provider->uniqid = $uniqid; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | } else { |
| 116 | - $uniqid = strtoupper('IAX-' . time()); |
|
| 116 | + $uniqid = strtoupper('IAX-'.time()); |
|
| 117 | 117 | $provider = new Providers(); |
| 118 | 118 | $provider->type = 'IAX'; |
| 119 | 119 | $provider->uniqid = $uniqid; |
@@ -203,14 +203,14 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function saveAction($type) |
| 205 | 205 | { |
| 206 | - if ( ! $this->request->isPost()) { |
|
| 206 | + if (!$this->request->isPost()) { |
|
| 207 | 207 | return $this->forward('network/index'); |
| 208 | 208 | } |
| 209 | 209 | $this->db->begin(); |
| 210 | 210 | $data = $this->request->getPost(); |
| 211 | 211 | |
| 212 | 212 | // Заполним параметры провайдера и его SIP IAX записей |
| 213 | - if ( ! $this->saveProvider($data, $type)) { |
|
| 213 | + if (!$this->saveProvider($data, $type)) { |
|
| 214 | 214 | $this->view->success = false; |
| 215 | 215 | $this->db->rollback(); |
| 216 | 216 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // Заполним параметры Кодеков |
| 221 | - if ( ! $this->saveCodecs($data, $type)) { |
|
| 221 | + if (!$this->saveCodecs($data, $type)) { |
|
| 222 | 222 | $this->view->success = false; |
| 223 | 223 | $this->db->rollback(); |
| 224 | 224 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | // Проверим это новый провайдер или старый |
| 250 | 250 | $provider = Providers::findFirstByUniqid($data['uniqid']); |
| 251 | - if ( ! $provider) { |
|
| 251 | + if (!$provider) { |
|
| 252 | 252 | $provider = new Providers(); |
| 253 | 253 | $provider->uniqid = $data['uniqid']; |
| 254 | 254 | switch ($type) { |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | 'codec' => $key, |
| 347 | 347 | ], |
| 348 | 348 | ]; |
| 349 | - if (array_key_exists('codec_' . $key, $data) && $data['codec_' . $key] == 'on') { |
|
| 349 | + if (array_key_exists('codec_'.$key, $data) && $data['codec_'.$key] == 'on') { |
|
| 350 | 350 | $newCodec = $classCodecs::findFirst($parameters); |
| 351 | - if ( ! $newCodec) { |
|
| 351 | + if (!$newCodec) { |
|
| 352 | 352 | $newCodec = new $classCodecs(); |
| 353 | 353 | } |
| 354 | 354 | $newCodec->$fieldUid = $data['uniqid']; |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | if ($provider) { |
| 391 | 391 | $this->db->begin(); |
| 392 | 392 | $errors = false; |
| 393 | - if ($provider->Iax && ! $provider->Iax->delete()) { |
|
| 393 | + if ($provider->Iax && !$provider->Iax->delete()) { |
|
| 394 | 394 | $errors = $provider->Iax->getMessages(); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if ($provider->Sip && ! $provider->Sip->delete()) { |
|
| 397 | + if ($provider->Sip && !$provider->Sip->delete()) { |
|
| 398 | 398 | $errors = $provider->Sip->getMessages(); |
| 399 | 399 | } |
| 400 | 400 | |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * Инициализация базововго класса |
| 26 | 26 | */ |
| 27 | - public function initialize(){ |
|
| 27 | + public function initialize() { |
|
| 28 | 28 | $this->di = $this->getDi(); |
| 29 | 29 | $this->actionName = $this->dispatcher->getActionName(); |
| 30 | - $this->controllerName = Text::camelize($this->dispatcher->getControllerName(),'_'); |
|
| 31 | - $this->controllerNameUnCamelized = Text::uncamelize( $this->controllerName ,'-'); |
|
| 30 | + $this->controllerName = Text::camelize($this->dispatcher->getControllerName(), '_'); |
|
| 31 | + $this->controllerNameUnCamelized = Text::uncamelize($this->controllerName, '-'); |
|
| 32 | 32 | |
| 33 | 33 | $this->moduleName = $this->dispatcher->getModuleName(); |
| 34 | 34 | |
| 35 | - if ( $this->request->isAjax() === FALSE ) { |
|
| 35 | + if ($this->request->isAjax() === FALSE) { |
|
| 36 | 36 | $this->prepareView( ); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -42,33 +42,33 @@ discard block |
||
| 42 | 42 | * Инициализирует шаблонизатор View и устанавливает переменные системы для отображения |
| 43 | 43 | */ |
| 44 | 44 | protected function prepareView() :void{ |
| 45 | - date_default_timezone_set( $this->getSessionData('PBXTimezone') ); |
|
| 46 | - $roSession = $this->sessionRO; |
|
| 45 | + date_default_timezone_set($this->getSessionData('PBXTimezone')); |
|
| 46 | + $roSession = $this->sessionRO; |
|
| 47 | 47 | $this->view->PBXVersion = $this->getSessionData('PBXVersion'); |
| 48 | - if ( $roSession !== null && array_key_exists('auth', $roSession)) { |
|
| 48 | + if ($roSession !== null && array_key_exists('auth', $roSession)) { |
|
| 49 | 49 | $this->view->SSHPort = $this->getSessionData('SSHPort'); |
| 50 | 50 | $this->view->PBXLicense = $this->getSessionData('PBXLicense'); |
| 51 | - $this->view->PBXLanguage= $this->getSessionData('PBXLanguage'); |
|
| 51 | + $this->view->PBXLanguage = $this->getSessionData('PBXLanguage'); |
|
| 52 | 52 | } else { |
| 53 | 53 | $this->view->SSHPort = ''; |
| 54 | 54 | $this->view->PBXLicense = ''; |
| 55 | - $this->view->PBXLanguage= ''; |
|
| 55 | + $this->view->PBXLanguage = ''; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Кеш версий модулей и атс, для правильной работы АТС при установке модулей |
| 59 | 59 | $versionHash = $this->getVersionsHash(); |
| 60 | - $this->session->set( 'versionHash', $versionHash); |
|
| 60 | + $this->session->set('versionHash', $versionHash); |
|
| 61 | 61 | |
| 62 | - if ( $roSession !== null && array_key_exists('SubmitMode', $roSession)) { |
|
| 63 | - $this->view->submitMode = $roSession[ 'SubmitMode' ]; |
|
| 62 | + if ($roSession !== null && array_key_exists('SubmitMode', $roSession)) { |
|
| 63 | + $this->view->submitMode = $roSession['SubmitMode']; |
|
| 64 | 64 | } else { |
| 65 | 65 | $this->view->submitMode = 'SaveSettings'; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Добавим версию модуля, если это модуль |
| 69 | - if ( $this->moduleName === 'PBXExtension' ) { |
|
| 70 | - $module = PbxExtensionModules::findFirstByUniqid( $this->controllerName ); |
|
| 71 | - if ( !$module ) { |
|
| 69 | + if ($this->moduleName === 'PBXExtension') { |
|
| 70 | + $module = PbxExtensionModules::findFirstByUniqid($this->controllerName); |
|
| 71 | + if (!$module) { |
|
| 72 | 72 | $module = new PbxExtensionModules(); |
| 73 | 73 | $module->disabled = '1'; |
| 74 | 74 | $module->name = 'Unknown module'; |
@@ -77,36 +77,36 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // Разрешим отправку анонимной информации об ошибках |
| 80 | - if ($this->getSessionData('SendMetrics') === '1'){ |
|
| 80 | + if ($this->getSessionData('SendMetrics') === '1') { |
|
| 81 | 81 | touch('/tmp/sendmetrics'); |
| 82 | 82 | $this->view->lastSentryEventId = Sentry\State\Hub::getCurrent()->getLastEventId(); |
| 83 | 83 | } else { |
| 84 | - if (file_exists('/tmp/sendmetrics')){ |
|
| 84 | + if (file_exists('/tmp/sendmetrics')) { |
|
| 85 | 85 | unlink('/tmp/sendmetrics'); |
| 86 | 86 | } |
| 87 | 87 | $this->view->lastSentryEventId = Null; |
| 88 | 88 | } |
| 89 | - switch ( $this->actionName ) { |
|
| 89 | + switch ($this->actionName) { |
|
| 90 | 90 | case'index': |
| 91 | 91 | case'delete': |
| 92 | 92 | case'save': |
| 93 | 93 | case'modify': |
| 94 | 94 | case'*** WITHOUT ACTION ***': |
| 95 | - $this->tag->setTitle( $this->config->application->kind . ' | ' |
|
| 96 | - . $this->translation->_( 'Breadcrumb' |
|
| 97 | - . $this->controllerName ) ); |
|
| 95 | + $this->tag->setTitle($this->config->application->kind.' | ' |
|
| 96 | + . $this->translation->_('Breadcrumb' |
|
| 97 | + . $this->controllerName)); |
|
| 98 | 98 | break; |
| 99 | 99 | default: |
| 100 | - $this->tag->setTitle( $this->config->application->kind . ' | ' |
|
| 101 | - . $this->translation->_( 'Breadcrumb' |
|
| 100 | + $this->tag->setTitle($this->config->application->kind.' | ' |
|
| 101 | + . $this->translation->_('Breadcrumb' |
|
| 102 | 102 | . $this->controllerName |
| 103 | - . $this->actionName ) ); |
|
| 103 | + . $this->actionName)); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $this->view->t = $this->translation; |
| 107 | 107 | $this->view->debugMode = $this->config->application->debugMode; |
| 108 | - $this->view->urlToLogo = $this->url->get( 'public/img/logo-mikopbx.svg' ); |
|
| 109 | - if ($this->language === 'ru'){ |
|
| 108 | + $this->view->urlToLogo = $this->url->get('public/img/logo-mikopbx.svg'); |
|
| 109 | + if ($this->language === 'ru') { |
|
| 110 | 110 | $this->view->urlToWiki |
| 111 | 111 | = "https://wiki.mikopbx.com/{$this->controllerNameUnCamelized}"; |
| 112 | 112 | } else { |
@@ -114,25 +114,25 @@ discard block |
||
| 114 | 114 | = "https://wiki.mikopbx.com/{$this->language}:{$this->controllerNameUnCamelized}"; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $this->view->urlToController = $this->url->get( $this->controllerNameUnCamelized ); |
|
| 117 | + $this->view->urlToController = $this->url->get($this->controllerNameUnCamelized); |
|
| 118 | 118 | $this->view->represent = ''; |
| 119 | 119 | $this->view->cacheName = "{$this->controllerName}{$this->actionName}{$this->language}{$versionHash}"; |
| 120 | 120 | |
| 121 | 121 | // Подключим нужный View |
| 122 | - if ( $this->moduleName === 'PBXExtension' ) { |
|
| 123 | - $this->view->setTemplateAfter( 'modules' ); |
|
| 122 | + if ($this->moduleName === 'PBXExtension') { |
|
| 123 | + $this->view->setTemplateAfter('modules'); |
|
| 124 | 124 | } else { |
| 125 | - $this->view->setTemplateAfter( 'main' ); |
|
| 125 | + $this->view->setTemplateAfter('main'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Для модулей кинем в кеш все статические картинки |
| 129 | - if ( $this->moduleName === 'PBXExtension' ) { |
|
| 129 | + if ($this->moduleName === 'PBXExtension') { |
|
| 130 | 130 | $modulesDir = $this->getDI()->getModulesDir(); |
| 131 | - $moduleImageDir = $modulesDir . $this->controllerName.'/public/img'; |
|
| 131 | + $moduleImageDir = $modulesDir.$this->controllerName.'/public/img'; |
|
| 132 | 132 | $moduleImageCacheDir = $this->config->application->imgCacheDir.$this->controllerName; |
| 133 | 133 | if (file_exists($moduleImageDir) |
| 134 | - && !file_exists($moduleImageCacheDir)){ |
|
| 135 | - symlink ( $moduleImageDir, $moduleImageCacheDir ); |
|
| 134 | + && !file_exists($moduleImageCacheDir)) { |
|
| 135 | + symlink($moduleImageDir, $moduleImageCacheDir); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -144,34 +144,34 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface |
| 146 | 146 | */ |
| 147 | - public function afterExecuteRoute( Dispatcher $dispatcher ) { |
|
| 148 | - if ( $this->request->isAjax() === TRUE ) { |
|
| 149 | - $this->view->disableLevel( [ |
|
| 147 | + public function afterExecuteRoute(Dispatcher $dispatcher) { |
|
| 148 | + if ($this->request->isAjax() === TRUE) { |
|
| 149 | + $this->view->disableLevel([ |
|
| 150 | 150 | View::LEVEL_ACTION_VIEW => TRUE, |
| 151 | 151 | View::LEVEL_LAYOUT => TRUE, |
| 152 | 152 | View::LEVEL_MAIN_LAYOUT => TRUE, |
| 153 | 153 | View::LEVEL_AFTER_TEMPLATE => TRUE, |
| 154 | 154 | View::LEVEL_BEFORE_TEMPLATE => TRUE, |
| 155 | - ] ); |
|
| 156 | - $this->response->setContentType( 'application/json', 'UTF-8' ); |
|
| 155 | + ]); |
|
| 156 | + $this->response->setContentType('application/json', 'UTF-8'); |
|
| 157 | 157 | $data = $this->view->getParamsToView(); |
| 158 | 158 | |
| 159 | 159 | /* Set global params if is not set in controller/action */ |
| 160 | - if (is_array($data) && isset($data['raw_response'])){ |
|
| 160 | + if (is_array($data) && isset($data['raw_response'])) { |
|
| 161 | 161 | $result = $data['raw_response']; |
| 162 | - } elseif ( is_array( $data ) ) { |
|
| 163 | - $data['success'] = array_key_exists( 'success', $data ) ? $data['success'] : TRUE; |
|
| 164 | - $data['reload'] = array_key_exists( 'reload', $data ) ? $data['reload'] : FALSE; |
|
| 162 | + } elseif (is_array($data)) { |
|
| 163 | + $data['success'] = array_key_exists('success', $data) ? $data['success'] : TRUE; |
|
| 164 | + $data['reload'] = array_key_exists('reload', $data) ? $data['reload'] : FALSE; |
|
| 165 | 165 | $data['message'] = $data['message'] ?? $this->flash->getMessages(); |
| 166 | 166 | |
| 167 | 167 | // Добавим информацию о последней ошибке для отображения диалогового окна для пользователя |
| 168 | 168 | if (file_exists('/tmp/sendmetrics')) { |
| 169 | 169 | $data['lastSentryEventId'] = Sentry\State\Hub::getCurrent()->getLastEventId(); |
| 170 | 170 | } |
| 171 | - $result = json_encode( $data ); |
|
| 171 | + $result = json_encode($data); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $this->response->setContent( $result ); |
|
| 174 | + $this->response->setContent($result); |
|
| 175 | 175 | } |
| 176 | 176 | return $this->response->send(); |
| 177 | 177 | } |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | * Перехват события перед обработкой в контроллере |
| 181 | 181 | */ |
| 182 | 182 | public function beforeExecuteRoute() :void{ |
| 183 | - if ($this->request->isPost()){ |
|
| 183 | + if ($this->request->isPost()) { |
|
| 184 | 184 | $data = $this->request->getPost('submitMode'); |
| 185 | - if (!empty($data)){ |
|
| 185 | + if (!empty($data)) { |
|
| 186 | 186 | $this->session->set('SubmitMode', $data); |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param string $uri |
| 195 | 195 | */ |
| 196 | - protected function forward( $uri ) { |
|
| 197 | - $uriParts = explode( '/', $uri ); |
|
| 198 | - $params = array_slice( $uriParts, 2 ); |
|
| 196 | + protected function forward($uri) { |
|
| 197 | + $uriParts = explode('/', $uri); |
|
| 198 | + $params = array_slice($uriParts, 2); |
|
| 199 | 199 | |
| 200 | 200 | return $this->dispatcher->forward( |
| 201 | 201 | [ |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | - protected function transliterate( $string ) :string{ |
|
| 217 | + protected function transliterate($string) :string{ |
|
| 218 | 218 | |
| 219 | 219 | $converter = [ |
| 220 | 220 | 'а' => 'a', |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | 'Я' => 'Ya', |
| 287 | 287 | ]; |
| 288 | 288 | |
| 289 | - return strtr( $string, $converter ); |
|
| 289 | + return strtr($string, $converter); |
|
| 290 | 290 | |
| 291 | 291 | } |
| 292 | 292 | |
@@ -295,10 +295,10 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | */ |
| 297 | 297 | private function getVersionsHash() :string{ |
| 298 | - $result = Models\PbxSettings::getValueByKey( 'PBXVersion' ); |
|
| 298 | + $result = Models\PbxSettings::getValueByKey('PBXVersion'); |
|
| 299 | 299 | $modulesVersions = Models\PbxExtensionModules::find(['columns'=>'id,version']); |
| 300 | 300 | foreach ($modulesVersions as $module) { |
| 301 | - $result.="{$module->version}{$module->version}"; |
|
| 301 | + $result .= "{$module->version}{$module->version}"; |
|
| 302 | 302 | } |
| 303 | 303 | return md5($result); |
| 304 | 304 | } |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | * @return string |
| 312 | 312 | */ |
| 313 | 313 | protected function getSessionData($key) :string{ |
| 314 | - $roSession = $this->sessionRO; |
|
| 315 | - if ( $roSession !== null && array_key_exists($key, $roSession) && !empty($roSession[ $key ])) { |
|
| 316 | - $value = $roSession[ $key ]; |
|
| 314 | + $roSession = $this->sessionRO; |
|
| 315 | + if ($roSession !== null && array_key_exists($key, $roSession) && !empty($roSession[$key])) { |
|
| 316 | + $value = $roSession[$key]; |
|
| 317 | 317 | } else { |
| 318 | - $value = Models\PbxSettings::getValueByKey( $key ) ; |
|
| 319 | - $this->session->set( $key, $value); |
|
| 318 | + $value = Models\PbxSettings::getValueByKey($key); |
|
| 319 | + $this->session->set($key, $value); |
|
| 320 | 320 | } |
| 321 | 321 | return $value; |
| 322 | 322 | } |
@@ -13,7 +13,8 @@ discard block |
||
| 13 | 13 | use Phalcon\Mvc\View; |
| 14 | 14 | use Phalcon\Text; |
| 15 | 15 | |
| 16 | -class BaseController extends Controller { |
|
| 16 | +class BaseController extends Controller |
|
| 17 | +{ |
|
| 17 | 18 | |
| 18 | 19 | protected $di; |
| 19 | 20 | protected $actionName; |
@@ -24,7 +25,8 @@ discard block |
||
| 24 | 25 | /** |
| 25 | 26 | * Инициализация базововго класса |
| 26 | 27 | */ |
| 27 | - public function initialize(){ |
|
| 28 | + public function initialize() |
|
| 29 | + { |
|
| 28 | 30 | $this->di = $this->getDi(); |
| 29 | 31 | $this->actionName = $this->dispatcher->getActionName(); |
| 30 | 32 | $this->controllerName = Text::camelize($this->dispatcher->getControllerName(),'_'); |
@@ -144,7 +146,8 @@ discard block |
||
| 144 | 146 | * |
| 145 | 147 | * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface |
| 146 | 148 | */ |
| 147 | - public function afterExecuteRoute( Dispatcher $dispatcher ) { |
|
| 149 | + public function afterExecuteRoute( Dispatcher $dispatcher ) |
|
| 150 | + { |
|
| 148 | 151 | if ( $this->request->isAjax() === TRUE ) { |
| 149 | 152 | $this->view->disableLevel( [ |
| 150 | 153 | View::LEVEL_ACTION_VIEW => TRUE, |
@@ -193,7 +196,8 @@ discard block |
||
| 193 | 196 | * |
| 194 | 197 | * @param string $uri |
| 195 | 198 | */ |
| 196 | - protected function forward( $uri ) { |
|
| 199 | + protected function forward( $uri ) |
|
| 200 | + { |
|
| 197 | 201 | $uriParts = explode( '/', $uri ); |
| 198 | 202 | $params = array_slice( $uriParts, 2 ); |
| 199 | 203 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $this->moduleName = $this->dispatcher->getModuleName(); |
| 34 | 34 | |
| 35 | - if ( $this->request->isAjax() === FALSE ) { |
|
| 35 | + if ( $this->request->isAjax() === false ) { |
|
| 36 | 36 | $this->prepareView( ); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | if (file_exists('/tmp/sendmetrics')){ |
| 85 | 85 | unlink('/tmp/sendmetrics'); |
| 86 | 86 | } |
| 87 | - $this->view->lastSentryEventId = Null; |
|
| 87 | + $this->view->lastSentryEventId = null; |
|
| 88 | 88 | } |
| 89 | 89 | switch ( $this->actionName ) { |
| 90 | 90 | case'index': |
@@ -145,13 +145,13 @@ discard block |
||
| 145 | 145 | * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface |
| 146 | 146 | */ |
| 147 | 147 | public function afterExecuteRoute( Dispatcher $dispatcher ) { |
| 148 | - if ( $this->request->isAjax() === TRUE ) { |
|
| 148 | + if ( $this->request->isAjax() === true ) { |
|
| 149 | 149 | $this->view->disableLevel( [ |
| 150 | - View::LEVEL_ACTION_VIEW => TRUE, |
|
| 151 | - View::LEVEL_LAYOUT => TRUE, |
|
| 152 | - View::LEVEL_MAIN_LAYOUT => TRUE, |
|
| 153 | - View::LEVEL_AFTER_TEMPLATE => TRUE, |
|
| 154 | - View::LEVEL_BEFORE_TEMPLATE => TRUE, |
|
| 150 | + View::LEVEL_ACTION_VIEW => true, |
|
| 151 | + View::LEVEL_LAYOUT => true, |
|
| 152 | + View::LEVEL_MAIN_LAYOUT => true, |
|
| 153 | + View::LEVEL_AFTER_TEMPLATE => true, |
|
| 154 | + View::LEVEL_BEFORE_TEMPLATE => true, |
|
| 155 | 155 | ] ); |
| 156 | 156 | $this->response->setContentType( 'application/json', 'UTF-8' ); |
| 157 | 157 | $data = $this->view->getParamsToView(); |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | if (is_array($data) && isset($data['raw_response'])){ |
| 161 | 161 | $result = $data['raw_response']; |
| 162 | 162 | } elseif ( is_array( $data ) ) { |
| 163 | - $data['success'] = array_key_exists( 'success', $data ) ? $data['success'] : TRUE; |
|
| 164 | - $data['reload'] = array_key_exists( 'reload', $data ) ? $data['reload'] : FALSE; |
|
| 163 | + $data['success'] = array_key_exists( 'success', $data ) ? $data['success'] : true; |
|
| 164 | + $data['reload'] = array_key_exists( 'reload', $data ) ? $data['reload'] : false; |
|
| 165 | 165 | $data['message'] = $data['message'] ?? $this->flash->getMessages(); |
| 166 | 166 | |
| 167 | 167 | // Добавим информацию о последней ошибке для отображения диалогового окна для пользователя |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | class OutboundRoutesController extends BaseController { |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Построениие списка исходящих маршрутов |
|
| 19 | - */ |
|
| 17 | + /** |
|
| 18 | + * Построениие списка исходящих маршрутов |
|
| 19 | + */ |
|
| 20 | 20 | public function indexAction() |
| 21 | 21 | { |
| 22 | 22 | |
@@ -25,112 +25,112 @@ discard block |
||
| 25 | 25 | foreach ($rules as $rule){ |
| 26 | 26 | $provider = $rule->Providers; |
| 27 | 27 | if ($provider){ |
| 28 | - $modelType = ucfirst( $provider->type ); |
|
| 29 | - $provByType = $provider->$modelType; |
|
| 30 | - $routingTable[] =[ |
|
| 31 | - 'id' => $rule->id, |
|
| 32 | - 'priority' => $rule->priority, |
|
| 33 | - 'provider' => $provider->getRepresent(), |
|
| 34 | - 'numberbeginswith' => $rule->numberbeginswith, |
|
| 35 | - 'restnumbers' => $rule->restnumbers, |
|
| 36 | - 'trimfrombegin' => $rule->trimfrombegin, |
|
| 37 | - 'prepend' => $rule->prepend, |
|
| 38 | - 'note' => $rule->note, |
|
| 39 | - 'rulename' => $rule->getRepresent(), |
|
| 40 | - 'disabled' => $provByType->disabled, |
|
| 41 | - ]; |
|
| 42 | - } else { |
|
| 43 | - $routingTable[] =[ |
|
| 44 | - 'id' => $rule->id, |
|
| 45 | - 'priority' => $rule->priority, |
|
| 46 | - 'provider' => null, |
|
| 47 | - 'numberbeginswith' => $rule->numberbeginswith, |
|
| 48 | - 'restnumbers' => $rule->restnumbers, |
|
| 49 | - 'trimfrombegin' => $rule->trimfrombegin, |
|
| 50 | - 'prepend' => $rule->prepend, |
|
| 51 | - 'note' => $rule->note, |
|
| 52 | - 'rulename' => '<i class="icon attention"></i> '.$rule->getRepresent(), |
|
| 53 | - 'disabled' => false, |
|
| 54 | - ]; |
|
| 55 | - } |
|
| 28 | + $modelType = ucfirst( $provider->type ); |
|
| 29 | + $provByType = $provider->$modelType; |
|
| 30 | + $routingTable[] =[ |
|
| 31 | + 'id' => $rule->id, |
|
| 32 | + 'priority' => $rule->priority, |
|
| 33 | + 'provider' => $provider->getRepresent(), |
|
| 34 | + 'numberbeginswith' => $rule->numberbeginswith, |
|
| 35 | + 'restnumbers' => $rule->restnumbers, |
|
| 36 | + 'trimfrombegin' => $rule->trimfrombegin, |
|
| 37 | + 'prepend' => $rule->prepend, |
|
| 38 | + 'note' => $rule->note, |
|
| 39 | + 'rulename' => $rule->getRepresent(), |
|
| 40 | + 'disabled' => $provByType->disabled, |
|
| 41 | + ]; |
|
| 42 | + } else { |
|
| 43 | + $routingTable[] =[ |
|
| 44 | + 'id' => $rule->id, |
|
| 45 | + 'priority' => $rule->priority, |
|
| 46 | + 'provider' => null, |
|
| 47 | + 'numberbeginswith' => $rule->numberbeginswith, |
|
| 48 | + 'restnumbers' => $rule->restnumbers, |
|
| 49 | + 'trimfrombegin' => $rule->trimfrombegin, |
|
| 50 | + 'prepend' => $rule->prepend, |
|
| 51 | + 'note' => $rule->note, |
|
| 52 | + 'rulename' => '<i class="icon attention"></i> '.$rule->getRepresent(), |
|
| 53 | + 'disabled' => false, |
|
| 54 | + ]; |
|
| 55 | + } |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $this->view->routingTable = $routingTable; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Карточка редактирования исходящего маршрута |
|
| 63 | - * @param null $id |
|
| 64 | - */ |
|
| 65 | - public function modifyAction($id=null){ |
|
| 61 | + /** |
|
| 62 | + * Карточка редактирования исходящего маршрута |
|
| 63 | + * @param null $id |
|
| 64 | + */ |
|
| 65 | + public function modifyAction($id=null){ |
|
| 66 | 66 | |
| 67 | - $rule = OutgoingRoutingTable::findFirstByid($id); |
|
| 68 | - if (!$rule) $rule = new OutgoingRoutingTable(); |
|
| 67 | + $rule = OutgoingRoutingTable::findFirstByid($id); |
|
| 68 | + if (!$rule) $rule = new OutgoingRoutingTable(); |
|
| 69 | 69 | |
| 70 | - $providers = Providers::find(); |
|
| 71 | - $providersList = array(); |
|
| 72 | - foreach ($providers as $provider){ |
|
| 73 | - $providersList[ $provider->uniqid ] = $provider->getRepresent(); |
|
| 74 | - } |
|
| 70 | + $providers = Providers::find(); |
|
| 71 | + $providersList = array(); |
|
| 72 | + foreach ($providers as $provider){ |
|
| 73 | + $providersList[ $provider->uniqid ] = $provider->getRepresent(); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - uasort($providersList, ["OutboundRoutesController", "sortArrayByNameAndState"]); |
|
| 76 | + uasort($providersList, ["OutboundRoutesController", "sortArrayByNameAndState"]); |
|
| 77 | 77 | |
| 78 | - if ($rule->restnumbers == -1){ |
|
| 79 | - $rule->restnumbers = ''; |
|
| 80 | - } |
|
| 81 | - $this->view->form = new OutgoingRouteEditForm($rule, $providersList); |
|
| 82 | - $this->view->represent = $rule->getRepresent(); |
|
| 78 | + if ($rule->restnumbers == -1){ |
|
| 79 | + $rule->restnumbers = ''; |
|
| 80 | + } |
|
| 81 | + $this->view->form = new OutgoingRouteEditForm($rule, $providersList); |
|
| 82 | + $this->view->represent = $rule->getRepresent(); |
|
| 83 | 83 | |
| 84 | - } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Сохранение карточки исходящего маршрута |
|
| 88 | - */ |
|
| 86 | + /** |
|
| 87 | + * Сохранение карточки исходящего маршрута |
|
| 88 | + */ |
|
| 89 | 89 | public function saveAction() |
| 90 | 90 | { |
| 91 | - $this->db->begin(); |
|
| 92 | - |
|
| 93 | - $data = $this->request->getPost(); |
|
| 94 | - |
|
| 95 | - $rule = OutgoingRoutingTable::findFirstByid($data['id']); |
|
| 96 | - if (!$rule) $rule = new OutgoingRoutingTable(); |
|
| 97 | - |
|
| 98 | - foreach ($rule as $name => $value) { |
|
| 99 | - switch($name) { |
|
| 100 | - case 'restnumbers':{ |
|
| 101 | - if (!array_key_exists($name, $data)) continue; |
|
| 102 | - $rule->$name = $data[$name]==''?-1:$data[$name]; |
|
| 103 | - break; |
|
| 104 | - } |
|
| 105 | - default: |
|
| 106 | - if (!array_key_exists($name, $data)) continue; |
|
| 107 | - $rule->$name = $data[$name]; |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - if ($rule->save() === false) { |
|
| 112 | - $errors = $rule->getMessages(); |
|
| 113 | - $this->flash->warning(implode('<br>', $errors)); |
|
| 114 | - $this->view->success = false; |
|
| 115 | - $this->db->rollback(); |
|
| 116 | - return; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - $this->flash->success($this->translation->_('ms_SuccessfulSaved')); |
|
| 120 | - $this->view->success=true; |
|
| 121 | - $this->db->commit(); |
|
| 122 | - |
|
| 123 | - // Если это было создание карточки то надо перегрузить страницу с указанием ID |
|
| 124 | - if (empty($data['id'])){ |
|
| 125 | - $this->view->reload = "outbound-routes/modify/{$rule->id}"; |
|
| 126 | - } |
|
| 91 | + $this->db->begin(); |
|
| 92 | + |
|
| 93 | + $data = $this->request->getPost(); |
|
| 94 | + |
|
| 95 | + $rule = OutgoingRoutingTable::findFirstByid($data['id']); |
|
| 96 | + if (!$rule) $rule = new OutgoingRoutingTable(); |
|
| 97 | + |
|
| 98 | + foreach ($rule as $name => $value) { |
|
| 99 | + switch($name) { |
|
| 100 | + case 'restnumbers':{ |
|
| 101 | + if (!array_key_exists($name, $data)) continue; |
|
| 102 | + $rule->$name = $data[$name]==''?-1:$data[$name]; |
|
| 103 | + break; |
|
| 104 | + } |
|
| 105 | + default: |
|
| 106 | + if (!array_key_exists($name, $data)) continue; |
|
| 107 | + $rule->$name = $data[$name]; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + if ($rule->save() === false) { |
|
| 112 | + $errors = $rule->getMessages(); |
|
| 113 | + $this->flash->warning(implode('<br>', $errors)); |
|
| 114 | + $this->view->success = false; |
|
| 115 | + $this->db->rollback(); |
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + $this->flash->success($this->translation->_('ms_SuccessfulSaved')); |
|
| 120 | + $this->view->success=true; |
|
| 121 | + $this->db->commit(); |
|
| 122 | + |
|
| 123 | + // Если это было создание карточки то надо перегрузить страницу с указанием ID |
|
| 124 | + if (empty($data['id'])){ |
|
| 125 | + $this->view->reload = "outbound-routes/modify/{$rule->id}"; |
|
| 126 | + } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Удаление исходящего маршрута из базы данных |
|
| 132 | - * @param null $id |
|
| 133 | - */ |
|
| 130 | + /** |
|
| 131 | + * Удаление исходящего маршрута из базы данных |
|
| 132 | + * @param null $id |
|
| 133 | + */ |
|
| 134 | 134 | public function deleteAction($id=null){ |
| 135 | 135 | $rule = OutgoingRoutingTable::findFirstByid($id); |
| 136 | 136 | if ($rule) $rule->delete(); |
@@ -138,36 +138,36 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Изменение приоритета правила |
|
| 143 | - * @param null $ruleid |
|
| 144 | - */ |
|
| 145 | - public function changePriorityAction($ruleid=null){ |
|
| 146 | - $this->view->disable(); |
|
| 147 | - $result = false; |
|
| 148 | - |
|
| 149 | - if (!$this->request->isPost()) { |
|
| 150 | - return; |
|
| 151 | - } |
|
| 152 | - $data = $this->request->getPost(); |
|
| 153 | - $rule = OutgoingRoutingTable::findFirstById($ruleid); |
|
| 154 | - if ($rule){ |
|
| 155 | - $rule->priority=intval($data['newPriority']); |
|
| 156 | - $result=$rule->update(); |
|
| 157 | - } |
|
| 158 | - echo json_encode($result); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - private function sortArrayByNameAndState ($a, $b) |
|
| 162 | - { |
|
| 163 | - $sDisabled = $this->translation->_('mo_Disabled'); |
|
| 164 | - if ($a == $b) { |
|
| 165 | - return 0; |
|
| 166 | - } elseif (strpos ( $a , $sDisabled)!==false && strpos ( $b , $sDisabled)===false) { |
|
| 167 | - return 1; |
|
| 168 | - } else { |
|
| 169 | - return ($a < $b) ? -1 : 1; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - } |
|
| 141 | + /** |
|
| 142 | + * Изменение приоритета правила |
|
| 143 | + * @param null $ruleid |
|
| 144 | + */ |
|
| 145 | + public function changePriorityAction($ruleid=null){ |
|
| 146 | + $this->view->disable(); |
|
| 147 | + $result = false; |
|
| 148 | + |
|
| 149 | + if (!$this->request->isPost()) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + $data = $this->request->getPost(); |
|
| 153 | + $rule = OutgoingRoutingTable::findFirstById($ruleid); |
|
| 154 | + if ($rule){ |
|
| 155 | + $rule->priority=intval($data['newPriority']); |
|
| 156 | + $result=$rule->update(); |
|
| 157 | + } |
|
| 158 | + echo json_encode($result); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + private function sortArrayByNameAndState ($a, $b) |
|
| 162 | + { |
|
| 163 | + $sDisabled = $this->translation->_('mo_Disabled'); |
|
| 164 | + if ($a == $b) { |
|
| 165 | + return 0; |
|
| 166 | + } elseif (strpos ( $a , $sDisabled)!==false && strpos ( $b , $sDisabled)===false) { |
|
| 167 | + return 1; |
|
| 168 | + } else { |
|
| 169 | + return ($a < $b) ? -1 : 1; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + } |
|
| 173 | 173 | } |
| 174 | 174 | \ No newline at end of file |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | $rules = OutgoingRoutingTable::find(array('order'=>'priority')); |
| 24 | 24 | $routingTable = array(); |
| 25 | - foreach ($rules as $rule){ |
|
| 26 | - $provider = $rule->Providers; |
|
| 27 | - if ($provider){ |
|
| 28 | - $modelType = ucfirst( $provider->type ); |
|
| 25 | + foreach ($rules as $rule) { |
|
| 26 | + $provider = $rule->Providers; |
|
| 27 | + if ($provider) { |
|
| 28 | + $modelType = ucfirst($provider->type); |
|
| 29 | 29 | $provByType = $provider->$modelType; |
| 30 | - $routingTable[] =[ |
|
| 30 | + $routingTable[] = [ |
|
| 31 | 31 | 'id' => $rule->id, |
| 32 | 32 | 'priority' => $rule->priority, |
| 33 | 33 | 'provider' => $provider->getRepresent(), |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'disabled' => $provByType->disabled, |
| 41 | 41 | ]; |
| 42 | 42 | } else { |
| 43 | - $routingTable[] =[ |
|
| 43 | + $routingTable[] = [ |
|
| 44 | 44 | 'id' => $rule->id, |
| 45 | 45 | 'priority' => $rule->priority, |
| 46 | 46 | 'provider' => null, |
@@ -62,24 +62,24 @@ discard block |
||
| 62 | 62 | * Карточка редактирования исходящего маршрута |
| 63 | 63 | * @param null $id |
| 64 | 64 | */ |
| 65 | - public function modifyAction($id=null){ |
|
| 65 | + public function modifyAction($id = null) { |
|
| 66 | 66 | |
| 67 | 67 | $rule = OutgoingRoutingTable::findFirstByid($id); |
| 68 | 68 | if (!$rule) $rule = new OutgoingRoutingTable(); |
| 69 | 69 | |
| 70 | 70 | $providers = Providers::find(); |
| 71 | 71 | $providersList = array(); |
| 72 | - foreach ($providers as $provider){ |
|
| 73 | - $providersList[ $provider->uniqid ] = $provider->getRepresent(); |
|
| 72 | + foreach ($providers as $provider) { |
|
| 73 | + $providersList[$provider->uniqid] = $provider->getRepresent(); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | uasort($providersList, ["OutboundRoutesController", "sortArrayByNameAndState"]); |
| 77 | 77 | |
| 78 | - if ($rule->restnumbers == -1){ |
|
| 78 | + if ($rule->restnumbers == -1) { |
|
| 79 | 79 | $rule->restnumbers = ''; |
| 80 | 80 | } |
| 81 | 81 | $this->view->form = new OutgoingRouteEditForm($rule, $providersList); |
| 82 | - $this->view->represent = $rule->getRepresent(); |
|
| 82 | + $this->view->represent = $rule->getRepresent(); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | if (!$rule) $rule = new OutgoingRoutingTable(); |
| 97 | 97 | |
| 98 | 98 | foreach ($rule as $name => $value) { |
| 99 | - switch($name) { |
|
| 99 | + switch ($name) { |
|
| 100 | 100 | case 'restnumbers':{ |
| 101 | 101 | if (!array_key_exists($name, $data)) continue; |
| 102 | - $rule->$name = $data[$name]==''?-1:$data[$name]; |
|
| 102 | + $rule->$name = $data[$name] == '' ?-1 : $data[$name]; |
|
| 103 | 103 | break; |
| 104 | 104 | } |
| 105 | 105 | default: |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $this->flash->success($this->translation->_('ms_SuccessfulSaved')); |
| 120 | - $this->view->success=true; |
|
| 120 | + $this->view->success = true; |
|
| 121 | 121 | $this->db->commit(); |
| 122 | 122 | |
| 123 | 123 | // Если это было создание карточки то надо перегрузить страницу с указанием ID |
| 124 | - if (empty($data['id'])){ |
|
| 124 | + if (empty($data['id'])) { |
|
| 125 | 125 | $this->view->reload = "outbound-routes/modify/{$rule->id}"; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * Удаление исходящего маршрута из базы данных |
| 132 | 132 | * @param null $id |
| 133 | 133 | */ |
| 134 | - public function deleteAction($id=null){ |
|
| 134 | + public function deleteAction($id = null) { |
|
| 135 | 135 | $rule = OutgoingRoutingTable::findFirstByid($id); |
| 136 | 136 | if ($rule) $rule->delete(); |
| 137 | 137 | return $this->forward('outbound-routes/index'); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * Изменение приоритета правила |
| 143 | 143 | * @param null $ruleid |
| 144 | 144 | */ |
| 145 | - public function changePriorityAction($ruleid=null){ |
|
| 145 | + public function changePriorityAction($ruleid = null) { |
|
| 146 | 146 | $this->view->disable(); |
| 147 | 147 | $result = false; |
| 148 | 148 | |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | $data = $this->request->getPost(); |
| 153 | 153 | $rule = OutgoingRoutingTable::findFirstById($ruleid); |
| 154 | - if ($rule){ |
|
| 155 | - $rule->priority=intval($data['newPriority']); |
|
| 156 | - $result=$rule->update(); |
|
| 154 | + if ($rule) { |
|
| 155 | + $rule->priority = intval($data['newPriority']); |
|
| 156 | + $result = $rule->update(); |
|
| 157 | 157 | } |
| 158 | 158 | echo json_encode($result); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - private function sortArrayByNameAndState ($a, $b) |
|
| 161 | + private function sortArrayByNameAndState($a, $b) |
|
| 162 | 162 | { |
| 163 | 163 | $sDisabled = $this->translation->_('mo_Disabled'); |
| 164 | 164 | if ($a == $b) { |
| 165 | 165 | return 0; |
| 166 | - } elseif (strpos ( $a , $sDisabled)!==false && strpos ( $b , $sDisabled)===false) { |
|
| 166 | + } elseif (strpos($a, $sDisabled) !== false && strpos($b, $sDisabled) === false) { |
|
| 167 | 167 | return 1; |
| 168 | 168 | } else { |
| 169 | 169 | return ($a < $b) ? -1 : 1; |
@@ -11,7 +11,8 @@ discard block |
||
| 11 | 11 | Models\Providers; |
| 12 | 12 | |
| 13 | 13 | |
| 14 | -class OutboundRoutesController extends BaseController { |
|
| 14 | +class OutboundRoutesController extends BaseController |
|
| 15 | +{ |
|
| 15 | 16 | |
| 16 | 17 | |
| 17 | 18 | /** |
@@ -62,10 +63,13 @@ discard block |
||
| 62 | 63 | * Карточка редактирования исходящего маршрута |
| 63 | 64 | * @param null $id |
| 64 | 65 | */ |
| 65 | - public function modifyAction($id=null){ |
|
| 66 | + public function modifyAction($id=null) |
|
| 67 | + { |
|
| 66 | 68 | |
| 67 | 69 | $rule = OutgoingRoutingTable::findFirstByid($id); |
| 68 | - if (!$rule) $rule = new OutgoingRoutingTable(); |
|
| 70 | + if (!$rule) { |
|
| 71 | + $rule = new OutgoingRoutingTable(); |
|
| 72 | + } |
|
| 69 | 73 | |
| 70 | 74 | $providers = Providers::find(); |
| 71 | 75 | $providersList = array(); |
@@ -93,17 +97,23 @@ discard block |
||
| 93 | 97 | $data = $this->request->getPost(); |
| 94 | 98 | |
| 95 | 99 | $rule = OutgoingRoutingTable::findFirstByid($data['id']); |
| 96 | - if (!$rule) $rule = new OutgoingRoutingTable(); |
|
| 100 | + if (!$rule) { |
|
| 101 | + $rule = new OutgoingRoutingTable(); |
|
| 102 | + } |
|
| 97 | 103 | |
| 98 | 104 | foreach ($rule as $name => $value) { |
| 99 | 105 | switch($name) { |
| 100 | 106 | case 'restnumbers':{ |
| 101 | - if (!array_key_exists($name, $data)) continue; |
|
| 107 | + if (!array_key_exists($name, $data)) { |
|
| 108 | + continue; |
|
| 109 | + } |
|
| 102 | 110 | $rule->$name = $data[$name]==''?-1:$data[$name]; |
| 103 | 111 | break; |
| 104 | 112 | } |
| 105 | 113 | default: |
| 106 | - if (!array_key_exists($name, $data)) continue; |
|
| 114 | + if (!array_key_exists($name, $data)) { |
|
| 115 | + continue; |
|
| 116 | + } |
|
| 107 | 117 | $rule->$name = $data[$name]; |
| 108 | 118 | } |
| 109 | 119 | } |
@@ -131,9 +141,12 @@ discard block |
||
| 131 | 141 | * Удаление исходящего маршрута из базы данных |
| 132 | 142 | * @param null $id |
| 133 | 143 | */ |
| 134 | - public function deleteAction($id=null){ |
|
| 144 | + public function deleteAction($id=null) |
|
| 145 | + { |
|
| 135 | 146 | $rule = OutgoingRoutingTable::findFirstByid($id); |
| 136 | - if ($rule) $rule->delete(); |
|
| 147 | + if ($rule) { |
|
| 148 | + $rule->delete(); |
|
| 149 | + } |
|
| 137 | 150 | return $this->forward('outbound-routes/index'); |
| 138 | 151 | |
| 139 | 152 | } |
@@ -142,7 +155,8 @@ discard block |
||
| 142 | 155 | * Изменение приоритета правила |
| 143 | 156 | * @param null $ruleid |
| 144 | 157 | */ |
| 145 | - public function changePriorityAction($ruleid=null){ |
|
| 158 | + public function changePriorityAction($ruleid=null) |
|
| 159 | + { |
|
| 146 | 160 | $this->view->disable(); |
| 147 | 161 | $result = false; |
| 148 | 162 | |
@@ -11,10 +11,10 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class MailSettingsController extends BaseController { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Построение формы настроек почты |
|
| 16 | - */ |
|
| 17 | - public function modifyAction() |
|
| 14 | + /** |
|
| 15 | + * Построение формы настроек почты |
|
| 16 | + */ |
|
| 17 | + public function modifyAction() |
|
| 18 | 18 | { |
| 19 | 19 | $arrKeys = MailSettingsController::getEmailSettingsArray(); |
| 20 | 20 | foreach ($arrKeys as $key) { |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $this->view->form = new MailSettingsEditForm(null,$MailSettingsFields); |
| 25 | - $this->view->submitMode = NULL; |
|
| 25 | + $this->view->submitMode = NULL; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Сохранение почтовых настроек |
|
| 31 | - */ |
|
| 32 | - public function saveAction() |
|
| 29 | + /** |
|
| 30 | + * Сохранение почтовых настроек |
|
| 31 | + */ |
|
| 32 | + public function saveAction() |
|
| 33 | 33 | { |
| 34 | 34 | if (!$this->request->isPost()) return; |
| 35 | 35 | $data = $this->request->getPost(); |
@@ -69,27 +69,27 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * Возвращает список ключей для настройки почты на станции |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 75 | - private function getEmailSettingsArray(){ |
|
| 76 | - return array( |
|
| 77 | - 'MailSMTPHost', |
|
| 78 | - 'MailSMTPPort', |
|
| 79 | - 'MailSMTPUsername', |
|
| 80 | - 'MailSMTPPassword', |
|
| 81 | - 'MailEnableNotifications', |
|
| 82 | - 'MailSMTPFromUsername', |
|
| 83 | - 'MailSMTPSenderAddress', |
|
| 84 | - 'MailSMTPUseTLS', |
|
| 85 | - 'MailSMTPCertCheck', |
|
| 86 | - 'MailTplMissedCallSubject', |
|
| 87 | - 'MailTplMissedCallBody', |
|
| 88 | - 'MailTplMissedCallFooter', |
|
| 89 | - 'MailTplVoicemailSubject', |
|
| 90 | - 'MailTplVoicemailBody', |
|
| 91 | - 'SystemNotificationsEmail', |
|
| 72 | + * Возвращает список ключей для настройки почты на станции |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | + private function getEmailSettingsArray(){ |
|
| 76 | + return array( |
|
| 77 | + 'MailSMTPHost', |
|
| 78 | + 'MailSMTPPort', |
|
| 79 | + 'MailSMTPUsername', |
|
| 80 | + 'MailSMTPPassword', |
|
| 81 | + 'MailEnableNotifications', |
|
| 82 | + 'MailSMTPFromUsername', |
|
| 83 | + 'MailSMTPSenderAddress', |
|
| 84 | + 'MailSMTPUseTLS', |
|
| 85 | + 'MailSMTPCertCheck', |
|
| 86 | + 'MailTplMissedCallSubject', |
|
| 87 | + 'MailTplMissedCallBody', |
|
| 88 | + 'MailTplMissedCallFooter', |
|
| 89 | + 'MailTplVoicemailSubject', |
|
| 90 | + 'MailTplVoicemailBody', |
|
| 91 | + 'SystemNotificationsEmail', |
|
| 92 | 92 | 'VoicemailNotificationsEmail' |
| 93 | - ); |
|
| 94 | - } |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $MailSettingsFields[$key] = PbxSettings::getValueByKey($key); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - $this->view->form = new MailSettingsEditForm(null,$MailSettingsFields); |
|
| 24 | + $this->view->form = new MailSettingsEditForm(null, $MailSettingsFields); |
|
| 25 | 25 | $this->view->submitMode = NULL; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * Возвращает список ключей для настройки почты на станции |
| 73 | 73 | * @return array |
| 74 | 74 | */ |
| 75 | - private function getEmailSettingsArray(){ |
|
| 75 | + private function getEmailSettingsArray() { |
|
| 76 | 76 | return array( |
| 77 | 77 | 'MailSMTPHost', |
| 78 | 78 | 'MailSMTPPort', |
@@ -9,13 +9,14 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | use Models\PbxSettings; |
| 11 | 11 | |
| 12 | -class MailSettingsController extends BaseController { |
|
| 12 | +class MailSettingsController extends BaseController |
|
| 13 | +{ |
|
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Построение формы настроек почты |
| 16 | 17 | */ |
| 17 | 18 | public function modifyAction() |
| 18 | - { |
|
| 19 | + { |
|
| 19 | 20 | $arrKeys = MailSettingsController::getEmailSettingsArray(); |
| 20 | 21 | foreach ($arrKeys as $key) { |
| 21 | 22 | $MailSettingsFields[$key] = PbxSettings::getValueByKey($key); |
@@ -30,8 +31,10 @@ discard block |
||
| 30 | 31 | * Сохранение почтовых настроек |
| 31 | 32 | */ |
| 32 | 33 | public function saveAction() |
| 33 | - { |
|
| 34 | - if (!$this->request->isPost()) return; |
|
| 34 | + { |
|
| 35 | + if (!$this->request->isPost()) { |
|
| 36 | + return; |
|
| 37 | + } |
|
| 35 | 38 | $data = $this->request->getPost(); |
| 36 | 39 | |
| 37 | 40 | $this->db->begin(); |
@@ -51,7 +54,9 @@ discard block |
||
| 51 | 54 | $record->value = ($data[$key] == 'on') ? "1" : "0"; |
| 52 | 55 | break; |
| 53 | 56 | default: |
| 54 | - if (!array_key_exists($key, $data)) continue; |
|
| 57 | + if (!array_key_exists($key, $data)) { |
|
| 58 | + continue; |
|
| 59 | + } |
|
| 55 | 60 | $record->value = $data[$key]; |
| 56 | 61 | } |
| 57 | 62 | if ($record->save() === false) { |
@@ -72,7 +77,8 @@ discard block |
||
| 72 | 77 | * Возвращает список ключей для настройки почты на станции |
| 73 | 78 | * @return array |
| 74 | 79 | */ |
| 75 | - private function getEmailSettingsArray(){ |
|
| 80 | + private function getEmailSettingsArray() |
|
| 81 | + { |
|
| 76 | 82 | return array( |
| 77 | 83 | 'MailSMTPHost', |
| 78 | 84 | 'MailSMTPPort', |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $this->view->form = new MailSettingsEditForm(null,$MailSettingsFields); |
| 25 | - $this->view->submitMode = NULL; |
|
| 25 | + $this->view->submitMode = null; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |