| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace ThurData\Servers\KerioEmail\App\UI\Client\Setting\Providers;
- use ThurData\Servers\KerioEmail\App\Enums\Kerio;
- use function ThurData\Servers\KerioEmail\Core\Helper\di;
- use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
- use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
- /**
- *
- * Created by PhpStorm.
- * User: ThurData
- * Date: 10.09.19
- * Time: 13:06
- * Class SettingDataProvider
- */
- class InfoSettingDataProvider extends BaseDataProvider
- {
- public function read()
- {
- $this->data['domain'] = $this->getWhmcsParamByKey('domain');
- $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
- try {
- $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
- $domainID = $api->getDomainId($this->getWhmcsParamByKey('domain'));
- } catch (KerioApiException $error) {
- logModuleCall(
- 'kerioEmail',
- __FUNCTION__,
- $error,
- 'Debug Error',
- $error->getMessage()
- );
- return ['error' => $error->getMessage()];
- }
- $fields = array(
- "id",
- "loginName",
- "isEnabled");
- try {
- $users = $api->getUsers($fields,$domainID);
- } catch (KerioApiException $error) {
- logModuleCall(
- 'kerioEmail',
- __FUNCTION__,
- $error,
- 'Debug Error',
- $error->getMessage()
- );
- return ['error' => $error->getMessage()];
- }
- $api->logout();
- foreach($users as $user) {
- if($user['isEnabled']){
- $this->availableValues['manager'][ $user['id']] = $user['loginName'] . '@' . $this->getWhmcsParamByKey('domain');
- }
- }
- $lang = di('lang');
- $this->availableValues['status'] = [
- Kerio::ACC_STATUS_ACTIVE => $lang->absoluteT('kerio','account','status','active'),
- Kerio::ACC_STATUS_CLOSED => $lang->absoluteT('kerio','account','status','closed'),
- ];
- $this->availableValues['type'] = [
- Kerio::RES_TYPE_LOCATION => $lang->absoluteT('kerio','ressource','type','location'),
- Kerio::RES_TYPE_EQUIPMENT => $lang->absoluteT('kerio','ressource','type','equipment')
- ];
- }
- public function create()
- {
- }
- public function updateStatus()
- {
- }
- public function update()
- {
- }
- }
|