Ejemplo n.º 1
0
 public function __construct($message, $type = EASYBLOG_MSG_ERROR, $silent = false, $customErrorCode = null)
 {
     // EASYBLOG_MSG_ERROR
     if (is_string($type)) {
         $code = isset(self::$codeMap[$type]) ? self::$codeMap[$type] : null;
         $this->type = $type;
         // array(400, EASYBLOG_MSG_ERROR)
     } else {
         if (is_array($type)) {
             $code = $type[0];
             $this->type = $code[1];
         }
     }
     // We're riding the third param. Blame strict standards.
     if (is_bool($silent)) {
         $previous = null;
     } else {
         $silent = false;
         $previous = $silent;
     }
     $this->customErrorCode = $customErrorCode;
     // Load front end language
     EB::loadLanguages(JPATH_ADMINISTRATOR);
     EB::loadLanguages(JPATH_ROOT);
     // Translate message so a user can pass in the language string directly.
     $message = JText::_($message);
     // Construct exception so we can retrieve the rest of the properties
     parent::__construct($message, $code, $previous);
     // Add to our global list of exceptions
     self::$exceptions[] = $this;
 }
Ejemplo n.º 2
0
 /**
  * Translates text
  *
  * @since	4.0
  * @access	public
  * @param	string	The language string to translate
  * @return	string
  */
 public function getLanguage($constant)
 {
     // Load languages on the site
     EB::loadLanguages();
     $string = JText::_(strtoupper($constant));
     return $string;
 }
