Skip to content

Commit

Permalink
fix php code
Browse files Browse the repository at this point in the history
  • Loading branch information
memurats committed Sep 15, 2023
1 parent 01dfee7 commit 35e2a79
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 117 deletions.
20 changes: 8 additions & 12 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@
namespace OCA\NMCSettings\AppInfo;

use OC\AppFramework\DependencyInjection\DIContainer;
use OC\Server;
use OC\Settings\Manager;
use OCA\NMCSettings\Listener\BeforeTemplateRenderedListener;
use OCA\NMCSettings\ManagerDecorator;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\Defaults;
use OCP\IServerContainer;
use OCP\Settings\IManager;
use OCA\NMCSettings\Listener\BeforeTemplateRenderedListener;

class Application extends App implements IBootstrap {
public const APP_ID = 'nmcsettings';
Expand All @@ -44,15 +40,15 @@ public function getCapturedSettingsContainer() {
}

public function register(IRegistrationContext $context): void {
/*
$this->getCapturedSettingsContainer()->registerService(IManager::class, function ($c) {
/*
$this->getCapturedSettingsContainer()->registerService(IManager::class, function ($c) {
$manager = $c->get(Manager::class);
$managerDecorator = new ManagerDecorator($manager);
$manager = $c->get(Manager::class);
$managerDecorator = new ManagerDecorator($manager);
return $managerDecorator;
});
*/
return $managerDecorator;
});
*/

// the listener is helpful to enforce theme constraints and inject additional parts
$context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
Expand Down
49 changes: 25 additions & 24 deletions lib/Sections/Personal/AccountSettings.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
<?php

namespace OCA\NmcSettings\Sections\Personal;

use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IIconSection;

class AccountSettings implements IIconSection {
private IL10N $l;
private IURLGenerator $urlGenerator;

public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
$this->l = $l;
$this->urlGenerator = $urlGenerator;
}

public function getIcon(): string {
return $this->urlGenerator->imagePath('nmctheme', 'actions/user.svg');
}

public function getID(): string {
return 'account';
}

public function getName(): string {
return $this->l->t('Account settings');
}

public function getPriority(): int {
return -2;
}
}
private IL10N $l;
private IURLGenerator $urlGenerator;

public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
$this->l = $l;
$this->urlGenerator = $urlGenerator;
}

public function getIcon(): string {
return $this->urlGenerator->imagePath('nmctheme', 'actions/user.svg');
}

public function getID(): string {
return 'account';
}

public function getName(): string {
return $this->l->t('Account settings');
}

public function getPriority(): int {
return -2;
}
}
49 changes: 25 additions & 24 deletions lib/Sections/Personal/DevicesSessions.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
<?php

namespace OCA\NmcSettings\Sections\Personal;

use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IIconSection;

class DevicesSessions implements IIconSection {
private IL10N $l;
private IURLGenerator $urlGenerator;

public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
$this->l = $l;
$this->urlGenerator = $urlGenerator;
}

public function getIcon(): string {
return $this->urlGenerator->imagePath('nmctheme', 'settings/replacement.svg');
}

public function getID(): string {
return 'sessions';
}

public function getName(): string {
return $this->l->t('Devices & sessions');
}

public function getPriority(): int {
return -1;
}
}
private IL10N $l;
private IURLGenerator $urlGenerator;

public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
$this->l = $l;
$this->urlGenerator = $urlGenerator;
}

public function getIcon(): string {
return $this->urlGenerator->imagePath('nmctheme', 'settings/replacement.svg');
}

public function getID(): string {
return 'sessions';
}

public function getName(): string {
return $this->l->t('Devices & sessions');
}

public function getPriority(): int {
return -1;
}
}
32 changes: 15 additions & 17 deletions lib/Settings/Personal/NmcPersonalInfo.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace OCA\NMCSettings\Settings\Personal;

use OC\Files\View;
Expand All @@ -9,7 +10,6 @@
use OCP\Accounts\IAccountProperty;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\Files\FileInfo;
use OCP\IConfig;
use OCP\IDBConnection;
Expand All @@ -19,12 +19,10 @@
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\L10N\IFactory;
use OCP\Notification\IManager;
use OCP\Settings\ISettings;


