Fixed bug #15338: sys_action: Link to edit the sql query action is missing for newly...
authorSteffen Kamper <info@sk-typo3.de>
Wed, 11 Aug 2010 08:12:33 +0000 (08:12 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Wed, 11 Aug 2010 08:12:33 +0000 (08:12 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8563 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/sys_action/locallang.xml
typo3/sysext/sys_action/task/class.tx_sysaction_task.php

index 5664112..4ebb4b5 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-08-11  Steffen Kamper  <steffen@typo3.org>
 
+       * Fixed bug #15338: sys_action: Link to edit the sql query action is missing for newly created actions (Thanks to Stefan Galinski)
        * Fixed bug #13802: Hardcoded typo3_src Folder in TestCase tests/t3lib/cache/t3lib_cache_factoryTest.php (Thanks to Stefano Kowalke)
 
 2010-08-10  Christian Kuhn  <lolli@schwarzbu.ch>
index 26950c6..cb36387 100755 (executable)
@@ -25,6 +25,8 @@
                        <label index="action_notReady">Error: The action configuration is not finished.</label>
                        <label index="action_download_file">Click here to download the exported data in a file</label>
                        <label index="action_editQuery">Edit Query</label>
+                       <label index="action_createQuery">Create Query</label>
+                       <label index="action_emptyQuery">Query is empty, create one first!</label>
                        <label index="action_error">Action error!</label>
                        <label index="action_lowlevelMissing">The extension "lowlevel" must be installed in order to create a query.</label>
                        <label index="action_BEu_hidden">Disable user</label>
index 61ca4db..bdcd2af 100644 (file)
@@ -795,34 +795,52 @@ class tx_sysaction_task implements tx_taskcenter_Task {
                if (t3lib_extMgm::isLoaded('lowlevel')) {
                        $sql_query = unserialize($record['t2_data']);
 
-                       if (is_array($sql_query) && strtoupper(substr(trim($sql_query['qSelect']), 0, 6)) == 'SELECT') {
+                       if (!is_array($sql_query) ||
+                               (is_array($sql_query) && strtoupper(substr(trim($sql_query['qSelect']), 0, 6)) === 'SELECT')) {
+
                                $actionContent = '';
 
-                               $fullsearch = t3lib_div::makeInstance("t3lib_fullsearch");
+                               $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
                                $fullsearch->formW = 40;
                                $fullsearch->noDownloadB = 1;
 
                                $type = $sql_query['qC']['search_query_makeQuery'];
-                               $res = $GLOBALS['TYPO3_DB']->sql_query($sql_query['qSelect']);
-
-                               if (!$GLOBALS['TYPO3_DB']->sql_error()) {
-                                       $fullsearch->formW = 48;
-                                               // additional configuration
-                                       $GLOBALS['SOBE']->MOD_SETTINGS['search_result_labels'] = 1;
-                                       $cP = $fullsearch->getQueryResultCode($type, $res, $sql_query['qC']['queryTable']);
-                                       $actionContent = $cP['content'];
-
-                                               // if the result is rendered as csv or xml, show a download link
-                                       if ($type == 'csv' || $type == 'xml' ) {
-                                               $actionContent .= '<br /><br /><a href="' . t3lib_div::getIndpEnv('REQUEST_URI') . '&download_file=1"><strong>' . $GLOBALS['LANG']->getLL('action_download_file') . '</strong></a>';
+                               $sqlQuery = $sql_query['qSelect'];
+                               $queryIsEmpty = FALSE;
+
+                               if ($sqlQuery) {
+                                       $res = $GLOBALS['TYPO3_DB']->sql_query($sqlQuery);
+
+                                       if (!$GLOBALS['TYPO3_DB']->sql_error()) {
+                                               $fullsearch->formW = 48;
+                                                       // additional configuration
+                                               $GLOBALS['SOBE']->MOD_SETTINGS['search_result_labels'] = 1;
+                                               $cP = $fullsearch->getQueryResultCode($type, $res, $sql_query['qC']['queryTable']);
+                                               $actionContent = $cP['content'];
+
+                                                       // if the result is rendered as csv or xml, show a download link
+                                               if ($type === 'csv' || $type === 'xml') {
+                                                       $actionContent .= '<br /><br /><a href="' . t3lib_div::getIndpEnv('REQUEST_URI') . '&download_file=1"><strong>' . $GLOBALS['LANG']->getLL('action_download_file') . '</strong></a>';
+                                               }
+                                       } else {
+                                               $actionContent .= $GLOBALS['TYPO3_DB']->sql_error();
                                        }
                                } else {
-                                       $actionContent .= $GLOBALS['TYPO3_DB']->sql_error();
+                                               // query is empty (not built)
+                                       $queryIsEmpty = TRUE;
+                                       $flashMessage = t3lib_div::makeInstance (
+                                               't3lib_FlashMessage',
+                                               $GLOBALS['LANG']->getLL('action_emptyQuery', TRUE),
+                                               $GLOBALS['LANG']->getLL('action_error'),
+                                               t3lib_FlashMessage::ERROR
+                                       );
+                                       $content .= '<br />' . $flashMessage->render();
                                }
-
-                               // Admin users are allowed to see and edit the query
+                                       // Admin users are allowed to see and edit the query
                                if ($GLOBALS['BE_USER']->isAdmin()) {
-                                       $actionContent .= '<hr /> ' . $fullsearch->tableWrap($sql_query['qSelect']);
+                                       if (!$queryIsEmpty) {
+                                               $actionContent .= '<hr /> ' . $fullsearch->tableWrap($sql_query['qSelect']);
+                                       }
                                        $actionContent .= '<br /><a title="' . $GLOBALS['LANG']->getLL('action_editQuery') . '" href="' . $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('lowlevel') . 'dbint/index.php?id=' .
                                                '&SET[function]=search' .
                                                '&SET[search]=query' .
@@ -830,7 +848,7 @@ class tx_sysaction_task implements tx_taskcenter_Task {
                                                '&storeControl[LOAD]=1' .
                                                '">
                                                <img class="icon"' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif') . ' alt="" />' .
-                                               $GLOBALS['LANG']->getLL('action_editQuery') . '</a><br /><br />';
+                                               $GLOBALS['LANG']->getLL($queryIsEmpty ? 'action_createQuery' : 'action_editQuery') . '</a><br /><br />';
                                }
 
                                $content .= $this->taskObject->doc->section($GLOBALS['LANG']->getLL('action_t2_result'), $actionContent, 0, 1);