public function store($log = true) { // @rule: Load language file from the front end. JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); $under_approval = false; if (isset($this->under_approval)) { $under_approval = true; // now we need to reset this variable from the blog object. unset($this->under_approval); } // @trigger: onBeforeSave $this->triggerBeforeSave(); // @rule: Determine if this record is new or not. if (empty($this->isnew)) { $isNew = empty($this->id) ? true : false; } else { $isNew = true; } // @rule: Get the rulesets for this user. $acl = EasyBlogACLHelper::getRuleSet(); // @rule: Process badword filters for title here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->title); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_TITLE_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Check for minimum words in the content if required. if ($config->get('main_post_min')) { $minimum = $config->get('main_post_length'); $total = JString::strlen(strip_tags($this->intro . $this->content)); if ($total < $minimum) { $this->setError(JText::sprintf('COM_EASYBLOG_CONTENT_LESS_THAN_MIN_LENGTH', $minimum)); return false; } } // @rule: Check for invalid title if (empty($this->title) || $this->title == JText::_('COM_EASYBLOG_DASHBOARD_WRITE_DEFAULT_TITLE')) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_TITLE_ERROR')); return false; } // @rule: For edited blogs, ensure that they have permissions to edit it. if (!$isNew && $this->created_by != JFactory::getUser()->id && !EasyBlogHelper::isSiteAdmin() && empty($acl->rules->moderate_entry)) { if (!class_exists('EasyBlogModelTeamBlogs')) { jimport('joomla.application.component.model'); JLoader::import('blog', EBLOG_ROOT . DIRECTORY_SEPARATOR . 'models'); } // @task: Only throw error when this blog post is not a team blog post and it's not owned by the current logged in user. JModel::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'models'); $model = JModel::getInstance('TeamBlogs', 'EasyBlogModel'); $contribution = $model->getBlogContributed($this->id); if (!$contribution || !$model->checkIsTeamAdmin(JFactory::getUser()->id, $contribution->team_id)) { $this->setError(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_BLOG')); return false; } } // @rule: Every blog post must be assigned to a category if (empty($this->category_id)) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_CATEGORY_ERROR')); return false; } // Filter / strip contents that are not allowed $filterTags = EasyBlogHelper::getHelper('Acl')->getFilterTags(); $filterAttributes = EasyBlogHelper::getHelper('Acl')->getFilterAttributes(); // @rule: Apply filtering on contents jimport('joomla.filter.filterinput'); $inputFilter = JFilterInput::getInstance($filterTags, $filterAttributes, 1, 1, 0); $inputFilter->tagBlacklist = $filterTags; $inputFilter->attrBlacklist = $filterAttributes; if (count($filterTags) > 0 && !empty($filterTags[0]) || count($filterAttributes) > 0 && !empty($filterAttributes[0])) { $this->intro = $inputFilter->clean($this->intro); $this->content = $inputFilter->clean($this->content); } // @rule: Process badword filters for content here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->intro . $this->content); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_POST_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Test for the empty-ness if (empty($this->intro) && empty($this->content)) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_CONTENT_ERROR')); } // alway set this to false no matter what! TODO: remove this column. $this->ispending = '0'; $state = parent::store(); $source = JRequest::getVar('blog_contribute_source', 'easyblog'); // @trigger: onBeforeSave $this->triggerAfterSave(); // if this is blog edit, then we should see the column isnew to determine // whether the post is really new or not. if (!$isNew) { $isNew = $this->isnew; } // @task: If auto featured is enabled, we need to feature the blog post automatically since the blogger is featured. if ($config->get('main_autofeatured', 0) && EasyBlogHelper::isFeatured('blogger', $this->created_by) && !EasyBlogHelper::isFeatured('post', $this->id)) { EasyBlogHelper::makeFeatured('post', $this->id); } // @task: This is when the blog is either created or updated. if ($source == 'easyblog' && $state && $this->published == POST_ID_PUBLISHED && $log) { // @rule: Add new stream item in jomsocial EasyBlogHelper::addJomSocialActivityBlog($this, $isNew); // @rule: Log new stream item into EasyBlog $activity = new stdClass(); $activity->actor_id = $this->created_by; $activity->target_id = '0'; $activity->context_type = 'post'; $activity->context_id = $this->id; $activity->verb = $isNew ? 'add' : 'update'; $activity->uuid = $this->title; EasyBlogHelper::activityLog($activity); } if ($source == 'easyblog' && $state && $this->published == POST_ID_PUBLISHED && $isNew && $log) { // @rule: Send email notifications out to subscribers. $author = EasyBlogHelper::getTable('Profile'); $author->load($this->created_by); // @rule: Ping pingomatic if ($config->get('main_pingomatic')) { if (!EasyBlogHelper::getHelper('Pingomatic')->ping($this->title, EasyBlogHelper::getExternalLink('index.php?option=com_easyblog&view=entry&id=' . $this->id, true))) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_PINGOMATIC_ERROR'), 'error'); } } // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('blog.create', $this->created_by); // @rule: Add userpoints for jomsocial if ($config->get('main_jomsocial_userpoint')) { $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($path)) { require_once $path; CUserPoints::assignPoint('com_easyblog.blog.add', $this->created_by); } } $link = $this->getExternalBlogLink('index.php?option=com_easyblog&view=entry&id=' . $this->id); // @rule: Add notifications for jomsocial 2.6 if ($config->get('integrations_jomsocial_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('JomSocial')->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_BLOG', $author->getName(), $link, $this->title), 'easyblog_new_blog', $target, $this->created_by, $link); } // @rule: Mighty Touch karma points EasyBlogHelper::getHelper('MightyTouch')->setKarma($this->created_by, 'new_blog'); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.blog', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_BLOG', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.blog', $this->created_by); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.blog', $this->created_by); // 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')); if ($config->get('integrations_easydiscuss_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('EasyDiscuss')->addNotification($this, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_BLOG', $author->getName(), $this->title), EBLOG_NOTIFICATIONS_TYPE_BLOG, $target, $this->created_by, $link); } $my = JFactory::getUser(); // @rule: Add points for AlphaUserPoints if ($my->id == $this->created_by && EasyBlogHelper::isAUPEnabled()) { // get blog post URL $url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $this->id); $aupid = AlphaUserPointsHelper::getAnyUserReferreID($this->created_by); AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_blog', $aupid, 'easyblog_add_blog_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_NEW_BLOG_CREATED', $url, $this->title)); } // @rule: Process trackbacks $this->processTrackbacks(); // Update the isnew column so that if user edits this entry again, it doesn't send any notifications the second time. $this->isnew = 0; $this->store(false); } return $state; }
public function store($updateNulls = false) { if (!$this->created) { $this->created = EB::date()->toMySQL(); } return parent::store($updateNulls); }
/** * Saves a new rating item * * @since 5.0 * @access public * @param string * @return */ public function store($updateNulls = false) { $config = EB::config(); $state = parent::store(); if ($this->type == 'entry' && $this->created_by) { // Load the post item $post = EB::post($this->uid); // Get the author of the post $author = $post->getAuthor(); // Get the link to the post $link = $post->getExternalPermalink(); // Notify EasySocial users that someone rated their post EB::easysocial()->notifySubscribers($post, 'ratings.add'); // Assign EasySocial points EB::easysocial()->assignPoints('blog.rate'); EB::easysocial()->assignPoints('blog.rated', $post->created_by); // Assign badge for users that report blog post. // Only give points if the viewer is viewing another person's blog post. EB::easysocial()->assignBadge('blog.rate', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_RATED_BLOG')); // Assign points for AUP EB::aup()->assign('plgaup_easyblog_rate_blog', '', 'easyblog_rating', JText::_('COM_EASYBLOG_AUP_BLOG_RATED')); // Add notifications for EasyDiscuss // Add notifications // EB::jomsocial()->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_RATING_FOR_YOUR_BLOG', str_replace("administrator/","", $author->getProfileLink()), $author->getName() , $link , $blog->title), 'easyblog_new_blog' , $target , $author , $link); // Add notifications for easydiscuss if ($config->get('integrations_jomsocial_notification_rating')) { $target = array($post->created_by); EB::easydiscuss()->addNotification($post, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_RATING_FOR_YOUR_BLOG', $author->getName(), $post->title), EBLOG_NOTIFICATIONS_TYPE_RATING, array($post->created_by), $this->created_by, $link); } } return $state; }
public function store() { $isNew = empty($this->id) ? true : false; $state = parent::store(); if ($state && $isNew) { $blog = EasyBlogHelper::getTable('Blog'); $blog->load($this->post_id); $profile = EasyBlogHelper::getTable('Profile'); $profile->load($blog->created_by); $obj = new stdClass(); $obj->blogtitle = $blog->title; $obj->blogauthor = $profile->getName(); $obj->subscribername = $this->fullname; $obj->subscriberemail = $this->email; $activity = new stdClass(); $activity->actor_id = empty($this->user_id) ? '0' : $this->user_id; $activity->target_id = $blog->created_by; $activity->context_type = 'post'; $activity->context_id = $this->post_id; $activity->verb = 'subscribe'; $activity->source_id = $this->id; $activity->uuid = serialize($obj); EasyBlogHelper::activityLog($activity); } return $state; }
public function store() { // @task: Load language file from the front end. JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $this->clear($this->draft_id); // @rule: Send notification to the author of the post. $draft = EasyBlogHelper::getTable('Draft'); $draft->load($this->draft_id); $author = EasyBlogHelper::getTable('Profile'); $author->load($draft->created_by); $data['blogTitle'] = $draft->title; $data['blogAuthor'] = $author->getName(); $data['blogAuthorAvatar'] = $author->getAvatar(); $data['blogEditLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=dashboard&layout=write&draft_id=' . $draft->id, false, true); $data['blogAuthorEmail'] = $author->user->email; $data['rejectMessage'] = $this->message; // 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['blogEditLink'] = JURI::root() . 'index.php?option=com_easyblog&view=dashboard&layout=write&draft_id=' . $draft->id; } $emailTitle = JText::_('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_REJECTED'); $obj = new StdClass(); $obj->unsubscribe = false; $obj->email = $author->user->email; $emails = array($obj); $notification = EasyBlogHelper::getHelper('Notification'); $notification->send($emails, $emailTitle, 'email.blog.rejected', $data); return parent::store(); }
public function store($updateNulls = false) { if (empty($this->key)) { $this->key = $this->generate(); } return parent::store($updateNulls); }
public function store($updateNulls = false) { if (!$this->created) { $this->created = EasyBlogHelper::getDate()->toMySQL(); } return parent::store($updateNulls); }
/** * Override the parents store method so we can send confirmation email * * @since 5.0 * @access public * @param string * @return */ public function store($updateNulls = false) { $isNew = !$this->id ? true : false; // Ensure that the `created` column is valid if (!$this->created) { $this->created = JFactory::getDate()->toSql(); } // Let the parent save the object first. $state = parent::store($updateNulls); $config = EB::config(); // Send confirmation email to subscribers if ($isNew && $config->get('main_subscription_confirmation')) { $subscription = EB::subscription(); $template = $subscription->getTemplate(); $template->uid = $this->uid; $template->utype = $this->utype; $template->user_id = $this->user_id; $template->uemail = $this->email; $template->ufullname = $this->fullname; $template->ucreated = $this->created; $target = $this->getObject(); $template->targetname = $target->title; $template->targetlink = $target->objPermalink; $subscription->addMailQueue($template); } // Notify site admins when there is a new subscriber if ($isNew && $config->get('main_subscription_admin_notification')) { $this->notifyAdmin(); } return $state; }
/** * Override the implementation of store * * @since 5.0 * @access public * @param string * @return */ public function store($updateNulls = false) { // Check if creation date have been set if (!$this->created) { $this->created = EB::date()->toSql(); } return parent::store($updateNulls); }
/** * Override the parent's store behavior * * @since 5.0 * @access public * @param string * @return */ public function store($updateNulls = false) { // @task: Load language file from the front end. JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); // Clear any previous messages $model = EB::model('PostReject'); $model->clear($this->post_id); return parent::store(); }
/** * Override the parents implementation of storing a profile * * @since 4.0 * @access public * @param string * @return */ public function store($updateNulls = false) { $isNew = empty($this->id) ? true : false; $state = parent::store($updateNulls); $my = JFactory::getUser(); // If the user is updating their own profile if ($my->id == $this->id) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); // @rule: Integrations with EasyDiscuss EB::easydiscuss()->log('easyblog.update.profile', $this->id, JText::_('COM_EASYBLOG_EASYDISCUSS_HISTORY_UPDATE_PROFILE')); EB::easydiscuss()->addPoint('easyblog.update.profile', $this->id); EB::easydiscuss()->addBadge('easyblog.update.profile', $this->id); } return $state; }
public function store($updateNulls = false) { $config = EasyBlogHelper::getConfig(); $maxTimes = $config->get('main_reporting_maxip'); // @task: Run some checks on reported items and if ($maxTimes > 0) { $db = EasyBlogHelper::db(); $query = 'SELECT COUNT(1) FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote($this->_tbl) . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('obj_id') . ' = ' . $db->Quote($this->obj_id) . ' ' . 'AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('obj_type') . ' = ' . $db->Quote($this->obj_type) . ' ' . 'AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('ip') . ' = ' . $db->Quote($this->ip); $db->setQuery($query); $total = (int) $db->loadResult(); if ($total >= $maxTimes) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $this->setError(JText::_('COM_EASYBLOG_REPORT_ALREADY_REPORTED')); return false; } } // 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.report', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_REPORT_BLOG')); return parent::store(); }
public function store($updateNulls = false) { $isNew = empty($this->id) ? true : false; $state = parent::store($updateNulls); $my = JFactory::getUser(); if ($my->id == $this->id) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.update.profile', $this->id, JText::_('COM_EASYBLOG_EASYDISCUSS_HISTORY_UPDATE_PROFILE')); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.update.profile', $this->id); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.update.profile', $this->id); } if (!$isNew) { $activity = new stdClass(); $activity->actor_id = $my->id; $activity->target_id = $my->id == $this->id ? '0' : $this->id; $activity->context_type = 'profile'; $activity->context_id = $this->id; $activity->verb = 'update'; EasyBlogHelper::activityLog($activity); } return $state; }
/** * Override parent's implementation of store * * @since 4.0 * @access public * @param string * @return */ public function store($updateNulls = false) { if (!$this->created) { $this->created = EB::date()->toSql(); } // Generate an alias if alias is empty if (!$this->alias) { $this->alias = EBR::normalizePermalink($this->title); } $my = JFactory::getUser(); // Add point integrations for new categories if ($this->id == 0 && $my->id > 0) { EB::loadLanguages(); // Integrations with EasyDiscuss EB::easydiscuss()->log('easyblog.new.category', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_CATEGORY', $this->title)); EB::easydiscuss()->addPoint('easyblog.new.category', $my->id); EB::easydiscuss()->addBadge('easyblog.new.category', $my->id); // AlphaUserPoints EB::aup()->assign('plgaup_easyblog_add_category', '', 'easyblog_add_category_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_NEW_CATEGORY_CREATED', $this->title)); // JomSocial integrations EB::jomsocial()->assignPoints('com_easyblog.category.add', $my->id); // Assign EasySocial points EB::easysocial()->assignPoints('category.create', $my->id); } // Figure out the proper nested set model if ($this->id == 0 && $this->lft == 0) { // No parent id, we use the current lft,rgt if ($this->parent_id) { $left = $this->getLeft($this->parent_id); $this->lft = $left; $this->rgt = $this->lft + 1; // Update parent's right $this->updateRight($left); $this->updateLeft($left); } else { $this->lft = $this->getLeft() + 1; $this->rgt = $this->lft + 1; } } if ($this->id == 0) { // new cats. we need to store the ordering. $this->ordering = $this->getOrdering($this->parent_id) + 1; } $isNew = !$this->id ? true : false; $state = parent::store(); return $state; }
/** * override save method * * @since 5.0 * @access public * @param string * @return */ public function store($updateNulls = false) { $state = false; // if created_by is empty, we do not want to save this record. if ($this->created_by) { $state = parent::store($updateNulls); } return $state; }
/** * Override parent's store behavior * * @since 4.0 * @access public * @param bool Determines if this is moderated * @return */ public function store($isModerated = false) { // Determines if this is a new comment $isNew = !$this->id ? true : false; // @rule: Update the ordering as long as this is a new comment. Regardless of the publishing status if ($isNew) { $this->updateOrdering(); } // @rule: If this was moderated and it is published, we should notify the other extensions. if ($isModerated && $this->published) { $isNew = true; } // @rule: Store after the ordering is updated $state = parent::store(); // @rule: Run point integrations here. if ($isNew && $this->published == 1 && $state) { // Get the current logged in user $my = JFactory::getUser(); // Get the blog object $blog = $this->getBlog(); // Load site's language file EB::loadLanguages(); // Get config $config = EB::config(); $author = $this->getAuthor(); // Get the external link of the blog post $link = $blog->getExternalBlogLink('index.php?option=com_easyblog&view=entry&id=' . $blog->id) . '#comment-' . $this->id; // @rule: Send notifications to the author of the blog for EasyDiscuss if ($blog->created_by != $this->created_by && $this->created_by != 0) { EB::easydiscuss()->addNotification($blog, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_COMMENT_IN_YOUR_BLOG', $blog->title), EBLOG_NOTIFICATIONS_TYPE_COMMENT, array($blog->created_by), $this->created_by, $link); // Add notifications for EasySocial EB::easysocial()->notifySubscribers($blog, 'new.comment', $this); } // Notify subscribers through notification system. if ($this->created_by != 0) { $targets = $this->getSubscribers($blog, array($this->created_by, $blog->created_by)); if (!empty($targets) && $config->get('integrations_easydiscuss_notification_comment_follower')) { EB::easydiscuss()->addNotification($blog, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_COMMENT_POSTED', $blog->title), EBLOG_NOTIFICATIONS_TYPE_COMMENT, $targets, $this->created_by, $link); } // Integrations with EasyDiscuss EB::easydiscuss()->log('easyblog.new.comment', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_COMMENT', $blog->title)); EB::easydiscuss()->addPoint('easyblog.new.comment', $this->created_by); EB::easydiscuss()->addBadge('easyblog.new.comment', $this->created_by); // Integrations with EasySocial EB::easysocial()->assignPoints('comment.create', $this->created_by); EB::easysocial()->assignPoints('comment.create.author', $blog->created_by); EB::easysocial()->assignBadge('comment.create', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_CREATE_COMMENT')); // Alpha user points $url = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $this->post_id); EB::aup()->assignPoints('plgaup_easyblog_add_comment', $this->created_by, JText::sprintf('COM_EASYBLOG_AUP_NEW_COMMENT_SUBMITTED', $url, $blog->title)); // @rule: Add comment for blog author if ($blog->created_by != $this->created_by) { EB::aup()->assignPoints('plgaup_easyblog_add_comment_blogger', $blog->created_by, JText::sprintf('COM_EASYBLOG_AUP_NEW_COMMENT_SUBMITTED', $url, $blog->title)); } } // Determine whether or not to push this as a normal activity $external = $blog->getBlogContribution(); // @rule: Add activity integrations for group integrations. if ($external && $external->type != EASYBLOG_POST_SOURCE_TEAM) { if ($external->type == EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP) { EB::groups()->addCommentStream($blog, $this, $external); } else { if ($external->type == EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT) { EB::event()->addCommentStream($blog, $this, $external); } } } else { // Add jomsocial stream EB::jomsocial()->insetCommentActivity($this, $blog); // Add EasySocial stream EB::easysocial()->createCommentStream($this, $blog); // Assign EasySocial points EB::easysocial()->assignPoints('comments.create'); // Give points to the comment author EB::jomsocial()->assignPoints('com_easyblog.comments.add'); // @rule: Give points to the blog author if ($my->id != $blog->created_by && $this->created_by != 0) { // Assign EasySocial points EB::easysocial()->assignPoints('comments.create.author', $blog->created_by); // Assign Jomsocial points EB::jomsocial()->assignPoints('com_easyblog.comments.addblogger', $blog->created_by); } } } return $state; }
public function store($updateNulls = false) { $config = EasyBlogHelper::getConfig(); $state = parent::store(); if ($this->type == 'entry' && $this->created_by) { $blog = EasyBlogHelper::getTable('Blog'); $blog->load($this->uid); $author = EasyBlogHelper::getTable('Profile'); $author->load($this->created_by); // Get list of users who subscribed to this blog. $link = $blog->getExternalBlogLink('index.php?option=com_easyblog&view=entry&id=' . $blog->id); $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_notifications_ratings') && $easysocial->exists()) { $easysocial->notifySubscribers($blog, 'ratings.add'); } // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('blog.rate'); $easysocial->assignPoints('blog.rated', $blog->created_by); // @rule: Add notifications for jomsocial 2.6 if ($config->get('integrations_jomsocial_notification_rating')) { $target = array($blog->created_by); EasyBlogHelper::getHelper('JomSocial')->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_RATING_FOR_YOUR_BLOG', str_replace("administrator/", "", $author->getProfileLink()), $author->getName(), $link, $blog->title), 'easyblog_new_blog', $target, $author, $link); } // @rule: Add notifications for easydiscuss if ($config->get('integrations_jomsocial_notification_rating')) { $target = array($blog->created_by); EasyBlogHelper::getHelper('EasyDiscuss')->addNotification($blog, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_RATING_FOR_YOUR_BLOG', $author->getName(), $blog->title), EBLOG_NOTIFICATIONS_TYPE_RATING, array($blog->created_by), $this->created_by, $link); } } return $state; }
/** * Saves the revision data * * @since 5.0 * @access public * @param string * @return */ public function store($pks = null) { // Normalize data $this->normalize(); // Update modification time $this->modified = EB::date()->toSql(); $state = parent::store(); return $state; }
/** * Stores the blog post * * @since 5.0 * @access public * @param string * @return */ public function store($log = true) { // Load language file from the front end. EB::loadLanguages(); // Whenever the blog post is stored, we need to clear the cache. $cache = EB::getCache(); $cache->clean('com_easyblog'); $cache->clean('_system'); $cache->clean('page'); // Get easyblog's config $config = EB::config(); // Get the current logged in user. $my = JFactory::getUser(); // @rule: no guest allowed to create blog post. if (JRequest::getVar('task', '') != 'cron' && JRequest::getVar('task', '') != 'cronfeed' && empty($my->id)) { $this->setError(JText::_('COM_EASYBLOG_YOU_ARE_NOT_LOGIN')); return false; } $under_approval = false; if (isset($this->under_approval)) { $under_approval = true; // now we need to reset this variable from the blog object. unset($this->under_approval); } // @trigger: onBeforeSave $this->triggerBeforeSave(); // @rule: Determine if this record is new or not. if (empty($this->isnew)) { $isNew = empty($this->id) ? true : false; } else { $isNew = true; } // @rule: Get the rulesets for this user. $acl = EB::acl(); // @rule: Process badword filters for title here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->title); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_TITLE_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Check for minimum words in the content if required. if ($config->get('main_post_min') && $this->_checkLength) { $minimum = $config->get('main_post_length'); $total = JString::strlen(strip_tags($this->intro . $this->content)); if ($total < $minimum) { $this->setError(JText::sprintf('COM_EASYBLOG_CONTENT_LESS_THAN_MIN_LENGTH', $minimum)); return false; } } // @rule: Check for invalid title if (empty($this->title) || $this->title == JText::_('COM_EASYBLOG_DASHBOARD_WRITE_DEFAULT_TITLE')) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_TITLE_ERROR')); return false; } // @rule: For edited blogs, ensure that they have permissions to edit it. if (!$isNew && $this->created_by != JFactory::getUser()->id && !EasyBlogHelper::isSiteAdmin() && !$acl->get('moderate_entry')) { // @task: Only throw error when this blog post is not a team blog post and it's not owned by the current logged in user. $model = EB::model('TeamBlogs'); $contribution = $model->getBlogContributed($this->id); if (!$contribution || !$model->checkIsTeamAdmin(JFactory::getUser()->id, $contribution->team_id)) { $this->setError(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_BLOG')); return false; } } // Filter / strip contents that are not allowed $filterTags = EasyBlogHelper::getHelper('Acl')->getFilterTags(); $filterAttributes = EasyBlogHelper::getHelper('Acl')->getFilterAttributes(); // @rule: Apply filtering on contents jimport('joomla.filter.filterinput'); $inputFilter = JFilterInput::getInstance($filterTags, $filterAttributes, 1, 1, 0); $inputFilter->tagBlacklist = $filterTags; $inputFilter->attrBlacklist = $filterAttributes; $filterTpe = EasyBlogHelper::getJoomlaVersion() >= '1.6' ? 'html' : 'string'; if (count($filterTags) > 0 && !empty($filterTags[0]) || count($filterAttributes) > 0 && !empty($filterAttributes[0])) { $this->intro = $inputFilter->clean($this->intro, $filterTpe); $this->content = $inputFilter->clean($this->content, $filterTpe); } // @rule: Process badword filters for content here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->intro . $this->content); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_POST_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Test for the empty-ness if (empty($this->intro) && empty($this->content)) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_CONTENT_ERROR')); } $state = parent::store(); $source = JRequest::getVar('blog_contribute_source', 'easyblog'); // if this is blog edit, then we should see the column isnew to determine // whether the post is really new or not. if (!$isNew) { $isNew = $this->isnew; } // this one is needed for the trigger to work properly. $this->isnew = $isNew; // @trigger: onAfterSave $this->triggerAfterSave(); // @task: If auto featured is enabled, we need to feature the blog post automatically since the blogger is featured. if ($config->get('main_autofeatured', 0) && EB::isFeatured('blogger', $this->created_by) && !EB::isFeatured('post', $this->id)) { // just call the model file will do as we do not want to create stream on featured action at this migration. $modelF = EB::model('Featured'); $modelF->makeFeatured('post', $this->id); } // @task: This is when the blog is either created or updated. if ($source == 'easyblog' && $state && $this->published == EASYBLOG_POST_PUBLISHED && $log) { $category = EB::table('Category'); $category->load($this->category_id); $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($category->private == 0) { // @rule: Add new stream item in jomsocial EB::jomsocial()->addBlogActivity($this, $isNew); } // @rule: Add stream for easysocial if ($config->get('integrations_easysocial_stream_newpost') && $easysocial->exists() && $isNew) { $easysocial->createBlogStream($this, $isNew); } // update privacy in easysocial. if ($config->get('integrations_easysocial_privacy') && $easysocial->exists()) { $easysocial->updateBlogPrivacy($this); } } if ($source == 'easyblog' && $state && $this->published == EASYBLOG_POST_PUBLISHED && $isNew && $log) { // @rule: Send email notifications out to subscribers. $author = EB::user($this->created_by); // Ping pingomatic EB::pingomatic()->ping($this); // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($easysocial->exists()) { $easysocial->assignPoints('blog.create', $this->created_by); } // @rule: Add userpoints for jomsocial if ($config->get('main_jomsocial_userpoint')) { $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($path)) { require_once $path; CUserPoints::assignPoint('com_easyblog.blog.add', $this->created_by); } } $link = $this->getExternalBlogLink('index.php?option=com_easyblog&view=entry&id=' . $this->id); // @rule: Add notifications for jomsocial 2.6 if ($config->get('integrations_jomsocial_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('JomSocial')->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_BLOG', str_replace("administrator/", "", $author->getProfileLink()), $author->getName(), $link, $this->title), 'easyblog_new_blog', $target, $author, $link); } // Get list of users who subscribed to this blog. // @rule: Add notifications for easysocial if ($config->get('integrations_easysocial_notifications_newpost') && $easysocial->exists()) { $easysocial->notifySubscribers($this, 'new.post'); } // @rule: Add indexer for easysocial if ($config->get('integrations_easysocial_indexer_newpost') && $easysocial->exists()) { $easysocial->addIndexerNewBlog($this); } // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.blog', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_BLOG', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.blog', $this->created_by); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.blog', $this->created_by); // 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')); if ($config->get('integrations_easydiscuss_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('EasyDiscuss')->addNotification($this, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_BLOG', $author->getName(), $this->title), EBLOG_NOTIFICATIONS_TYPE_BLOG, $target, $this->created_by, $link); } // AUP EB::aup()->assignPoints('plgaup_easyblog_add_blog', $this->created_by, JText::sprintf('COM_EASYBLOG_AUP_NEW_BLOG_CREATED', $this->getPermalink(), $this->title)); // Update the isnew column so that if user edits this entry again, it doesn't send any notifications the second time. $this->isnew = $this->published && $this->isnew ? 0 : 1; $this->store(false); } return $state; }
public function store($isModerated = false) { $isNew = empty($this->id) ? true : false; // @rule: Update the ordering as long as this is a new comment. Regardless of the publishing status if ($isNew) { $this->updateOrdering(); } // @rule: If this was moderated and it is published, we should notify the other extensions. if ($isModerated && $this->published) { $isNew = true; } // @rule: Store after the ordering is updated $state = parent::store(); // @rule: Run point integrations here. if ($isNew && $this->published == 1 && $state) { $my = JFactory::getUser(); $blog = EasyBlogHelper::getTable('Blog'); $blog->load($this->post_id); JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); $author = EasyBlogHelper::getTable('Profile'); $author->load($this->created_by); // @task: Blog external link. $link = $blog->getExternalBlogLink('index.php?option=com_easyblog&view=entry&id=' . $blog->id) . '#comment-' . $this->id; // @rule: Send notifications to the author of the blog for EasyDiscuss if ($blog->created_by != $this->created_by && $this->created_by != 0) { if ($config->get('integrations_easydiscuss_notification_comment')) { EasyBlogHelper::getHelper('EasyDiscuss')->addNotification($blog, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_COMMENT_IN_YOUR_BLOG', $blog->title), EBLOG_NOTIFICATIONS_TYPE_COMMENT, array($blog->created_by), $this->created_by, $link); } // @rule: Add notifications for jomsocial 2.6 if ($config->get('integrations_jomsocial_notification_comment')) { // Get list of users who subscribed to this blog. EasyBlogHelper::getHelper('JomSocial')->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_COMMENT_IN_YOUR_BLOG', $link, $blog->title), 'easyblog_comment_blog', array($blog->created_by), $author, $link); } $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_notifications_newcomment') && $easysocial->exists()) { $easysocial->notifySubscribers($blog, 'new.comment', $this); } } // @rule: Notify subscribers through notification system. if ($config->get('integrations_jomsocial_notification_comment_follower') && $this->created_by != 0) { $target = $this->getSubscribers($blog, array($this->created_by, $blog->created_by)); if (!empty($target)) { // Get list of users who subscribed to this blog. EasyBlogHelper::getHelper('JomSocial')->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_COMMENT_POSTED', $link, $blog->title), 'easyblog_comment_blog_sub', $target, $author, $link); } } // @rule: Notify subscribers through notification system. if ($config->get('integrations_easydiscuss_notification_comment_follower') && $this->created_by != 0) { $target = $this->getSubscribers($blog, array($this->created_by, $blog->created_by)); if (!empty($target)) { EasyBlogHelper::getHelper('EasyDiscuss')->addNotification($blog, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_COMMENT_POSTED', $blog->title), EBLOG_NOTIFICATIONS_TYPE_COMMENT, $target, $this->created_by, $link); } } if ($this->created_by != 0) { // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.comment', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_COMMENT', $blog->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.comment', $this->created_by); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.comment', $this->created_by); EasyBlogHelper::getHelper('EasySocial')->assignPoints('comment.create', $this->created_by); EasyBlogHelper::getHelper('EasySocial')->assignPoints('comment.create.author', $blog->created_by); EasyBlogHelper::getHelper('EasySocial')->assignBadge('comment.create', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_CREATE_COMMENT')); } // AlphaUserPoints // since 1.2 if (EasyBlogHelper::isAUPEnabled() && $this->created_by != 0) { $url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $this->post_id); AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_comment', AlphaUserPointsHelper::getAnyUserReferreID($this->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_NEW_COMMENT_SUBMITTED', $url, $blog->title)); // @rule: Add comment for blog author if ($blog->created_by != $this->created_by) { AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_comment_blogger', AlphaUserPointsHelper::getAnyUserReferreID($blog->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_NEW_COMMENT_SUBMITTED', $url, $blog->title)); } } // Determine whether or not to push this as a normal activity $external = $blog->getBlogContribution(); // @rule: Add activity integrations for group integrations. if ($external) { if ($external instanceof TableExternal) { EasyBlogHelper::getHelper('Event')->addCommentStream($blog, $this, $external); } else { // @task: Legacy support prior to 3.5 EasyBlogHelper::getHelper('Groups')->addCommentStream($blog, $this, $external); } } else { EasyBlogHelper::addJomSocialActivityComment($this, $blog->title); // Add EasySocial stream $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->createCommentStream($this, $blog); // Assign EasySocial points $easysocial->assignPoints('comments.create'); // @rule: Give points to the comment author EasyBlogHelper::addJomsocialPoint('com_easyblog.comments.add'); // @rule: Give points to the blog author if ($my->id != $blog->created_by && $this->created_by != 0) { // Assign EasySocial points $easysocial->assignPoints('comments.create.author', $blog->created_by); EasyBlogHelper::addJomsocialPoint('com_easyblog.comments.addblogger', $blog->created_by); } } } if ($isNew && $state) { $blog = EasyBlogHelper::getTable('Blog'); $blog->load($this->post_id); $blogauthor = EasyBlogHelper::getTable('Profile'); $blogauthor->load($blog->created_by); $obj = new stdClass(); $obj->comment = $this->comment; $obj->commentauthor = $this->name; $obj->blogtitle = $blog->title; $obj->blogautor = $blogauthor->getName(); $activity = new stdClass(); $activity->actor_id = empty($this->created_by) ? '0' : $this->created_by; $activity->target_id = $blog->created_by; $activity->context_type = 'comment'; $activity->context_id = $this->id; $activity->verb = 'add'; $activity->source_id = $this->post_id; $activity->uuid = serialize($obj); EasyBlogHelper::activityLog($activity); } return $state; }
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 store($updateNulls = false) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); // @rule: Check for empty title if (empty($this->title)) { $this->setError(JText::_('COM_EASYBLOG_INVALID_TAG')); return false; } // @rule: Check if such tag exists. if ($this->exists($this->title, !$this->id)) { $this->setError(JText::_('COM_EASYBLOG_TAG_ALREADY_EXISTS')); return false; } // @task: If alias is null, we need to generate them here. jimport('joomla.filesystem.filter.filteroutput'); $i = 1; while ($this->aliasExists() || empty($this->alias)) { $this->alias = empty($this->alias) ? $this->title : $this->alias . '-' . $i; $i++; } $this->alias = EasyBlogRouter::generatePermalink($this->alias); if (!empty($this->created)) { $offset = EasyBlogDateHelper::getOffSet(); $newDate = EasyBlogHelper::getDate($this->created, $offset); $this->created = $newDate->toMySQL(); } else { $newDate = EasyBlogHelper::getDate(); $this->created = $newDate->toMySQL(); } $isNew = !$this->id; $state = parent::store(); $my = JFactory::getUser(); if ($isNew && $my->id != 0) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.tag', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_TAG', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.tag', $my->id); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.tag', $my->id); // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('tag.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.tag.add', $my->id); } } // AlphaUserPoints // since 1.2 if (EasyBlogHelper::isAUPEnabled()) { AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_tag', '', 'easyblog_add_tag_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_TAG_ADDED', $this->title)); } } if ($state) { //activity logging. $activity = new stdClass(); $activity->actor_id = $my->id; $activity->target_id = '0'; $activity->context_type = 'tag'; $activity->context_id = $this->id; $activity->verb = $isNew ? 'add' : 'update'; $activity->uuid = $this->title; EasyBlogHelper::activityLog($activity); } return $state; }
/** * Override parent's store method. */ public function store() { return parent::store(); }
public function store($updateNulls = false) { if (!empty($this->created)) { $offset = EasyBlogDateHelper::getOffSet(); $newDate = EasyBlogHelper::getDate($this->created, $offset); $this->created = $newDate->toMySQL(); } else { $newDate = EasyBlogHelper::getDate(); $this->created = $newDate->toMySQL(); } $my = JFactory::getUser(); // Add point integrations for new categories if ($this->id == 0 && $my->id > 0) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.category', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_CATEGORY', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.category', $my->id); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.category', $my->id); // @since 1.2 // AlphaUserPoints if (EasyBlogHelper::isAUPEnabled()) { AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_category', '', 'easyblog_add_category_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_NEW_CATEGORY_CREATED', $this->title)); } if ($config->get('main_jomsocial_userpoint')) { $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($path)) { require_once $path; CUserPoints::assignPoint('com_easyblog.category.add', $my->id); } } // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('category.create', $my->id); } // Figure out the proper nested set model if ($this->id == 0 && $this->lft == 0) { // No parent id, we use the current lft,rgt if ($this->parent_id) { $left = $this->getLeft($this->parent_id); $this->lft = $left; $this->rgt = $this->lft + 1; // Update parent's right $this->updateRight($left); $this->updateLeft($left); } else { $this->lft = $this->getLeft() + 1; $this->rgt = $this->lft + 1; } } $isNew = empty($this->id) ? true : false; $return = parent::store(); //activity logging. $activity = new stdClass(); $activity->actor_id = $my->id; $activity->target_id = '0'; $activity->context_type = 'category'; $activity->context_id = $this->id; $activity->verb = $isNew ? 'add' : 'update'; $activity->uuid = $this->title; EasyBlogHelper::activityLog($activity); return $return; }