This repository has been archived by the owner on Sep 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscribe.php
122 lines (110 loc) · 3.98 KB
/
subscribe.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
115
116
117
118
119
120
121
122
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Event calendar plugin - mail subscription to events notification
*
*/
/**
* e107 Event calendar plugin
*
* Event calendar plugin - mail subscription to events notification
*
* @package e107_plugins
* @subpackage event_calendar
*/
if (!defined('e_SINGLE_ENTRY'))
{
require_once('../../class2.php');
}
$e107 = e107::getInstance();
if (!$e107->isInstalled('calendar_menu'))
{
//headerx('Location: '.e_BASE.'index.php');
e107::redirect();
exit();
}
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
if (!is_object($ecal_class)) $ecal_class = new ecal_class;
e107::lan('calendar_menu', e_LANGUAGE, false);
define('PAGE_NAME', EC_LAN_80);
require_once(HEADERF);
if ((USER) && (isset($ecal_class->pref['eventpost_asubs']) && ($ecal_class->pref['eventpost_asubs'] == '1')))
{
$cal_db = new db; // Probably best to keep this
if (isset($_POST['upsubs']))
{
$cal_cats = e107::getParser()->toDB($_POST['event_list']); // IDs of allowed categories
$cal_subs = e107::getParser()->toDB($_POST['event_subd']); // Checkbox results
$cal_db->db_Delete('event_subs', "event_userid='" . USERID . "'"); // Delete all for this user to start
foreach($cal_cats as $cal_row)
{ // Now add in a subscription for each allowed category
if ($cal_subs[$cal_row])
{
$cal_inargs = "0,'" . USERID . "','" . $cal_row . "'";
$cal_db->db_Insert('event_subs', $cal_inargs);
}
// print $cal_row . $cal_subs[$cal_row] . "<br />";
}
$caltext = "<table class='table fborder' width='97%'>
<tr><td class='fcaption' >" . EC_LAN_130 . "</td></tr>
<tr><td class='forumheader3' ><a href='calendar.php'>" . EC_LAN_131 . "</a></tr>
<tr><td class='fcaption' > </td></tr></table>";
}
else
{
$caltext = "<form id='calsubs' action='" . e_SELF . "' method='post' >
<table class='table fborder' width='97%'>
<tr><td class='fcaption' colspan='3'>" . EC_LAN_125 . "</td></tr>
<tr><td class='forumheader2' >" . EC_LAN_126 . "</td><td class='forumheader2' >" . EC_LAN_127 . "</td><td class='forumheader2' >" . EC_LAN_136 . "</td></tr>";
// Get list of currently subscribed
$cal_db->db_Select('event_subs', 'event_cat', "where event_userid='" . USERID . "'", "nowhere");
while ($cal_s = $cal_db->db_Fetch())
{
extract($cal_s);
$cal_array[] = $event_cat;
} // while
// Get list of categories that have subscriptions and are visible to this member
$cal_args = "select * from #event_cat
where event_cat_subs>0 and (find_in_set(event_cat_class,'".USERCLASS_LIST."') OR find_in_set(event_cat_force_class,'".USERCLASS_LIST."'))";
if ($cal_db->db_Select_gen($cal_args))
{
// echo $cal_args."<br />";
while ($cal_row = $cal_db->db_Fetch())
{
extract($cal_row);
$caltext .= "<tr><td class='forumheader3' style='width:10%;'>";
if (check_class($event_cat_force_class))
{
$caltext .= EC_LAN_126;
}
else
{
$caltext .= "<input type='hidden' name='event_list[]' value='" . $event_cat_id . "' />
<input type='checkbox' class='tbox' value='1' name='event_subd[$event_cat_id]' " . (in_array($event_cat_id, $cal_array)?"checked='checked' ":"") . " /> </td>";
}
$caltext .= "<td class='forumheader3'>{$event_cat_name}</td><td class='forumheader3'>{$event_cat_description}</td></tr>";
}
}
else
{
$caltext .= "<tr><td class='forumheader3' colspan='3'>" . EC_LAN_128 . "</td></tr>";
}
$caltext .= "<tr><td class='forumheader3' colspan='3'><input class='tbox' type='submit' value='" . EC_LAN_129 . "' name='upsubs' /></td></tr>";
$caltext .= "</table></form>";
}
}
else
{
if (isset($ecal_class->pref['eventpost_asubs']) && ($ecal_class->pref['eventpost_asubs'] == '1'))
$caltext = EC_LAN_142; // Register or log in
else
$caltext = EC_LAN_143; // No facility
}
e107::getRender()->tablerender(EC_LAN_124, $caltext);
require_once(FOOTERF);
?>