0f90177674e407d0cc9ff9fd116db640ce3238ff
[Packages/TYPO3.CMS.git] / typo3 / sysext / openid / Classes / OpenidModuleSetup.php
1 <?php
2 namespace TYPO3\CMS\Openid;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Lang\LanguageService;
21
22 /**
23 * This class is the OpenID return script for the TYPO3 Backend (used in the user-settings module).
24 */
25 class OpenidModuleSetup {
26
27 /**
28 * Checks weather BE user has access to change its OpenID identifier
29 *
30 * @return bool Whether it is allowed to modify the given field
31 */
32 public function accessLevelCheck() {
33 $setupConfig = $this->getBackendUser()->getTSConfigProp('setup.fields');
34 return empty($setupConfig['tx_openid_openid.']['disabled']);
35 }
36
37 /**
38 * Render OpenID identifier field for user setup
39 *
40 * @return string HTML input field to change the OpenId
41 */
42 public function renderOpenID() {
43 $openid = $this->getBackendUser()->user['tx_openid_openid'];
44 $add = htmlspecialchars(
45 $this->getLanguageService()->sL('LLL:EXT:openid/Resources/Private/Language/locallang.xlf:addopenid')
46 );
47
48 $parameters = ['P[itemName]' => 'data[be_users][tx_openid_openid]'];
49 $popUpUrl = GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_openid', $parameters));
50 return '<div class="input-group">' .
51 '<input id="field_tx_openid_openid"' .
52 ' class="form-control"' .
53 ' type="text" name="data[be_users][tx_openid_openid]"' .
54 ' value="' . htmlspecialchars($openid) . '" />' .
55 '<div class="input-group-addon">' .
56 '<a href="#" onclick="' .
57 'vHWin=window.open(' . $popUpUrl . ',null,\'width=800,height=400,status=0,menubar=0,scrollbars=0\');' .
58 'vHWin.focus();return false;' .
59 '">' .
60 '<img src="../typo3/sysext/openid/ext_icon_small.png" alt="' . $add . '" title="' . $add . '"/>' .
61 '</a>' .
62 '</div>' .
63 '</div>';
64 }
65
66 /**
67 * @return BackendUserAuthentication
68 */
69 protected function getBackendUser() {
70 return $GLOBALS['BE_USER'];
71 }
72
73 /**
74 * @return LanguageService
75 */
76 protected function getLanguageService() {
77 return $GLOBALS['LANG'];
78 }
79 }