1: <?php
2: /**
3: * This code is licensed under AGPLv3 license or Afterlogic Software License
4: * if commercial version of the product was purchased.
5: * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files.
6: */
7:
8: namespace Aurora\Modules\Ios;
9:
10: /**
11: * Allows to configure iOS device automatically for syncing mails, contacts and calendars using iOS profile.
12: *
13: * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
14: * @license https://afterlogic.com/products/common-licensing Afterlogic Software License
15: * @copyright Copyright (c) 2023, Afterlogic Corp.
16: *
17: * @package Modules
18: */
19: class Module extends \Aurora\System\Module\AbstractModule
20: {
21: /***** private functions *****/
22: /**
23: * Initializes IOS Module.
24: *
25: * @ignore
26: */
27: public function init()
28: {
29: $this->AddEntries(
30: array(
31: 'ios' => 'EntryIos',
32: 'profile' => 'EntryProfile'
33: )
34: );
35: }
36: /***** private functions *****/
37:
38: /***** public functions *****/
39: /**
40: *
41: * @return array
42: */
43: public function GetSettings()
44: {
45: \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous);
46:
47: return array(
48: 'AllowIosProfile' => $this->getConfig('AllowIosProfile', false),
49: 'SyncIosAfterLogin' => $this->getConfig('SyncIosAfterLogin', false)
50: );
51: }
52:
53: /**
54: * @ignore
55: * @return string
56: */
57: public function EntryIos()
58: {
59: $sResult = \file_get_contents($this->GetPath().'/templates/Ios.html');
60:
61: $oApiIntegrator = \Aurora\System\Managers\Integrator::getInstance();
62: $iUserId = \Aurora\System\Api::getAuthenticatedUserId();
63: if (0 < $iUserId) {
64: $sResult = strtr($sResult, array(
65: '{{IOS/HELLO}}' => $this->i18N('HELLO'),
66: '{{IOS/DESC_P1}}' => $this->i18N('DESC_P1'),
67: '{{IOS/DESC_P2}}' => $this->i18N('DESC_P2'),
68: '{{IOS/DESC_P3}}' => $this->i18N('DESC_P3'),
69: '{{IOS/DESC_P4}}' => $this->i18N('DESC_P4'),
70: '{{IOS/DESC_P5}}' => $this->i18N('DESC_P5'),
71: '{{IOS/DESC_P6}}' => $this->i18N('DESC_P6'),
72: '{{IOS/DESC_P7}}' => $this->i18N('DESC_P7'),
73: '{{IOS/DESC_BUTTON_YES}}' => $this->i18N('DESC_BUTTON_YES'),
74: '{{IOS/DESC_BUTTON_SKIP}}' => $this->i18N('DESC_BUTTON_SKIP'),
75: '{{IOS/DESC_BUTTON_OPEN}}' => $this->i18N('DESC_BUTTON_OPEN'),
76: '{{AppVersion}}' => AU_APP_VERSION,
77: '{{IntegratorLinks}}' => $oApiIntegrator->buildHeadersLink()
78: ));
79: \Aurora\Modules\CoreWebclient\Module::Decorator()->SetHtmlOutputHeaders();
80: } else {
81: \Aurora\System\Api::Location('./');
82: }
83:
84: return $sResult;
85: }
86:
87: /**
88: * @ignore
89: */
90: public function EntryProfile()
91: {
92: $oIosManager = new Manager($this);
93:
94: $oUser = \Aurora\System\Api::getAuthenticatedUser();
95:
96: $mResultProfile = $oIosManager && $oUser ? $oIosManager->generateXMLProfile($oUser) : false;
97:
98: if (!$mResultProfile) {
99: \Aurora\System\Api::Location('./?IOS/Error');
100: } else {
101: \header('Content-type: application/x-apple-aspen-config; chatset=utf-8');
102: \header('Content-Disposition: attachment; filename="afterlogic.mobileconfig"');
103: echo $mResultProfile;
104: }
105: }
106: /***** public functions *****/
107: }
108: