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_20091004_last_tracker_items_modules_merge_tiki($installer)
17{
18	$result = $installer->query("select moduleId, params from tiki_modules where name='last_modif_tracker_items'; ");
19	while ($row = $result->fetchRow()) {
20		$params = $row['params'];
21		if (strpos($params, "sort_mode=") === false) {
22			if ($params) {
23				$params .= "&";
24			}
25			$params .= "sort_mode=lastModif_desc";
26		}
27		$installer->query("update tiki_modules set params='" . $params . "', name='last_tracker_items' where moduleId=" . $row['moduleId'] . "; ");
28	}
29}
30