0016846_44.patch

Administrator Admin, 2010-12-26 19:21

Download (3.33 KB)

View differences:

t3lib/class.t3lib_loaddbgroup.php (Arbeitskopie)
626 626
			if (!(t3lib_div::testInt($updateToUid) && $updateToUid > 0)) {
627 627
				$updateToUid = 0;
628 628
			}
629
			$fields = 'uid,'.$foreign_field.($symmetric_field ? ','.$symmetric_field : '');
630 629

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

  
632
			$fields = 'uid,' . $foreign_field;
633
				// Consider the symmetric field if defined:
634
			if ($symmetric_field) {
635
				$fields .= ',' . $symmetric_field;
636
			}
637
				// Consider workspaces if defined and currently used:
638
			if ($considerWorkspaces) {
639
				$fields .= ',' . 't3ver_state,t3ver_oid';
640
			}
641

  
631 642
				// update all items
632 643
			foreach ($this->itemArray as $val) {
633 644
				$uid = $val['id'];
634 645
				$table = $val['table'];
635 646

  
636 647
					// fetch the current (not overwritten) relation record if we should handle symmetric relations
637
				if ($conf['symmetric_field']) {
648
				if ($symmetric_field || $considerWorkspaces) {
638 649
					$row = t3lib_BEfunc::getRecord($table,$uid,$fields,'',false);
650
				}
651
				if ($symmetric_field) {
639 652
					$isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $conf, $row);
640 653
				}
641 654

  
642 655
				$updateValues = array();
656
				$workspaceValues = array();
643 657

  
644 658
					// no update to the uid is requested, so this is the normal behaviour
645 659
					// just update the fields and care about sorting
......
664 678
						} elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby']) {	// manual sortby for all table records
665 679
							$sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'];
666 680
						}
667
							// strip a possible "ORDER BY" in front of the $sortby value
668
						$sortby = $GLOBALS['TYPO3_DB']->stripOrderBy($sortby);
669
						$symSortby = $conf['symmetric_sortby'];
681
							// Apply sorting on the symmetric side (it depends on who created the relation, so what uid is in the symmetric_field):
682
						if ($isOnSymmetricSide && isset($conf['symmetric_sortby']) && $conf['symmetric_sortby']) {
683
							$sortby = $conf['symmetric_sortby'];
684
							// Strip a possible "ORDER BY" in front of the $sortby value:
685
						} else {
686
							$sortby = $GLOBALS['TYPO3_DB']->stripOrderBy($sortby);
687
						}
670 688

  
671
							// set the sorting on the right side, it depends on who created the relation, so what uid is in the symmetric_field
672
						if ($isOnSymmetricSide && $symSortby) {
673
							$updateValues[$symSortby] = ++$c;
674
						} elseif ($sortby) {
675
							$updateValues[$sortby] = ++$c;
689
						if ($sortby) {
690
							$updateValues[$sortby] = $workspaceValues[$sortby] = ++$c;
676 691
						}
677 692
					}
678 693

  
......
686 701
					}
687 702
				}
688 703

  
704
					// Update accordant fields in the database:
689 705
				if (count($updateValues)) {
690 706
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($uid), $updateValues);
691 707
					$this->updateRefIndex($table, $uid);
692 708
				}
709
					// Update accordant fields in the database for workspaces overlays/placeholders:
710
				if (count($workspaceValues) && $considerWorkspaces) {
711
					if (isset($row['t3ver_oid']) && $row['t3ver_oid'] && $row['t3ver_state'] == -1) {
712
						$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($row['t3ver_oid']), $workspaceValues);
713
					}
714
				}
693 715
			}
694 716
		}
695 717
	}