33 trace(
"instant_notification:: email content $emailContent", 3);
40 $emailTo = $l_user->$emailField;
42 $emailHandler->send();
53 $firstPost =
$message->Topic()->FirstPost();
54 $url =
"http://" .
$config[
"http_host"] .
"/forum_topic?forum_id={$firstPost->forum_id}&topic_id={$firstPost->topic_id}";
56 $content =
"Forum Topic: \"{$firstPost->title}\" posted by {$firstPost->Author()->getFullName()}\n";
57 $content .=
"http://" .
$config[
"http_host"] .
"/forum_topic?forum_id={$firstPost->forum_id}&topic_id={$firstPost->topic_id}\n\n";
58 $content .=
"Reply: \"{$message->title}\" posted by {$message->Author()->getFullName()}\n\n";
69 $messageFooter =
"\n\nTo unsubscribe to these messages or change your subscription preferences, go to ";
88 trace(
"update_subscription:: subscription change", 3);
89 $subscription->filter =
new InclusionFilter(
"subscription_type");
91 $subscription->save();
95 trace(
"update_subscription:: unsubscribe", 3);
96 $subscription->delete();
103 $current = $subscription->subscription_type;
109 $selected = ($current == $value) ?
" checked" :
"";
110 $html .=
"<input style='border: none' type='radio' id='subscription[{$forum_subscription_id}]' name='subscription[{$forum_subscription_id}]' value='$value' $selected>$name</option><br>\n";
130 if($topicSubscriptionCount > 0)
143 class ForumSubscriptionHelper
150 var $topicSubscription;
153 var $topics_page =
false;
154 var $subscriptionOptions = array();
157 "forum" =>
"/fakoli/images/icon_subscribed_to_topic.png",
158 "topic" =>
"/fakoli/images/icon_subscribed_to_topic.png");
160 var $buttons = array(
161 "forum" =>
"/fakoli/images/button_subscribe_forum.png",
162 "topic" =>
"/fakoli/images/button_subscribe_topic.png");
164 var $subscribeTypes = array(
"new_topic",
"new_forum",
"update_topic",
"update_forum",
"topic_to_forum");
165 var $subscripeType =
"";
178 if(!$this->forumSubscription && count($this->topicSubscriptions))
180 $this->subscribeType =
"topic_to_forum";
189 $this->topics_page =
true;
191 $this->topicSubscription = $this->subscription;
192 if($this->forumSubscription)
194 $this->subscribeType =
"update_forum";
198 $this->subscribeType = ($this->topicSubscription) ?
"update_topic" :
"new_topic";
202 $this->
title = $this->getTitle();
209 $title = $this->topic->getTitle();
213 $title = preg_replace(
"/forum$/i",
"", $this->forum->title) .
" Forum";
231 $count = count($this->topicSubscriptions);
233 if($this->subscribeType ==
"new_topic" || $this->subscribeType ==
"new_forum")
235 $this->drawButtonLink();
237 else if($this->subscribeType ==
"topic_to_forum")
239 $text =
"You are Currently Subscribed to $count ";
241 $text .=
" in this Forum";
243 $this->drawIconLink(
$text, $topOffset);
245 else if($this->subscribeType ==
"update_forum" || $this->subscribeType ==
"update_topic")
247 $text =
"You are Currently Subscribed to";
248 if(!$this->topics_page)
250 $text .=
" this Forum";
252 else if($this->topics_page && $this->forumSubscription)
254 $text .=
" all Topics in this Forum";
258 $text .=
" this Topic";
260 $this->drawIconLink(
$text);
264 function drawIconLink(
$text, $topOffset = 0)
266 $icon = ($this->topics_page) ? $this->icons[
"topic"] : $this->icons[
"forum"];
267 $alt = ($this->topics_page) ?
"subscribe_topic" :
"subscribe_forum";
269 $img =
"<img src='$icon' alt='{$alt}' style='border: none'>";
270 echo
"<p style=\"text-align: right\">$img <a id='subscription_link' href=\"#\" onclick=\"forumSubscriptionMgr.showSubscriptionDialog(); return false\">$text</a></p>\n";
273 function drawButtonLink(
$button, $topOffset = 0)
275 $button = ($this->topics_page) ? $this->buttons[
"topic"] : $this->buttons[
"forum"];
277 $img =
"<img src='$button' style='border: none'>";
278 echo
"<div style=\"display: inline-block; float: right\"><a id='subscription_link' href=\"#\" onclick=\"forumSubscriptionMgr.showSubscriptionDialog(); return false\">$img</a></div>\n";
281 function drawHeaderText()
283 if(!$this->topics_page)
285 $text = $this->formatForumSubscriptionHeader();
289 $text = $this->formatTopicSubscriptionHeader();
295 function formatForumSubscriptionHeader()
297 $subscription = $this->subscription;
298 $count = count($this->topicSubscriptions);
299 $subscribeForumText =
"If you prefer, you can subscribe to the forum as a whole.";
301 if(!$subscription AND
$count == 0)
303 $text =
"<p>You can subscribe to the forum's daily digest or subscribe to instant notification to receive an email whenever a new topic or reply is posted.</p>\n";
307 $text =
"<p>You are currently subscribed to the following topic(s) in this forum:</p>";
308 $text .=
"<ul>\n" . formatItems($this->topicSubscriptions,
"<li>{ForumSubscriptionHelper::formatTopicSubscription}</li>",
"\n") .
"</ul>\n";
309 $text .=
"<p>{$subscribeForumText}</p>";
311 elseif(!$subscription AND
$count > 0)
313 $text =
"<p>You are currently subscribed to several topics in this forum:</p>";
314 $text .=
"<p>{$subscribeForumText}</p>";
316 else if($subscription)
319 $text =
"<p>You are currently subscribed to $subscriptionType for this forum. You can change your subscription type or unsubscribe.</p>";
325 static function formatTopicSubscription($subscription)
327 return $subscription->ForumTopic()->FirstPost()->title;
330 function formatTopicSubscriptionHeader()
332 $subscription = $this->topicSubscription;
336 return "<p>You can subscribe to the topics's daily digest or subscribe to instant notification to receive an email whenever a reply is posted.</p>\n";
341 return "<p>You are currently subscribed to $subscriptionType for this topic. You can change your subscription type or unsubscribe.</p>";
371 function formatSubscriptionOptions()
375 $subscription = $this->subscription;
376 $count = count($this->topicSubscriptions);
383 $unsubscribeText =
"Unsubscribe from";
388 else if(!$subscription && !$this->topics_page &&
$count)
401 function saveForumSubscription(
$form)
403 $subscription =
$form->data;
404 $type = $subscription->subscription_type;
408 $subscription->filter =
new InclusionFilter(
"subscription_type");
409 $subscription->save();
413 trace(
"**************forum saveForumSubscription type is not unsubscribe - save new subscription");
414 if(!$subscription->topics_page)
416 $this->forumUnsubscribe();
418 $subscription->save();
422 $this->forumUnsubscribe();
426 trace(
"update_subscription:: nothing to do", 3);
436 function forumUnsubscribe()
438 trace(
"SubscriptionManager:: forumUnsubscribe", 3);
446 $forumSubscription->delete(
"WHERE forum_id={$this->forum->forum_id} AND $user_id={$user_id}");
451 function writeScript()
454 $topic_id = $this->topic->topic_id ? $this->topic->topic_id : 0;
460 <script type=
"text/javascript" src=
"/components/forum/js/forum_subscription_manager.js"></script>
461 <script type=
"text/javascript">
463 var forumSubscriptionMgr;
465 window.addEvent(
'domready',
function()
467 forumSubscriptionMgr =
new ForumSubscriptionManager(
494 class ForumTopicSubscriptionHelper
extends ForumSubscriptionHelper
505 if($this->forumSubscription)
507 $this->subscribeType =
"update_forum";
511 $this->subscribeType = ($this->subscription) ?
"update_topic" :
"new_topic";
514 $this->
title = $this->topic->getTitle();
523 if($this->subscribeType ==
"new_topic")
525 $this->drawButtonLink();
527 else if($this->subscribeType ==
"update_topic")
529 $text =
"You are Currently Subscribed to";
531 $this->drawIconLink(
$text);
535 function drawHeaderText()
537 echo $this->formatHeader();
540 function formatHeader()
542 if(!$this->subscription)
544 return "<p>You can subscribe to the topics's daily digest or subscribe to instant notification to receive an email whenever a reply is posted.</p>\n";
549 return "<p>You are currently subscribed to $subscriptionType for this topic. You can change your subscription type or unsubscribe.</p>";
static using()
Import the datamodels, views and manifest for the specified component(s).
static getUserTopicSubscriptions($forum_id)
static findUserSubscription($forum_id, $topic_id=0)
static $subscriptionOptions
Provides the interface to the user model for the application.
const subscription_unsubscribe
static formatUnsubscribeMessageFooter()
static updateSubscription($subscription, $subscription_type)
static formatSubscriptionOptions($forum, $forumSubscription, $topicSubscriptionCount=0)
static formatTopicInstantNotification($message)
const subscription_instant_notification
static renderSubscriptionType($subscription)
static sendInstantNotifications($message)
const subscription_daily_digest
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content