/
cache-tools.inc
65 lines (57 loc) · 2.51 KB
/
cache-tools.inc
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
<?php
# $Id: cache-tools.inc,v 1.27 2005/11/01 00:56:21 frabcus Exp $
# The Public Whip, Copyright (C) 2003 Francis Irving and Julian Todd
# This is free software, and you are welcome to redistribute it under
# certain conditions. However, it comes with ABSOLUTELY NO WARRANTY.
# For details see the file LICENSE.html in the top level of the source.
require_once $toppath . "account/user.inc";
function newsletter_navbar() {
$ret = "";
if (!user_isloggedin()) {
$ret .= '<a title="Subscribe to our email newsletter" href="/account/register.php">News</a>';
} else {
$ret .= '<a title="Email newsletter archives" href="/newsletters/archive.php">News</a>';
}
return $ret;
}
function account_navbar() {
global $this_place;
$this_place = $_SERVER["REQUEST_URI"];
# don't go back to confusing/logging out pages after login
if (stristr($this_place, "logout.php"))
$this_place = "";
if (stristr($this_place, "lostpass.php"))
$this_place = "";
if (stristr($this_place, "register.php"))
$this_place = "";
$ret = "";
if (user_isloggedin()) {
global $user_name;
$ret .= '<a title="Change account settings, such as whether you get the newsletter" href="/account/settings.php">';
$ret .= "You are: $user_name";
$ret .= '</a> ';
$ret .= '<a title="Make your browser forget that you are logged into The Public Whip as ' . $user_name .'" href="/account/logout.php'.
"?r=".urlencode($this_place).'">';
$ret .= "Logout";
$ret .= '</a> ';
} else {
$ret .= '<a title="Register to get a newsletter or make/edit policies" href="/account/register.php?r='. ($_GET['r']?urlencode($_GET['r']):urlencode($this_place)).'">';
$ret .= "Sign Up";
$ret .= '</a> ';
$ret .= '<a title="Login to edit policies or change your newsletter settings" href="/account/settings.php'.
"?r=".urlencode($this_place)."\">";
$ret .= "Login";
$ret .= '</a> ';
}
return $ret;
}
# Mark database caches for update...
# ... when anything about a Dream MP changes
function notify_dream_mp_updated($db, $dreamid) {
$db->query("delete from pw_cache_dreaminfo where dream_id = '$dreamid'");
}
# ... when piece of motion text is edited
function notify_motion_updated($db, $division_date, $division_number, $house) {
$db->query("delete from pw_cache_divwiki where division_date = '$division_date'
and division_number = '$division_number' and house = '$house'");
}