Merge branch 'stable'

This commit is contained in:
following 2013-03-22 10:24:26 +01:00
commit 8056b1430e
6 changed files with 10 additions and 17 deletions

View File

@ -192,6 +192,12 @@
UPDATE `caches` SET `last_modified`=NOW() WHERE `cache_id`=nCacheId;
END IF;
/* This is a hack for the XML interface which delivers cache-related records
* like descriptions and pictures only depending on their last_modified date.
* Data may not have been deliverd or stored somewhere depending on the cache
* status, so when status changes, all has to be sent (again) via XML.
*/
UPDATE `cache_desc` SET `last_modified`=NOW() WHERE `cache_id`=nCacheId;
UPDATE `cache_logs` SET `last_modified`=NOW() WHERE `cache_id`=nCacheId;
UPDATE `coordinates` SET `last_modified`=NOW() WHERE `cache_id`=nCacheId AND `type`=1;

View File

@ -447,7 +447,8 @@ function getWaypoints($cacheid)
$activation_date = 'NULL';
}
//save to DB
// save to DB
// status update will trigger touching the last_modified date of all depending records
sql("UPDATE `caches` SET `name`='&1', `longitude`='&2', `latitude`='&3', `type`='&4', `date_hidden`='&5', `country`='&6', `size`='&7', `difficulty`='&8', `terrain`='&9', `status`='&10', `search_time`='&11', `way_length`='&12', `logpw`='&13', `wp_gc`='&14', `wp_nc`='&15', `date_activate` = $activation_date WHERE `cache_id`='&16'", $cache_name, $cache_lon, $cache_lat, $cache_type, date('Y-m-d', mktime(0, 0, 0, $cache_hidden_month, $cache_hidden_day, $cache_hidden_year)), $cache_country, $sel_size, $cache_difficulty, $cache_terrain, $status, $search_time, $way_length, $log_pw, $wp_gc, $wp_nc, $cache_id);
// do not use slave server for the next time ...
@ -475,8 +476,6 @@ function getWaypoints($cacheid)
// if old status is not yet published and new status is published => notify-event
if ($status_old == 5 && $status != 5)
{
touchCache($cache_id);
// send new cache event
event_notify_new_cache($cache_id);
}

View File

@ -81,16 +81,6 @@
sql("UPDATE `caches` SET `last_found`='&1' WHERE `cache_id`=&2", $r['date'], $cacheid);
}
// update last_modified=NOW() for every object depending on that cacheid
function touchCache($cacheid)
{
sql("UPDATE `caches` SET `last_modified`=NOW() WHERE `cache_id`='&1'", $cacheid);
sql("UPDATE `caches`, `cache_logs` SET `cache_logs`.`last_modified`=NOW() WHERE `caches`.`cache_id`=`cache_logs`.`cache_id` AND `caches`.`cache_id`='&1'", $cacheid);
sql("UPDATE `caches`, `cache_desc` SET `cache_desc`.`last_modified`=NOW() WHERE `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`cache_id`='&1'", $cacheid);
sql("UPDATE `caches`, `pictures` SET `pictures`.`last_modified`=NOW() WHERE `caches`.`cache_id`=`pictures`.`object_id` AND `pictures`.`object_type`=2 AND `caches`.`cache_id`='&1'", $cacheid);
sql("UPDATE `caches`, `cache_logs`, `pictures` SET `pictures`.`last_modified`=NOW() WHERE `caches`.`cache_id`=`cache_logs`.`cache_id` AND `cache_logs`.`id`=`pictures`.`object_id` AND `pictures`.`object_type`=1 AND `caches`.`cache_id`='&1'", $cacheid);
}
// read a file and return it as a string
// WARNING: no huge files!
function read_file($file='')

View File

@ -13,7 +13,7 @@
if (isset($_REQUEST['post']))
{
sql("UPDATE `caches` SET `status`=3, `last_modified`=NOW() WHERE `wp_oc`='&1'", $wp);
sql("UPDATE `caches` SET `status`=3 WHERE `wp_oc`='&1'", $wp);
}
?>
<html>

View File

@ -23,8 +23,6 @@
sql("DELETE FROM `caches_attributes` WHERE `cache_id`='&1'", $cache_id);
foreach ($attrs AS $attr)
sql("INSERT INTO `caches_attributes` (`cache_id`, `attrib_id`) VALUES ('&1', '&2')", $cache_id, $attr);
sql("UPDATE `caches` SET `last_modified`=NOW() WHERE `cache_id`='&1'", $cache_id);
}
$attrs = array();

View File

@ -48,10 +48,10 @@
$cacheid = $rPublish['cache_id'];
// update cache status to active
// will touch the last_modified date of all depending records
sql("UPDATE `caches` SET `status`=1, `date_activate`=NULL WHERE `cache_id`='&1'", $cacheid);
// send events
touchCache($cacheid);
event_new_cache($userid);
event_notify_new_cache($cacheid);
}