2005-12-19 Sebastian Kurfuerst <sebastian@garbahe-group.de>
authorSebastian Kurfürst <sebastian.kurfuerst@typo3.org>
Mon, 19 Dec 2005 20:29:26 +0000 (20:29 +0000)
committerSebastian Kurfürst <sebastian.kurfuerst@typo3.org>
Mon, 19 Dec 2005 20:29:26 +0000 (20:29 +0000)
* New feature #1078: make javascript warning/confirmation popups
configurable
* Fixed bug #1578: Radio button validation does not work if
there is only one radio button
* Fixed bug #1906: first part only implements override.* for
arbitary adminPanel options - relates to #1518

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@919 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_clipboard.php
t3lib/class.t3lib_tceforms.php
t3lib/class.t3lib_tsfebeuserauth.php
t3lib/class.t3lib_userauthgroup.php
t3lib/jsfunc.validateform.js
typo3/alt_clickmenu.php
typo3/alt_doc.php
typo3/file_upload.php
typo3/sysext/cms/tslib/class.tslib_content.php

index dcbc4bd..897458f 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
+2005-12-19  Sebastian Kurfuerst  <sebastian@garbahe-group.de>
+
+       * New feature #1078: make javascript warning/confirmation popups configurable
+       * Fixed bug #1578: Radio button validation does not work if there is only one radio button
+       * Fixed bug #1906: first part only implements override.* for arbitary adminPanel options - relates to #1518
+
 2005-12-19  Michael Stucki  <michael@typo3.org>
 
-       * Added support for objects in conditions. Use it like this: [globalString = TSFE:fe_user|user|username = myname]
+       * Added support for objects in conditions. Use it like this: [globalString = TSFE:fe_user|user|username = myname]
 
 2005-12-19  Kasper Skaarhoj  <kasper2005@typo3.com>
 
