/** * @param string $username * @param string $userpassword * * @return boolean * @throws \Cms\Exception (auch bei fehlerhafter Anmeldung) */ public function checkFtpLogin($username, $userpassword) { $accessManager = AccessManager::singleton(); $autResult = $accessManager->checkLogin($username, $userpassword); if (!$accessManager->isAuthResultValid($autResult)) { throw new \Cms\Exception(2006, __METHOD__, __LINE__); } // only superusers are allowed to login via FTP $identity = $autResult->getIdentity(); if (!is_array($identity) || !isset($identity['superuser']) || $identity['superuser'] != true) { throw new \Cms\Exception(2007, __METHOD__, __LINE__); } // module development must be enabled to login via FTP $quota = new Quota(); if (!$quota->getModuleQuota()->getEnableDev()) { throw new \Cms\Exception(2007, __METHOD__, __LINE__); } return true; }
/** * @test * * @group quota * @group small * @group dev */ public function test_getDefaultMediaQuotaSuccess() { // ARRANGE $expectedMaxFileSize = 0; $expectedMaxSizePerWebsite = 0; ConfigHelper::removeValue(array('quota')); // ACT $quota = new Quota(); $actualMediaQuota = $quota->getMediaQuota(); // ASSERT $actualMaxFileSize = $actualMediaQuota->getMaxFileSize(); $this->assertEquals($expectedMaxFileSize, $actualMaxFileSize); $actualMaxSizePerWebsite = $actualMediaQuota->getMaxSizePerWebsite(); $this->assertEquals($expectedMaxSizePerWebsite, $actualMaxSizePerWebsite); }
/** * Checks if the module developments is allowed. Throws Exception if not! * * @throws \Cms\Exception */ public function checkModuleDevelopmentQuota() { $quota = new Quota(); $moduleQuota = $quota->getModuleQuota(); if (!$moduleQuota->getEnableDev()) { throw new CmsException(2301, __METHOD__, __LINE__); } }
/** * @param array $attributes * @param string $websiteId * @throws /Cms/Exception */ protected function checkWebhostingMaxCountQuota(array $attributes, $websiteId = null) { if (!array_key_exists('publishingenabled', $attributes)) { return; } if (!$attributes['publishingenabled']) { return; } $quotas = new Quota(); $webhostingQuota = $quotas->getWebhostingQuota(); if ($this->getNewPublishingEnabledCount($websiteId) > $webhostingQuota->getMaxCount()) { throw new CmsException(2303, __METHOD__, __LINE__); } }
/** * Checks if the export is allowed. Throws Exception if not! * * @throws \Cms\Exception */ protected function checkExportQuota() { $quota = new Quota(); $exportQuota = $quota->getExportQuota(); if (!$exportQuota->getExportAllowed()) { throw new CmsException(2302, __METHOD__, __LINE__); } }
/** * @return \Cms\Data\MediaQuota */ public function getQuota() { $quota = new Quota(); return $quota->getMediaQuota(); }