[TASK] Change PHP namespace of EXT:openid to FoT3
[Packages/TYPO3.CMS.git] / typo3 / sysext / openid / Classes / OpenidModuleSetup.php
1 <?php
2 namespace FoT3\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 {
34 $setupConfig = $this->getBackendUser()->getTSConfigProp('setup.fields');
35 return empty($setupConfig['tx_openid_openid.']['disabled']);
36 }
37
38 /**
39 * Render OpenID identifier field for user setup
40 *
41 * @return string HTML input field to change the OpenId
42 */
43 public function renderOpenID()
44 {
45 $openid = $this->getBackendUser()->user['tx_openid_openid'];
46 $add = htmlspecialchars(
47 $this->getLanguageService()->sL('LLL:EXT:openid/Resources/Private/Language/locallang.xlf:addopenid')
48 );
49
50 $parameters = ['P[itemName]' => 'data[be_users][tx_openid_openid]'];
51 $popUpUrl = GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_openid', $parameters));
52 return '<div class="input-group">' .
53 '<input id="field_tx_openid_openid"' .
54 ' class="form-control"' .
55 ' type="text" name="data[be_users][tx_openid_openid]"' .
56 ' value="' . htmlspecialchars($openid) . '" />' .
57 '<div class="input-group-addon">' .
58 '<a href="#" onclick="' .
59 'vHWin=window.open(' . $popUpUrl . ',null,\'width=800,height=600,status=0,menubar=0,scrollbars=0\');' .
60 'vHWin.focus();return false;' .
61 '">' .
62 '<img src="../typo3/sysext/openid/ext_icon_small.png" alt="' . $add . '" title="' . $add . '"/>' .
63 '</a>' .
64 '</div>' .
65 '</div>';
66 }
67
68 /**
69 * @return BackendUserAuthentication
70 */
71 protected function getBackendUser()
72 {
73 return $GLOBALS['BE_USER'];
74 }
75
76 /**
77 * @return LanguageService
78 */
79 protected function getLanguageService()
80 {
81 return $GLOBALS['LANG'];
82 }
83 }