Ejemplo n.º 1
1
 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;
 }
Ejemplo n.º 2
0
 function remove()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('comment');
     $comments = JRequest::getVar('cid', '', 'POST');
     $message = '';
     $type = 'message';
     if (empty($comments)) {
         $message = JText::_('Invalid comment id');
         $type = 'error';
     } else {
         $table = EasyBlogHelper::getTable('Comment', 'Table');
         foreach ($comments as $comment) {
             $table->load($comment);
             // AlphaUserPoints
             // since 1.2
             if (!empty($table->created_by) && EasyBlogHelper::isAUPEnabled()) {
                 $aupid = AlphaUserPointsHelper::getAnyUserReferreID($table->created_by);
                 AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_comment', $aupid, '', JText::_('COM_EASYBLOG_AUP_COMMENT_DELETED'));
             }
             if (!$table->delete()) {
                 $message = JText::_('COM_EASYBLOG_COMMENTS_COMMENT_REMOVE_ERROR');
                 $type = 'error';
                 $this->setRedirect('index.php?option=com_easyblog&view=comments', $message, $type);
                 return;
             }
             $message = JText::_('COM_EASYBLOG_COMMENTS_COMMENT_REMOVED');
         }
     }
     $this->setRedirect('index.php?option=com_easyblog&view=comments', $message, $type);
 }
Ejemplo n.º 3
0
 public function vote($value, $uid, $type, $elementId)
 {
     $ajax = new Ejax();
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($uid);
     if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
         if (!EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) {
             echo 'Invalid Access.';
             exit;
         }
     }
     $rating = EasyBlogHelper::getTable('Ratings', 'Table');
     // Do not allow guest to vote, or if the voter already voted.
     if ($rating->fill($my->id, $uid, $type, JFactory::getSession()->getId()) || $my->id < 1 && !$config->get('main_ratings_guests')) {
         // We wouldn't allow user to vote more than once so don't do anything here
         $ajax->send();
     }
     $rating->set('created_by', $my->id);
     $rating->set('type', $type);
     $rating->set('uid', $uid);
     $rating->set('ip', @$_SERVER['REMOTE_ADDR']);
     $rating->set('value', (int) $value);
     $rating->set('sessionid', JFactory::getSession()->getId());
     $rating->set('created', EasyBlogHelper::getDate()->toMySQL());
     $rating->set('published', 1);
     $rating->store();
     $model = EasyBlogHelper::getModel('Ratings');
     $ratingValue = $model->getRatingValues($uid, $type);
     $total = $ratingValue->total;
     $rating = $ratingValue->ratings;
     // 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.rate', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_RATED_BLOG'));
     $ajax->script('eblog.loader.doneLoading("' . $elementId . '-command .ratings-text")');
     $ajax->script('eblog.ratings.update("' . $elementId . '", "' . $type . '" , "' . $rating . '" , "' . JText::_('COM_EASYBLOG_RATINGS_RATED_THANK_YOU') . '");');
     $ajax->assign($elementId . ' .ratings-value', '<i></i>' . $total . '<b>&radic;</b>');
     if (EasyBlogHelper::isAUPEnabled()) {
         $id = AlphaUserPointsHelper::getAnyUserReferreID($my->id);
         AlphaUserPointsHelper::newpoints('plgaup_easyblog_rate_blog', $id, '', JText::sprintf('COM_EASYBLOG_AUP_BLOG_RATED'), '');
     }
     $ajax->send();
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
 function remove()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('category');
     $categories = JRequest::getVar('cid', '', 'POST');
     $message = '';
     $type = 'info';
     if (empty($categories)) {
         $message = JText::_('COM_EASYBLOG_CATEGORIES_INVALID_CATEGORY');
         $type = 'error';
     } else {
         $table = EasyBlogHelper::getTable('Category', 'Table');
         foreach ($categories as $category) {
             $table->load($category);
             if ($table->getPostCount()) {
                 $message = JText::sprintf('COM_EASYBLOG_CATEGORIES_DELETE_ERROR_POST_NOT_EMPTY', $table->title);
                 $type = 'error';
                 $this->setRedirect('index.php?option=com_easyblog&view=categories', $message, $type);
                 return;
             }
             if ($table->getChildCount()) {
                 $message = JText::sprintf('COM_EASYBLOG_CATEGORIES_DELETE_ERROR_CHILD_NOT_EMPTY', $table->title);
                 $type = 'error';
                 $this->setRedirect('index.php?option=com_easyblog&view=categories', $message, $type);
                 return;
             }
             if (!$table->delete()) {
                 $message = JText::_('COM_EASYBLOG_CATEGORIES_DELETE_ERROR');
                 $type = 'error';
                 $this->setRedirect('index.php?option=com_easyblog&view=categories', $message, $type);
                 return;
             } else {
                 // AlphaUserPoints
                 // since 1.2
                 if (EasyBlogHelper::isAUPEnabled()) {
                     $aupid = AlphaUserPointsHelper::getAnyUserReferreID($table->created_by);
                     AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_category', $aupid, '', JText::sprintf('AUP CATEGORY DELETED', $table->title));
                 }
             }
         }
         $message = JText::_('COM_EASYBLOG_CATEGORIES_DELETE_SUCCESS');
     }
     $this->setRedirect('index.php?option=com_easyblog&view=categories', $message, $type);
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 public function delete($cid = null)
 {
     $state = parent::delete($cid);
     $my = JFactory::getUser();
     // @rule: Remove comment's stream
     $this->removeStream();
     if ($this->created_by != 0 && $this->published == '1') {
         $blog = EasyBlogHelper::getTable('Blog');
         $blog->load($this->post_id);
         JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
         $config = EasyBlogHelper::getConfig();
         // @rule: Integrations with EasyDiscuss
         EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.delete.comment', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_COMMENT', $blog->title));
         EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.delete.comment', $this->created_by);
         EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.delete.comment', $this->created_by);
         // @since 1.2
         // AlphaUserPoints
         if (EasyBlogHelper::isAUPEnabled()) {
             AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_comment', AlphaUserPointsHelper::getAnyUserReferreID($this->created_by), '', JText::_('COM_EASYBLOG_AUP_COMMENT_DELETED'));
             // @rule: Add comment for blog author
             if ($blog->created_by != $this->created_by) {
                 AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_comment_blogger', AlphaUserPointsHelper::getAnyUserReferreID($blog->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_COMMENT_DELETED_BLOGGER', $url, $blog->title));
             }
         }
         // Assign EasySocial points
         $easysocial = EasyBlogHelper::getHelper('EasySocial');
         $easysocial->assignPoints('comments.remove', $this->created_by);
         // @rule: Deduct points from the comment author
         EasyBlogHelper::addJomsocialPoint('com_easyblog.comments.remove', $this->created_by);
         // @rule: Give points to the blog author
         if ($my->id != $blog->created_by) {
             // Assign EasySocial points
             $easysocial->assignPoints('comments.remove.author', $blog->created_by);
             EasyBlogHelper::addJomsocialPoint('com_easyblog.comments.removeblogger', $blog->created_by);
         }
     }
     return $state;
 }
