This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from owncloud/feat/license-info
feat: admin panel with license information
- Loading branch information
Showing
5 changed files
with
93 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace OCA\QNAP; | ||
|
||
use OCP\IUser; | ||
use OCP\Settings\ISettings; | ||
use OCP\Template; | ||
|
||
class AdminPanel implements ISettings { | ||
public function getPriority() { | ||
return 10; | ||
} | ||
|
||
public function getPanel() { | ||
$license = new QnapLicense(); | ||
$tmpl = new Template('qnap', 'settings-admin'); | ||
$tmpl->assign('licenses', $license->getLicenses()); | ||
$tmpl->assign('licensed_users', $license->getUserAllowance()); | ||
$tmpl->assign('active_users', $this->getUserCount()); | ||
# foreach ($params as $key => $value) { | ||
# $tmpl->assign($key, $value); | ||
# } | ||
return $tmpl; | ||
} | ||
|
||
public function getSectionID() { | ||
return 'security'; | ||
} | ||
|
||
private function getUserCount(): int { | ||
$numberOfActiveUsers = 0; | ||
\OC::$server->getUserManager()->callForAllUsers(function (IUser $user) use (&$numberOfActiveUsers) { | ||
if ($user->isEnabled()) { | ||
$numberOfActiveUsers++; | ||
} | ||
}); | ||
|
||
return $numberOfActiveUsers; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** @var array $_ */ | ||
/** @var \OCP\IL10N $l */ | ||
?> | ||
<div id="qnap" class="section"> | ||
<h2 class="inlineblock"><?php p($l->t('QNAP License')); ?></h2> | ||
<p> | ||
<?php p($l->t('Active users: %d', $_['active_users']))?> | ||
<br> | ||
<?php p($l->t('Licensed users: %d', $_['licensed_users']))?> | ||
<br> | ||
<a href="https://software.qnap.com/owncloud.html"><?php p($l->t('Visit the QNAP Store to purchase more licenses.')) ?></a> | ||
</p> | ||
|
||
<h3><?php p($l->t('License Overview')); ?></h3> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th scope="col"><?php p($l->t('License ID')); ?></th> | ||
<th scope="col"><?php p($l->t('Valid until')); ?></th> | ||
<th scope="col"><?php p($l->t('Number of users')); ?></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php foreach ($_['licenses'] as $lic): ?> | ||
<tr> | ||
<td><?php p($lic['license_id']); ?></td> | ||
<td><?php p($lic['license_info']['valid_until']->format(\DateTime::COOKIE)); ?></td> | ||
<td><?php p($lic['license_info']['attributes']['owncloud_account']); ?></td> | ||
</tr> | ||
<?php endforeach ?> | ||
</tbody> | ||
</table> | ||
</div> |