Fixed bug #14949: "View Item" does not resolve real MM-relations
authorFrancois Suter <francois.suter@typo3.org>
Sun, 22 Aug 2010 17:13:30 +0000 (17:13 +0000)
committerFrancois Suter <francois.suter@typo3.org>
Sun, 22 Aug 2010 17:13:30 +0000 (17:13 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8642 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
typo3/show_item.php

index f5762df..6a2eac1 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2010-08-22  Francois Suter  <francois@typo3.org>
 
        * Fixed bug #15102: Scheduler: BE module does not use new skin properly (TYPO3 4.5)
+       * Fixed bug #14949: "View Item" does not resolve real MM-relations (thanks to Caspar Stuebs)
 
 2010-08-20 Steffen Kamper  <steffen@typo3.org>
 
index dc5ebf0..e7ec670 100644 (file)
@@ -2177,36 +2177,40 @@ final class t3lib_BEfunc {
                                break;
                                case 'select':
                                        if ($theColConf['MM']) {
-                                               // Display the title of MM related records in lists
-                                               if ($noRecordLookup) {
-                                                       $MMfield = $theColConf['foreign_table'].'.uid';
-                                               } else  {
-                                                       $MMfields = array($theColConf['foreign_table'].'.'.$TCA[$theColConf['foreign_table']]['ctrl']['label']);
-                                                       foreach (t3lib_div::trimExplode(',', $TCA[$theColConf['foreign_table']]['ctrl']['label_alt'], 1) as $f) {
-                                                               $MMfields[] = $theColConf['foreign_table'].'.'.$f;
+                                               if ($uid) {
+                                                               // Display the title of MM related records in lists
+                                                       if ($noRecordLookup) {
+                                                               $MMfield = $theColConf['foreign_table'] . '.uid';
+                                                       } else  {
+                                                               $MMfields = array($theColConf['foreign_table'] . '.' . $TCA[$theColConf['foreign_table']]['ctrl']['label']);
+                                                               foreach (t3lib_div::trimExplode(',', $TCA[$theColConf['foreign_table']]['ctrl']['label_alt'], 1) as $f) {
+                                                                       $MMfields[] = $theColConf['foreign_table'] . '.' . $f;
+                                                               }
+                                                               $MMfield = join(',', $MMfields);
                                                        }
-                                                       $MMfield = join(',',$MMfields);
-                                               }
 
-                                               $dbGroup = t3lib_div::makeInstance('t3lib_loadDBGroup');
-                                               $dbGroup->start($value, $theColConf['foreign_table'], $theColConf['MM'], $uid, $table, $theColConf);
-                                               $selectUids = $dbGroup->tableArray[$theColConf['foreign_table']];
-
-                                               if (is_array($selectUids) && count($selectUids)>0) {
-                                                       $MMres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                                               'uid, '.$MMfield,
-                                                               $theColConf['foreign_table'],
-                                                               'uid IN ('.implode(',', $selectUids).')'
-                                                       );
-                                                       while($MMrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($MMres)) {
-                                                               $mmlA[] = ($noRecordLookup ? $MMrow['uid'] : self::getRecordTitle($theColConf['foreign_table'], $MMrow, FALSE, $forceResult));
-                                                       }
-                                                       $GLOBALS['TYPO3_DB']->sql_free_result($MMres);
+                                                       $dbGroup = t3lib_div::makeInstance('t3lib_loadDBGroup');
+                                                       $dbGroup->start($value, $theColConf['foreign_table'], $theColConf['MM'], $uid, $table, $theColConf);
+                                                       $selectUids = $dbGroup->tableArray[$theColConf['foreign_table']];
 
-                                                       if (is_array($mmlA)) {
-                                                               $l = implode('; ', $mmlA);
+                                                       if (is_array($selectUids) && count($selectUids)>0) {
+                                                               $MMres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                                                                       'uid, ' . $MMfield,
+                                                                       $theColConf['foreign_table'],
+                                                                       'uid IN (' . implode(',', $selectUids) . ')'
+                                                               );
+                                                               while ($MMrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($MMres)) {
+                                                                       $mmlA[] = ($noRecordLookup ? $MMrow['uid'] : self::getRecordTitle($theColConf['foreign_table'], $MMrow, FALSE, $forceResult));
+                                                               }
+                                                               $GLOBALS['TYPO3_DB']->sql_free_result($MMres);
+
+                                                               if (is_array($mmlA)) {
+                                                                       $l = implode('; ', $mmlA);
+                                                               } else {
+                                                                       $l = '';
+                                                               }
                                                        } else {
-                                                               $l = '';
+                                                               $l = 'N/A';
                                                        }
                                                } else {
                                                        $l = 'N/A';
index d91118e..0f7031a 100644 (file)
@@ -278,16 +278,16 @@ class SC_show_item {
                $i = 0;
 
                        // Traverse the list of fields to display for the record:
-               $fieldList = t3lib_div::trimExplode(',',$TCA[$this->table]['interface']['showRecordFieldList'],1);
-               foreach($fieldList as $name)    {
+               $fieldList = t3lib_div::trimExplode(',', $TCA[$this->table]['interface']['showRecordFieldList'], 1);
+               foreach ($fieldList as $name) {
                        $name = trim($name);
                        if ($TCA[$this->table]['columns'][$name])       {
-                               if (!$TCA[$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$this->table.':'.$name))        {
+                               if (!$TCA[$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name)) {
                                        $i++;
                                        $tableRows[] = '
                                                <tr>
                                                        <td class="t3-col-header">' . $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($this->table, $name), 1) . '</td>
-                                                       <td>' . htmlspecialchars(t3lib_BEfunc::getProcessedValue($this->table, $name, $this->row[$name])) . '</td>
+                                                       <td>' . htmlspecialchars(t3lib_BEfunc::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $this->row['uid'])) . '</td>
                                                </tr>';
                                }
                        }