1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) { 9 header("location: index.php"); 10 exit; 11} 12 13/** 14 * @param $installer 15 */ 16function upgrade_20110609_batch_update_tracker_item_links_tiki($installer) 17{ 18 $fields = $installer->fetchMap("SELECT fieldId, options FROM tiki_tracker_fields WHERE type = 'r'"); 19 20 foreach ($fields as $fieldId => $options) { 21 $options = explode(',', $options); 22 23 if (isset($options[1])) { 24 $remoteFieldId = $options[1]; 25 26 $installer->query( 27 "UPDATE tiki_tracker_item_fields r" . 28 " INNER JOIN tiki_tracker_item_fields l ON r.value = l.value AND l.fieldId = ?" . 29 " SET r.value = l.itemId" . 30 " WHERE r.fieldId = ?", 31 [$remoteFieldId, $fieldId] 32 ); 33 } 34 } 35} 36