1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | namespace Aurora\Modules\Ios; |
9: | |
10: | use Aurora\System\Application; |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | class Module extends \Aurora\System\Module\AbstractModule |
24: | { |
25: | |
26: | |
27: | |
28: | public static function getInstance() |
29: | { |
30: | return parent::getInstance(); |
31: | } |
32: | |
33: | |
34: | |
35: | |
36: | public static function Decorator() |
37: | { |
38: | return parent::Decorator(); |
39: | } |
40: | |
41: | |
42: | |
43: | |
44: | public function getModuleSettings() |
45: | { |
46: | return $this->oModuleSettings; |
47: | } |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | |
54: | |
55: | public function init() |
56: | { |
57: | $this->AddEntries( |
58: | array( |
59: | 'ios' => 'EntryIos', |
60: | 'ios-error' => 'EntryIosError', |
61: | 'profile' => 'EntryProfile' |
62: | ) |
63: | ); |
64: | } |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | |
71: | |
72: | public function GetSettings() |
73: | { |
74: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous); |
75: | |
76: | return array( |
77: | 'AllowIosProfile' => $this->oModuleSettings->AllowIosProfile, |
78: | 'SyncIosAfterLogin' => $this->oModuleSettings->SyncIosAfterLogin |
79: | ); |
80: | } |
81: | |
82: | |
83: | |
84: | |
85: | |
86: | public function EntryIos() |
87: | { |
88: | $sResult = \file_get_contents($this->GetPath() . '/templates/Ios.html'); |
89: | |
90: | $oApiIntegrator = \Aurora\System\Managers\Integrator::getInstance(); |
91: | $iUserId = \Aurora\System\Api::getAuthenticatedUserId(); |
92: | if (0 < $iUserId) { |
93: | $sResult = strtr($sResult, array( |
94: | '{{IOS/HELLO}}' => $this->i18N('HELLO'), |
95: | '{{IOS/DESC_P1}}' => $this->i18N('DESC_P1'), |
96: | '{{IOS/DESC_P2}}' => $this->i18N('DESC_P2'), |
97: | '{{IOS/DESC_P3}}' => $this->i18N('DESC_P3'), |
98: | '{{IOS/DESC_P4}}' => $this->i18N('DESC_P4'), |
99: | '{{IOS/DESC_P5}}' => $this->i18N('DESC_P5'), |
100: | '{{IOS/DESC_P6}}' => $this->i18N('DESC_P6'), |
101: | '{{IOS/DESC_P7}}' => $this->i18N('DESC_P7'), |
102: | '{{IOS/DESC_BUTTON_YES}}' => $this->i18N('DESC_BUTTON_YES'), |
103: | '{{IOS/DESC_BUTTON_SKIP}}' => $this->i18N('DESC_BUTTON_SKIP'), |
104: | '{{IOS/DESC_BUTTON_OPEN}}' => $this->i18N('DESC_BUTTON_OPEN'), |
105: | '{{AppVersion}}' => Application::GetVersion(), |
106: | '{{IntegratorLinks}}' => $oApiIntegrator->buildHeadersLink() |
107: | )); |
108: | \Aurora\Modules\CoreWebclient\Module::Decorator()->SetHtmlOutputHeaders(); |
109: | } else { |
110: | \Aurora\System\Api::Location('./'); |
111: | } |
112: | |
113: | return $sResult; |
114: | } |
115: | |
116: | |
117: | |
118: | |
119: | |
120: | public function EntryIosError() |
121: | { |
122: | $sResult = \file_get_contents($this->GetPath() . '/templates/Ios-error.html'); |
123: | |
124: | $oApiIntegrator = \Aurora\System\Managers\Integrator::getInstance(); |
125: | $iUserId = \Aurora\System\Api::getAuthenticatedUserId(); |
126: | if (0 < $iUserId) { |
127: | $sResult = strtr($sResult, array( |
128: | '{{IOS/ERROR_TITLE}}' => $this->i18N('ERROR_TITLE'), |
129: | '{{IOS/ERROR_DESC}}' => $this->i18N('ERROR_DESC'), |
130: | '{{IOS/DESC_BUTTON_OPEN}}' => $this->i18N('DESC_BUTTON_OPEN'), |
131: | '{{AppVersion}}' => Application::GetVersion(), |
132: | '{{IntegratorLinks}}' => $oApiIntegrator->buildHeadersLink() |
133: | )); |
134: | \Aurora\Modules\CoreWebclient\Module::Decorator()->SetHtmlOutputHeaders(); |
135: | } else { |
136: | \Aurora\System\Api::Location('./'); |
137: | } |
138: | |
139: | return $sResult; |
140: | } |
141: | |
142: | |
143: | |
144: | |
145: | public function EntryProfile() |
146: | { |
147: | $oIosManager = new Manager($this); |
148: | |
149: | $oUser = \Aurora\System\Api::getAuthenticatedUser(); |
150: | |
151: | $mResultProfile = false; |
152: | if (!$oUser) { |
153: | \Aurora\System\Api::Log('Ios profile error: user is not authorized!'); |
154: | } else { |
155: | $mResultProfile = $oIosManager->generateXMLProfile($oUser); |
156: | } |
157: | |
158: | if (!$mResultProfile) { |
159: | \Aurora\System\Api::Location('./?ios-error'); |
160: | } else { |
161: | \header('Content-type: application/x-apple-aspen-config; chatset=utf-8'); |
162: | \header('Content-Disposition: attachment; filename="afterlogic.mobileconfig"'); |
163: | echo $mResultProfile; |
164: | } |
165: | } |
166: | |
167: | } |
168: | |