0005704_v4.patch

Administrator Admin, 2007-06-14 14:32

Download (6.42 KB)

View differences:

t3lib/class.t3lib_tceforms_inline.php (Arbeitskopie)
157 157
				$inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
158 158
				$this->inlineView = $inlineView[$table][$row['uid']];
159 159
			}
160
				// if pid is negative, fetch the previous record and take its pid
161
			if ($row['pid'] < 0) {
160
				// If the parent is a page, use the uid(!) of the (new?) page as pid for the child records:
161
			if ($table == 'pages') {
162
				$this->inlineFirstPid = $row['uid'];
163
				// If pid is negative, fetch the previous record and take its pid:
164
			} elseif ($row['pid'] < 0) {
162 165
				$prevRec = t3lib_BEfunc::getRecord($table, abs($row['pid']));
163 166
				$this->inlineFirstPid = $prevRec['pid'];
164
				// take the pid as it is
167
				// Take the pid as it is:
165 168
			} else {
166 169
				$this->inlineFirstPid = $row['pid'];
167 170
			}
......
1294 1297

  
1295 1298
			// If the command is to create a NEW record...:
1296 1299
		if ($cmd=='new') {
1297
			$calcPRec = t3lib_BEfunc::getRecord('pages',$this->inlineFirstPid);
1298
			if(!is_array($calcPRec)) {
1299
				return false;
1300
			}
1301
			$CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);	// Permissions for the parent page
1302
			if ($table=='pages')	{	// If pages:
1303
				$hasAccess = $CALC_PERMS&8 ? 1 : 0; // Are we allowed to create new subpages?
1300
				// If the pid is numerical, check if it's possible to write to this page:
1301
			if (t3lib_div::testInt($this->inlineFirstPid)) {
1302
				$calcPRec = t3lib_BEfunc::getRecord('pages', $this->inlineFirstPid);
1303
				if(!is_array($calcPRec)) {
1304
					return false;
1305
				}
1306
				$CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);	// Permissions for the parent page
1307
				if ($table=='pages')	{	// If pages:
1308
					$hasAccess = $CALC_PERMS&8 ? 1 : 0; // Are we allowed to create new subpages?
1309
				} else {
1310
					$hasAccess = $CALC_PERMS&16 ? 1 : 0; // Are we allowed to edit content on this page?
1311
				}
1312
				// If the pid is a NEW... value, the access will be checked on creating the page:
1313
				// (if the page with the same NEW... value could be created in TCEmain, this child record can neither)
1304 1314
			} else {
1305
				$hasAccess = $CALC_PERMS&16 ? 1 : 0; // Are we allowed to edit content on this page?
1315
				$hasAccess = 1;
1306 1316
			}
1307 1317
		} else {	// Edit:
1308 1318
			$calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
t3lib/class.t3lib_tcemain.php (Arbeitskopie)
333 333
	var $removeFilesStore=array();				// For accumulation of files which must be deleted after processing of all input content
334 334
	var $uploadedFileArray = array();			// Uploaded files, set by process_uploads()
335 335
	var $registerDBList=array();				// Used for tracking references that might need correction after operations
336
	var $registerDBPids=array();				// Used for tracking references that might need correction in pid field after operations (e.g. IRRE)
336 337
	var $copyMappingArray = Array();			// Used by the copy action to track the ids of new pages so subpages are correctly inserted! THIS is internally cleared for each executed copy operation! DO NOT USE THIS FROM OUTSIDE! Read from copyMappingArray_merged instead which is accumulating this information.
337 338
	var $remapStack = array();					// array used for remapping uids and values at the end of process_datamap
338 339
	var $remapStackRecords = array();			// array used for remapping uids and values at the end of process_datamap (e.g. $remapStackRecords[<table>][<uid>] = <index in $remapStack>)
......
2796 2797
				} else {
2797 2798
					$childDestPid = -$v['id'];
2798 2799
				}
2800

  
2801
					// If the current field is set on a page record, update the pid of related child records:
2802
				if ($table == 'pages') {
2803
					$this->registerDBPids[$v['table']][$v['id']] = $uid;
2804
					// If the current field has ancestors that have a field on a page record, update the pid of related child records:
2805
				} elseif (isset($this->registerDBPids[$table][$uid])) {
2806
					$this->registerDBPids[$v['table']][$v['id']] = $this->registerDBPids[$table][$uid];
2807
				}
2808

  
2799 2809
				$newId = $this->copyRecord($v['table'], $v['id'], $childDestPid);
2800 2810
				$dbAnalysis->itemArray[$k]['id'] = $newId;
2801 2811
			}
......
4267 4277
	 * @param	string		$value: Field value
4268 4278
	 * @param	integer		$uid: The uid of the ORIGINAL record
4269 4279
	 * @param	string		$table: Table name
4270
	 * @return	string		The value to be updated on the table field in the database
4280
	 * @return	void
4271 4281
	 */
4272 4282
	function remapListedDBRecords_procInline($conf, $value, $uid, $table) {
4273 4283
		$theUidToUpdate = $this->copyMappingArray_merged[$table][$uid];
......
4275 4285
		if ($conf['foreign_table']) {
4276 4286
			$inlineType = $this->getInlineFieldType($conf);
4277 4287

  
4278
			if ($inlineType == 'field') {
4288
			if ($inlineType == 'mm') {
4289
				$this->remapListedDBRecords_procDBRefs($conf, $value, $theUidToUpdate, $table);
4290

  
4291
			} elseif ($inlineType !== false) {
4279 4292
				$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
4280
				$dbAnalysis->start($value, $conf['foreign_table'], $conf['MM'], 0, $table, $conf);
4293
				$dbAnalysis->start($value, $conf['foreign_table'], '', 0, $table, $conf);
4281 4294

  
4282
				$dbAnalysis->writeForeignField($conf, $uid, $theUidToUpdate);
4283
			} elseif ($inlineType == 'mm') {
4284
				$vArray = $this->remapListedDBRecords_procDBRefs($conf, $value, $theUidToUpdate, $table);
4295
					// If the current field is set on a page record, update the pid of related child records:
4296
				if ($table == 'pages') {
4297
					$thePidToUpdate = $theUidToUpdate;
4298
					// If the current field has ancestors that have a field on a page record, update the pid of related child records:
4299
				} elseif (isset($this->registerDBPids[$table][$uid])) {
4300
					$thePidToUpdate = $this->registerDBPids[$table][$uid];
4301
					$thePidToUpdate = $this->copyMappingArray_merged['pages'][$thePidToUpdate];
4302
				}
4303

  
4304
					// Update child records if using pointer fields ('foreign_field'):
4305
				if ($inlineType == 'field') {
4306
					$dbAnalysis->writeForeignField($conf, $uid, $theUidToUpdate);
4307
				}
4308

  
4309
					// Update child records if change to pid is required: 
4310
				if ($thePidToUpdate) {
4311
					$updateValues = array('pid' => $thePidToUpdate);
4312
					foreach ($dbAnalysis->itemArray as $v) {
4313
						if ($v['id'] && $v['table']) {
4314
							$GLOBALS['TYPO3_DB']->exec_UPDATEquery($v['table'], 'uid='.intval($v['id']), $updateValues);
4315
						}
4316
					}
4317
				}
4285 4318
			}
4286 4319
		}
4287 4320
	}