831 |
florian |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
4 |
// //
|
|
|
5 |
// Copyright (C) 2006 Phorum Development Team //
|
|
|
6 |
// http://www.phorum.org //
|
|
|
7 |
// //
|
|
|
8 |
// This program is free software. You can redistribute it and/or modify //
|
|
|
9 |
// it under the terms of either the current Phorum License (viewable at //
|
|
|
10 |
// phorum.org) or the Phorum License that was distributed with this file //
|
|
|
11 |
// //
|
|
|
12 |
// This program is distributed in the hope that it will be useful, //
|
|
|
13 |
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
|
|
|
14 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
|
|
|
15 |
// //
|
|
|
16 |
// You should have received a copy of the Phorum License //
|
|
|
17 |
// along with this program. //
|
|
|
18 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
19 |
|
|
|
20 |
if(!defined("PHORUM")) return;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* This is the callback-function for removing hidden messages from an array of messages
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
function phorum_remove_hidden($val)
|
|
|
27 |
{
|
|
|
28 |
return ($val['status'] > 0);
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* This function sets the stats for a thread like count, timestamp, etc.
|
|
|
33 |
*/
|
|
|
34 |
|
|
|
35 |
function phorum_update_thread_info($thread)
|
|
|
36 |
{
|
|
|
37 |
$PHORUM = $GLOBALS["PHORUM"];
|
|
|
38 |
|
|
|
39 |
$messages=phorum_db_get_messages($thread);
|
|
|
40 |
//these are not needed here
|
|
|
41 |
unset($messages['users']);
|
|
|
42 |
|
|
|
43 |
// remove hidden/unapproved messages from the array
|
|
|
44 |
$filtered_messages=array_filter($messages, "phorum_remove_hidden");
|
|
|
45 |
|
|
|
46 |
$thread_count=count($filtered_messages);
|
|
|
47 |
|
|
|
48 |
if($thread_count>0){
|
|
|
49 |
|
|
|
50 |
$message_ids=array_keys($filtered_messages);
|
|
|
51 |
|
|
|
52 |
$parent_message=$filtered_messages[$thread];
|
|
|
53 |
|
|
|
54 |
if (isset($PHORUM["reverse_threading"]) && $PHORUM["reverse_threading"]) {
|
|
|
55 |
reset($filtered_messages);
|
|
|
56 |
$recent_message=current($filtered_messages);
|
|
|
57 |
} else {
|
|
|
58 |
$recent_message=end($filtered_messages);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
// prep the message to save
|
|
|
62 |
$message["thread_count"]=$thread_count;
|
|
|
63 |
$message["modifystamp"]=$recent_message["datestamp"];
|
|
|
64 |
$message["meta"]=$parent_message["meta"];
|
|
|
65 |
$message["meta"]["recent_post"]["user_id"]=$recent_message["user_id"];
|
|
|
66 |
$message["meta"]["recent_post"]["author"]=$recent_message["author"];
|
|
|
67 |
$message["meta"]["recent_post"]["message_id"]=$recent_message["message_id"];
|
|
|
68 |
$message["meta"]["message_ids"]=$message_ids;
|
|
|
69 |
// used only for mods
|
|
|
70 |
$message["meta"]["message_ids_moderator"]=array_keys($messages);
|
|
|
71 |
|
|
|
72 |
phorum_db_update_message($thread, $message);
|
|
|
73 |
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
?>
|