diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-02-04 13:06:27 +0300 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-02-04 13:07:11 +0300 |
commit | dd51a36931d4ba450fb4a8d7fe5c1609892d25b6 (patch) | |
tree | 5261739552340d953c4952e8c8f0fc873fee9696 /lib/Controller | |
parent | 11e3a3bd87de2c3ddf757943e898e78a8df7d1a0 (diff) |
Add PRODID to new contacts
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/PageController.php | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index afbccb45..95951337 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -25,17 +25,27 @@ namespace OCA\Contacts\Controller; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IConfig; use OCP\IRequest; class PageController extends Controller { + protected $appName; private $userId; + /** + * @var IConfig + */ + private $config; + public function __construct(string $AppName, IRequest $request, - string $UserId = null) { + string $UserId = null, + IConfig $config) { parent::__construct($AppName, $request); + $this->appName = $AppName; $this->userId = $UserId; + $this->config = $config; } /** @@ -45,9 +55,20 @@ class PageController extends Controller { * Default routing */ public function index(): TemplateResponse { - $params = ['user' => $this->userId]; - - return new TemplateResponse('contacts', 'main', $params); // templates/main.php + \OCP\Util::connectHook('\OCP\Config', 'js', $this, 'addJavaScriptVariablesForIndex'); + return new TemplateResponse('contacts', 'main'); // templates/main.php } + /** + * add parameters to javascript for user sites + * + * @param array $array + */ + public function addJavaScriptVariablesForIndex(array $array) { + $appversion = $this->config->getAppValue($this->appName, 'installed_version'); + + $array['array']['oca_contacts'] = \json_encode([ + 'versionstring' => $appversion, + ]); + } } |