-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallpagesread.php
114 lines (90 loc) · 4.2 KB
/
allpagesread.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
if(!defined("PHORUM")) return;
function mod_allpagesread()
{
if (phorum_page != 'read' && phorum_page != 'list') return;
GLOBAL $PHORUM;
$PHORUM["DATA"]["mod_allpagesread"]["enable"]=1;
if(empty($PHORUM["mod_allpagesread"]["max_read_length"]) ||
(!empty($PHORUM["read_length"]) &&
$PHORUM["mod_allpagesread"]["max_read_length"]<$PHORUM["read_length"])){
$PHORUM["mod_allpagesread"]["max_read_length"]=200;
}
// Set default value for enable_for:
// 0 = all visitors
// 1 = only logged in users
if (!isset($PHORUM["mod_allpagesread"]["enable_for"])) {
$PHORUM["mod_allpagesread"]["enable_for"] = 0;
}
if ($PHORUM["mod_allpagesread"]["enable_for"] == 0 ||
$PHORUM["DATA"]["LOGGEDIN"]){
if(phorum_page =="read"){
if(!empty($PHORUM["args"]["page"]) &&
$PHORUM["args"]["page"]=="all"){
$PHORUM["read_length"] =
$PHORUM["mod_allpagesread"]["max_read_length"];
}
}
}
return;
}
function mod_allpagesread_createlink($data)
{
GLOBAL $PHORUM;
// Only do this in case flat reading mode is enabled.
// Do not do this for a threaded list mode.
if((phorum_page == "list" && $PHORUM["threaded_list"]) ||
(isset($PHORUM["threaded_read"]) && $PHORUM["threaded_read"]))
return $data;
if ($PHORUM["mod_allpagesread"]["enable_for"] == 0 ||
$PHORUM["DATA"]["LOGGEDIN"]){
// The configured maxium readlength for this module.
$maxreadlen = $PHORUM["mod_allpagesread"]["max_read_length"];
// Handle the read page.
if(phorum_page=="read"){
if(isset($PHORUM["DATA"]["PAGES"][0])){
// Determine the number of posts in this thread.
// We might have more messages for mods.
$thread = $data[$PHORUM["args"][1]];
if($PHORUM["DATA"]["MODERATOR"] &&
isset($thread["meta"]["message_ids_moderator"])) {
$threadnum=count($thread["meta"]["message_ids_moderator"]);
} else {
$threadnum=$thread["thread_count"];
}
// Only show the All link, in case the number of
// messages in the thread is below the configured maximum.
if ($threadnum > $maxreadlen) return $data;
// Add the All link to the paging.
$newpage_index=count($PHORUM["DATA"]["PAGES"]);
$PHORUM["DATA"]["PAGES"][$newpage_index]["pageno"] = $PHORUM["DATA"]["LANG"]["mod_allpagesread"]["all_page_link"];
$PHORUM["DATA"]["PAGES"][$newpage_index]["url"] = str_replace("page=1", "page=all", $PHORUM["DATA"]["PAGES"][0]["url"]);
}
// Handle the list page.
} else {
foreach ($data as $key=>$value) {
if(!empty($value["pages"])) {
// Determine the number of posts in this thread.
// We might have more messages for mods.
if($PHORUM["DATA"]["MODERATOR"] &&
isset($value["meta"]["message_ids_moderator"])) {
$threadnum=count($value["meta"]["message_ids_moderator"]);
} else {
$threadnum=$value["thread_count"];
}
// Only show the All link, in case the number of
// messages in the thread is below the configured maximum.
if ($threadnum > $maxreadlen) continue;
// Add the All link to the paging.
$read_url = isset($value["url"])
? $value["url"] // Phorum 5.0.x
: $value["URL"]["READ"]; // Phorum 5.1.x
$data[$key]["pages"].=" <a href=\"$read_url,page=all\">".$PHORUM["DATA"]["LANG"]["mod_allpagesread"]["all_page_link"]."</a>";
$data[$key]["pages"]=str_replace(", "," ",$data[$key]["pages"]);
}
}
}
}
return $data;
}
?>