index 32a906c..4c1daa9 100755 (executable)
@@ -333,11 +333,16 @@ class t3lib_clipboard {
                }
                                // Delete:
                if ($elCount)   {
-                       $opt[]='<option value="'.htmlspecialchars("
+                       if($GLOBALS['BE_USER']->jsConfirmation(4))      {
+                               $js = "
                        if(confirm(".$GLOBALS['LANG']->JScharCode(sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.deleteClip'),$elCount)).")){
                                document.location='".$this->deleteUrl(0,$this->fileMode?1:0)."&redirect='+top.rawurlencode(document.location);
                        }
-                       ").'">'.$this->clLabel('delete','rm').'</option>';
+                                       ";
+                       } else {
+                               $js = " document.location='".$this->deleteUrl(0,$this->fileMode?1:0)."&redirect='+top.rawurlencode(document.location); ";
+                       }
+                       $opt[]='<option value="'.htmlspecialchars($js).'">'.$this->clLabel('delete','rm').'</option>';
                }
                $selector_menu = '<select name="_clipMenu" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$opt).'</select>';
 
@@ -625,6 +630,7 @@ class t3lib_clipboard {
         * @return      string          JavaScript "confirm" message
         */
        function confirmMsg($table,$rec,$type,$clElements)      {
+               if($GLOBALS['BE_USER']->jsConfirmation(2))      {
                $labelKey = 'LLL:EXT:lang/locallang_core.php:mess.'.($this->currentMode()=='copy'?'copy':'move').($this->current=='normal'?'':'cb').'_'.$type;
                $msg = $GLOBALS['LANG']->sL($labelKey);
 
@@ -658,6 +664,9 @@ class t3lib_clipboard {
                        t3lib_div::fixed_lgd_cs($selRecTitle,30),
                        t3lib_div::fixed_lgd_cs($thisRecTitle,30)
                        )).')';
+               } else {
+                       $conf = '';
+               }
                return $conf;
        }
 
index 12d722f..c32d336 100755 (executable)
@@ -736,9 +736,11 @@ class t3lib_TCEforms       {
                                if (
                                                (($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
                                                ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div::inList($TCA[$table]['ctrl']['requestUpdate'],$field)))
-                                               && !$BE_USER->uc['noOnChangeAlertInTypeFields'])        {
+                                               && $GLOBALS['BE_USER']->jsConfirmation(1))      {
                                        $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
-                               } else {$alertMsgOnChange='';}
+                               } else {
+                                       $alertMsgOnChange = 'if(TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm();}';
+                               }
 
                                        // Render as a hidden field?
                                if (in_array($field,$this->hiddenFieldListArr)) {
@@ -2022,7 +2024,12 @@ class t3lib_TCEforms     {
                $tCells =array();
                $pct = round(100/count($sArr));
                foreach($sArr as $sKey => $sheetCfg)    {
-                       $onClick = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm()};";
+                       if ($GLOBALS['BE_USER']->jsConfirmation(1))     {
+                               $onClick = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){'.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm()};";
+                       } else {
+                               $onClick = 'if(TBE_EDITOR_checkSubmit(-1)){ '.$this->elName($elName).".value='".$sKey."'; TBE_EDITOR_submitForm();}";
+                       }
+
 
                        $tCells[]='<td width="'.$pct.'%" style="'.($sKey==$sheetKey ? 'background-color: #9999cc; font-weight: bold;' : 'background-color: #aaaaaa;').' cursor: hand;" onclick="'.htmlspecialchars($onClick).'" align="center">'.
                                        ($sheetCfg['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($sheetCfg['ROOT']['TCEforms']['sheetTitle']) : $sKey).
@@ -2176,13 +2183,14 @@ class t3lib_TCEforms    {
                                                                                'rows' => 2
                                                                        );
                                                                }
+
                                                                if (
                                                                        (($GLOBALS['TCA'][$table]['ctrl']['type'] && !strcmp($key,$GLOBALS['TCA'][$table]['ctrl']['type'])) ||
                                                                        ($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'] && t3lib_div::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'],$key)))
-                                                                       && !$GLOBALS['BE_USER']->uc['noOnChangeAlertInTypeFields']) {
+                                                                       && $GLOBALS['BE_USER']->jsConfirmation(1))      {
                                                                        $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
                                                                } else {
-                                                                       $alertMsgOnChange='';
+                                                                       $alertMsgOnChange = 'if(TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm();}';
                                                                }
 
                                                                $fakePA['fieldChangeFunc']=$PA['fieldChangeFunc'];
index 524f9f2..3e18bdc 100755 (executable)
@@ -739,6 +739,7 @@ class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
        function extGetFeAdminValue($pre,$val='')       {
                if ($this->extAdmModuleEnabled($pre))   {       // Check if module is enabled.
                                // Exceptions where the values can be overridden from backend:
+                               // deprecated
                        if ($pre.'_'.$val == 'edit_displayIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayIcons'])     {
                                return true;
                        }
@@ -747,11 +748,11 @@ class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
                        }
 
                                // override all settings with user TSconfig
-                       if ($this->extAdminConfig['module.'][$pre.'.'][$val] && $val)   {
-                               return $this->extAdminConfig['module.'][$pre.'.'][$val];
+                       if ($this->extAdminConfig['override.'][$pre.'.'][$val] && $val) {
+                               return $this->extAdminConfig['override.'][$pre.'.'][$val];
                        }
-                       if ($this->extAdminConfig['module.'][$pre])     {
-                               return $this->extAdminConfig['module.'][$pre];
+                       if ($this->extAdminConfig['override.'][$pre])   {
+                               return $this->extAdminConfig['override.'][$pre];
                        }
 
                        $retVal = $val ? $this->uc['TSFE_adminConfig'][$pre.'_'.$val] : 1;
index 4fa1c40..955af33 100755 (executable)
@@ -959,8 +959,32 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                return $this->groupData['filemounts'];
        }
 
-
-
+       /**
+        * Returns true or false, depending if an alert popup (a javascript confirmation) should be shown
+        * call like $GLOBALS['BE_USER']->jsConfirmation($BITMASK)
+        *
+        * @param $bitmask int   Bitmask
+        *    1 - typeChange
+        *    2 - copy/move/paste
+        *    4 - delete
+        *    8 - frontend editing
+        *    128 - other (not used yet)
+        * @return boolean true if the confirmation should be shown
+        **/
+        function jsConfirmation($bitmask)      {
+                $alertPopup = $GLOBALS['BE_USER']->getTSConfig('options.alertPopups');
+                $alertPopup = (int)$alertPopup['value'];
+
+                if(!$alertPopup)       {
+                        $alertPopup = 255;     // default: show all warnings
+                }
+
+                if(($alertPopup&$bitmask) == $bitmask) { // show confirmation
+                        return 1;
+                } else { // don't show confirmation
+                        return 0;
+                }
+        }
 
 
 
index ccdc875..b229e09 100755 (executable)
@@ -88,10 +88,16 @@ function validateForm(theFormname,theFieldlist,goodMess,badMess,emailMess)  {
                                                }
                                        break;
                                        case "radio":
-                                               var l=fObj.length;
-                                               for (a=0; a<l;a++)      {
-                                                       if (fObj[a].checked)    {
-                                                               value = fObj[a].value;
+                                               var len=fObj.length;
+                                               if (len)        {
+                                                       for (a=0;a<len;a++)     {
+                                                               if (fObj[a].checked)    {
+                                                                       value = fObj[a].value;
+                                                               }
+                                                       }
+                                               } else {
+                                                       if (fObj.checked)       {
+                                                               value = fObj.value;
                                                        }
                                                }
                                        break;
index 479ed2e..11b7d42 100755 (executable)
@@ -443,7 +443,11 @@ class clickMenu {
        function DB_paste($table,$uid,$type,$elInfo)    {
                $editOnClick = '';
                $loc = 'top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
+               if($GLOBALS['BE_USER']->jsConfirmation(2))      {
                $conf = $loc.' && confirm('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.($elInfo[2]=='copy'?'copy':'move').'_'.$type),$elInfo[0],$elInfo[1])).')';
+               } else {
+                       $conf = $loc;
+               }
                $editOnClick = 'if('.$conf.'){'.$loc.'.document.location=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
 
                return $this->linkItem(
@@ -696,7 +700,12 @@ class clickMenu {
        function DB_delete($table,$uid,$elInfo) {
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-               $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),$elInfo[0])).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
+               if($GLOBALS['BE_USER']->jsConfirmation(4))      {
+                       $conf = "confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),$elInfo[0])).")";
+               } else {
+                       $conf = '1==1';
+               }
+               $editOnClick='if('.$loc." && ".$conf." ){".$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
                        "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
 
                return $this->linkItem(
@@ -923,7 +932,12 @@ class clickMenu {
        function FILE_delete($path)     {
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-               $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),basename($path))).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
+               if($GLOBALS['BE_USER']->jsConfirmation(4))      {
+                       $conf = "confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),basename($path))).")";
+               } else {
+                       $conf = '1==1';
+               }
+               $editOnClick='if('.$loc." && ".$conf." ){".$loc.".document.location=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
                        "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
 
                return $this->linkItem(
@@ -945,7 +959,12 @@ class clickMenu {
        function FILE_paste($path,$target,$elInfo)      {
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
+               if($GLOBALS['BE_USER']->jsConfirmation(2))      {
                $conf=$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.($elInfo[2]=='copy'?'copy':'move').'_into'),$elInfo[0],$elInfo[1])).")";
+               } else {
+                       $conf=$loc;
+               }
+
                $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
                        "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
 
index e52f30a..bffb5d6 100755 (executable)
@@ -433,7 +433,9 @@ class SC_alt_doc {
                                }
                        }
                        function deleteRecord(table,id,url)     {       //
-                               if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).'))      {
+                               if (
+                                       '.($GLOBALS['BE_USER']->jsConfirmation(4)?'confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')':'1==1').'
+                               )       {
                                        document.location = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
                                }
                                return false;