Ejemplo n.º 3
0
 /**
  * Display a list of email activities
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tpl = null)
 {
     $this->checkAccess('easyblog.manage.mail');
     $layout = $this->getLayout();
     if (method_exists($this, $layout)) {
         return $this->{$layout}();
     }
     // Load frontend language file
     EB::loadLanguages();
     // Set heading
     $this->setHeading('COM_EASYBLOG_TITLE_MAIL_ACTIVITIES', '', 'fa-send-o');
     $filter_state = $this->app->getUserStateFromRequest('com_easyblog.spools.filter_state', 'filter_state', '*', 'word');
     $search = $this->app->getUserStateFromRequest('com_easyblog.spools.search', 'search', '', 'string');
     $search = trim(JString::strtolower($search));
     $order = $this->app->getUserStateFromRequest('com_easyblog.spools.filter_order', 'filter_order', 'created', 'cmd');
     $orderDirection = $this->app->getUserStateFromRequest('com_easyblog.spools.filter_order_Dir', 'filter_order_Dir', 'asc', 'word');
     $mails = $this->get('Data');
     $pagination = $this->get('Pagination');
     $this->set('mails', $mails);
     $this->set('pagination', $pagination);
     $this->set('state', JHTML::_('grid.state', $filter_state, JText::_('COM_EASYBLOG_SENT'), JText::_('COM_EASYBLOG_PENDING')));
     $this->set('search', $search);
     $this->set('order', $order);
     $this->set('orderDirection', $orderDirection);
     parent::display('spools/default');
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     // Load language file
     EB::loadLanguages();
     $this->app = JFactory::getApplication();
     $this->exists = $this->exists();
     parent::__construct();
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     EB::loadLanguages(JPATH_ADMINISTRATOR);
     // Load our own js library
     EB::init('admin');
     // $this->doc = JFactory::getDocument();
     // $this->doc->addStylesheet(rtrim(JURI::base(), '/') . '/components/com_easyblog/themes/default/css/elements.css');
     JHTML::_('behavior.modal');
     $this->app = JFactory::getApplication();
 }
Ejemplo n.º 6
0
 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 ' . $db->nameQuote($this->_tbl) . ' ' . 'WHERE ' . $db->nameQuote('obj_id') . ' = ' . $db->Quote($this->obj_id) . ' ' . 'AND ' . $db->nameQuote('obj_type') . ' = ' . $db->Quote($this->obj_type) . ' ' . 'AND ' . $db->nameQuote('ip') . ' = ' . $db->Quote($this->ip);
         $db->setQuery($query);
         $total = (int) $db->loadResult();
         if ($total >= $maxTimes) {
             EB::loadLanguages();
             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();
 }
Ejemplo n.º 7
0
 /**
  * Displays a list of templates
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function templates()
 {
     // Ensure the user has access to manage templates
     $this->checkAccess('easyblog.manage.templates');
     $this->setHeading('COM_EASYBLOG_BLOGS_POST_TEMPLATES_TITLE', '', 'fa-clipboard');
     EB::loadLanguages();
     $model = EB::model('Templates');
     $rows = $model->getItems();
     $pagination = $model->getPagination();
     $templates = array();
     foreach ($rows as $row) {
         $template = EB::table('PostTemplate');
         $template->bind($row);
         $templates[] = $template;
     }
     $this->set('templates', $templates);
     $this->set('pagination', $pagination);
     parent::display('blogs/templates');
 }
Ejemplo n.º 8
0
function EasyBlogParseRoute(&$segments)
{
    // Load site's language file
    EB::loadLanguages();
    $vars = array();
    $active = JFactory::getApplication()->getMenu()->getActive();
    $config = EB::config();
    // We know that the view=categories&layout=listings&id=xxx because there's only 1 segment
    // and the active menu is view=categories
    if (isset($active) && $active->query['view'] == 'categories' && !isset($active->query['layout']) && count($segments) == 1) {
        $vars['view'] = 'categories';
        $vars['layout'] = 'listings';
        $category = EB::table('Category');
        $category->load(array('alias' => $segments[0]));
        // if still can't get the correct category id try this
        if (!$category->id) {
            $categoryAlias = $segments[0];
            $categoryAlias = str_replace(':', '-', $categoryAlias);
            $category->load(array('alias' => $categoryAlias));
        }
        $vars['id'] = $category->id;
        return $vars;
    }
    // RSD View
    if (isset($segments[0]) && $segments[0] == 'rsd') {
        $vars['view'] = 'rsd';
        return $vars;
    }
    // Feed view
    if (isset($segments[1])) {
        if ($segments[1] == 'rss' || $segments[1] == 'atom') {
            $vars['view'] = $segments[0];
            unset($segments);
            return $vars;
        }
    }
    // If user chooses to use the simple sef setup, we need to add the proper view
    if ($config->get('main_sef') == 'simple' && count($segments) == 1) {
        $files = JFolder::folders(JPATH_ROOT . '/components/com_easyblog/views');
        $views = array();
        foreach ($files as $file) {
            $views[] = EBR::translate($file);
        }
        if (!in_array($segments[0], $views)) {
            array_unshift($segments, EBR::translate('entry'));
        }
    }
    // Composer view
    if (isset($segments[0]) && $segments[0] == EBR::translate('composer')) {
        $vars['view'] = 'composer';
    }
    // Entry view
    if (isset($segments[0]) && $segments[0] == EBR::translate('entry')) {
        $count = count($segments);
        $entryId = '';
        // perform manual split on the string.
        if ($config->get('main_sef_unicode')) {
            $permalinkSegment = $segments[$count - 1];
            $permalinkArr = explode(':', $permalinkSegment);
            $entryId = $permalinkArr[0];
        } else {
            $index = $count - 1;
            $alias = $segments[$index];
            $post = EB::post();
            $post->loadByPermalink($alias);
            if ($post) {
                $entryId = $post->id;
            }
        }
        if ($entryId) {
            $vars['id'] = $entryId;
        }
        $vars['view'] = 'entry';
    }
    // Calendar view
    if (isset($segments[0]) && $segments[0] == EBR::translate('calendar')) {
        $vars['view'] = 'calendar';
        $count = count($segments);
        $totalSegments = $count - 1;
        if ($totalSegments >= 1) {
            // First segment is always the year
            if (isset($segments[1])) {
                $vars['year'] = $segments[1];
            }
            // Second segment is always the month
            if (isset($segments[2])) {
                $vars['month'] = $segments[2];
            }
            // Third segment is always the day
            if (isset($segments[3])) {
                $vars['day'] = $segments[3];
            }
        }
    }
    if (isset($segments[0]) && $segments[0] == EBR::translate('archive')) {
        $vars['view'] = 'archive';
        $count = count($segments);
        $totalSegments = $count - 1;
        if ($totalSegments >= 1) {
            $indexSegment = 1;
            if ($segments[1] == 'calendar') {
                $vars['layout'] = 'calendar';
                $indexSegment = 2;
            }
            // First segment is always the year
            if (isset($segments[$indexSegment])) {
                $vars['archiveyear'] = $segments[$indexSegment];
            }
            // Second segment is always the month
            if (isset($segments[$indexSegment + 1])) {
                $vars['archivemonth'] = $segments[$indexSegment + 1];
            }
            // Third segment is always the day
            if (isset($segments[$indexSegment + 2])) {
                $vars['archiveday'] = $segments[$indexSegment + 2];
            }
        }
    }
    // Process categories sef links
    // index.php?option=com_easyblog&view=categories
    if (isset($segments[0]) && $segments[0] == EBR::translate('categories')) {
        // Set the view
        $vars['view'] = 'categories';
        // Get the total number of segments
        $count = count($segments);
        // Ensure that the first index is not a system layout
        $layouts = array('listings', 'simple');
        if ($count == 2 && !in_array($segments[1], $layouts)) {
            $id = null;
            // If unicode alias is enabled, just explode the data
            if ($config->get('main_sef_unicode')) {
                $tmp = explode(':', $segments[1]);
                $id = $tmp[0];
            }
            // Encode segments
            $segments = EBR::encodeSegments($segments);
            if (!$id) {
                $category = EB::table('Category');
                $category->load(array('alias' => $segments[1]));
                $id = $category->id;
            }
            $vars['id'] = $id;
            $vars['layout'] = 'listings';
        }
        // index.php?option=com_easyblog&view=categories&layout=simple
        if ($count == 2 && in_array($segments[1], $layouts)) {
            $vars['layout'] = $segments[1];
        }
    }
    if (isset($segments[0]) && $segments[0] == EBR::translate('tags')) {
        $count = count($segments);
        if ($count > 1) {
            $tagId = '';
            if ($config->get('main_sef_unicode')) {
                // perform manual split on the string.
                $permalinkSegment = $segments[$count - 1];
                $permalinkArr = explode(':', $permalinkSegment);
                $tagId = $permalinkArr[0];
            }
            $segments = EBR::encodeSegments($segments);
            if (empty($tagId)) {
                $table = EB::table('Tag');
                $table->load($segments[$count - 1], true);
                $tagId = $table->id;
            }
            $vars['id'] = $tagId;
            $vars['layout'] = 'tag';
        }
        $vars['view'] = 'tags';
    }
    // view=blogger&layout=listings&id=xxx
    if (isset($segments[0]) && $segments[0] == EBR::translate('blogger')) {
        $vars['view'] = 'blogger';
        $count = count($segments);
        if ($count > 1) {
            if ($count == 3) {
                // this is bloggers sorting page
                $vars['sort'] = $segments[2];
            } else {
                // Default user id
                $id = 0;
                // Parse the segments
                $segments = EBR::encodeSegments($segments);
                // For unicode urls we definitely know that the author's id would be in the form of ID-title
                if ($config->get('main_sef_unicode')) {
                    $permalink = explode(':', $segments[1]);
                    $id = $permalink[0];
                }
                if (!$id) {
                    // Try to get the user id
                    $permalink = $segments[1];
                    $id = EB::getUserId($permalink);
                    if (!$id) {
                        $id = EB::getUserId(JString::str_ireplace('-', ' ', $permalink));
                    }
                    if (!$id) {
                        $id = EB::getUserId(JString::str_ireplace('-', '_', $permalink));
                    }
                }
                if ($id) {
                    $vars['layout'] = 'listings';
                    $vars['id'] = $id;
                }
            }
            // if count > 3
        }
    }
    if (isset($segments[0]) && $segments[0] == EBR::translate('dashboard')) {
        $count = count($segments);
        if ($count > 1) {
            switch (EBR::translate($segments[1])) {
                case EBR::translate('write'):
                    $vars['layout'] = 'write';
                    break;
                case EBR::translate('profile'):
                    $vars['layout'] = 'profile';
                    break;
                case EBR::translate('drafts'):
                    $vars['layout'] = 'drafts';
                    break;
                case EBR::translate('entries'):
                    $vars['layout'] = 'entries';
                    break;
                case EBR::translate('comments'):
                    $vars['layout'] = 'comments';
                    break;
                case EBR::translate('categories'):
                    $vars['layout'] = 'categories';
                    break;
                case EBR::translate('requests'):
                    $vars['layout'] = 'requests';
                    break;
                case EBR::translate('listCategories'):
                    $vars['layout'] = 'listCategories';
                    break;
                case EBR::translate('category'):
                    $vars['layout'] = 'category';
                    break;
                case EBR::translate('tags'):
                    $vars['layout'] = 'tags';
                    break;
                case EBR::translate('review'):
                    $vars['layout'] = 'review';
                    break;
                case EBR::translate('pending'):
                    $vars['layout'] = 'pending';
                    break;
                case EBR::translate('revisions'):
                    $vars['layout'] = 'revisions';
                    break;
                case EBR::translate('teamblogs'):
                    $vars['layout'] = 'teamblogs';
                    break;
                case EBR::translate('quickpost'):
                    $vars['layout'] = 'quickpost';
                    break;
                case EBR::translate('moderate'):
                    $vars['layout'] = 'moderate';
                    break;
                case EBR::translate('templates'):
                    $vars['layout'] = 'templates';
                    break;
                case EBR::translate('templateform'):
                    $vars['layout'] = 'templateform';
                    break;
                case EBR::translate('compare'):
                    $vars['layout'] = 'compare';
                    break;
            }
            // Check if there's any default type
            if (isset($vars['layout']) && $vars['layout'] == 'quickpost' && isset($segments[2])) {
                $vars['type'] = $segments[2];
            }
            if (isset($vars['layout']) && $vars['layout'] == 'compare' && isset($segments[2])) {
                $vars['blogid'] = $segments[2];
            }
            if (isset($vars['layout']) && $vars['layout'] == 'entries') {
                if (count($segments) == 3) {
                    if (isset($segments[2])) {
                        $vars['postType'] = $segments[2];
                    }
                }
                if (count($segments) == 4) {
                    if (isset($segments[2])) {
                        $vars['filter'] = $segments[2];
                    }
                    if (isset($segments[3])) {
                        $vars['postType'] = $segments[3];
                    }
                }
            } else {
                if (isset($segments[2])) {
                    $vars['filter'] = $segments[2];
                }
            }
        }
        $vars['view'] = 'dashboard';
    }
    if (isset($segments[0]) && $segments[0] == EBR::translate('teamblog')) {
        $count = count($segments);
        if ($count > 1) {
            $rawSegments = $segments;
            $segments = EBR::encodeSegments($segments);
            if ($config->get('main_sef_unicode')) {
                // perform manual split on the string.
                if (isset($segments[2]) && $segments[2] == EBR::translate('statistic')) {
                    $permalinkSegment = $rawSegments[1];
                } else {
                    $permalinkSegment = $rawSegments[$count - 1];
                }
                $permalinkArr = explode(':', $permalinkSegment);
                $teamId = $permalinkArr[0];
            } else {
                if (isset($segments[2]) && $segments[2] == EBR::translate('statistic')) {
                    $permalink = $segments[1];
                } else {
                    $permalink = $segments[$count - 1];
                }
                $table = EB::table('TeamBlog');
                $loaded = $table->load($permalink, true);
                if (!$loaded) {
                    $name = $segments[$count - 1];
                    $name = JString::str_ireplace(':', ' ', $name);
                    $name = JString::str_ireplace('-', ' ', $name);
                    $table->load($name, true);
                }
                $teamId = $table->id;
            }
            $vars['id'] = $teamId;
            if (isset($segments[2]) && $segments[2] == EBR::translate('statistic')) {
                $vars['layout'] = EBR::translate($segments[2]);
                if ($count == 5) {
                    if (isset($segments[3])) {
                        $vars['stat'] = EBR::translate($segments[3]);
                        switch (EBR::translate($segments[3])) {
                            case EBR::translate('category'):
                                if ($config->get('main_sef_unicode')) {
                                    // perform manual split on the string.
                                    $permalinkSegment = $rawSegments[4];
                                    $permalinkArr = explode(':', $permalinkSegment);
                                    $categoryId = $permalinkArr[0];
                                } else {
                                    $table = EB::table('Category');
                                    $table->load($segments[4], true);
                                    $categoryId = $table->id;
                                }
                                $vars['catid'] = $categoryId;
                                break;
                            case EBR::translate('tag'):
                                if ($config->get('main_sef_unicode')) {
                                    // perform manual split on the string.
                                    $permalinkSegment = $segments[4];
                                    $permalinkArr = explode(':', $permalinkSegment);
                                    $tagId = $permalinkArr[0];
                                } else {
                                    $table = EB::table('Tag');
                                    $table->load($segments[4], true);
                                    $tagId = $table->id;
                                }
                                $vars['tagid'] = $tagId;
                                break;
                            default:
                                // do nothing.
                        }
                    }
                }
            } else {
                $vars['layout'] = 'listings';
            }
        }
        $vars['view'] = 'teamblog';
    }
    if (isset($segments[0]) && $segments[0] == EBR::translate('search')) {
        $count = count($segments);
        if ($count == 2) {
            if ($segments[1] == "parsequery") {
                $vars['layout'] = EBR::translate($segments[1]);
            } else {
                $vars['query'] = $segments[1];
            }
        }
        $vars['view'] = 'search';
    }
    $count = count($segments);
    if ($count == 1) {
        switch (EBR::translate($segments[0])) {
            case EBR::translate('latest'):
                $vars['view'] = 'latest';
                break;
            case EBR::translate('featured'):
                $vars['view'] = 'featured';
                break;
            case EBR::translate('images'):
                $vars['view'] = 'images';
                break;
            case EBR::translate('login'):
                $vars['view'] = 'login';
                break;
            case EBR::translate('myblog'):
                $vars['view'] = 'myblog';
                break;
            case EBR::translate('ratings'):
                $vars['view'] = 'ratings';
                break;
            case EBR::translate('subscription'):
                $vars['view'] = 'subscription';
                break;
        }
    }
    return $vars;
}
Ejemplo n.º 9
0
* @copyright    Copyright (C) 2010 - 2015 Stack Ideas Sdn Bhd. All rights reserved.
* @license      GNU/GPL, see LICENSE.php
* EasyBlog is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
// Require main framework for EasyBlog
require_once JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/easyblog.php';
// Looks like we need to manually include the router
require_once __DIR__ . '/router.php';
// Process ajax calls
EB::ajax()->process();
// Start profiling
EB::profiler()->start();
// Load extension languages
EB::loadLanguages();
// Include the main controller
require_once dirname(__FILE__) . '/controllers/controller.php';
// Execute services
EB::loadServices();
// Get controller name if specified
$app = JFactory::getApplication();
$controllerName = $app->input->get('controller', 'easyblog', 'cmd');
// Create controller
$controller = JControllerLegacy::getInstance('easyblog');
$task = $app->input->get('task');
$controller->execute($task);
$controller->redirect();
Ejemplo n.º 10
0
 /**
  * Allows caller to send a subscribe IPN to mailchimp
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function subscribe($email, $firstName, $lastName = '')
 {
     EB::loadLanguages();
     if (!function_exists('curl_init')) {
         return false;
     }
     if (!$this->config->get('subscription_mailchimp')) {
         return false;
     }
     // Get the list id
     $listId = $this->config->get('subscription_mailchimp_listid');
     if (!$listId) {
         return false;
     }
     $firstName = urlencode($firstName);
     $lastName = urlencode($lastName);
     // Determines if we should send the welcome email
     $sendWelcome = $this->config->get('subscription_mailchimp_welcome') ? 'true' : 'false';
     $url = $this->url . '?method=listSubscribe';
     $url = $url . '&apikey=' . $this->key;
     $url = $url . '&id=' . $listId;
     $url = $url . '&output=json';
     $url = $url . '&email_address=' . $email;
     $url = $url . '&merge_vars[FNAME]=' . $firstName;
     $url = $url . '&merge_vars[LNAME]=' . $lastName;
     $url = $url . '&merge_vars[email_type]=html';
     $url = $url . '&merge_vars[send_welcome]=' . $sendWelcome;
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     $result = curl_exec($ch);
     curl_close($ch);
     return true;
 }
Ejemplo n.º 11
0
 /**
  * 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;
 }
Ejemplo n.º 12
0
 /**
  * Retrieves the template contents.
  *
  **/
 public function getTemplateContents($template, $data)
 {
     // Load front end's language file.
     EB::loadLanguages();
     // We only want to show unsubscribe link when the user is really subscribed to the blogs
     if (!isset($data['unsubscribeLink'])) {
         $data['unsubscribeLink'] = '';
     }
     $config = EasyBlogHelper::getConfig();
     // @rule: Detect what type of emails that we should process.
     $type = $config->get('main_mailqueuehtmlformat') ? 'html' : 'text';
     $theme = EB::template();
     // Fetch the child theme first.
     foreach ($data as $key => $val) {
         $theme->set($key, $val);
     }
     $namespace = 'site/emails/html/' . $template;
     $contents = $theme->output($namespace);
     // @rule: Now we need to process the main template holder.
     $title = $config->get('notifications_title');
     $theme->set('unsubscribe', $data['unsubscribeLink']);
     $theme->set('emailTitle', $title);
     $theme->set('contents', $contents);
     $output = $theme->output('site/emails/html/template');
     return $output;
 }
