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 * prefs for some system gallery roots have become out of sync somehow historically - this attempts to repair them 15 * 16 * @param $installer 17 */ 18function upgrade_20130415_repair_file_galleries_again_tiki($installer) 19{ 20 // first user gals 21 $id = $installer->getOne("SELECT `galleryId` FROM `tiki_file_galleries` WHERE `type` = 'system' AND `name` = 'Users File Galleries'"); 22 $pref = $installer->getOne("SELECT `value` FROM `tiki_preferences` WHERE `name` = 'fgal_root_user_id'"); 23 if ($pref != $id) { 24 if ($pref) { 25 $installer->query("UPDATE `tiki_preferences` SET `value` = ? WHERE `name` = 'fgal_root_user_id';", $id); 26 } else { 27 $installer->query("INSERT INTO `tiki_preferences` (`name`, `value`) VALUES ('fgal_root_user_id', ? );", $id); 28 } 29 $installer->query("UPDATE `tiki_file_galleries` SET `parentId` = ? WHERE `type` = 'user';", $id); 30 } 31 // than wiki attachments 32 $id = $installer->getOne("SELECT `galleryId` FROM `tiki_file_galleries` WHERE `type` = 'system' AND `name` = 'Wiki Attachments'"); 33 $pref = $installer->getOne("SELECT `value` FROM `tiki_preferences` WHERE `name` = 'fgal_root_wiki_attachments_id'"); 34 if ($pref != $id) { 35 if ($pref) { 36 $installer->query("UPDATE `tiki_preferences` SET `value` = ? WHERE `name` = 'fgal_root_wiki_attachments_id';", $id); 37 } else { 38 $installer->query("INSERT INTO `tiki_preferences` (`name`, `value`) VALUES ('fgal_root_wiki_attachments_id', ? );", $id); 39 } 40 $installer->query("UPDATE `tiki_file_galleries` SET `parentId` = ? WHERE `type` = 'attachments';", $id); 41 } 42} 43