index 35acae2..a6086c5 100755 (executable)
@@ -141,11 +141,17 @@ class SC_file_upload {
                $this->doc->docType = 'xhtml_trans';
                $this->doc->backPath = $BACK_PATH;
                $this->doc->form='<form action="tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">';
+
+               if($GLOBALS['BE_USER']->jsConfirmation(1))      {
+                       $confirm = ' && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).')';
+               } else {
+                       $confirm = '';
+               }
                $this->doc->JScode=$this->doc->wrapScriptTags('
                        var path = "'.$this->target.'";
 
                        function reload(a)      {       //
-                               if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).')))  {
+                               if (!changed || (changed '.$confirm.')) {
                                        var params = "&target="+escape(path)+"&number="+a+"&returnUrl='.htmlspecialchars($this->returnUrl).'";
                                        document.location = "file_upload.php?"+params;
                                }
index 4fac18c..2fc417f 100755 (executable)
@@ -6927,7 +6927,7 @@ class tslib_cObj {
                                $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$nPid.']=new&noView='.$nV,$currentRecord);
                        }
                } else {
-                       if ($confirm)   {
+                       if ($confirm && $GLOBALS['BE_USER']->jsConfirmation(8)) {
                                $cf1="if (confirm(unescape('".t3lib_div::rawurlencodeJS($confirm)."'))){";
                                $cf2='}';
                        } else {