Project

General

Profile

Bug #20123 » 10596_setuphook_v2.diff

Administrator Admin, 2009-03-03 17:04

View differences:

typo3/interfaces/interface.setup_usersettingshook.php (revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009 Steffen Kamper <info@sk-typo3.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* interface for classes which hook into setup for manipulating user fields and posted data
*
* @author Steffen Kamper <info@sk-typo3.de>
* @package TYPO3
* @subpackage setup
*/
interface setup_userSettingsHook {
/**
* modifies posted array [t3lib_div::_POST('data')]
*
* @param array array of posted data
* @param SC_mod_user_setup_index parent object
* @return void
*/
public function processUserSettingPost(&$dataArray, &$parentObject);
/**
* modifies menuItems array
*
* @param array array of menu Items
* @param SC_mod_user_setup_index parent object
* @return void
*/
public function manipulateUserSettingFields(&$menuItems, &$parentObject);
}
?>
typo3/sysext/setup/mod/index.php (working copy)
$d = t3lib_div::_POST('data');
if (is_array($d)) {
// Hook for manipulating userSettings
if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['setup']['processUserSettingPost'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['setup']['processUserSettingPost'] as $classData) {
$hookObject = &t3lib_div::getUserObj($classData);
if(!($hookObject instanceof setup_userSettingsHook)) {
throw new UnexpectedValueException('$hookObject must implement interface setup_userSettingsHook', 1235863751);
}
$hookObject->processUserSettingPost($d, $this);
}
}
// UC hashed before applying changes
$save_before = md5(serialize($BE_USER->uc));
......
// Personal data
$code = array();
$i = 0;
$label = $LANG->getLL('language').' & '.$LANG->getLL('personal_data');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('beUser_realName');
$code[$label][$i++][1] = $this->getCSH('beUser_realName');
}
$code[$i][1] = $this->setLabel('beUser_realName');
$code[$i][2] = '<input id="field_beUser_realName" type="text" name="ext_beuser[realName]" value="'.htmlspecialchars($BE_USER->user['realName']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('beUser_realName');
$code[$label][$i][1] = $this->setLabel('beUser_realName');
$code[$label][$i][2] = '<input id="field_beUser_realName" type="text" name="ext_beuser[realName]" value="'.htmlspecialchars($BE_USER->user['realName']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('beUser_realName');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('beUser_email');
$code[$label][$i++][1] = $this->getCSH('beUser_email');
}
$code[$i][1] = $this->setLabel('beUser_email');
$code[$i][2] = '<input id="field_beUser_email" type="text" name="ext_beuser[email]" value="'.htmlspecialchars($BE_USER->user['email']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('beUser_email');
$code[$label][$i][1] = $this->setLabel('beUser_email');
$code[$label][$i][2] = '<input id="field_beUser_email" type="text" name="ext_beuser[email]" value="'.htmlspecialchars($BE_USER->user['email']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('beUser_email');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('emailMeAtLogin');
$code[$label][$i++][1] = $this->getCSH('emailMeAtLogin');
}
$code[$i][1] = $this->setLabel('emailMeAtLogin').($BE_USER->user['email'] ? ' ('.$BE_USER->user['email'].')' : '');
$code[$i][2] = '<input id="field_emailMeAtLogin" type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('emailMeAtLogin');
$code[$label][$i][1] = $this->setLabel('emailMeAtLogin').($BE_USER->user['email'] ? ' ('.$BE_USER->user['email'].')' : '');
$code[$label][$i][2] = '<input id="field_emailMeAtLogin" type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('emailMeAtLogin');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('newPassword');
$code[$label][$i++][1] = $this->getCSH('newPassword');
}
$code[$i][1] = $this->setLabel('newPassword');
$code[$i][2] = '<input id="field_newPassword" type="password" name="ext_beuser[password1]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('newPassword');
$code[$label][$i][1] = $this->setLabel('newPassword');
$code[$label][$i][2] = '<input id="field_newPassword" type="password" name="ext_beuser[password1]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('newPassword');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('newPasswordAgain');
$code[$label][$i++][1] = $this->getCSH('newPasswordAgain');
}
$code[$i][1] = $this->setLabel('newPasswordAgain');
$code[$i][2] = '<input id="field_newPasswordAgain" type="password" name="ext_beuser[password2]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('newPasswordAgain');
$code[$label][$i][1] = $this->setLabel('newPasswordAgain');
$code[$label][$i][2] = '<input id="field_newPasswordAgain" type="password" name="ext_beuser[password2]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('newPasswordAgain');
// Languages:
$opt = array();
......
if ($displayFullText) {
$code[$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH);
$code[$label][$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH);
}
$code[$i][1] = $this->setLabel('language');
$code[$i][2] = $languageCode;
$code[$i++][3] = $displayFullText ? '&nbsp;' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH);
$code[$label][$i][1] = $this->setLabel('language');
$code[$label][$i][2] = $languageCode;
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH);
$menuItems[] = array(
'label' => $LANG->getLL('language').' & '.$LANG->getLL('personal_data'),
'content' => $this->doc->spacer(20).$this->doc->table($code)
);
// compiling the 'Startup' section
$code = array();
$label = $LANG->getLL('opening');
$i = 0;
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('condensedMode');
$code[$label][$i++][1] = $this->getCSH('condensedMode');
}
$code[$i][1] = $this->setLabel('condensedMode','condensedMode');
$code[$i][2] = '<input id="field_condensedMode" type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('condensedMode');
$code[$label][$i][1] = $this->setLabel('condensedMode','condensedMode');
$code[$label][$i][2] = '<input id="field_condensedMode" type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('condensedMode');
if($GLOBALS['BE_USER']->uc['interfaceSetup'] == 'backend_old') {
$code[$i][1] = $this->setLabel('noMenuMode','noMenuMode');
$code[$i][2] = '<select id="field_noMenuMode" name="data[noMenuMode]">
$code[$label][$i][1] = $this->setLabel('noMenuMode','noMenuMode');
$code[$label][$i][2] = '<select id="field_noMenuMode" name="data[noMenuMode]">
<option value=""'.(!$BE_USER->uc['noMenuMode']?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_def').'</option>
<option value="1"'.($BE_USER->uc['noMenuMode'] && (string)$BE_USER->uc['noMenuMode']!="icons"?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_sel').'</option>
<option value="icons"'.((string)$BE_USER->uc['noMenuMode']=='icons'?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_icons').'</option>
</select>';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('noMenuMode');
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('noMenuMode');
}
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('startModule');
$code[$label][$i++][1] = $this->getCSH('startModule');
}
$code[$i][1] = $this->setLabel('startModule','startModule');
$code[$label][$i][1] = $this->setLabel('startModule','startModule');
$modSelect = '<select id="field_startModule" name="data[startModule]">';
$modSelect .= '<option value=""></option>';
if (empty($BE_USER->uc['startModule'])) {
......
}
}
$modSelect .= '</select>';
$code[$i][2] = $modSelect;
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('startModule');
$code[$label][$i][2] = $modSelect;
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('startModule');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('showThumbs');
$code[$label][$i++][1] = $this->getCSH('showThumbs');
}
$code[$i][1] = $this->setLabel('showThumbs','thumbnailsByDefault');
$code[$i][2] = '<input id="field_showThumbs" type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('showThumbs');
$code[$label][$i][1] = $this->setLabel('showThumbs','thumbnailsByDefault');
$code[$label][$i][2] = '<input id="field_showThumbs" type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('showThumbs');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('helpText');
$code[$label][$i++][1] = $this->getCSH('helpText');
}
$code[$i][1] = $this->setLabel('helpText');
$code[$i][2] = '<input id="field_helpText" type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('helpText');
$code[$label][$i][1] = $this->setLabel('helpText');
$code[$label][$i][2] = '<input id="field_helpText" type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('helpText');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('edit_showFieldHelp');
$code[$label][$i++][1] = $this->getCSH('edit_showFieldHelp');
}
$code[$i][1] = $this->setLabel('edit_showFieldHelp');
$code[$i][2] = '<select id="field_edit_showFieldHelp" name="data[edit_showFieldHelp]">
$code[$label][$i][1] = $this->setLabel('edit_showFieldHelp');
$code[$label][$i][2] = '<select id="field_edit_showFieldHelp" name="data[edit_showFieldHelp]">
<option value="">'.$LANG->getLL('edit_showFieldHelp_none').'</option>
<option value="icon"'.($BE_USER->uc['edit_showFieldHelp']=='icon'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_icon').'</option>
<option value="text"'.($BE_USER->uc['edit_showFieldHelp']=='text'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_message').'</option>
</select>';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_showFieldHelp');
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_showFieldHelp');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('maxTitleLen');
$code[$label][$i++][1] = $this->getCSH('maxTitleLen');
}
$code[$i][1] = $this->setLabel('maxTitleLen','titleLen');
$code[$i][2] = '<input id="field_maxTitleLen" type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('maxTitleLen');
$code[$label][$i][1] = $this->setLabel('maxTitleLen','titleLen');
$code[$label][$i][2] = '<input id="field_maxTitleLen" type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('maxTitleLen');
$menuItems[] = array(
'label' => $LANG->getLL('opening'),
'content' => $this->doc->spacer(20).$this->doc->table($code)
);
// Edit
$code = array();
$label = $LANG->getLL('edit_functions') . ' & ' . $LANG->getLL('functions');
$i = 0;
if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled']) {
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('edit_RTE');
$code[$label][$i++][1] = $this->getCSH('edit_RTE');
}
$code[$i][1] = $this->setLabel('edit_RTE');
$code[$i][2] = '<input id="field_edit_RTE" type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_RTE');
$code[$label][$i][1] = $this->setLabel('edit_RTE');
$code[$label][$i][2] = '<input id="field_edit_RTE" type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_RTE');
}
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('edit_docModuleUpload');
$code[$label][$i++][1] = $this->getCSH('edit_docModuleUpload');
}
$code[$i][1] = $this->setLabel('edit_docModuleUpload');
$code[$i][2] = '<input id="field_edit_docModuleUpload" type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_docModuleUpload');
$code[$label][$i][1] = $this->setLabel('edit_docModuleUpload');
$code[$label][$i][2] = '<input id="field_edit_docModuleUpload" type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_docModuleUpload');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('disableCMlayers');
$code[$label][$i++][1] = $this->getCSH('disableCMlayers');
}
$code[$i][1] = $this->setLabel('disableCMlayers');
$code[$i][2] = '<input id="field_disableCMlayers" type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('disableCMlayers');
$code[$label][$i][1] = $this->setLabel('disableCMlayers');
$code[$label][$i][2] = '<input id="field_disableCMlayers" type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('disableCMlayers');
// Advanced Operations:
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('copyLevels');
$code[$label][$i++][1] = $this->getCSH('copyLevels');
}
$code[$i][1] = $this->setLabel('copyLevels');
$code[$i][2] = '<input id="field_copyLevels" type="text" name="data[copyLevels]" value="'.$BE_USER->uc['copyLevels'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />&nbsp;'.$LANG->getLL('levels');
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('copyLevels');
$code[$label][$i][1] = $this->setLabel('copyLevels');
$code[$label][$i][2] = '<input id="field_copyLevels" type="text" name="data[copyLevels]" value="'.$BE_USER->uc['copyLevels'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />&nbsp;'.$LANG->getLL('levels');
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('copyLevels');
if ($displayFullText) {
$code[$i++][1] = $this->getCSH('recursiveDelete');
$code[$label][$i++][1] = $this->getCSH('recursiveDelete');
}
$code[$i][1] = $this->setLabel('recursiveDelete');
$code[$i][2] = '<input id="field_recursiveDelete" type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />';
$code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('recursiveDelete');
$code[$label][$i][1] = $this->setLabel('recursiveDelete');
$code[$label][$i][2] = '<input id="field_recursiveDelete" type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />';
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('recursiveDelete');
$menuItems[] = array(
'label' => $LANG->getLL('edit_functions') . ' & ' . $LANG->getLL('functions'),
'content' => $this->doc->spacer(20).$this->doc->table($code)
);
$code = array();
$i = 0;
// Admin functions
if($BE_USER->isAdmin()) {
$label = $LANG->getLL('adminFunctions');
$i = 0;
// Simulate selector box:
if ($this->simulateSelector) {
if ($displayFullText) {
$code[$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH);
$code[$label][$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH);
}
$code[$i][1] = $this->setLabel('simulate');
$code[$i][2] = $this->simulateSelector;
$code[$i++][3] = $displayFullText ? '&nbsp;' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH);
$code[$label][$i][1] = $this->setLabel('simulate');
$code[$label][$i][2] = $this->simulateSelector;
$code[$label][$i++][3] = $displayFullText ? '&nbsp;' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH);
}
}
$menuItems[] = array(
'label' => $LANG->getLL('adminFunctions'),
'content' => $this->doc->spacer(20).$this->doc->table($code)
);
// Hook for manipulating userSetting fields
if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['setup']['manipulateUserSettingFields'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['setup']['manipulateUserSettingFields'] as $classData) {
$hookObject = &t3lib_div::getUserObj($classData);
if(!($hookObject instanceof setup_userSettingsHook)) {
throw new UnexpectedValueException('$hookObject must implement interface setup_userSettingsHook', 1235863751);
}
$hookObject->manipulateUserSettingFields($code, $this);
}
}
// compile table data
foreach ($code as $key => $tabFields) {
$menuItems[] = array(
'label' => $key,
'content' => $this->doc->spacer(20) . $this->doc->table($tabFields)
);
}
$this->content .= $this->doc->spacer(20);
$this->content .= $this->doc->getDynTabMenu($menuItems, 'user-setup', false, false, 100);
......
t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $BACK_PATH)
);
// Notice
$this->content .= $this->doc->spacer(30);
$this->content .= $this->doc->section('', $LANG->getLL('activateChanges'));
(3-3/3)