Ejemplo n.º 8
0
 function saveProfile()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $mainframe = JFactory::getApplication();
     $acl = EasyBlogACLHelper::getRuleSet();
     $post = JRequest::get('post');
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $this->checkLogin();
     if (EasyBlogHelper::isSiteAdmin() || $config->get('layout_dashboard_biography_editor')) {
         $post['description'] = JRequest::getVar('description', '', 'POST', '', JREQUEST_ALLOWRAW);
         $post['biography'] = JRequest::getVar('biography', '', 'POST', '', JREQUEST_ALLOWRAW);
         // 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])) {
             $post['description'] = $inputFilter->clean($post['description']);
             $post['biography'] = $inputFilter->clean($post['biography']);
         }
     }
     array_walk($post, array($this, '_trim'));
     if ($config->get('main_dashboard_editaccount')) {
         if (!$this->_validateProfileFields($post)) {
             $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
             return;
         }
         $my->name = $post['fullname'];
         $my->save();
     }
     if ($config->get('main_joomlauserparams')) {
         $email = $post['email'];
         $password = $post['password'];
         $password2 = $post['password2'];
         if (JString::strlen($password) || JString::strlen($password2)) {
             if ($password != $password2) {
                 EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_ACCOUNT_PASSWORD_ERROR'), 'error');
                 $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
                 return false;
             }
         }
         // Store basic Joomla information
         $user = JFactory::getUser();
         $data = array('email' => $email, 'password' => $password, 'password2' => $password2);
         $user->bind($data);
         if (!$user->save()) {
             EasyBlogHelper::setMessageQueue($user->getError(), 'error');
             $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
             return false;
         }
         $session = JFactory::getSession();
         $session->set('user', $user);
         $table = JTable::getInstance('Session');
         $table->load($session->getId());
         $table->username = $user->get('username');
         $table->store();
     }
     $post['permalink'] = $post['user_permalink'];
     unset($post['user_permalink']);
     // Check if permalink exists.
     $model = EasyBlogHelper::getModel('Users');
     if ($model->permalinkExists($post['permalink'], $my->id)) {
         EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_ACCOUNT_PERMALINK_EXISTS'), 'error');
         $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
         return false;
     }
     $profile = EasyBlogHelper::getTable('Profile', 'Table');
     $profile->load($my->id);
     $profile->bind($post);
     if ($config->get('main_feedburner') && $config->get('main_feedburnerblogger') && !empty($acl->rules->allow_feedburner)) {
         $feedburner = EasyBlogHelper::getTable('Feedburner', 'Table');
         $feedburner->load($my->id);
         $feedburner->url = $post['feedburner_url'];
         $feedburner->store();
     }
     JTable::addIncludePath(EBLOG_TABLES);
     if (!empty($acl->rules->update_twitter)) {
         $mainframe = JFactory::getApplication();
         $twitter = EasyBlogHelper::getTable('Oauth', 'Table');
         $twitter->loadByUser($my->id, EBLOG_OAUTH_TWITTER);
         $twitter->auto = JRequest::getVar('integrations_twitter_auto');
         $twitter->message = JRequest::getVar('integrations_twitter_message');
         if (!$twitter->store()) {
             EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_INTEGRATIONS_TWITTER_ERROR'), 'error');
         }
     }
     // Map linkedin items
     if (!empty($acl->rules->update_linkedin)) {
         $mainframe = JFactory::getApplication();
         $linkedin = EasyBlogHelper::getTable('Oauth', 'Table');
         $linkedin->loadByUser($my->id, EBLOG_OAUTH_LINKEDIN);
         $linkedin->auto = JRequest::getVar('integrations_linkedin_auto');
         $linkedin->message = JRequest::getVar('integrations_linkedin_message');
         $linkedin->private = JRequest::getVar('integrations_linkedin_private');
         if (!$linkedin->store()) {
             EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_INTEGRATIONS_LINKEDIN_ERROR'), 'error');
         }
     }
     if (!empty($acl->rules->update_facebook)) {
         $mainframe = JFactory::getApplication();
         $facebook = EasyBlogHelper::getTable('Oauth', 'Table');
         $facebook->loadByUser($my->id, EBLOG_OAUTH_FACEBOOK);
         $facebook->auto = JRequest::getVar('integrations_facebook_auto');
         $facebook->message = '';
         if (!$facebook->store()) {
             EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_INTEGRATIONS_FACEBOOK_FAILED_UPDATE_INFO_ERROR'), 'error');
         }
     }
     $this->saveAdsenseUserParams();
     //save avatar
     if (!empty($acl->rules->upload_avatar)) {
         $file = JRequest::getVar('Filedata', '', 'files', 'array');
         if (!empty($file['name'])) {
             $newAvatar = $this->_upload($profile);
             $profile->avatar = $newAvatar;
             // AlphaUserPoints
             // since 1.2
             if (EasyBlogHelper::isAUPEnabled()) {
                 AlphaUserPointsHelper::newpoints('plgaup_easyblog_upload_avatar', '', 'easyblog_upload_avatar_' . $my->id, JText::_('COM_EASYBLOG_AUP_UPLOADED_AVATAR'));
             }
         }
     }
     //save meta
     if (!empty($acl->rules->add_entry)) {
         //meta post info
         $metaId = JRequest::getInt('metaid', 0);
         $metapost = array();
         $metapost['keywords'] = JRequest::getVar('metakeywords', '');
         $metapost['description'] = JRequest::getVar('metadescription', '');
         $metapost['content_id'] = $my->id;
         $metapost['type'] = META_TYPE_BLOGGER;
         $meta = EasyBlogHelper::getTable('Meta', 'Table');
         $meta->load($metaId);
         $meta->bind($metapost);
         $meta->store();
     }
     //save params
     $userparams = EasyBlogHelper::getRegistry('');
     $userparams->set('theme', $post['theme']);
     // @rule: Save google profile url
     if (isset($post['google_profile_url'])) {
         $userparams->set('google_profile_url', $post['google_profile_url']);
     }
     if (isset($post['show_google_profile_url'])) {
         $userparams->set('show_google_profile_url', $post['show_google_profile_url']);
     }
     $profile->params = $userparams->toString();
     if ($config->get('main_dashboard_editaccount') && $config->get('main_joomlauserparams')) {
         $my->save(true);
     }
     if ($profile->store()) {
         EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_PROFILE_UPDATE_SUCCESS'), 'info');
     } else {
         EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_PROFILE_UPDATE_FAILED'), 'error');
     }
     $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
 }
Ejemplo n.º 9
0
 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;
 }