1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +02:00

Various small fixes, mostly to do with subscriptions

This commit is contained in:
e107steved
2009-04-29 20:27:18 +00:00
parent da5a2608c4
commit efdc410cea
3 changed files with 42 additions and 30 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar.php,v $
| $Revision: 1.3 $ | $Revision: 1.4 $
| $Date: 2009-02-01 20:54:08 $ | $Date: 2009-04-29 20:27:18 $
| $Author: e107steved $ | $Author: e107steved $
| |
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
@@ -146,7 +146,7 @@ $events = array();
else else
{ // Its a 'normal' event { // Its a 'normal' event
$tmp = date('j',$row['event_start']); // Day of month for start $tmp = date('j',$row['event_start']); // Day of month for start
$tmp2 = date('j',$row['event_end']); // Day of month for end $tmp2 = date('j',$row['event_end']-1); // Day of month for end - knock off a second to allow for BST and suchlike
if(($row['event_start']>=$monthstart) && ($row['event_start']<=$monthend)) if(($row['event_start']>=$monthstart) && ($row['event_start']<=$monthend))
{ // Start within month { // Start within month

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ecal_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ecal_class.php,v $
| $Revision: 1.8 $ | $Revision: 1.9 $
| $Date: 2008-09-28 20:35:05 $ | $Date: 2009-04-29 20:27:18 $
| $Author: e107steved $ | $Author: e107steved $
| |
| Event calendar class: | Event calendar class:
@@ -501,7 +501,7 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
// Read a list of events between start and end dates // Read a list of events between start and end dates
// If $start_only is TRUE, only searches based on the start date/time // If $start_only is TRUE, only searches based on the start date/time
// Potential option to hook in other routines later // Potential option to hook in other routines later
function get_events($start_time, $end_time, $start_only=FALSE, $cat_filter='*', $inc_recur=FALSE, $event_fields='*', $cat_fields='*') function get_events($start_time, $end_time, $start_only=FALSE, $cat_filter=0, $inc_recur=FALSE, $event_fields='*', $cat_fields='*')
{ {
global $sql; global $sql;
@@ -520,12 +520,12 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
} }
if ($cat_filter && ($cat_filter != '*')) $category_filter = " AND find_in_set(e.event_category, '".$cat_filter."') "; if ($cat_filter && ($cat_filter != '*')) $category_filter = " AND find_in_set(e.event_category, '".$cat_filter."') ";
if ($inc_recur) $extra = " OR (e.event_recurring >'0' AND (e.event_start <= ".intval($end_time)." AND e.event_end >= ".intval($start_time).")) "; if ($inc_recur) $extra = " OR (e.event_recurring >'0' AND (e.event_start < ".intval($end_time)." AND e.event_end >= ".intval($start_time).")) ";
$so = $start_only ? 'start' : 'end'; $so = $start_only ? 'start' : 'end';
$qry = "SELECT {$event_fields}{$cat_fields} FROM #event as e {$cat_lj} $qry = "SELECT {$event_fields}{$cat_fields} FROM #event as e {$cat_lj}
WHERE ( WHERE (
(e.event_recurring = '0' AND ((e.event_{$so} >= ".intval($start_time)." AND e.event_start <= ".intval($end_time)."))) (e.event_recurring = '0' AND ((e.event_{$so} >= ".intval($start_time)." AND e.event_start < ".intval($end_time).")))
{$extra}) {$extra})
{$category_filter} {$category_filter}
{$this->extra_query} {$this->extra_query}

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/subs_menu.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/subs_menu.php,v $
| $Revision: 1.3 $ | $Revision: 1.4 $
| $Date: 2008-08-11 21:24:42 $ | $Date: 2009-04-29 20:27:18 $
| $Author: e107steved $ | $Author: e107steved $
| |
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
@@ -114,7 +114,7 @@ subs_log_a_line("\r\n\r\nMail subscriptions run started at ".date("D j M Y G:i:s
// Start with the 'in advance' emails // Start with the 'in advance' emails
$cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class != '') and $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
event_cat_last < " . intval($cal_starttime) . " and event_cat_last < " . intval($cal_starttime) . " and
event_cat_ahead > 0 and event_cat_ahead > 0 and
event_start >= (" . intval($cal_starttime) . "+(86400*(event_cat_ahead))) and event_start >= (" . intval($cal_starttime) . "+(86400*(event_cat_ahead))) and
@@ -126,7 +126,7 @@ ec_send_mailshot($cal_args, 'Advance',1, $calendar_shortcodes);
// then for today // then for today
$cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class != '') and $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
event_cat_today < " . intval($cal_starttime) . " and event_cat_today < " . intval($cal_starttime) . " and
event_start >= (" . intval($cal_starttime) . ") and event_start >= (" . intval($cal_starttime) . ") and
event_start < (86400+" . intval($cal_starttime) . ") and event_start < (86400+" . intval($cal_starttime) . ") and
@@ -135,12 +135,23 @@ find_in_set(event_cat_notify,'2,3,6,7')";
ec_send_mailshot($cal_args, 'today',2, $calendar_shortcodes); ec_send_mailshot($cal_args, 'today',2, $calendar_shortcodes);
if ($ec_debug_level == 0)
{
// Finally do 'day before' emails (its an alternative to 'today' emails) // Finally do 'day before' emails (its an alternative to 'today' emails)
$cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class != '') and $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
event_cat_today < " . intval($cal_starttime) . " and event_cat_today < " . intval($cal_starttime) . " and
event_start >= (" . intval($cal_starttime) ." + 86400 ) and event_start >= (" . intval($cal_starttime) ." + 86400 ) and
event_start < (" . intval($cal_starttime) ." + 172800) and event_start < (" . intval($cal_starttime) ." + 172800) and
find_in_set(event_cat_notify,'4,5,6,7')"; find_in_set(event_cat_notify,'4,5,6,7')";
}
else
{
// Finally do 'day before' emails (its an alternative to 'today' emails)
$cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
event_start >= (" . intval($cal_starttime) ." + 86400 ) and
event_start < (" . intval($cal_starttime) ." + 172800) and
find_in_set(event_cat_notify,'4,5,6,7')";
}
ec_send_mailshot($cal_args, 'tomorrow',2, $calendar_shortcodes); ec_send_mailshot($cal_args, 'tomorrow',2, $calendar_shortcodes);
@@ -245,41 +256,42 @@ function ec_send_mailshot($cal_query, $shot_type, $msg_num, $calendar_shortcodes
$manual_subs = (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1')); $manual_subs = (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1'));
$subs_fields = ''; $subs_fields = '';
$subs_join = ''; $subs_join = '';
$where_clause = ''; $whereClause = '';
$group_clause = ''; $group_clause = '';
if ($event_cat_force_class != e_UC_MEMBER) if ($event_cat_force_class != e_UC_MEMBER)
{ // Cases 1, 3, 4 (basic query does for case 2) { // Cases 1, 3, 4 (basic query does for case 2)
if ((!$event_cat_force_class) || ($manual_subs)) if ((!$event_cat_force_class) || ($manual_subs))
{ // Cases 1 & 4 - need to join with event_subs database { // Cases 1 & 4 - need to join with event_subs database
$subs_fields = ", es.* "; $subs_fields = ", es.* ";
if ($event_cat_force_class) $subs_join = "LEFT"; else $subs_join = "INNER"; if ($event_cat_force_class) $subs_join = "LEFT"; else $subs_join = "INNER";
$subs_join .= " join #event_subs AS es on u.user_id=es.event_userid "; $subs_join .= " join #event_subs AS es on u.user_id=es.event_userid ";
$where_clause = " es.event_cat='".intval($event_category)."' "; $whereClause = " es.event_cat='".intval($event_category)."' ";
$group_clause = " GROUP BY u.user_id"; $group_clause = " GROUP BY u.user_id";
} }
if ($event_cat_force_class) if ($event_cat_force_class)
{ // cases 3 and 4 - ... and check for involuntary subscribers { // cases 3 and 4 - ... and check for involuntary subscribers
if ($where_clause) $where_clause .= " OR "; if ($whereClause) $whereClause .= " OR ";
if ($event_cat_force_class == e_UC_ADMIN) if ($event_cat_force_class == e_UC_ADMIN)
{ {
$where_clause .= "(u.user_admin = '1' )"; $whereClause .= "(u.user_admin = 1 )";
} }
else else
{ {
$where_clause .= "find_in_set('".intval($event_cat_force_class)."', u.user_class)"; $whereClause .= "find_in_set('".intval($event_cat_force_class)."', u.user_class)";
// $forced_regexp = "'(^|,)(".intval($event_cat_force_class).")(,|$)'";
// $whereClause .= " (u.user_class REGEXP '".$forced_regexp."') ";
$group_clause = " GROUP BY u.user_id";
} }
} }
if ($where_clause) $where_clause = ' AND ('.$where_clause.' ) '; if ($whereClause) $whereClause = ' AND ('.$whereClause.' ) ';
} // End of cases 1, 3, 4 } // End of cases 1, 3, 4
$cal_emilargs = "SELECT u.user_id, u.user_class, u.user_email, u.user_name, u.user_ban, u.user_admin{$subs_fields} $cal_emilargs = "SELECT u.user_id, u.user_class, u.user_email, u.user_name, u.user_ban, u.user_admin{$subs_fields}
from #user AS u {$subs_join} from #user AS u {$subs_join}
WHERE u.user_ban = '0' {$where_clause} {$group_clause}"; WHERE u.user_ban = '0' {$whereClause} {$group_clause}";
if ($ec_debug_level >= 2) if ($ec_debug_level >= 2)
@@ -299,7 +311,7 @@ function ec_send_mailshot($cal_query, $shot_type, $msg_num, $calendar_shortcodes
$send_result = " **DEBUG**"; $send_result = " **DEBUG**";
if ($ec_log_requirement > 1) if ($ec_log_requirement > 1)
{ {
subs_log_a_line(" Send to: ".$user_email." Name: ".$user_name." Result = ".$send_result."\r\n",FALSE,TRUE); subs_log_a_line(" Send to ".$user_id.':'.$user_email." Name: ".$user_name." Result = ".$send_result."\r\n",FALSE,TRUE);
} }
} }
} }