public function onAfterReply($message) { if (JString::strlen($message->message) > $this->params->get('activity_points_limit', 0)) { CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('com_kunena.thread.reply'); } $content = KunenaHtmlParser::plainBBCode($message->message, $this->params->get('activity_stream_limit', 0)); // Add readmore permalink $content .= '<br /><a rel="nofollow" href="' . $message->getTopic()->getPermaUrl() . '" class="small profile-newsfeed-item-action">' . JText::_('COM_KUNENA_READMORE') . '</a>'; $act = new stdClass(); $act->cmd = 'wall.write'; $act->actor = $message->userid; $act->target = 0; // no target $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE', '<a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a>')); $act->content = $content; $act->app = 'kunena.post'; $act->cid = $message->thread; $act->access = $this->getAccess($message->getCategory()); // Comments and like support $act->comment_id = $message->thread; $act->comment_type = 'kunena.post'; $act->like_id = $message->thread; $act->like_type = 'kunena.post'; // Do not add private activities if ($act->access > 20) { return; } CFactory::load('libraries', 'activities'); CActivityStream::add($act); }
public function onAfterReply($message) { $content = KunenaHtmlParser::plainBBCode($message->message, $this->params->get('activity_stream_limit', 0)); // Add readmore permalink $content .= '<br /><a rel="nofollow" href="'.$message->getTopic()->getPermaUrl().'" class="small profile-newsfeed-item-action">'.JText::_('COM_KUNENA_READMORE').'</a>'; $msg = AwdwallHelperUser::formatUrlInMsg($msg); $wall =& JTable::getInstance('Wall', 'Table'); $wall->user_id = $message->userid; $wall->group_id = NULL; $wall->type = 'text'; $wall->commenter_id = $message->userid; $wall->user_name = ''; $wall->avatar = ''; $wall->message = JText::sprintf ( 'PLG_KUNENA_JOMWALL_ACTIVITY_REPLY_TITLE', '<a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a>' ).'<br>'.$content; $wall->reply = 0; $wall->is_read = 0; $wall->is_pm = 0; $wall->is_reply = 0; $wall->posted_id = NULL; $wall->wall_date = time(); if (!$wall->store()){ } }
public function onAfterReply($message) { CFactory::load ( 'libraries', 'userpoints' ); CUserPoints::assignPoint ( 'com_kunena.thread.reply' ); // Check for permisions of the current category - activity only if public or registered if ($message->getCategory()->pub_access <= 0) { //activity stream - reply post require_once KPATH_SITE.'/lib/kunena.link.class.php'; $JSPostLink = CKunenaLink::GetThreadPageURL ( 'view', $message->catid, $message->thread, 0 ); kimport('kunena.html.parser'); $content = KunenaHtmlParser::plainBBCode($message->message, $this->_config->activity_limit); // Add readmore link $content .= '<br /><a href="'. CKunenaLink::GetMessageURL($message->id, $message->catid). '" class="small profile-newsfeed-item-action">'.JText::sprintf('Read more...').'</a>'; $act = new stdClass (); $act->cmd = 'wall.write'; $act->actor = $message->userid; $act->target = 0; // no target $act->title = JText::_ ( '{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::_ ( 'COM_KUNENA_JS_ACTIVITYSTREAM_REPLY_MSG1' ) . ' <a href="' . $JSPostLink . '">' . $message->subject . '</a> ' . JText::_ ( 'COM_KUNENA_JS_ACTIVITYSTREAM_REPLY_MSG2' ) ); $act->content = $content; $act->app = 'kunena.post'; $act->cid = $message->thread; // jomsocial 0 = public, 20 = registered members if ($message->getCategory()->pub_access == 0) { $act->access = 0; } else { $act->access = 20; } CFactory::load ( 'libraries', 'activities' ); CActivityStream::add ( $act ); } }
public function onAfterReply($message) { CFactory::load ( 'libraries', 'userpoints' ); CUserPoints::assignPoint ( 'com_kunena.thread.reply' ); $content = KunenaHtmlParser::plainBBCode($message->message, $this->_config->activity_limit); // Add readmore permalink $content .= '<br /><a rel="nofollow" href="'. KunenaRoute::_($message->getPermaUrl()). '" class="small profile-newsfeed-item-action">'.JText::_('COM_KUNENA_READMORE').'</a>'; $act = new stdClass (); $act->cmd = 'wall.write'; $act->actor = $message->userid; $act->target = 0; // no target $act->title = JText::_ ( '{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::_ ( 'COM_KUNENA_JS_ACTIVITYSTREAM_REPLY_MSG1' ) . ' <a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a> ' . JText::_ ( 'COM_KUNENA_JS_ACTIVITYSTREAM_REPLY_MSG2' ) ); $act->content = $content; $act->app = 'kunena.post'; $act->cid = $message->thread; $act->access = $this->getAccess($message->getCategory()); CFactory::load ( 'libraries', 'activities' ); CActivityStream::add ( $act ); }
public function sendNotification($url=null) { $config = KunenaFactory::getConfig(); if ($this->hold > 1) { return; } elseif ($this->hold == 1) { $mailsubs = 0; $mailmods = (bool) $config->mailmod; $mailadmins = (bool) $config->mailadmin; } else { $mailsubs = (bool) $config->allowsubscriptions; $mailmods = 0; $mailadmins = 0; } $once = false; if ($mailsubs) { if (!$this->parent) { // New topic: Send email only to category subscribers $mailsubs = $config->category_subscriptions != 'disabled' ? 3 : 0; $once = $config->category_subscriptions == 'topic'; } elseif ($config->category_subscriptions != 'post') { // Existing topic: Send email only to topic subscribers $mailsubs = $config->topic_subscriptions != 'disabled' ? 2 : 0; $once = $config->topic_subscriptions == 'first'; } else { // Existing topic: Send email to both category and topic subscribers $mailsubs = $config->topic_subscriptions == 'disabled' ? 3 : 1; // FIXME: category subcription can override topic $once = $config->topic_subscriptions == 'first'; } } if (!$url) { $url = JURI::root().trim($this->getPermaUrl(null, true), '/'); } //get all subscribers, moderators and admins who will get the email $me = KunenaUserHelper::get(); $acl = KunenaFactory::getAccessControl(); $emailToList = $acl->getSubscribers($this->catid, $this->thread, $mailsubs, $mailmods, $mailadmins, $me->userid); $topic = $this->getTopic(); if (count ( $emailToList )) { jimport('joomla.mail.helper'); if (! $config->email ) { KunenaError::warning ( JText::_ ( 'COM_KUNENA_EMAIL_DISABLED' ) ); return false; } elseif ( ! JMailHelper::isEmailAddress ( $config->email ) ) { KunenaError::warning ( JText::_ ( 'COM_KUNENA_EMAIL_INVALID' ) ); return false; } // clean up the message for review $message = KunenaHtmlParser::plainBBCode ( $this->message ); $mailsender = JMailHelper::cleanAddress ( $config->board_title ); $mailsubject = JMailHelper::cleanSubject ( "[" . $config->board_title . "] " . $topic->subject . " (" . $this->getCategory()->name . ")" ); $subject = $this->subject ? $this->subject : $topic->subject; // Make a list from all receivers $sentusers = array(); $receivers = array(0=>array(), 1=>array()); foreach ( $emailToList as $emailTo ) { if (! $emailTo->email || ! JMailHelper::isEmailAddress ( $emailTo->email )) { continue; } $receivers[$emailTo->subscription][] = $emailTo->email; $sentusers[] = $emailTo->id; } // Create email $mail = JFactory::getMailer(); $mail->setSubject($mailsubject); $mail->setSender(array($this->_config->email, $mailsender)); // Send email to all subscribers if (!empty($receivers[1])) { $mail->setBody($this->createEmailBody(1, $subject, $url, $message, $once)); $this->sendEmail($mail, $receivers[1]); } // Send email to all moderators if (!empty($receivers[0])) { $mail->setBody($this->createEmailBody(0, $subject, $url, $message, $once)); $this->sendEmail($mail, $receivers[0]); } // Update subscriptions if ($once && $sentusers) { $sentusers = implode (',', $sentusers); $db = JFactory::getDBO(); $query = "UPDATE #__kunena_user_topics SET subscribed=2 WHERE topic_id={$this->thread} AND user_id IN ({$sentusers}) AND subscribed=1"; $db->setQuery ($query); $db->query (); KunenaError::checkDatabaseError(); } } }
public function sendNotification($url=null) { $config = KunenaFactory::getConfig(); if ($this->hold > 1) { return; } elseif ($this->hold == 1) { $mailsubs = 0; $mailmods = (bool) $config->mailmod; $mailadmins = (bool) $config->mailadmin; } else { $mailsubs = (bool) $config->allowsubscriptions; $mailmods = 0; $mailadmins = 0; } kimport ('kunena.html.parser'); $once = false; if ($mailsubs) { if (!$this->parent) { // New topic: Send email only to category subscribers $mailsubs = $config->category_subscriptions != 'disabled' ? 3 : 0; $once = $config->category_subscriptions == 'topic'; } elseif ($config->category_subscriptions != 'post') { // Existing topic: Send email only to topic subscribers $mailsubs = $config->topic_subscriptions != 'disabled' ? 2 : 0; $once = $config->topic_subscriptions == 'first'; } else { // Existing topic: Send email to both category and topic subscribers $mailsubs = $config->topic_subscriptions == 'disabled' ? 3 : 1; // FIXME: category subcription can override topic $once = $config->topic_subscriptions == 'first'; } } if (!$url) { $url = JURI::root().trim(CKunenaLink::GetMessageURL($this->id, $this->catid, 0, false), '/'); } //get all subscribers, moderators and admins who will get the email $me = KunenaUserHelper::get(); $acl = KunenaFactory::getAccessControl(); $emailToList = $acl->getSubscribers($this->catid, $this->thread, $mailsubs, $mailmods, $mailadmins, $me->userid); $category = $this->getCategory(); $topic = $this->getTopic(); if (count ( $emailToList )) { jimport('joomla.mail.helper'); if (! $config->email ) { KunenaError::warning ( JText::_ ( 'COM_KUNENA_EMAIL_DISABLED' ) ); return false; } elseif ( ! JMailHelper::isEmailAddress ( $config->email ) ) { KunenaError::warning ( JText::_ ( 'COM_KUNENA_EMAIL_INVALID' ) ); return false; } // clean up the message for review $message = KunenaHtmlParser::plainBBCode ( $this->message ); $mailsender = JMailHelper::cleanAddress ( $config->board_title ); $mailsubject = JMailHelper::cleanSubject ( "[" . $config->board_title . "] " . $topic->subject . " (" . $category->name . ")" ); $subject = $this->subject ? $this->subject : $topic->subject; $sentusers = array(); foreach ( $emailToList as $emailTo ) { if (! $emailTo->email || ! JMailHelper::isEmailAddress ( $emailTo->email )) continue; if ($emailTo->subscription) { $msg1 = $this->parent ? JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1' ) : JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1_CAT' ); $msg2 = $this->parent ? JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2' ) : JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2_CAT' ); } else { $msg1 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD1' ); $msg2 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD2' ); } $msg = "$emailTo->name,\n\n"; $msg .= $msg1 . " " . $config->board_title . "\n\n"; // DO NOT REMOVE EXTRA SPACE, JMailHelper::cleanBody() removes "Subject:" from the message body $msg .= JText::_ ( 'COM_KUNENA_MESSAGE_SUBJECT' ) . " : " . $subject . "\n"; $msg .= JText::_ ( 'COM_KUNENA_GEN_CATEGORY' ) . " : " . $category->name . "\n"; $msg .= JText::_ ( 'COM_KUNENA_VIEW_POSTED' ) . " : " . $this->name . "\n\n"; $msg .= "URL : {$url}\n\n"; if ($config->mailfull) { $msg .= JText::_ ( 'COM_KUNENA_GEN_MESSAGE' ) . " :\n-----\n"; $msg .= $message; $msg .= "\n-----\n\n"; } $msg .= $msg2 . "\n"; if ($emailTo->subscription && $once) { if ($this->parent) { $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_READ' ) . "\n"; } else { $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_SUBSCRIBE' ) . "\n"; } } $msg .= "\n"; $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION3' ) . "\n"; $msg = JMailHelper::cleanBody ( $msg ); JUtility::sendMail ( $config->email, $mailsender, $emailTo->email, $mailsubject, $msg ); $sentusers[] = $emailTo->id; } if ($once && $sentusers) { $sentusers = implode (',', $sentusers); $db = JFactory::getDBO(); $query = "UPDATE #__kunena_user_topics SET subscribed=2 WHERE topic_id={$this->thread} AND user_id IN ({$sentusers}) AND subscribed=1"; $db->setQuery ($query); $db->query (); KunenaError::checkDatabaseError(); } } }