芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/cloud.pulsehost.co.uk/modules/Google/Module.php
oModuleSettings; } /***** private functions *****/ /** * Initializes Google Module. * * @ignore */ public function init() { $this->subscribeEvent('GetServicesSettings', array($this, 'onGetServicesSettings')); $this->subscribeEvent('UpdateServicesSettings', array($this, 'onUpdateServicesSettings')); } /** * Adds service settings to array passed by reference. * * @ignore * @param array $aServices Array with services settings passed by reference. */ public function onGetServicesSettings(&$aServices) { $aSettings = $this->GetSettings(); if (!empty($aSettings)) { $aServices[] = $aSettings; } } /** * Updates service settings. * * @ignore * @param array $aServices Array with new values for service settings. * * @throws \Aurora\System\Exceptions\ApiException */ public function onUpdateServicesSettings($aServices) { $aSettings = $aServices[$this->sService]; if (\is_array($aSettings)) { $this->UpdateSettings($aSettings['EnableModule'], $aSettings['Id'], $aSettings['Secret'], $aSettings['Key']); } } /***** private functions *****/ /***** public functions might be called with web API *****/ /** * Obtains list of module settings for authenticated user. * * @return array */ public function GetSettings() { $aResult = array(); \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous); $oUser = \Aurora\System\Api::getAuthenticatedUser(); if ($oUser && $oUser->Role === \Aurora\System\Enums\UserRole::SuperAdmin) { $aResult = array( 'Name' => $this->sService, 'DisplayName' => self::GetName(), 'EnableModule' => $this->oModuleSettings->EnableModule, 'Id' => $this->oModuleSettings->Id, 'Secret' => $this->oModuleSettings->Secret, 'Key' => $this->oModuleSettings->Key ); } if ($oUser && $oUser->isNormalOrTenant()) { $oAccount = null; $oOAuthIntegratorWebclientDecorator = \Aurora\Modules\OAuthIntegratorWebclient\Module::Decorator(); if ($oOAuthIntegratorWebclientDecorator) { $oAccount = $oOAuthIntegratorWebclientDecorator->GetAccount($this->sService); } $aResult = array( 'EnableModule' => $this->oModuleSettings->EnableModule, 'Connected' => $oAccount ? true : false, 'AccountId' => $oAccount instanceof \Aurora\Modules\OAuthIntegratorWebclient\Models\OauthAccount ? $oAccount->Id : null ); $aArgs = array( 'OAuthAccount' => $oAccount ); } $this->broadcastEvent('GetSettings', $aArgs, $aResult); return $aResult; } /** * Updates service settings. * * @param boolean $EnableModule **true** if module should be enabled. * @param string $Id Service app identifier. * @param string $Secret Service app secret. * @param string $Key Service app key. * * @throws \Aurora\System\Exceptions\ApiException */ public function UpdateSettings($EnableModule, $Id, $Secret, $Key) { \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::TenantAdmin); try { $this->setConfig('EnableModule', $EnableModule); $this->setConfig('Id', $Id); $this->setConfig('Secret', $Secret); $this->setConfig('Key', $Key); $this->saveModuleConfig(); } catch (\Exception $ex) { throw new \Aurora\System\Exceptions\ApiException(\Aurora\System\Notifications::CanNotSaveSettings); } return true; } /** * Deletes DropBox account. * * @return boolean */ public function DeleteAccount() { \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::NormalUser); $bResult = false; $oOAuthIntegratorWebclientDecorator = \Aurora\Modules\OAuthIntegratorWebclient\Module::Decorator(); if ($oOAuthIntegratorWebclientDecorator) { $bResult = $oOAuthIntegratorWebclientDecorator->DeleteAccount($this->sService); } return $bResult; } /***** public functions might be called with web API *****/ }