0016846.patch

Administrator Admin, 2010-12-26 18:45

Download (3.33 KB)

View differences:

t3lib/class.t3lib_loaddbgroup.php (Arbeitskopie)
620 620
			if (!(t3lib_div::testInt($updateToUid) && $updateToUid > 0)) {
621 621
				$updateToUid = 0;
622 622
			}
623
			$fields = 'uid,' . $foreign_field . ($symmetric_field ? ',' . $symmetric_field : '');
624 623

  
624
			$considerWorkspaces = ($GLOBALS['BE_USER']->workspace !== 0 && t3lib_BEfunc::isTableWorkspaceEnabled($foreign_table));
625

  
626
			$fields = 'uid,' . $foreign_field;
627
				// Consider the symmetric field if defined:
628
			if ($symmetric_field) {
629
				$fields .= ',' . $symmetric_field;
630
			}
631
				// Consider workspaces if defined and currently used:
632
			if ($considerWorkspaces) {
633
				$fields .= ',' . 't3ver_state,t3ver_oid';
634
			}
635

  
625 636
				// update all items
626 637
			foreach ($this->itemArray as $val) {
627 638
				$uid = $val['id'];
628 639
				$table = $val['table'];
629 640

  
630 641
					// fetch the current (not overwritten) relation record if we should handle symmetric relations
631
				if ($conf['symmetric_field']) {
642
				if ($symmetric_field || $considerWorkspaces) {
632 643
					$row = t3lib_BEfunc::getRecord($table, $uid, $fields, '', FALSE);
644
				}
645
				if ($symmetric_field) {
633 646
					$isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $conf, $row);
634 647
				}
635 648

  
636 649
				$updateValues = array();
650
				$workspaceValues = array();
637 651

  
638 652
					// no update to the uid is requested, so this is the normal behaviour
639 653
					// just update the fields and care about sorting
......
658 672
						} elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby']) { // manual sortby for all table records
659 673
							$sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'];
660 674
						}
661
							// strip a possible "ORDER BY" in front of the $sortby value
662
						$sortby = $GLOBALS['TYPO3_DB']->stripOrderBy($sortby);
663
						$symSortby = $conf['symmetric_sortby'];
675
							// Apply sorting on the symmetric side (it depends on who created the relation, so what uid is in the symmetric_field):
676
						if ($isOnSymmetricSide && isset($conf['symmetric_sortby']) && $conf['symmetric_sortby']) {
677
							$sortby = $conf['symmetric_sortby'];
678
							// Strip a possible "ORDER BY" in front of the $sortby value:
679
						} else {
680
							$sortby = $GLOBALS['TYPO3_DB']->stripOrderBy($sortby);
681
						}
664 682

  
665
							// set the sorting on the right side, it depends on who created the relation, so what uid is in the symmetric_field
666
						if ($isOnSymmetricSide && $symSortby) {
667
							$updateValues[$symSortby] = ++$c;
668
						} elseif ($sortby) {
669
							$updateValues[$sortby] = ++$c;
683
						if ($sortby) {
684
							$updateValues[$sortby] = $workspaceValues[$sortby] = ++$c;
670 685
						}
671 686
					}
672 687

  
......
680 695
					}
681 696
				}
682 697

  
698
					// Update accordant fields in the database:
683 699
				if (count($updateValues)) {
684 700
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($uid), $updateValues);
685 701
					$this->updateRefIndex($table, $uid);
686 702
				}
703
					// Update accordant fields in the database for workspaces overlays/placeholders:
704
				if (count($workspaceValues) && $considerWorkspaces) {
705
					if (isset($row['t3ver_oid']) && $row['t3ver_oid'] && $row['t3ver_state'] == -1) {
706
						$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($row['t3ver_oid']), $workspaceValues);
707
					}
708
				}
687 709
			}
688 710
		}
689 711
	}