芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/cloud.pulsehost.co.uk/modules/CorporateFiles/Module.php
subscribeEvent('Files::GetQuota::after', array($this, 'onAfterGetQuota')); } /** * @return Module */ public static function getInstance() { return parent::getInstance(); } /** * @return Module */ public static function Decorator() { return parent::Decorator(); } /** * @return Settings */ public function getModuleSettings() { return $this->oModuleSettings; } /** * Obtains list of module settings. * * @return array */ public function GetSettings() { \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous); return array( 'SpaceLimitMb' => $this->oModuleSettings->SpaceLimitMb, ); } /** * Updates module's settings - saves them to config.json file. * * @param int $SpaceLimitMb Space limit setting in Mb. * @return bool */ public function UpdateSettings($SpaceLimitMb) { \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::TenantAdmin); $this->setConfig('SpaceLimitMb', $SpaceLimitMb); return (bool) $this->saveModuleConfig(); } public function UpdateUsedSpace() { $iResult = 0; \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::NormalUser); $oUser = \Aurora\System\Api::getAuthenticatedUser(); if ($oUser) { $oTenant = \Aurora\Modules\Core\Module::Decorator()->GetTenantWithoutRoleCheck($oUser->IdTenant); if ($oTenant) { $iResult = $this->getManager()->getUserSpaceUsed($oUser->PublicId, [\Aurora\System\Enums\FileStorageType::Corporate]); $oTenant->setExtendedProp(self::GetName() . '::UsedSpace', $iResult); $oTenant->save(); } } return $iResult; } public function onAfterGetQuota($aArgs, &$mResult) { if ($this->checkStorageType($aArgs['Type'])) { $iSize = 0; $oUser = \Aurora\Modules\Core\Module::Decorator()->GetUserWithoutRoleCheck((int)$aArgs['UserId']); if ($oUser) { $oTenant = \Aurora\Modules\Core\Module::Decorator()->GetTenantWithoutRoleCheck($oUser->IdTenant); if ($oTenant) { $iSize = null !== $oTenant->getExtendedProp(self::GetName() . '::UsedSpace') ? (int) $oTenant->getExtendedProp(self::GetName() . '::UsedSpace') : 0; } } $mResult = array( 'Used' => (int) $iSize, 'Limit' => $this->oModuleSettings->SpaceLimitMb * 1024 * 1024 ); } } }