public function sendModerationEmail() { // @rule: Send email to the team admin's. $team = EasyBlogHelper::getTable('TeamBlog'); $team->load($this->team_id); $notification = EasyBlogHelper::getHelper('Notification'); $emails = array(); $config = EasyBlogHelper::getConfig(); if ($config->get('custom_email_as_admin')) { $notification->getCustomEmails($emails); } else { $notification->getAdminEmails($emails); } $notification->getTeamAdminEmails($emails, $team->id); $user = EasyBlogHelper::getTable('Profile'); $user->load($this->user_id); $date = EasyBlogDateHelper::dateWithOffSet($this->created); if (count($emails) > 0) { $data = array('teamName' => $team->title, 'authorAvatar' => $user->getAvatar(), 'authorLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $user->id, false, true), 'authorName' => $user->getName(), 'requestDate' => EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'), 'reviewLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=dashboard&layout=teamblogs', false, true)); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EasyBlogRouter::isSh404Enabled(); if (JFactory::getApplication()->isAdmin() && $sh404exists) { $data['authorLink'] = JURI::root() . 'index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $user->id; $data['reviewLink'] = JURI::root() . 'index.php?option=com_easyblog&view=dashboard&layout=teamblogs'; } $emailTitle = JText::_('COM_EASYBLOG_TEAMBLOG_NEW_REQUEST'); $notification->send($emails, $emailTitle, 'email.teamblog.request', $data); } }
function display($tmpl = null) { $config = EasyBlogHelper::getConfig(); $jConfig = EasyBlogHelper::getJConfig(); if (!$config->get('main_rss')) { return; } $model = $this->getModel('Featured'); $data = $model->getFeaturedBlog(); $document = JFactory::getDocument(); $document->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=featured'); $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_FEATURED_TITLE')); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_FEATURED_DESC', JURI::root())); if (!empty($data)) { for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($row->created_by); $created = EasyBlogDateHelper::dateWithOffSet($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } // $row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat(); $row->created = $created->toMySQL(); if ($config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; //read more for feed $row->text .= '<br /><a href=' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>'; } else { $row->text = $row->intro . $row->content; } $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text); $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text); $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_id); // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $row->text; $item->date = $row->created; $item->category = $category->title; $item->author = $profile->getName(); if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $profile->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } $document->addItem($item); } } }
public function mapPost($row, $strip_tags = '', $text_length = 0, $skip = array()) { $config = EasyBlogHelper::getConfig(); $blog = EasyBlogHelper::getTable('Blog'); $blog->load($row->id); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($row->created_by); $created = EasyBlogDateHelper::dateWithOffSet($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } $blog->created = $created->toMySQL(); $blog->text = $row->intro . $row->content; $config->set('max_video_width', 320); $config->set('max_video_width', 180); $blog->text = EasyBlogHelper::getHelper('Videos')->processVideos($blog->text); $blog->text = EasyBlogGoogleAdsense::stripAdsenseCode($blog->text); $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_id); $item = new PostSimpleSchema(); $item->textplain = $blog->text; // @TODO : Take care of a case when strip tags and length are used together if ($strip_tags) { $item->textplain = strip_tags($blog->text, $strip_tags); } if ($text_length > 0) { $pos = JString::strpos(strip_tags($item->textplain), ' ', $text_length); $item->textplain = JString::substr(strip_tags($blog->text), 0, $pos); } $image_data = json_decode($blog->image); $item->postid = $blog->id; $item->title = $blog->title; $item->text = $blog->text; $item->textplain = $this->sanitize($item->textplain); $item->image = $blog->getImage(); $item->image->url = $image_data->url; $item->created_date = $blog->created; $item->created_date_elapsed = EasyBlogDateHelper::getLapsedTime($blog->created); $item->author->name = $profile->nickname; $item->author->photo = JURI::root() . $profile->avatar; $item->category->categoryid = $category->id; $item->category->title = $category->title; $item->url = JURI::root() . trim(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id), '/'); // Tags $modelPT = EasyBlogHelper::getModel('PostTag'); $item->tags = $modelPT->getBlogTags($blog->id); foreach ($skip as $v) { unset($item->{$v}); } return $item; }
public function notify(EasyBlogTableBlog $blog) { $config = EasyBlogHelper::getConfig(); // Send notification to site admins when a new blog post is reported $data = array(); $data['blogTitle'] = $blog->title; $data['blogLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); // @rule: Send email notifications out to subscribers. $author = EasyBlogHelper::getTable('Profile'); $author->load($this->created_by); $data['reporterAvatar'] = $author->getAvatar(); $data['reporterName'] = $author->getName(); $data['reporterLink'] = $author->getProfileLink(); $data['reason'] = $this->reason; $date = EasyBlogDateHelper::dateWithOffSet($this->created); $data['reportDate'] = EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EasyBlogRouter::isSh404Enabled(); if (JFactory::getApplication()->isAdmin() && $sh404exists) { $data['blogLink'] = JURI::root() . 'index.php?option=com_easyblog&view=entry&id=' . $blog->id; } $emailBlogTitle = JString::substr($blog->title, 0, $config->get('main_mailtitle_length')); $emailTitle = JText::sprintf('COM_EASYBLOG_EMAIL_TITLE_NEW_REPORT', $emailBlogTitle) . ' ...'; $notification = EasyBlogHelper::getHelper('Notification'); $emails = array(); // @rule: Fetch custom emails defined at the back end. if ($config->get('notification_blogadmin')) { if ($config->get('custom_email_as_admin')) { $notification->getCustomEmails($emails); } else { $notification->getAdminEmails($emails); } } if (!empty($emails)) { $notification->send($emails, $emailTitle, 'email.blog.report', $data); } }
public function notify($underApproval = false) { if (empty($this->send_notification_emails)) { return; } // @rule: Send email notifications out to subscribers. $author = EasyBlogHelper::getTable('Profile'); $author->load($this->created_by); $data['blogTitle'] = $this->title; $data['blogAuthor'] = $author->getName(); $data['blogAuthorAvatar'] = $author->getAvatar(); $data['blogAuthorLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id, false, true); $data['blogAuthorEmail'] = $author->user->email; $data['blogIntro'] = $this->intro; $data['blogContent'] = $this->content; // Try to truncate introtext based on the configured settings because content is empty. if (empty($this->content)) { $obj = clone $this; $obj->readmore = EasyBlogHelper::requireReadmore($obj); EasyBlogHelper::truncateContent($obj, false, true); $data['blogIntro'] = $obj->text; } $data['blogLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $this->id, false, true); $date = EasyBlogDateHelper::dateWithOffSet($this->created); $data['blogDate'] = EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EasyBlogRouter::isSh404Enabled(); if (JFactory::getApplication()->isAdmin() && $sh404exists) { $data['blogLink'] = JURI::root() . 'index.php?option=com_easyblog&view=entry&id=' . $this->id; $data['blogAuthorLink'] = JURI::root() . 'index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id; } $config = EasyBlogHelper::getConfig(); $emailBlogTitle = JString::substr($this->title, 0, $config->get('main_mailtitle_length')); $emailTitle = JText::sprintf('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_ADDED_WITH_TITLE', $emailBlogTitle) . ' ...'; $notification = EasyBlogHelper::getHelper('Notification'); $emails = array(); // @rule: Fetch custom emails defined at the back end. if ($config->get('notification_blogadmin')) { if ($config->get('custom_email_as_admin')) { $notification->getCustomEmails($emails); } else { $notification->getAdminEmails($emails); } } // @task: If this blog post is a team posting, we shouldn't send notification to everyone. $model = JModel::getInstance('TeamBlogs', 'EasyBlogModel'); $contribution = $model->getBlogContributed($this->id); if ($contribution) { $team = EasyBlogHelper::getTable('TeamBlog'); $team->load($contribution->team_id); $contribution->access = $team->access; } else { $contribution = new stdClass(); $contribution->access = EBLOG_TEAMBLOG_ACCESS_EVERYONE; } // @task: This is when this blog post is posted into a team. if ($contribution && $config->get('notification_teamsubscriber') && isset($contribution->team_id)) { // @task: Send emails to users who is a member of the team $notification->getTeamUserEmails($emails, $contribution->team_id); // @task: Send emails to users who have subscribed to the team $notification->getTeamSubscriberEmails($emails, $this); } // @task: Only send emails to these group of users provided that, it is not a team posting or private team posting. if (!$contribution || $contribution->access != EBLOG_TEAMBLOG_ACCESS_MEMBER) { // @rule: Get all email addresses for the whole site. if ($config->get('notification_allmembers')) { $notification->getAllEmails($emails); } else { // @rule: Send to subscribers that subscribe to the bloggers if ($config->get('notification_blogsubscriber')) { $notification->getBloggerSubscriberEmails($emails, $this); } // @rule: Send to subscribers that subscribed to the category if ($config->get('notification_categorysubscriber')) { $notification->getCategorySubscriberEmails($emails, $this); } // @rule: Send notification to all site's subscribers if ($config->get('notification_sitesubscriber')) { $notification->getSiteSubscriberEmails($emails, $this); } } } // @rule: We need to remove the email of the creator since the creator of this blog post should not receive the email. if (isset($emails[$author->user->email])) { unset($emails[$author->user->email]); } // @task: Add the emails into the mail queue now. if (!empty($emails)) { $notification->send($emails, $emailTitle, 'email.blog.new', $data); } // @task: If this blog post is under approval, we need to send email to the site admin if ($underApproval) { // We know that this blog post requires moderation. Send notification to the author and let them know, that it is being moderated. $authorEmail = array(); $obj = new stdClass(); $obj->unsubscribe = false; $obj->email = $author->user->email; $authorEmail[$author->user->email] = $obj; $notification->send($authorEmail, JText::_('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_APPROVED'), 'email.blog.approved', $data); } }
public function store($updateNulls = false) { $state = parent::store(); // @rule: Process notifications for admins when the blog post is pending approvals if ($this->pending_approval) { $user = EasyBlogHelper::getTable('Profile'); $user->load($this->created_by); $date = EasyBlogDateHelper::dateWithOffSet($this->created); $data = array('blogTitle' => $this->title, 'blogAuthor' => $user->getName(), 'blogAuthorLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $user->id, false, true), 'blogIntro' => $this->intro, 'blogContent' => $this->content, 'blogAuthorAvatar' => $user->getAvatar(), 'blogDate' => EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'), 'reviewLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=dashboard&layout=pending&draft_id=' . $this->id, false, true)); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EasyBlogRouter::isSh404Enabled(); if (JFactory::getApplication()->isAdmin() && $sh404exists) { $data['blogAuthorLink'] = JURI::root() . 'index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $user->id; $data['reviewLink'] = JURI::root() . 'index.php?option=com_easyblog&view=dashboard&layout=pending&draft_id' . $this->id; } $emailTitle = JText::_('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_PENDING_REVIEW'); $emails = array(); $notification = EasyBlogHelper::getHelper('Notification'); $config = EasyBlogHelper::getConfig(); // @rule: if custom_email_as_admin is enabled, use custom email as admin email if ($config->get('custom_email_as_admin')) { // @rule: Send to custom email addresses $notification->getCustomEmails($emails); } else { // @rule: Send to administrator's on the site. $notification->getAdminEmails($emails); } $notification->send($emails, $emailTitle, 'email.blog.review', $data); } return $state; }
public function getSharedDate($blogId) { $db = EasyBlogHelper::db(); $query = 'SELECT ' . $db->nameQuote('sent') . ' FROM ' . $db->nameQuote('#__easyblog_oauth_posts') . ' ' . 'WHERE ' . $db->nameQuote('oauth_id') . '=' . $db->Quote($this->id) . ' ' . 'AND ' . $db->nameQuote('post_id') . '=' . $db->Quote($blogId); $db->setQuery($query); $result = $db->loadResult(); return EasyBlogDateHelper::dateWithOffSet($result)->toMySQL(); }
function saveDraft($params, $content, $intro) { $ajax = new Ejax(); $config = EasyBlogHelper::getConfig(); if (!EasyBlogHelper::isLoggedIn()) { echo JText::_('COM_EASYBLOG_NOT_ALLOWED'); exit; } $acl = EasyBlogACLHelper::getRuleSet(); if (empty($acl->rules->add_entry)) { echo JText::_('COM_EASYBLOG_NOT_ALLOWED'); exit; } // Try to load this draft to see if it exists $draft = EasyBlogHelper::getTable('Draft', 'Table'); $draft->load($params['draft_id']); if (isset($params['id']) && !empty($params['id'])) { $draft->entry_id = $params['id']; unset($params['id']); } $draft->intro = $intro; $draft->content = $content; $draft->bind($params, true); if (isset($params['draft_id']) && !empty($params['draft_id'])) { $draft->id = $params['draft_id']; } $my = JFactory::getUser(); if ($draft->id && $draft->created_by != $my->id && !EasyBlogHelper::isSiteAdmin()) { echo JText::_('COM_EASYBLOG_NOT_ALLOWED'); exit; } $draft->store(); $date = EasyBlogDateHelper::dateWithOffSet(EasyBlogHelper::getDate()->toMySQL()); $date = EasyBlogDateHelper::toFormat($date, $config->get('layout_timeformat', '%I:%M:%S %p')); if (isset($date[0]) && $date[0] == 0) { $date = JString::substr($date, 1, JString::strlen($date)); } $ajax->assign('draft_status span', JText::sprintf('COM_EASYBLOG_DRAFT_SAVED_TIME', $date)); $ajax->script('$( "#draft_status" ).show();'); $ajax->value('draft_id', $draft->id); $ajax->callback(''); $ajax->send(); return; }
</form> </div> </div> <?php } ?> <form name="adminForm" id="adminForm" class=""> <?php if ($tags) { ?> <ul class="tag-list reset-ul float-li clearfix"> <?php foreach ($tags as $tag) { $created = EasyBlogDateHelper::dateWithOffSet($tag->created); ?> <li id="td-<?php echo $tag->id; ?> "> <a class="tag-delete" href="javascript:eblog.tag.remove('<?php echo EasyBlogRouter::_('index.php?option=com_easyblog&controller=dashboard'); ?> ','<?php echo $tag->id; ?> ');"> <?php echo JText::_('COM_EASYBLOG_DELETE');
function display($tmpl = null) { $config = EasyBlogHelper::getConfig(); $jConfig = EasyBlogHelper::getJConfig(); if (!$config->get('main_rss')) { return; } $mainframe = JFactory::getApplication(); $menuParams = $mainframe->getParams(); $date = EasyBlogHelper::getDate(); $sort = 'latest'; $model = $this->getModel('Archive'); $year = $model->getArchiveMinMaxYear(); $defaultYear = $menuParams->get('es_archieve_year', empty($year['maxyear']) ? $date->toFormat('%Y') : $year['maxyear']); $defaultMonth = $menuParams->get('es_archieve_month', $date->toFormat('%m')); $archiveYear = JRequest::getVar('archiveyear', $defaultYear, 'REQUEST'); $archiveMonth = JRequest::getVar('archivemonth', $defaultMonth, 'REQUEST'); $data = EasyBlogHelper::formatBlog($model->getArchive($archiveYear, $archiveMonth)); $pagination = $model->getPagination(); $params = $mainframe->getParams('com_easyblog'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $document = JFactory::getDocument(); $viewDate = EasyBlogHelper::getDate($archiveYear . '-' . $archiveMonth . '-01'); $document->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=archive'); $document->setTitle(JText::sprintf('COM_EASYBLOG_FEEDS_ARCHIVE_TITLE', $viewDate->toFormat('%B %Y'))); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_ARCHIVE_DESC', $viewDate->toFormat('%B %Y'))); if (!empty($data)) { for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $blog = EasyBlogHelper::getTable('Blog'); $blog->load($row->id); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($row->created_by); $created = EasyBlogDateHelper::dateWithOffSet($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } //$row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat(); $row->created = $created->toMySQL(); if ($config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; $row->text .= '<br /><a href=' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>'; } else { $row->text = $row->intro . $row->content; } $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text); $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text); $image = ''; if ($blog->getImage()) { $image = '<img src="' . $blog->getImage()->getSource('frontpage') . '" />'; } $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_id); // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $image . $row->text; $item->date = $row->created; $item->category = $category->title; $item->author = $profile->getName(); if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $profile->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } $document->addItem($item); } } }
?> </span></h3> <?php } ?> <ul id="blog-comment" class="reset-ul"> <!-- Comment anchor --> <a name="comments" id="comments"> </a> <?php if ($blogComments) { ?> <?php $counter = count($blogComments) > 0 ? 1 : 0; foreach ($blogComments as $comment) { $created = EasyBlogDateHelper::dateWithOffSet($comment->created); $indentDirection = $this->getDirection() == 'rtl' ? 'right' : 'left'; ?> <li id="comment-<?php echo $comment->id; ?> " class="comment-row comment-style-<?php echo $counter % 2; ?> <?php echo $comment->depth > 0 ? 'comment-replied' : ''; ?> " <?php echo $comment->depth > 0 ? 'style="margin-' . $indentDirection . ':' . $comment->depth * 30 . 'px;"' : ''; ?> >
public static function getDate($str = '') { return EasyBlogDateHelper::dateWithOffSet($str); }
private function sendNotificationsJomsocial($blog, $isNew, $uid, $source, $author) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); // @rule: Send email notifications out to subscribers. $author = EasyBlogHelper::getTable('Profile'); $author->load($blog->created_by); $data['blogTitle'] = $blog->title; $data['blogAuthor'] = $author->getName(); $data['blogAuthorAvatar'] = $author->getAvatar(); $data['blogAuthorLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id, false, true); $data['blogAuthorEmail'] = $author->user->email; $data['blogIntro'] = $blog->intro; $data['blogContent'] = $blog->content; $data['blogLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); $date = EasyBlogDateHelper::dateWithOffSet($blog->created); $data['blogDate'] = EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EasyBlogRouter::isSh404Enabled(); if (JFactory::getApplication()->isAdmin() && $sh404exists) { $data['blogLink'] = JURI::root() . 'index.php?option=com_easyblog&view=entry&id=' . $blog->id; $data['blogAuthorLink'] = JURI::root() . 'index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id; } if (is_array($uid)) { $uid = $uid[0]; } JTable::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'tables'); $event = JTable::getInstance('Event', 'CTable'); $event->load($uid); $members = $event->getMembers(1, 99999); $emails = array(); $jsCoreFile = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; foreach ($members as $member) { $user = CFactory::getUser($member->id); // Do not send email to the author. if ($author->user->email != $user->email) { $obj = new stdClass(); $obj->email = $user->email; $emails[] = $obj; } } $notification = EasyBlogHelper::getHelper('Notification'); $emailBlogTitle = JString::substr($blog->title, 0, $config->get('main_mailtitle_length')); $emailTitle = JText::sprintf('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_ADDED_WITH_TITLE', $emailBlogTitle) . ' ...'; $notification->send($emails, $emailTitle, 'email.blog.new', $data); }
function formatDate($format, $dateString) { $date = EasyBlogDateHelper::dateWithOffSet($dateString); return EasyBlogDateHelper::toFormat($date, $format); }
"><a href="<?php echo EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=categories&order=latest'); ?> "><?php echo JText::_('COM_EASYBLOG_SORT_BY_DATE_CREATED'); ?> </a></li> </ul> </div> <?php if ($categories) { ?> <ul class="item_list no-cbox reset-ul"> <?php foreach ($categories as $category) { $created = EasyBlogDateHelper::dateWithOffSet($category->created); ?> <li id="td-<?php echo $category->id; ?> " class="prel"> <?php if ($system->config->get('layout_categoryavatar')) { ?> <div class="ui-avatar float-l"> <a class="avatar float-l" href="<?php echo EasyBlogRouter::_('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $category->id); ?> "> <img src="<?php echo $category->getAvatar();
* other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Restricted access'); $url = rtrim(JURI::base(), '/'); ?> <h1><a href="<?php echo $url . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id); ?> "><?php echo $blog->title; ?> </a></h1> <?php $date = EasyBlogDateHelper::dateWithOffSet($blog->created); $postdate = EasyBlogDateHelper::toFormat($date, $config->get('layout_shortdateformat', '%b %d')); ?> <p class="meta-bottom"> <?php echo JText::_('COM_EASYBLOG_POSTED_ON'); ?> <?php echo $postdate; ?> , <?php echo JText::sprintf('COM_EASYBLOG_POSTED_BY_AUTHOR', $url . $blogger->getProfileLink(), $blogger->displayName); echo JText::_('COM_EASYBLOG_CATEGORY'); ?> <a href="<?php
/** * comment save function used by cb.easyblog plugin. */ function saveCBcomment($post) { require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'constants.php'; $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $ajax = new Ejax(); if (JString::strlen($post['comment']) == 0) { $ajax->script('easyblogApp.comment.notify("' . $post['id'] . '","' . JText::_('Comment is empty') . '","' . 'error' . '")'); $ajax->script('easyblogApp.spinner.hide()'); $ajax->script('easyblogApp.element.focus("comment")'); return $ajax->send(); } // We don't require a title here. $post['title'] = ''; //real work start here. $isModerate = false; $parentId = "0"; $commentDepth = $post['comment_depth']; $blogId = $post['id']; //we need to rename the esname and esemail back to name and email. $post['url'] = ''; $post['name'] = $post['esname']; $post['email'] = $post['esemail']; unset($post['esname']); unset($post['esemail']); JTable::addIncludePath(EBLOG_TABLES); $db = EasyBlogHelper::db(); $comment = EasyBlogHelper::getTable('Comment', 'Table'); $comment->bindPost($post); $now = EasyBlogHelper::getDate(); $totalComment = empty($post['totalComment']) ? 1 : $post['totalComment']; $comment->created = $now->toMySql(); $comment->modified = $now->toMySql(); $comment->published = 1; $comment->parent_id = $parentId; $comment->created_by = $my->id; if ($my->id != 0 && $config->get('comment_moderatecomment') == 1 || $my->id == 0 && $config->get('comment_moderateguestcomment') == 1) { $comment->published = 0; $isModerate = true; } jimport('joomla.application.component.model'); JLoader::import('Comment', EBLOG_ROOT . DIRECTORY_SEPARATOR . 'models'); $model = JModel::getInstance('Comment', 'EasyBlogModel'); $latestComment = $model->getLatestComment($blogId, $parentId); $left = 1; $right = 2; if (!empty($latestComment)) { $left = $latestComment->rgt + 1; $right = $latestComment->rgt + 2; $model->updateCommentSibling($blogId, $latestComment->rgt); } $comment->lft = $left; $comment->rgt = $right; if (!$comment->store()) { $ajax->script('easyblogApp.comment.notify("' . $post['id'] . '","' . JText::_('Comment add failed') . '","' . 'error' . '")'); $ajax->script('easyblogApp.spinner.hide()'); $ajax->{$ajax}('easyblogApp.element.focus("comment")'); return $ajax->send(); } $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($comment->created_by); $comment->creator = $profile; $date = EasyBlogDateHelper::dateWithOffSet($comment->created); $comment->formattedDate = $date->toFormat($config->get('layout_dateformat', '%A, %d %B %Y')); $text = JString::strlen($comment->comment) > 50 ? JString::substr(strip_tags($comment->comment), 0, 50) . '...' : strip_tags($comment->comment); $commentText = ' <li> <div class="blog-comment-avatar"> <a href="' . $comment->creator->getProfileLink() . '"><img src="' . $comment->creator->getAvatar() . '" width="32" /></a> </div> <div class="blog-comment-item eztc"> <div class="small"> <a href="' . $comment->creator->getProfileLink() . '">' . $comment->creator->getName() . '</a> ' . JText::_('on') . ' <span class="small">' . $comment->formattedDate . '</span> </div> ' . $text . ' </div> <div style="clear: both;"></div> </li>'; $ajax->prepend('comments-wrapper' . $blogId, $commentText); $ajax->script('easyblogApp.comment.cancel("' . $blogId . '")'); $ajax->script('easyblogApp.spinner.hide()'); $ajax->script('easyblogApp.comment.notify("' . $blogId . '","' . JText::_('Comment Added') . '","' . 'success' . '")'); return $ajax->send(); }
public function processEmails($isModerated = false, $blog) { $config = EasyBlogHelper::getConfig(); // @task: Fix contents of comments. $content = $this->comment; // $content = nl2br( $this->comment ); // $content = EasyBlogCommentHelper::parseBBCode( $content ); // Initialize what we need $commentAuthor = $this->name; $commentAuthorEmail = $this->email; $commentAuthorAvatar = JURI::root() . 'components/com_easyblog/assets/images/default_blogger.png'; $date = EasyBlogDateHelper::dateWithOffSet($this->created); $commentDate = EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'); $teamLink = ''; $emails = array(); if (isset($blog->team)) { $teamLink = '&team=' . $blog->team; } if ($this->created_by != 0) { $user = EasyBlogHelper::getTable('Profile'); $user->load($this->created_by); $commentAuthor = $user->getName(); $commentAuthorEmail = $user->user->email; $commentAuthorAvatar = $user->getAvatar(); } $blogAuthor = EasyBlogHelper::getTable('Profile'); $blogAuthor->load($blog->created_by); $data = array('blogTitle' => $blog->title, 'blogIntro' => $blog->intro, 'blogContent' => $blog->content, 'blogLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry' . $teamLink . '&id=' . $blog->id, false, true), 'commentTitle' => empty($comment->title) ? '-' : $comment->title, 'commentContent' => $content, 'commentAuthor' => $commentAuthor, 'commentAuthorAvatar' => $commentAuthorAvatar, 'commentDate' => $commentDate, 'commentLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry' . $teamLink . '&id=' . $blog->id, false, true) . '#comment-' . $this->id); $emails = array(); $notification = EasyBlogHelper::getHelper('Notification'); if ($isModerated) { $hashkey = EasyBlogHelper::getTable('HashKeys'); $hashkey->uid = $this->id; $hashkey->type = 'comments'; $hashkey->store(); $data['approveLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&controller=dashboard&task=approvecomment&key=' . $hashkey->key, false, true); $notification->getCustomEmails($emails); $notification->getAdminEmails($emails); $notification->send($emails, JText::_('COM_EASYBLOG_NEW_COMMENT_ADDED_MODERATED_TITLE'), 'email.comment.moderate', $data); return true; } if (!$isModerated) { if ($config->get('notification_commentadmin')) { if ($config->get('custom_email_as_admin')) { $notification->getCustomEmails($emails); } else { $notification->getAdminEmails($emails); } } // @rule: Send notification to blog authors. if ($config->get('notification_commentauthor')) { $obj = new stdClass(); $obj->unsubscribe = false; $obj->email = $blogAuthor->user->email; $emails[$blogAuthor->user->email] = $obj; } // @rule: Send notifications to blog subscribers if ($config->get('main_subscription') && $blog->subscription == '1' && $config->get('notification_commentsubscriber')) { $notification->getBlogSubscriberEmails($emails, $blog->id); } // @rule: Do not send to the person that commented on the blog post. unset($emails[$commentAuthorEmail]); // @rule: Send the emails now. if (!empty($emails)) { $emailTitle = JText::_('COM_EASYBLOG_NEW_COMMENT_ADDED'); if ($config->get('main_comment_email')) { $emailTitle = '[#' . $this->id . ']: ' . $emailTitle; } $notification->send($emails, $emailTitle, 'email.comment.new', $data); } return true; } }
?> </div> <?php } ?> --> <div class="comment-content"> <!-- <div class="comment-head prel"> <i class="comment-arrow pabs"></i> <span class="comment-name"><b><?php echo $my->displayName; ?> </b></span> <span class="comment-date"><?php echo EasyBlogDateHelper::toFormat(EasyBlogDateHelper::dateWithOffSet(), $config->get('layout_dateformat', '%A, %d %B %Y')); ?> </span> </div> --> <div class="comment-body prel"> <i class="comment-arrow pabs"></i> <?php // if($canRegister && $my->id == 0){ ?> <!--<div class="form-row mtm"> <label class="label"><?php echo JText::_('COM_EASYBLOG_FILL_IN_USERNAME_AND_FULLNAME_TO_REGISTER'); ?> </label>
function display($tmpl = null) { $config = EasyBlogHelper::getConfig(); $jConfig = EasyBlogHelper::getJConfig(); if (!$config->get('main_rss')) { return; } require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'date.php'; require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'helper.php'; require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'string.php'; require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php'; $sort = JRequest::getCmd('sort', $config->get('layout_postorder')); $model = $this->getModel('Blog'); $data = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true); $document = JFactory::getDocument(); $document->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=latest'); $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_LATEST_TITLE')); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_LATEST_DESC', JURI::root())); if (!empty($data)) { $modelPT = $this->getModel('PostTag'); for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $blog = EasyBlogHelper::getTable('Blog'); $blog->load($row->id); $user = JFactory::getUser($row->created_by); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($user->id); $created = EasyBlogDateHelper::dateWithOffSet($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } //$row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat(); $row->created = $created->toMySQL(); if ($config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; $row->text .= '<br /><a href=' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>' . JText::_('COM_EASYBLOG_READ_MORE') . '</a>'; } else { $row->text = $row->intro . $row->content; //add read more in feed } $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text); $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text); $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_id); // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); $image = ''; if ($blog->getImage()) { $image = '<img src="' . $blog->getImage()->getSource('frontpage') . '" />'; } // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $image . $row->text; $item->date = $row->created; $item->category = $category->title; $item->author = $profile->getName(); if ($jConfig->get('feed_email') != 'none') { if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } } $document->addItem($item); } } }
echo JText::_('COM_EASYBLOG_TEAMBLOGS_APPROVAL'); ?> </th> </tr> </thead> <tbody> <?php if (count($this->requests) > 0) { $k = 0; $x = 0; for ($i = 0, $n = count($this->requests); $i < $n; $i++) { $entry = $this->requests[$i]; $requestor = JFactory::getUser($entry->user_id); $user = EasyBlogHelper::getTable('Profile', 'Table'); $user->setUser($requestor); $created = EasyBlogDateHelper::dateWithOffSet($entry->created); ?> <tr class="<?php echo "row{$k}"; ?> "> <td valign="top" class="item-data"> <?php echo $entry->title; ?> </td> <td valign="top"> <?php echo $user->getName(); ?> </td>
<div class="ui-content"> <div class="ui-comment-meta mbs"> <?php $blogLink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id); $blogTitle = $comment->blog_title; $profileLink = '#'; if ($comment->created_by != 0) { $commentor = EasyBlogHelper::getTable('Profile', 'Table'); $commentor->load($comment->created_by); $profileLink = $commentor->getProfileLink(); $submitterName = $commentor->getName(); } else { $submitterName = $comment->name; } $submitterLink = $profileLink; $dateSubmitted = EasyBlogDateHelper::toFormat(EasyBlogDateHelper::dateWithOffSet($comment->created), $system->config->get('layout_dateformat', '%A, %d %B %Y')); echo JText::sprintf('COM_EASYBLOG_DASHBOARD_COMMENTS_COMMENTED_ON_BLOG', '<b>' . $submitterName . '</b>', $blogLink, $blogTitle); ?> </div> <div class="ui-item-content" id="comment-content-<?php echo $comment->id; ?> "> <?php if (!empty($comment->title)) { ?> <b class="ui-comment-title"> <?php $commentLink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id . '#comment-' . $comment->id); $commentTitle = !empty($comment->title) ? $comment->title : JText::_('COM_EASYBLOG_COMMENT_NO_TITLE'); echo JText::sprintf('COM_EASYBLOG_DASHBOARD_COMMENTS_COMMENT_TITLE', $commentLink, $commentTitle);
public static function editPost($postid, $username, $password, $content, $publish) { $mainframe = JFactory::getApplication(); global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue; EasyBlogXMLRPCHelper::loginUser($username, $password); jimport('joomla.application.component.model'); $my = JFactory::getUser($username); $acl = EasyBlogACLHelper::getRuleSet($my->id); if (empty($my->id)) { return new xmlrpcresp(0, $xmlrpcerruser + 1, JText::_('NO PERMISSION TO CREATE BLOG')); } if (empty($acl->rules->add_entry)) { return new xmlrpcresp(0, $xmlrpcerruser + 1, JText::_('NO PERMISSION TO CREATE BLOG')); } $isNew = true; // create a new blog jtable object $isDraft = false; $blog = ''; if (empty($acl->rules->publish_entry)) { // Try to load this draft to see if it exists $blog = EasyBlogHelper::getTable('Draft'); $isDraft = true; } else { $blog = EasyBlogHelper::getTable('Blog', 'Table'); } if (isset($postid) && !empty($postid)) { $isNew = false; //we are doing editing $blog->load($postid); } //prepare initial blog settings. $config = EasyBlogHelper::getConfig(); $isPrivate = $config->get('main_blogprivacy', '0'); $allowComment = $config->get('main_comment', 1); $allowSubscribe = $config->get('main_subscription', 1); $showFrontpage = $config->get('main_newblogonfrontpage', 0); $sendEmails = $config->get('main_sendemailnotifications', 1); //check if user have permission to enable privacy. $aclBlogPrivacy = $acl->rules->enable_privacy; $isPrivate = empty($aclBlogPrivacy) ? '0' : $isPrivate; $showFrontpage = empty($acl->rules->contribute_frontpage) ? '0' : $showFrontpage; /** * Map the data input into blog's recognised data format */ $post = array(); $post['permalink'] = $blog->permalink; if (isset($content["wp_slug"])) { $post['permalink'] = $content["wp_slug"]; } //check if comment is allow on this blog if (isset($content["mt_allow_comments"])) { if (!is_numeric($content["mt_allow_comments"])) { switch ($content["mt_allow_comments"]) { case "closed": $post['allowcomment'] = 0; break; case "open": $post['allowcomment'] = 1; break; default: $post['allowcomment'] = $allowComment; break; } } else { switch ((int) $content["mt_allow_comments"]) { case 0: case 2: $post['allowcomment'] = 0; break; case 1: $post['allowcomment'] = 1; break; default: $post['allowcomment'] = $allowComment; break; } } } //end if allowcomment $post['title'] = $content['title']; $post['intro'] = ''; $post['content'] = ''; if (isset($content['mt_text_more']) && $content['mt_text_more']) { $post['intro'] = $content['description']; $post['content'] = $content['mt_text_more']; } else { if (isset($content['more_text']) && $content['more_text']) { $post['intro'] = $content['description']; $post['content'] = $content['more_text']; } else { $post['content'] = $content['description']; } } // if introtext still empty and excerpt is provide, then we use it. if (empty($post['intro']) && isset($content['mt_excerpt'])) { $post['intro'] = $content['mt_excerpt']; } //set category if (isset($content['categories'])) { $categoryTitle = ''; if (is_array($content['categories'])) { //always get the 1st option. currently not supported multi categories $categoryTitle = @$content['categories'][0]; } else { $categoryTitle = $content['categories']; } if (empty($categoryTitle)) { if ($isNew) { $post['category_id'] = 1; } // by default the 1 is the uncategorised. } else { $db = EasyBlogHelper::db(); $query = 'SELECT `id` FROM `#__easyblog_category`'; $query .= ' WHERE `title` = ' . $db->Quote($categoryTitle); $db->setQuery($query); $result = $db->loadResult(); if (!empty($result)) { $post['category_id'] = $result; } else { $post['category_id'] = 1; } } } else { if ($isNew) { $post['category_id'] = 1; } } $post['published'] = $publish; $post['private'] = $isPrivate; if (isset($content["post_status"])) { switch ($content["post_status"]) { case 'publish': $post['published'] = 1; break; case 'private': $post['published'] = 1; $post['private'] = 1; break; case 'draft': $post['published'] = 0; break; case 'schedule': $post['published'] = 2; break; case 'pending': default: $post['published'] = 0; break; } } // echo '<pre>'; // var_dump($post['published']); // var_dump($post['content']); // echo '</pre>'; // exit; // Do some timestamp voodoo $tzoffset = EasyBlogDateHelper::getOffSet(); $overwriteDate = false; if (!empty($content['date_created_gmt'])) { $date = EasyBlogHelper::getDate($content['date_created_gmt']); $blog->created = $date->toFormat(); } else { if (!empty($content['dateCreated'])) { $date = EasyBlogHelper::getDate($content['dateCreated']); //$date = EasyBlogDateHelper::dateWithOffSet( $content['dateCreated'] ); $today = EasyBlogHelper::getDate(); // somehow blogsy time always return the current time 5 sec faster. if ($date->toUnix() > $today->toUnix() + 5) { $post['published'] = 2; $overwriteDate['created'] = $today->toFormat(); $overwriteDate['publish_up'] = $date->toFormat(); } else { $blog->created = $date->toFormat(); $overwriteDate['created'] = $date->toFormat(); } // echo $date->toUnix(); // echo '##'; // echo $date->toFormat(); // echo '##'; // echo $today->toFormat(); // echo '##'; // echo $today->toUnix(); // echo '##'; // echo $today->toUnix() + 5; // exit; } else { if (!$isNew) { $date = EasyBlogDateHelper::dateWithOffSet($blog->created); $blog->created = $date->toFormat(); $date = EasyBlogDateHelper::dateWithOffSet($blog->publish_up); $blog->publish_up = $date->toFormat(); } } } // we bind this attribute incase if easyblog was a old version. $post['issitewide'] = '1'; //bind the inputs $blog->bind($post, true); $blog->intro = $post['intro']; $blog->content = $post['content']; $blog->created_by = $my->id; $blog->ispending = 0; //(empty($acl->rules->publish_entry)) ? 1 : 0; $blog->published = $post['published']; if ($overwriteDate !== false) { $blog->created = $overwriteDate['created']; if (isset($overwriteDate['publish_up'])) { $blog->publish_up = $overwriteDate['publish_up']; } } $blog->subscription = $allowSubscribe; $blog->frontpage = $showFrontpage; $blog->send_notification_emails = $sendEmails; $blog->permalink = empty($post['permalink']) ? EasyBlogHelper::getPermalink($blog->title) : $post['permalink']; // add in fancy box style. $postcontent = $blog->intro . $blog->content; // cater for wlw $pattern = '#<a.*?\\><img[^>]*><\\/a>#i'; preg_match_all($pattern, $postcontent, $matches); if ($matches && count($matches[0]) > 0) { foreach ($matches[0] as $match) { $input = $match; $largeImgPath = ''; //getting large image path $pattern = '#<a[^>]*>#i'; preg_match($pattern, $input, $anchors); if ($anchors) { preg_match('/href\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i', $anchors[0], $adata); if ($adata) { $largeImgPath = $adata[1]; } } $input = $match; $pattern = '#<img[^>]*>#i'; preg_match($pattern, $input, $images); if ($images) { preg_match('/src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i', $images[0], $data); if ($data) { $largeImgPath = empty($largeImgPath) ? $data[1] : $largeImgPath; $largeImgPath = urldecode($largeImgPath); $largeImgPath = str_replace(' ', '-', $largeImgPath); $encodedurl = urldecode($data[1]); $encodedurl = str_replace(' ', '-', $encodedurl); $images[0] = str_replace($data[1], $encodedurl, $images[0]); $blog->intro = str_replace($input, '<a class="easyblog-thumb-preview" href="' . $largeImgPath . '">' . $images[0] . '</a>', $blog->intro); $blog->content = str_replace($input, '<a class="easyblog-thumb-preview" href="' . $largeImgPath . '">' . $images[0] . '</a>', $blog->content); } } } } else { $pattern = '#<img[^>]*>#i'; preg_match_all($pattern, $postcontent, $matches); if ($matches && count($matches[0]) > 0) { foreach ($matches[0] as $match) { $input = $match; preg_match('/src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i', $input, $data); if ($data) { $oriImage = $data[1]; $data[1] = urldecode($data[1]); $data[1] = str_replace(' ', '-', $data[1]); $encodedurl = urldecode($oriImage); $encodedurl = str_replace(' ', '-', $encodedurl); $imageurl = str_replace($oriImage, $encodedurl, $input); $blog->intro = str_replace($input, '<a class="easyblog-thumb-preview" href="' . $data[1] . '">' . $imageurl . '</a>', $blog->intro); $blog->content = str_replace($input, '<a class="easyblog-thumb-preview" href="' . $data[1] . '">' . $imageurl . '</a>', $blog->content); } } } } if ($isDraft) { $blog->pending_approval = true; // we need to process trackbacks and tags here. //adding trackback. if (!empty($acl->rules->add_trackback)) { $trackback = isset($content['mt_tb_ping_urls']) ? $content['mt_tb_ping_urls'] : ''; if (!empty($trackback) && count($trackback) > 0) { $trackback = implode("\n", $trackback); $blog->trackbacks = $trackback; } } // add new tag $tags = isset($content['mt_keywords']) ? $content['mt_keywords'] : ''; $blog->tags = $tags; } if (!$blog->store()) { $msg = $blog->getError(); $msg = empty($msg) ? 'Post store failed' : $msg; return new xmlrpcresp(0, $xmlrpcerruser + 1, $msg); } if ($isDraft && !empty($blog->id)) { // if this post is under moderation, we will stop here. return new xmlrpcresp(new xmlrpcval($blog->id, $xmlrpcString)); } /** * JomSocial userpoint. */ if ($isNew && $blog->published == '1' && $my->id != 0) { // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('blog.create', $my->id); if ($config->get('main_jomsocial_userpoint')) { $jsUserPoint = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($jsUserPoint)) { require_once $jsUserPoint; CUserPoints::assignPoint('com_easyblog.blog.add', $my->id); } } // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.blog', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_BLOG', $blog->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.blog', $my->id); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.blog', $my->id); // Assign badge for users that report blog post. // Only give points if the viewer is viewing another person's blog post. EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.create', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_CREATE_BLOG_POST')); // @rule: Mighty Touch karma points EasyBlogHelper::getHelper('MightyTouch')->setKarma($my->id, 'new_blog'); } //add jomsocial activities if ($blog->published == '1' && $config->get('main_jomsocial_activity')) { EasyBlogXMLRPCHelper::addJomsocialActivities($blog, $isNew); } // AlphaUserPoints // since 1.2 if (EasyBlogHelper::isAUPEnabled()) { // get blog post URL $url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id); AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_blog', '', 'easyblog_add_blog_' . $blog->id, JText::sprintf('AUP NEW BLOG CREATED', $url, $blog->title)); } //adding trackback. if (!empty($acl->rules->add_trackback)) { $trackback = isset($content['mt_tb_ping_urls']) ? $content['mt_tb_ping_urls'] : ''; EasyBlogXMLRPCHelper::addTrackback($trackback, $blog, $my); } // add new tag $date = EasyBlogHelper::getDate(); $tags = isset($content['mt_keywords']) ? $content['mt_keywords'] : ''; $postTagModel = EasyBlogHelper::getModel('PostTag'); if ($blog->id != '0') { //Delete existing associated tags. $postTagModel->deletePostTag($blog->id); } if (!empty($tags)) { $arrTags = explode(',', $tags); $tagModel = EasyBlogHelper::getModel('Tags'); foreach ($arrTags as $tag) { if (!empty($tag)) { $table = EasyBlogHelper::getTable('Tag', 'Table'); //@task: Only add tags if it doesn't exist. if (!$table->exists($tag)) { if ($acl->rules->create_tag) { $tagInfo['created_by'] = $my->id; $tagInfo['title'] = JString::trim($tag); $tagInfo['created'] = $date->toMySQL(); $table->bind($tagInfo); $table->published = 1; $table->status = ''; $table->store(); } } else { $table->load($tag, true); } //@task: Store in the post tag $postTagModel->add($table->id, $blog->id, $date->toMySQL()); } } } if ($blog->published) { $allowed = array(EBLOG_OAUTH_LINKEDIN, EBLOG_OAUTH_FACEBOOK, EBLOG_OAUTH_TWITTER); $blog->autopost($allowed, $allowed); } return new xmlrpcresp(new xmlrpcval($blog->id, $xmlrpcString)); }
private function sendNotificationsJomsocial($blog, $isNew, $key, $source, $author) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); // @rule: Send email notifications out to subscribers. $author = EB::user($blog->created_by); $data['blogTitle'] = $blog->title; $data['blogAuthor'] = $author->getName(); $data['blogAuthorAvatar'] = $author->getAvatar(); $data['blogAuthorLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id, false, true); $data['blogAuthorEmail'] = $author->user->email; $data['blogIntro'] = $blog->intro; $data['blogContent'] = $blog->content; $data['blogLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); $date = EasyBlogDateHelper::dateWithOffSet($blog->created); $data['blogDate'] = EasyBlogDateHelper::toFormat($date, JText::_('DATE_FORMAT_LC1')); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EasyBlogRouter::isSh404Enabled(); if (JFactory::getApplication()->isAdmin() && $sh404exists) { $data['blogLink'] = JURI::root() . 'index.php?option=com_easyblog&view=entry&id=' . $blog->id; $data['blogAuthorLink'] = JURI::root() . 'index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id; } // Get group members emails if (!class_exists('CommunityModelGroups')) { jimport('joomla.application.component.model'); JLoader::import('groups', JPATH_ROOT . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'models'); } $model = JModelLegacy::getInstance('Groups', 'CommunityModel'); if (is_array($key)) { $key = $key[0]; } if (!method_exists($model, 'getAllMember')) { // Snippet taken from getAllMember $db = EasyBlogHelper::db(); $query = 'SELECT a.' . $db->nameQuote('memberid') . ' AS id, a.' . $db->nameQuote('approved') . ' , b.' . $db->nameQuote('name') . ' as name , a.' . $db->nameQuote('permissions') . ' as permission FROM ' . $db->nameQuote('#__community_groups_members') . ' AS a ' . ' INNER JOIN ' . $db->nameQuote('#__users') . ' AS b ' . ' WHERE b.' . $db->nameQuote('id') . '=a.' . $db->nameQuote('memberid') . ' AND a.' . $db->nameQuote('groupid') . '=' . $db->Quote($key) . ' AND b.' . $db->nameQuote('block') . '=' . $db->Quote('0') . ' ' . ' AND a.' . $db->nameQuote('permissions') . ' !=' . $db->quote(-1); $db->setQuery($query); $members = $db->loadObjectList(); } else { $members = $model->getAllMember($key); } $emails = array(); $jsCoreFile = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; foreach ($members as $member) { $user = CFactory::getUser($member->id); $userParam = $user->getParams(); $enabled = $userParam->get('etype_groups_sendmail', 0); if (!$enabled) { continue; } if ($author->user->email != $user->email) { $obj = new stdClass(); $obj->email = $user->email; $emails[] = $obj; } } $config = EasyBlogHelper::getConfig(); $notification = EasyBlogHelper::getHelper('Notification'); $emailBlogTitle = JString::substr($blog->title, 0, $config->get('main_mailtitle_length')); $emailTitle = JText::sprintf('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_ADDED_WITH_TITLE', $emailBlogTitle) . ' ...'; $notification->send($emails, $emailTitle, 'email.blog.new', $data); }