class NmcPersonalInfo implements ISettings {

/** @var IConfig */
Expand Down Expand Up @@ -60,7 +58,7 @@ class NmcPersonalInfo implements ISettings {
/** @var IDBConnection */
private $db;

public function __construct(
public function __construct(
IConfig $config,
IUserManager $userManager,
IGroupManager $groupManager,
Expand All @@ -72,7 +70,7 @@ public function __construct(
IInitialStateService $initialStateService,
IManager $manager,
IDBConnection $db
) {
) {
$this->config = $config;
$this->userManager = $userManager;
$this->accountManager = $accountManager;
Expand All @@ -84,7 +82,7 @@ public function __construct(
$this->initialStateService = $initialStateService;
$this->manager = $manager;
$this->db = $db;
}
}

public function getForm(): TemplateResponse {
$federationEnabled = $this->appManager->isEnabledForUser('federation');
Expand All @@ -105,7 +103,7 @@ public function getForm(): TemplateResponse {

$imageStorageInBytes = $this->storageUtilization($uid, $imageMimetypes);
$videoStorageInBytes = $this->storageUtilization($uid, $videoMimetypes);
$photoVideoSizeInBytes = $imageStorageInBytes + $videoStorageInBytes;
$photoVideoSizeInBytes = $imageStorageInBytes + $videoStorageInBytes;

// make sure FS is setup before querying storage related stuff...
\OC_Util::setupFS($user->getUID());
Expand All @@ -122,7 +120,7 @@ public function getForm(): TemplateResponse {
$trashSizeinBytes = self::getTrashbinSize($uid);
$filesSizeInBytes = $storageInfo['used'] - ($photoVideoSizeInBytes);

if($filesSizeInBytes < 0){
if($filesSizeInBytes < 0) {
$filesSizeInBytes = 0;
}

Expand Down Expand Up @@ -175,10 +173,10 @@ public function getForm(): TemplateResponse {
'profileConfig' => $this->profileManager->getProfileConfigWithMetadata($user, $user),
];

$this->initialStateService->provideInitialState('settings','profileEnabledGlobally', $this->profileManager->isProfileEnabled());
$this->initialStateService->provideInitialState('settings','personalInfoParameters', $personalInfoParameters);
$this->initialStateService->provideInitialState('settings','accountParameters', $accountParameters);
$this->initialStateService->provideInitialState('settings','profileParameters', $profileParameters);
$this->initialStateService->provideInitialState('settings', 'profileEnabledGlobally', $this->profileManager->isProfileEnabled());
$this->initialStateService->provideInitialState('settings', 'personalInfoParameters', $personalInfoParameters);
$this->initialStateService->provideInitialState('settings', 'accountParameters', $accountParameters);
$this->initialStateService->provideInitialState('settings', 'profileParameters', $profileParameters);

return new TemplateResponse('nmcsettings', 'settings/personal/account', $parameters, '');
//return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
Expand Down Expand Up @@ -379,11 +377,11 @@ private function getTariff($quota) {
$tariff = $this->l->t('MagentaCLOUD S');
} elseif ($totalSpaceInGB == 100) {
$tariff = $this->l->t('MagentaCLOUD M');
} else if ($totalSpaceInGB == 500) {
} elseif ($totalSpaceInGB == 500) {
$tariff = $this->l->t('MagentaCLOUD L');
} else if ($totalSpaceInGB == 1024) {
} elseif ($totalSpaceInGB == 1024) {
$tariff = $this->l->t('MagentaCLOUD XL');
} else if ($totalSpaceInGB == 5120) {
} elseif ($totalSpaceInGB == 5120) {
$tariff = $this->l->t('MagentaCLOUD XXL');
} else {
$tariff = $this->l->t('Tariff unknown');
Expand All @@ -398,7 +396,7 @@ private static function getTrashbinSize($user) {
return isset($fileInfo['size']) ? $fileInfo['size'] : 0;
}

private function storageUtilization($user=null, $filterMimetypes=null) {
private function storageUtilization($user = null, $filterMimetypes = null) {
$details = null;

$rootFolder = \OC::$server->getRootFolder()->getUserFolder($user);
Expand All @@ -422,4 +420,4 @@ private function storageUtilization($user=null, $filterMimetypes=null) {
$result->closeCursor();
return $details;
}
}
}
Loading

0 comments on commit 35e2a79

Please sign in to comment.