12a9b698c58a5d65c0d7961d77e431dba951c3f1
[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\Utility\GeneralUtility;
19
20 /**
21 * This class is the OpenID return script for the TYPO3 Backend (used in the user-settings module).
22 *
23 * @author Steffen Gebert <steffen@steffen-gebert.de>
24 */
25 class OpenidModuleSetup {
26
27 /**
28 * Checks weather BE user has access to change its OpenID identifier
29 *
30 * @param array $config: Configuration of the field
31 * @return bool Whether it is allowed to modify the given field
32 */
33 public function accessLevelCheck(array $config) {
34 $setupConfig = $GLOBALS['BE_USER']->getTSConfigProp('setup.fields');
35 if (isset($setupConfig['tx_openid_openid.']['disabled']) && $setupConfig['tx_openid_openid.']['disabled']) {
36 return FALSE;
37 }
38 return TRUE;
39 }
40
41 /**
42 * Render OpenID identifier field for user setup
43 *
44 * @param array $parameters Configuration of the field
45 * @param \TYPO3\CMS\Setup\Controller\SetupModuleController $parent: The calling parent object
46 * @return string HTML input field to change the OpenId
47 */
48 public function renderOpenID(array $parameters, \TYPO3\CMS\Setup\Controller\SetupModuleController $parent) {
49 $openid = $GLOBALS['BE_USER']->user['tx_openid_openid'];
50 $add = htmlspecialchars(
51 $GLOBALS['LANG']->sL('LLL:EXT:openid/Resources/Private/Language/Wizard.xlf:addopenid')
52 );
53
54 return '<div class="input-group">' .
55 '<input id="field_tx_openid_openid"' .
56 ' class="form-control"' .
57 ' type="text" name="data[be_users][tx_openid_openid]"' .
58 ' value="' . htmlspecialchars($openid) . '" />' .
59 '<div class="input-group-addon">' .
60 '<a href="#" onclick="' .
61 'vHWin=window.open(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_openid') . '&P[itemName]=data%5Bbe_users%5D%5Btx_openid_openid%5D') .
62 ',null,\'width=600,height=400,status=0,menubar=0,scrollbars=0\');' .
63 'vHWin.focus();return false;' .
64 '">' .
65 '<img src="../typo3/sysext/openid/ext_icon.png" alt="' . $add . '" title="' . $add . '"/>' .
66 '</a>' .
67 '</div>' .
68 '</div>';
69 }
70
71 }