Ejemplo n.º 13
0
 /**
  * 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;
 }
Ejemplo n.º 14
0
 /**
  * Retrieves the biography from the specific blogger
  *
  * @since	4.0
  * @access	public
  * @param	boolean		True to retrieve raw data
  * @return	string
  */
 public function getBiography($raw = false)
 {
     static $items = array();
     if (!isset($items[$this->id])) {
         EB::loadLanguages();
         $biography = $raw ? $this->biography : nl2br($this->biography);
         if (!$biography) {
             $biography = JText::sprintf('COM_EASYBLOG_BIOGRAPHY_NOT_SET', $this->getName());
         }
         $items[$this->id] = $biography;
     }
     return $items[$this->id];
 }
Ejemplo n.º 15
0
 public function __construct()
 {
     EB::loadLanguages();
 }
Ejemplo n.º 16
0
 /**
  * Deletes a post from the site
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete()
 {
     // Load site's language file just in case the blog post was deleted from the back end
     EB::loadLanguages();
     // Load our own plugins
     JPluginHelper::importPlugin('finder');
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     // Trigger
     $dispatcher->trigger('onBeforeEasyBlogDelete', array(&$this));
     // Delete the post from the db now
     $state = $this->post->delete();
     // Trigger
     $dispatcher->trigger('onAfterEasyBlogDelete', array(&$this));
     // Delete from finder.
     $dispatcher->trigger('onFinderAfterDelete', array('easyblog.blog', $this->post));
     // Delete all relations with this post
     $this->deleteRatings();
     $this->deleteReports();
     $this->deleteRevisions();
     $this->deleteCategoryRelations();
     $this->deleteBlogTags();
     $this->deleteMetas();
     $this->deleteComments();
     $this->deleteTeamContribution();
     $this->deleteAssets();
     $this->deleteFeedHistory();
     // Delete all subscribers to this post
     $this->deleteSubscribers();
     // Delete from featured table
     $this->deleteFeatured();
     // Relocate media files into "My Media"
     $this->relocateMediaFiles();
     // Delete all other 3rd party integrations
     $this->deleteOtherRelations();
     return $state;
 }
Ejemplo n.º 17
0
 /**
  * Overrides the parent's delete method
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete($pk = null)
 {
     // Try to delete the comment item first
     $state = parent::delete($pk);
     // Get the current logged in user
     $my = JFactory::getUser();
     // Remove comment's stream
     $this->removeStream();
     if ($this->created_by != 0 && $this->published == '1') {
         // Get the blog post
         $post = $this->getBlog();
         // Load language
         EB::loadLanguages();
         $config = EB::config();
         // Integrations with EasyDiscuss
         EB::easydiscuss()->log('easyblog.delete.comment', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_COMMENT', $post->title));
         EB::easydiscuss()->addPoint('easyblog.delete.comment', $this->created_by);
         EB::easydiscuss()->addBadge('easyblog.delete.comment', $this->created_by);
         // AlphaUserPoints
         EB::aup()->assign('plgaup_easyblog_delete_comment', $this->created_by, JText::_('COM_EASYBLOG_AUP_COMMENT_DELETED'));
         // Assign EasySocial points
         EB::easysocial()->assignPoints('comments.remove', $this->created_by);
         // Deduct points from the comment author
         EB::jomsocial()->assignPoints('com_easyblog.comments.remove', $this->created_by);
         // Deduct points from the blog post author
         if ($my->id != $post->created_by) {
             // Deduct EasySocial points
             EB::easysocial()->assignPoints('comments.remove.author', $post->created_by);
             // JomSocial
             EB::jomsocial()->assignPoints('com_easyblog.comments.removeblogger', $post->created_by);
             // AUP
             EB::aup()->assignPoints('plgaup_easyblog_delete_comment_blogger', $post->created_by, JText::sprintf('COM_EASYBLOG_AUP_COMMENT_DELETED_BLOGGER', $url, $post->title));
         }
     }
     return $state;
 }
Ejemplo n.º 18
0
 /**
  * Sends notifications out
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function notify($reject = false)
 {
     $notification = EB::notification();
     // Load up the team blog
     $team = EB::table('TeamBlog');
     $team->load($this->team_id);
     // Send email notifications to the requester
     $requester = JFactory::getUser($this->user_id);
     $data = array('teamName' => $team->title, 'teamDescription' => $team->getDescription(), 'teamAvatar' => $team->getAvatar(), 'teamLink' => EBR::getRoutedURL('index.php?option=com_easyblog&view=teamblog&layout=listings&id=' . $this->team_id, false, true));
     $template = $reject ? 'team.rejected' : 'team.approved';
     // Load site language file
     EB::loadLanguages();
     $subject = $reject ? JText::sprintf('COM_EASYBLOG_TEAMBLOGS_REQUEST_REJECTED', $team->title) : JText::sprintf('COM_EASYBLOG_TEAMBLOGS_REQUEST_APPROVED', $team->title);
     $obj = new stdClass();
     $obj->unsubscribe = false;
     $obj->email = $requester->email;
     $emails = array($obj);
     $notification->send($emails, $subject, $template, $data);
 }
Ejemplo n.º 19
0
 /**
  * Main method to import the feed items
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function import(EasyBlogTableFeed &$feed, $limit = 0)
 {
     // Load site language file
     EB::loadLanguages();
     // Import simplepie library
     jimport('simplepie.simplepie');
     // We need DomDocument to exist
     if (!class_exists('DomDocument')) {
         return false;
     }
     // Set the maximum execution time to a higher value
     @ini_set('max_execution_time', 720);
     // Get the feed params
     $params = EB::registry($feed->params);
     // Determines the limit of items to fetch
     $limit = $limit ? $limit : $params->get('feedamount', 0);
     // Setup the outgoing connection to the feed source
     $connector = EB::connector();
     $connector->addUrl($feed->url);
     $connector->execute();
     // Get the contents
     $contents = $connector->getResult($feed->url);
     // If contents is empty, we know something failed
     if (!$contents) {
         return EB::exception(JText::sprintf('COM_EASYBLOG_FEEDS_UNABLE_TO_REACH_TARGET_URL', $feed->url), EASYBLOG_MSG_ERROR);
     }
     // Get the cleaner to clean things up
     $cleaner = $this->getAdapter('Cleaner');
     $contents = $cleaner->cleanup($contents);
     // Load up the xml parser
     $parser = new SimplePie();
     $parser->strip_htmltags(false);
     $parser->set_raw_data($contents);
     @$parser->init();
     // Get a list of items
     // We need to supress errors here because simplepie will throw errors on STRICT mode.
     $items = @$parser->get_items();
     if (!$items) {
         // TODO: Language string
         return EB::exception('COM_EASYBLOG_FEEDS_NOTHING_TO_BE_IMPORTED_CURRENTLY', EASYBLOG_MSG_ERROR);
     }
     // Get the feeds model
     $model = EB::model('Feeds');
     // Determines the total number of items migrated
     $total = 0;
     foreach ($items as $item) {
         // If it reaches limit, skip processing
         if ($limit && $total == $limit) {
             break;
         }
         // Get the item's unique id
         $uid = @$item->get_id();
         // If item already exists, skip this
         if ($model->isFeedItemImported($feed->id, $uid)) {
             continue;
         }
         // Log down a new history record to avoid fetching of the same item again
         $history = EB::table('FeedHistory');
         $history->feed_id = $feed->id;
         $history->uid = $uid;
         $history->created = EB::date()->toSql();
         $history->store();
         // Get the item's link
         $link = @$item->get_link();
         // Load up the post library
         $post = EB::post();
         $createOption = array('overrideDoctType' => 'legacy', 'checkAcl' => false, 'overrideAuthorId' => $feed->item_creator);
         $post->create($createOption);
         // Pass this to the adapter to map the items
         $mapper = $this->getAdapter('Mapper');
         $mapper->map($post, $item, $feed, $params);
         // Now we need to get the content of the blog post
         $mapper->mapContent($post, $item, $feed, $params);
         $saveOptions = array('applyDateOffset' => false, 'validateData' => false, 'useAuthorAsRevisionOwner' => true, 'checkAcl' => false, 'overrideAuthorId' => $feed->item_creator);
         // Try to save the blog post now
         try {
             $post->save($saveOptions);
             // Update the history table
             $history->post_id = $post->id;
             $history->store();
             $total++;
         } catch (EasyBlogException $exception) {
             // do nothing.
         }
     }
     return EB::exception(JText::sprintf('COM_EASYBLOG_FEEDS_POSTS_MIGRATED_FROM_FEED', $total, $feed->url), EASYBLOG_MSG_SUCCESS);
 }
Ejemplo n.º 20
0
 public function getLanguage($lang)
 {
     // Load language support for front end and back end.
     EB::loadLanguages();
     return JText::_(strtoupper($lang));
 }