Beispiel #1
0
 public function store()
 {
     // @task: Load language file from the front end.
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     $this->clear($this->draft_id);
     // @rule: Send notification to the author of the post.
     $draft = EasyBlogHelper::getTable('Draft');
     $draft->load($this->draft_id);
     $author = EasyBlogHelper::getTable('Profile');
     $author->load($draft->created_by);
     $data['blogTitle'] = $draft->title;
     $data['blogAuthor'] = $author->getName();
     $data['blogAuthorAvatar'] = $author->getAvatar();
     $data['blogEditLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=dashboard&layout=write&draft_id=' . $draft->id, false, true);
     $data['blogAuthorEmail'] = $author->user->email;
     $data['rejectMessage'] = $this->message;
     // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
     $sh404exists = EasyBlogRouter::isSh404Enabled();
     if (JFactory::getApplication()->isAdmin() && $sh404exists) {
         $data['blogEditLink'] = JURI::root() . 'index.php?option=com_easyblog&view=dashboard&layout=write&draft_id=' . $draft->id;
     }
     $emailTitle = JText::_('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_REJECTED');
     $obj = new StdClass();
     $obj->unsubscribe = false;
     $obj->email = $author->user->email;
     $emails = array($obj);
     $notification = EasyBlogHelper::getHelper('Notification');
     $notification->send($emails, $emailTitle, 'email.blog.rejected', $data);
     return parent::store();
 }
Beispiel #2
0
    public static function getHTML($row)
    {
        $config = EasyBlogHelper::getConfig();
        if (!$config->get('main_tweetmeme')) {
            return '';
        }
        $service = $config->get('main_tweetmeme_url');
        $style = $config->get('main_tweetmeme_style');
        $source = $config->get('main_tweetmeme_rtsource');
        $buttonSize = 'social-button-';
        switch ($style) {
            case 'normal':
                $buttonSize .= 'large';
                break;
            case 'compact':
            default:
                $buttonSize .= 'small';
                break;
        }
        $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $row->id, false, true);
        $title = addslashes($row->title);
        $placeholder = 'sb-' . rand();
        $html = '<div class="social-button ' . $buttonSize . ' tweetmeme"><span id="' . $placeholder . '"></span></div>';
        $html .= EasyBlogHelper::addScriptDeclarationBookmarklet('$("#' . $placeholder . '").bookmarklet("tweetMeme", {
			service: "' . $service . '",
			style: "' . $style . '",
			url: "' . $url . '",
			title: "' . $title . '",
			source: "' . $source . '"
		});');
        return $html;
    }
Beispiel #3
0
 public static function addCard(&$blog, $rawIntroText)
 {
     $cfg = EasyBlogHelper::getConfig();
     // @rule: Check if user really wants to append the opengraph tags on the headers.
     if (!$cfg->get('main_twitter_cards')) {
         return false;
     }
     // Get the absolute permalink for this blog item.
     $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
     // Get the image of the blog post.
     $image = self::getImage($blog, $rawIntroText);
     // @task: Get Joomla's document object.
     $doc = JFactory::getDocument();
     // Add card definition.
     $doc->addCustomTag('<meta property="twitter:card" content="summary" />');
     $doc->addCustomTag('<meta property="twitter:url" content="' . $url . '" />');
     $doc->addCustomTag('<meta property="twitter:title" content="' . $blog->title . '" />');
     $text = EasyBlogHelper::stripEmbedTags($rawIntroText);
     $text = strip_tags($text);
     $text = str_ireplace("\r\n", "", $text);
     // Remove any " in the content as this would mess up the headers.
     $text = str_ireplace('"', '', $text);
     $maxLength = 137;
     if (!empty($maxLength)) {
         $text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text;
     }
     $text = EasyBlogStringHelper::escape($text);
     $doc->addCustomTag('<meta property="twitter:description" content="' . $text . '" />');
     if ($image) {
         $doc->addCustomTag('<meta property="twitter:image" content="' . $image . '"/> ');
     }
     return true;
 }
Beispiel #4
0
 public function sendApprovalEmail($approvalType)
 {
     $user = EasyBlogHelper::getTable('Profile');
     $user->load($this->user_id);
     $team = EasyBlogHelper::getTable('TeamBlog');
     $team->load($this->team_id);
     $template = $approvalType ? 'email.teamblog.approved' : 'email.teamblog.rejected';
     $obj = new stdClass();
     $obj->unsubscribe = false;
     $obj->email = $user->user->email;
     $emails = array($obj->email => $obj);
     $data = array('teamName' => $team->title, 'teamDescription' => $team->getDescription(), 'teamAvatar' => $team->getAvatar(), 'teamLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=teamblog&layout=listings&id=' . $this->team_id, false, true));
     // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
     $sh404exists = EasyBlogRouter::isSh404Enabled();
     if (JFactory::getApplication()->isAdmin() && $sh404exists) {
         $data['teamLink'] = JURI::root() . 'index.php?option=com_easyblog&view=teamblog&layout=listings&id=' . $team->id;
     }
     $notification = EasyBlogHelper::getHelper('Notification');
     $notification->send($emails, JText::_('COM_EASYBLOG_TEAMBLOG_JOIN_REQUEST'), $template, $data);
 }
Beispiel #5
0
 public function notify(EasyBlogTableBlog $blog)
 {
     $config = EasyBlogHelper::getConfig();
     // Send notification to site admins when a new blog post is reported
     $data = array();
     $data['blogTitle'] = $blog->title;
     $data['blogLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
     // @rule: Send email notifications out to subscribers.
     $author = EasyBlogHelper::getTable('Profile');
     $author->load($this->created_by);
     $data['reporterAvatar'] = $author->getAvatar();
     $data['reporterName'] = $author->getName();
     $data['reporterLink'] = $author->getProfileLink();
     $data['reason'] = $this->reason;
     $date = EasyBlogDateHelper::dateWithOffSet($this->created);
     $data['reportDate'] = EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y');
     // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
     $sh404exists = EasyBlogRouter::isSh404Enabled();
     if (JFactory::getApplication()->isAdmin() && $sh404exists) {
         $data['blogLink'] = JURI::root() . 'index.php?option=com_easyblog&view=entry&id=' . $blog->id;
     }
     $emailBlogTitle = JString::substr($blog->title, 0, $config->get('main_mailtitle_length'));
     $emailTitle = JText::sprintf('COM_EASYBLOG_EMAIL_TITLE_NEW_REPORT', $emailBlogTitle) . ' ...';
     $notification = EasyBlogHelper::getHelper('Notification');
     $emails = array();
     // @rule: Fetch custom emails defined at the back end.
     if ($config->get('notification_blogadmin')) {
         if ($config->get('custom_email_as_admin')) {
             $notification->getCustomEmails($emails);
         } else {
             $notification->getAdminEmails($emails);
         }
     }
     if (!empty($emails)) {
         $notification->send($emails, $emailTitle, 'email.blog.report', $data);
     }
 }
Beispiel #6
0
 /**
  * Process email notifications
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function processEmails($isModerated = false, $blog)
 {
     $config = EB::config();
     // Fix contents of comments.
     $content = $this->comment;
     // Initialize what we need
     $commentAuthor = $this->name;
     $commentAuthorEmail = $this->email;
     $commentAuthorAvatar = JURI::root() . 'components/com_easyblog/assets/images/default_blogger.png';
     // Get the date object
     $date = EB::date();
     // Format the date
     $commentDate = $date->format(JText::_('DATE_FORMAT_LC3'));
     $teamLink = '';
     if (isset($blog->team)) {
         $teamLink = '&team=' . $blog->team;
     }
     // Get the author data
     if ($this->created_by != 0) {
         $user = $this->getAuthor();
         $commentAuthor = $user->getName();
         $commentAuthorEmail = $user->user->email;
         $commentAuthorAvatar = $user->getAvatar();
     }
     $blogAuthor = EB::user($blog->created_by);
     $data = array('blogTitle' => $blog->title, 'blogIntro' => $blog->intro, 'blogContent' => $blog->content, 'blogLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry' . $teamLink . '&id=' . $blog->id, false, true), 'commentTitle' => empty($comment->title) ? '-' : $comment->title, 'commentContent' => $content, 'commentAuthor' => $commentAuthor, 'commentAuthorAvatar' => $commentAuthorAvatar, 'commentDate' => $commentDate, 'commentLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry' . $teamLink . '&id=' . $blog->id, false, true) . '#comment-' . $this->id);
     // Get a list of emails
     $emails = array();
     // Get the notification library
     $notification = EB::notification();
     if ($isModerated) {
         $hashkey = EB::table('HashKeys');
         $hashkey->uid = $this->id;
         $hashkey->type = 'comments';
         $hashkey->store();
         // Generate the approval and reject links
         $data['approveLink'] = EBR::getRoutedURL('index.php?option=com_easyblog&task=comments.approve&key=' . $hashkey->key, false, true);
         $data['rejectLink'] = EBR::getRoutedURL('index.php?option=com_easyblog&task=comments.reject&key=' . $hashkey->key, false, true);
         // Send email notification to admin.
         if ($config->get('custom_email_as_admin')) {
             $notification->getCustomEmails($emails);
         } else {
             $notification->getAdminEmails($emails);
         }
         // @rule: Send email notification to blog authors.
         if ($config->get('notification_commentmoderationauthor')) {
             $obj = new stdClass();
             $obj->unsubscribe = false;
             $obj->email = $blogAuthor->user->email;
             $emails[$blogAuthor->user->email] = $obj;
         }
         $notification->send($emails, JText::_('COM_EASYBLOG_NEW_COMMENT_ADDED_MODERATED_TITLE'), 'comment.moderate', $data);
         return true;
     }
     if (!$isModerated) {
         // Get a list of admin emails
         $notification->getAdminNotificationEmails($emails);
         // Send notification to blog authors.
         if ($config->get('notification_commentauthor')) {
             $obj = new stdClass();
             $obj->unsubscribe = false;
             $obj->email = $blogAuthor->user->email;
             $emails[$blogAuthor->user->email] = $obj;
         }
         // Send notifications to blog subscribers
         if ($config->get('main_subscription') && $blog->subscription == '1' && $config->get('notification_commentsubscriber')) {
             $notification->getBlogSubscriberEmails($emails, $blog->id);
         }
         // Do not send to the person that commented on the blog post.
         unset($emails[$commentAuthorEmail]);
         if (!$emails) {
             return false;
         }
         // Send the emails now.
         $subject = JText::sprintf('COM_EASYBLOG_NEW_COMMENT_ADDED_IN_POST', $blog->title);
         $notification->send($emails, $subject, 'comment.new', $data);
         return true;
     }
 }
Beispiel #7
0
 public static function getUnsubscribeLink($subdata, $external = false, $isAllType = false, $email = '')
 {
     $easyblogItemId = EasyBlogRouter::getItemId('latest');
     if ($isAllType && $email) {
         $types = array();
         $ids = array();
         $created = array();
         foreach ($subdata as $type => $id) {
             $types[] = $type;
             $tmpId = explode('|', $id);
             $ids[] = $tmpId[0];
             $created[] = $tmpId[1];
         }
         $stype = implode(',', $types);
         $sid = implode(',', $ids);
         $screated = implode(',', $created);
         $unsubdata = base64_encode("type=" . $stype . "\r\nsid=" . $sid . "\r\nuid=" . $email . "\r\ntoken=" . $screated);
     } else {
         $unsubdata = base64_encode("type=" . $subdata->type . "\r\nsid=" . $subdata->id . "\r\nuid=" . $subdata->user_id . "\r\ntoken=" . md5($subdata->id . $subdata->created));
     }
     return EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&task=subscription.unsubscribe&data=' . $unsubdata . '&Itemid=' . $easyblogItemId, false, $external);
 }
Beispiel #8
0
 function addTeamSubscription($teamId, $email, $userId = '0', $fullname = '')
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EasyBlogACLHelper::getRuleSet();
     $my = JFactory::getUser();
     $teamTbl = EasyBlogHelper::getTable('Teamblog', 'Table');
     $teamTbl->load($teamId);
     $gid = EasyBlogHelper::getUserGids($userId);
     $isMember = $teamTbl->isMember($userId, $gid);
     if ($teamTbl->allowSubscription($teamTbl->access, $userId, $isMember, $acl->rules->allow_subscription)) {
         $date = EasyBlogHelper::getDate();
         $subscriber = EasyBlogHelper::getTable('TeamSubscription', 'Table');
         $subscriber->team_id = $teamId;
         $subscriber->email = $email;
         if ($userId != '0') {
             $subscriber->user_id = $userId;
         }
         $subscriber->fullname = $fullname;
         $subscriber->created = $date->toMySQL();
         $state = $subscriber->store();
         if ($state) {
             // lets send confirmation email to subscriber.
             $helper = EasyBlogHelper::getHelper('Subscription');
             $template = $helper->getTemplate();
             $template->uid = $subscriber->id;
             $template->utype = 'teamsubscription';
             $template->user_id = $subscriber->user_id;
             $template->uemail = $email;
             $template->ufullname = $fullname;
             $template->ucreated = $subscriber->created;
             $template->targetname = $teamTbl->title;
             $template->targetlink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=teamblog&layout=listings&id=' . $teamId, false, true);
             $helper->addMailQueue($template);
         }
     }
 }
Beispiel #9
0
    private function getUrl(&$article, $context) {

        $uri = "";
        $url = JURI::getInstance();
        $domain= $url->getScheme() ."://" . $url->getHost();
        
        switch($this->currentOption) {
            case "com_content":
            	
            	// It's an implementation of "com_myblog"
            	// I don't know why but $option contains "com_content" for a value
            	// I hope it will be fixed in the future versions of "com_myblog"
            	if(strcmp($context, "com_myblog") != 0) {
                	$uri = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug), false);
                	break;
            	}
            	
            case "com_myblog":
                $uri = $article->permalink;
                break;    
                
                
            case "com_k2":
                $uri = $article->link;
                break;
                
            case "com_virtuemart":
                $uri = $article->link;
                break;
                
            case "com_jevents":
                // Display buttons only in the description
                if (is_a($article, "jIcalEventRepeat")) { 
                    $uri = $this->getCurrentURI($url);
                };
                
                break;

            case "com_easyblog":
            	$uri	= EasyBlogRouter::getRoutedURL( 'index.php?option=com_easyblog&view=entry&id=' . $article->id , false , false );
                break;

            case "com_vipportfolio":
                $uri = JRoute::_($article->link, false);
                break;
                    
            case "com_zoo":
                $uri = $this->getCurrentURI($url);
                break;
                
            case "com_jshopping":
                $uri = $this->getCurrentURI($url);
                break;

            case "com_hikashop":
                $uri = $article->link;
                break;
                
            case "com_vipquotes":
                $uri = $article->link;
                break;
                
            default:
                $uri = "";
                break;   
        }
        
        return $domain.$uri;
        
    }
Beispiel #10
0
 public function submitForm($type, $post)
 {
     $ejax = new Ejax();
     $mainframe = JFactory::getApplication();
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     $acl = EasyBlogACLHelper::getRuleSet();
     $id = isset($post['id']) ? $post['id'] : '';
     if (empty($acl->rules->allow_subscription) && (empty($my->id) && !$config->get('main_allowguestsubscribe'))) {
         $theme = new CodeThemes();
         $theme->set('message', JText::_('COM_EASYBLOG_NO_PERMISSION_TO_SUBSCRIBE_BLOG'));
         $theme->set('type', $type);
         $theme->set('id', $id);
         $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject();
         $ejax->dialog($options);
         return $ejax->send();
     }
     $isModerate = false;
     $userId = isset($post['userid']) ? $post['userid'] : '';
     $email = JString::trim($post['email']);
     //registration
     $register = isset($post['esregister']) ? true : false;
     $fullname = isset($post['esfullname']) ? $post['esfullname'] : '';
     $username = isset($post['esusername']) ? $post['esusername'] : '';
     $newId = '';
     $msg = '';
     if (JString::trim($email) == '') {
         $theme = new CodeThemes();
         $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_EMPTY_ERROR'));
         $theme->set('type', $type);
         $theme->set('id', $id);
         $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject();
         $ejax->dialog($options);
         return $ejax->send();
     } else {
         if (!EasyBlogHelper::getHelper('Email')->isValidInetAddress($email)) {
             $theme = new CodeThemes();
             $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_INVALID_ERROR'));
             $theme->set('type', $type);
             $theme->set('id', $id);
             $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject();
             $ejax->dialog($options);
             return $ejax->send();
         }
     }
     if (JString::trim($fullname) == '') {
         $theme = new CodeThemes();
         $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_NAME_EMPTY_ERROR'));
         $theme->set('type', $type);
         $theme->set('id', $id);
         $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject();
         $ejax->dialog($options);
         return $ejax->send();
     }
     if ($register && $my->id == 0) {
         if (JString::trim($username) == '') {
             $theme = new CodeThemes();
             $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_USERNAME_EMPTY_ERROR'));
             $theme->set('type', $type);
             $theme->set('id', $id);
             $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject();
             $ejax->dialog($options);
             return $ejax->send();
         }
         $registor = EasyBlogHelper::getRegistor();
         $options = array('username' => $username, 'email' => $email);
         $validate = $registor->validate($options);
         if ($validate !== true) {
             $theme = new CodeThemes();
             $theme->set('message', $validate);
             $theme->set('type', $type);
             $theme->set('id', $id);
             $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject();
             $ejax->dialog($options);
             return $ejax->send();
         } else {
             $options['fullname'] = $fullname;
             $newId = $registor->addUser($options);
             if (!is_numeric($newId)) {
                 // registration failed.
                 $msg = $newId;
             } else {
                 $userId = $newId;
             }
         }
     }
     // Real logic operation goes here.
     $method = 'subscribe' . ucfirst($type);
     // @rule: Process mailchimp subscriptions here.
     EasyBlogHelper::getHelper('Mailchimp')->subscribe($email, $fullname);
     if (!$this->{$method}($id, $userId, $email, $fullname)) {
         $theme = new CodeThemes();
         $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_ALREADY_SUBSCRIBED_ERROR'));
         $theme->set('type', $type);
         $theme->set('id', $id);
         $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject();
         $ejax->dialog($options);
         return $ejax->send();
     }
     // message
     if ($register && is_numeric($newId)) {
         $message = JText::sprintf('COM_EASYBLOG_YOU_SUCCESSFULLY_SUBSCRIBED_AND_REGISTERED_AS_MEMBER');
     } else {
         $message = JText::sprintf('COM_EASYBLOG_SUBSCRIPTION_SUBSCRIBED_SUCCESS', $email);
     }
     $theme = new CodeThemes();
     $theme->set('message', $message);
     $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_SUCCESS_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.success.php'))->toObject();
     $ejax->dialog($options);
     // Send email to notify admin upon successful subscriptions
     $user = EasyBlogHelper::getTable('Profile');
     $user->load($userId);
     $date = EasyBlogDateHelper::getDate();
     $subscriberName = $my->id == 0 ? $post['esfullname'] : $user->getName();
     $data = array('title' => JText::_('COM_EASYBLOG_SUBSCRIPTION_SUCCESS_DIALOG_TITLE'), 'subscriber' => $subscriberName, 'subscriberLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $user->id, false, true), 'subscriberAvatar' => $user->getAvatar(), 'subscriberDate' => EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'), 'type' => $type);
     if ($type == 'entry') {
         $data['reviewLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $id, false, true);
     }
     if ($type == 'category') {
         $data['reviewLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $id, false, true);
     }
     $emailTitle = JText::_('COM_EASYBLOG_NEW') . ' ' . JText::_('COM_EASYBLOG_SUBSCRIPTION_TYPE_' . strtoupper($type)) . ' ' . strtolower(JText::_('COM_EASYBLOG_SUBSCRIPTION'));
     $emails = array();
     $notification = EasyBlogHelper::getHelper('Notification');
     $config = EasyBlogHelper::getConfig();
     // @rule: if custom_email_as_admin is enabled, use custom email as admin email
     if ($config->get('custom_email_as_admin')) {
         // @rule: Send to custom email addresses
         $notification->getCustomEmails($emails);
     } else {
         // @rule: Send to administrator's on the site.
         $notification->getAdminEmails($emails);
     }
     $notification->send($emails, $emailTitle, 'email.subscriptions', $data);
     return $ejax->send();
 }
Beispiel #11
0
 /**
  * Shares a story through 3rd party oauth clients
  *
  * @param	TableBlog	$blog	A blog table object
  * @param	string		$type	The type of oauth client
  *
  * @return	boolean		True on success and false otherwise.
  **/
 public function share($blog, $type, $useCentralized = false)
 {
     JTable::addIncludePath(EBLOG_TABLES);
     $oauth = EasyBlogHelper::getTable('Oauth', 'Table');
     $oauths = array();
     $config = EasyBlogHelper::getConfig();
     // @rule: Process centralized notifications, be it a page or an account update
     if ($useCentralized) {
         $userId = $config->get('integrations_' . strtolower($type) . '_centralized_userid');
         $message = $config->get('integrations_' . JString::strtolower($type) . '_centralized_auto_post');
         $auto = $config->get('integrations_' . JString::strtolower($type) . '_centralized_auto_post');
         $oauth->loadByUser($userId, $type);
         // For legacy fix prior to 3.0, we need to set system=1
         if ($oauth->id && !$oauth->system) {
             $oauth->system = 1;
             $oauth->store();
         }
         // @task: Now we try to load the real object
         $oauth->loadSystemByType($type);
         if ($oauth->id) {
             $oauths[] = $oauth;
         }
     } else {
         if ($config->get('integrations_' . JString::strtolower($type) . '_centralized_and_own')) {
             JTable::addIncludePath(EBLOG_TABLES);
             $oauth = EasyBlogHelper::getTable('Oauth', 'Table');
             $oauth->loadByUser($blog->created_by, $type);
             $oauths[] = $oauth;
         }
     }
     $key = $config->get('integrations_' . $type . '_api_key');
     $secret = $config->get('integrations_' . $type . '_secret_key');
     // @rule: Set callback URLs
     $callback = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&controller=oauth&task=grant&type=' . $type, false, true);
     if ($oauths) {
         foreach ($oauths as $oauth) {
             // Skip processing anything that does not have an access token
             if (!$oauth->access_token) {
                 continue;
             }
             $acl = EasyBlogACLHelper::getRuleSet($blog->created_by);
             $rule = 'update_' . $type;
             // @task: If entry is already shared or automatic postings is disabled do not share this entry.
             if ($oauth->isShared($blog->id, $useCentralized) || !$acl->rules->{$rule} && !EasyBlogHelper::isSiteAdmin()) {
                 continue;
             }
             // @rule: Retrieve the consumer object for this oauth client.
             $consumer = EasyBlogOauthHelper::getConsumer($type, $key, $secret, $callback);
             $consumer->setAccess($oauth->access_token);
             if ($consumer->share($blog, $oauth->message, $oauth, $useCentralized)) {
                 // @task: mark this as sent!
                 $oauthPost = EasyBlogHelper::getTable('OauthPost', 'Table');
                 $oauthPost->loadByOauthId($blog->id, $oauth->id);
                 $date = EasyBlogHelper::getDate();
                 $oauthPost->post_id = $blog->id;
                 $oauthPost->oauth_id = $oauth->id;
                 $oauthPost->created = $date->toMySQL();
                 $oauthPost->modified = $date->toMySQL();
                 $oauthPost->sent = $date->toMySQL();
                 $oauthPost->store();
             }
         }
     }
     return true;
 }
Beispiel #12
0
 function addSiteSubscription($email, $userId = '0', $fullname = '')
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EasyBlogACLHelper::getRuleSet();
     $my = JFactory::getUser();
     if ($acl->rules->allow_subscription || empty($my->id) && $config->get('main_allowguestsubscribe')) {
         $date = EasyBlogHelper::getDate();
         $subscription = EasyBlogHelper::getTable('SiteSubscription');
         $subscription->email = $email;
         if ($userId) {
             $subscription->user_id = $userId;
         }
         $subscription->fullname = $fullname;
         $subscription->created = EasyBlogHelper::getDate()->toMySQL();
         $state = $subscription->store();
         if ($state) {
             // lets send confirmation email to subscriber.
             $helper = EasyBlogHelper::getHelper('Subscription');
             $template = $helper->getTemplate();
             $template->uid = $subscription->id;
             $template->utype = 'sitesubscription';
             $template->user_id = $subscription->user_id;
             $template->uemail = $email;
             $template->ufullname = $fullname;
             $template->ucreated = $subscription->created;
             $template->targetname = $config->get('main_title');
             $template->targetlink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=latest', false, true);
             $helper->addMailQueue($template);
         }
         return $state;
     }
 }
Beispiel #13
0
 public function processTrackbacks()
 {
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     if (!class_exists('EasyBlogModelTrackbackSent')) {
         JLoader::import('trackbacksent', EBLOG_ROOT . DIRECTORY_SEPARATOR . 'models');
     }
     $model = JModel::getInstance('TrackbackSent', 'EasyBlogModel');
     // get lists of trackback URLs based on blog ID
     $trackbacks = $model->getSentTrackbacks($this->id, true);
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'trackback.php';
     require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php';
     if (!$trackbacks) {
         return false;
     }
     foreach ($trackbacks as $trackback) {
         $author = EasyBlogHelper::getTable('Profile');
         $author->load($this->created_by);
         $tb = new EasyBlogTrackBack($author->getName(), $author->getName(), 'UTF-8');
         $text = empty($this->intro) ? $this->content : $this->intro;
         $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $this->id, false, true);
         if ($tb->ping($trackback->url, $url, $this->title, $text)) {
             $table = EasyBlogHelper::getTable('TrackbackSent');
             $table->load($trackback->id);
             $table->markSent();
         }
     }
     return true;
 }
Beispiel #14
0
 public function getCategoryLink($blog)
 {
     return EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $blog->category_id . $this->getItemId(), false, true);
 }
Beispiel #15
0
		</h3>

			<b><?php 
        echo $this->formatDate('%b %d %Y', $post->created);
        ?>
</b> -
			<?php 
        echo $post->content;
        ?>
...
			<br />
		<a href="<?php 
        echo EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $post->id);
        ?>
"  class="search-permalink"><?php 
        echo EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $post->id, false, true);
        ?>
</a>
	</li>
	<?php 
    }
    ?>
</ul>

<?php 
    if ($pagination->getPagesLinks()) {
        ?>
<div class="eblog-pagination"><?php 
        echo $pagination->getPagesLinks();
        ?>
</div>
Beispiel #16
0
 /**
  * Shares a new content on Facebook
  **/
 public function share($blog, $message = '', $oauth, $useSystem = false)
 {
     $config = EasyBlogHelper::getConfig();
     $source = $config->get('integrations_facebook_source');
     $content = isset($blog->{$source}) && !empty($blog->{$source}) ? $blog->{$source} : $blog->intro . $blog->content;
     $content = EasyBlogHelper::getHelper('Videos')->strip($content);
     $image = '';
     // @rule: Ensure that only public posts are allowed
     if ($blog->private != 0) {
         return false;
     }
     // @rule: Try to get the blog image.
     if ($blog->getImage()) {
         $image = $blog->getImage()->getSource('frontpage');
     }
     if (empty($image)) {
         // @rule: Match images from blog post
         $pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i';
         preg_match($pattern, $content, $matches);
         $image = '';
         if ($matches) {
             $image = isset($matches[1]) ? $matches[1] : '';
             if (JString::stristr($matches[1], 'https://') === false && JString::stristr($matches[1], 'http://') === false && !empty($image)) {
                 $image = rtrim(JURI::root(), '/') . '/' . ltrim($image, '/');
             }
         }
     }
     $maxContentLen = $config->get('integrations_facebook_blogs_length');
     $text = strip_tags($content);
     if (!empty($maxContentLen)) {
         $text = JString::strlen($text) > $maxContentLen ? JString::substr($text, 0, $maxContentLen) . '...' : $text;
     }
     $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
     // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
     $sh404exists = EasyBlogRouter::isSh404Enabled();
     $mainframe = JFactory::getApplication();
     if ($mainframe->isAdmin() && $sh404exists) {
         $url = rtrim(JURI::root(), '/') . '/index.php?option=com_easyblog&view=entry&id=' . $blog->id;
     }
     preg_match('/expires=(.*)/i', $this->_access_token, $expires);
     if (isset($expires[1])) {
         $this->_access_token = str_ireplace('&expires=' . $expires[1], '', $this->_access_token);
     }
     // Remove adsense codes
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php';
     $text = EasyBlogGoogleAdsense::stripAdsenseCode($text);
     $jConfig = EasyBlogHelper::getJConfig();
     $params = array('link' => $url, 'name' => $blog->title, 'description' => $text, 'message' => $blog->title, 'access_token' => $this->_access_token);
     if (empty($image)) {
         $params['picture'] = rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/images/default_facebook.png';
         $params['source'] = rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/images/default_facebook.png';
     } else {
         $params['picture'] = $image;
         $params['source'] = $image;
     }
     // @rule: For system messages, we need to see if there's any pages associated.
     if ($oauth->system && $useSystem) {
         if ($config->get('integrations_facebook_impersonate_page') || $config->get('integrations_facebook_impersonate_group')) {
             if ($config->get('integrations_facebook_impersonate_page')) {
                 $pages = JString::trim($config->get('integrations_facebook_page_id'));
                 $pages = explode(',', $pages);
                 $total = count($pages);
                 // @rule: Test if there are any pages at all the user can access
                 $accounts = parent::api('/me/accounts', array('access_token' => $this->_access_token));
                 if (is_array($accounts) && isset($accounts['data'])) {
                     for ($i = 0; $i < $total; $i++) {
                         foreach ($accounts['data'] as $page) {
                             if ($page['id'] == $pages[$i]) {
                                 $params['access_token'] = $page['access_token'];
                                 $query = parent::api('/' . $page['id'] . '/feed', 'post', $params);
                             }
                         }
                     }
                 }
             }
             if ($config->get('integrations_facebook_impersonate_group')) {
                 $groupsId = JString::trim($config->get('integrations_facebook_group_id'));
                 $groupsId = explode(',', $groupsId);
                 $total = count($groupsId);
                 // @rule: Test if there are any groups at all the user can access
                 $accounts = parent::api('/me/groups', 'GET', array('access_token' => $this->_access_token));
                 $params['access_token'] = $this->_access_token;
                 if (is_array($accounts) && isset($accounts['data'])) {
                     for ($i = 0; $i < $total; $i++) {
                         foreach ($accounts['data'] as $group) {
                             if ($group['id'] == $groupsId[$i]) {
                                 $query = parent::api('/' . $group['id'] . '/feed', 'post', $params);
                             }
                         }
                     }
                 }
             }
         } else {
             // @rule: If this is just a normal posting, just post it on their page.
             $query = parent::api('/me/feed', 'post', $params);
         }
     } else {
         // @rule: If this is just a normal posting, just post it on their page.
         $query = parent::api('/me/feed', 'post', $params);
     }
     $success = isset($query['id']) ? true : false;
     return $success;
 }
 private function getUrl(&$article)
 {
     $url = JURI::getInstance();
     $domain = $url->getScheme() . "://" . $url->getHost();
     $uri = "";
     switch ($this->currentOption) {
         case "com_content":
             if (strcmp("categories", $this->currentView) == 0) {
                 $uri = JRoute::_(ContentHelperRoute::getCategoryRoute($article->slug, $article->language), false);
             } else {
                 $uri = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->language), false);
             }
             break;
         case "com_k2":
             $uri = $article->link;
             break;
         case "com_virtuemart":
             $uri = $article->link;
             break;
         case "com_jevents":
             // Display buttons only in the description
             if (is_a($article, "jIcalEventRepeat")) {
                 $uri = $this->getCurrentURI($url);
             }
             break;
         case "com_easyblog":
             $uri = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $article->id, false, false);
             break;
         case "com_vipportfolio":
             $uri = JRoute::_($article->link, false);
             break;
         case "com_zoo":
             $uri = $this->getCurrentURI($url);
             break;
         case "com_jshopping":
             $uri = $this->getCurrentURI($url);
             break;
         case "com_hikashop":
             $uri = $article->link;
             break;
         case "com_vipquotes":
             $uri = $article->link;
             break;
         case "com_userideas":
             $uri = JRoute::_($article->link, false);
             break;
         default:
             $uri = "";
             break;
     }
     // Filter the URL
     $filter = JFilterInput::getInstance();
     return $filter->clean($domain . $uri);
 }
Beispiel #18
0
 function preview()
 {
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $mainframe = JFactory::getApplication();
     $acl = EasyBlogACLHelper::getRuleSet();
     $config = EasyBlogHelper::getConfig();
     $document = JFactory::getDocument();
     $my = JFactory::getUser();
     $params = $mainframe->getParams('com_easyblog');
     if (!EasyBlogHelper::isLoggedIn()) {
         EasyBlogHelper::showLogin();
         return;
     }
     $draftId = JRequest::getVar('draftid', '');
     $draft = EasyBlogHelper::getTable('Draft', 'Table');
     $draft->load($draftId);
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->bind($draft);
     $blogger = null;
     if ($blog->created_by != 0) {
         $blogger = EasyBlogHelper::getTable('Profile', 'Table');
         $blogger->load($blog->created_by);
     }
     // @rule: Set the author object into the table.
     $blog->author = $blogger;
     $blog->blogger = $blogger;
     $blogId = empty($draft->entry_id) ? $draft->id : $draft->entry_id;
     $limitstart = '0';
     $notice = '';
     $team = '';
     $blog->tags = empty($draft->tags) ? array() : $this->bindTags(explode(',', $draft->tags));
     // metas
     $meta = new stdClass();
     $meta->id = '';
     $meta->keywords = $draft->metakey;
     $meta->description = $draft->metadesc;
     $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title'));
     $document->setTitle($blog->title . $pageTitle);
     // process the video here if nessary
     $blog->intro = EasyBlogHelper::getHelper('Videos')->processVideos($blog->intro);
     $blog->content = EasyBlogHelper::getHelper('Videos')->processVideos($blog->content);
     // @rule: Process audio files.
     $blog->intro = EasyBlogHelper::getHelper('Audio')->process($blog->intro);
     $blog->content = EasyBlogHelper::getHelper('Audio')->process($blog->content);
     // @rule: Before any trigger happens, try to replace the gallery first and append it at the bottom.
     $blog->intro = EasyBlogHelper::getHelper('Gallery')->process($blog->intro, $blog->created_by);
     $blog->content = EasyBlogHelper::getHelper('Gallery')->process($blog->content, $blog->created_by);
     // Process jomsocial album's.
     $blog->intro = EasyBlogHelper::getHelper('Album')->process($blog->intro, $blog->created_by);
     $blog->content = EasyBlogHelper::getHelper('Album')->process($blog->content, $blog->created_by);
     // @trigger: onEasyBlogPrepareContent
     EasyBlogHelper::triggerEvent('easyblog.prepareContent', $blog, $params, $limitstart);
     //onPrepareContent trigger start
     $blog->introtext = $blog->intro;
     $blog->text = $blog->intro . $blog->content;
     // @trigger: onEasyBlogPrepareContent
     EasyBlogHelper::triggerEvent('prepareContent', $blog, $params, $limitstart);
     $blog->intro = $blog->introtext;
     $blog->content = $blog->text;
     $isFeatured = false;
     //page setup
     $blogHtml = '';
     $commentHtml = '';
     $blogHeader = '';
     $blogFooter = '';
     $adsenseHtml = '';
     $trackbackHtml = '';
     $blogger = null;
     if ($blog->created_by != 0) {
         $blogger = EasyBlogHelper::getTable('Profile', 'Table');
         $blogger->load($blog->created_by);
     }
     //onAfterDisplayTitle, onBeforeDisplayContent, onAfterDisplayContent trigger start
     $blog->event = new stdClass();
     // @trigger: onAfterDisplayTitle / onContentAfterTitle
     $results = EasyBlogHelper::triggerEvent('afterDisplayTitle', $blog, $params, $limitstart);
     $blog->event->afterDisplayTitle = JString::trim(implode("\n", $results));
     // @trigger: onBeforeDisplayContent / onContentBeforeDisplay
     $results = EasyBlogHelper::triggerEvent('beforeDisplayContent', $blog, $params, $limitstart);
     $blog->event->beforeDisplayContent = JString::trim(implode("\n", $results));
     // @trigger: onAfterDisplayContent / onContentAfterDisplay
     EasyBlogHelper::triggerEvent('afterDisplayContent', $blog, $params, $limitstart);
     $blog->event->afterDisplayContent = JString::trim(implode("\n", $results));
     if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id)) {
         $this->setPathway($blogger->getName(), $blogger->getLink());
     }
     if (!EasyBlogRouter::isCurrentActiveMenu('entry', $blog->id)) {
         $this->setPathway($blog->title, '');
     }
     $blog->totalComments = 0;
     // Facebook Like integrations
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'facebook.php';
     $facebookLike = EasyBlogFacebookLikes::getLikeHTML($blog);
     $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
     //get blog navigation object
     $blogNav = EasyBlogHelper::getBlogNavigation($blog->id, $blog->created, $team, 'team');
     //$team
     $prevLink = array();
     if (!empty($blogNav['prev'])) {
         $prevLink['id'] = $blogNav['prev'][0]->id;
         $prevLink['title'] = JString::strlen($blogNav['prev'][0]->title) > 50 ? JString::substr($blogNav['prev'][0]->title, 0, 50) . '...' : $blogNav['prev'][0]->title;
     }
     $nextLink = array();
     if (!empty($blogNav['next'])) {
         $nextLink['id'] = $blogNav['next'][0]->id;
         $nextLink['title'] = JString::strlen($blogNav['next'][0]->title) > 50 ? JString::substr($blogNav['next'][0]->title, 0, 50) . '...' : $blogNav['next'][0]->title;
     }
     // @rule: Hide introtext if necessary
     if ($config->get('main_hideintro_entryview')) {
         $blog->intro = '';
     }
     //get social bookmark provider.
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'bookmark.php';
     $bookmark = EasyBlogBookmark::getHTML();
     $theme = new CodeThemes();
     $theme->set('facebookLike', $facebookLike);
     $theme->set('notice', $notice);
     $theme->set('blog', $blog);
     $theme->set('tags', $blog->tags);
     $theme->set('blogger', $blogger);
     $theme->set('prevLink', $prevLink);
     $theme->set('nextLink', $nextLink);
     $theme->set('blogRelatedPost', '');
     $theme->set('isFeatured', $isFeatured);
     $theme->set('isMineBlog', true);
     $theme->set('acl', $acl);
     $theme->set('url', $url);
     $theme->set('commentHTML', $commentHtml);
     $theme->set('bookmark', $bookmark);
     $theme->set('pdfLinkProperties', EasyBlogHelper::getPDFlinkProperties());
     $theme->set('ispreview', true);
     // @task: trackbacks
     $trackbacks = '';
     $theme->set('trackbackURL', EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=trackback&post_id=' . $blog->id, true, true));
     $theme->set('trackbacks', $trackbacks);
     //google adsense
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php';
     $adsense = EasyBlogGoogleAdsense::getHTML($blogger->id);
     $blogHeader = $adsense->header;
     $blogFooter = $adsense->footer;
     $theme->set('adsenseHTML', $adsense->beforecomments);
     $blogHtml = $theme->fetch('blog.read.php');
     echo $blogHeader;
     echo $blogHtml;
     echo $blogFooter;
 }
Beispiel #19
0
 function getPost($postid, $username, $password)
 {
     global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;
     EasyBlogXMLRPCHelper::loginUser($username, $password);
     $my = JFactory::getUser($username);
     $acl = EasyBlogACLHelper::getRuleSet($my->id);
     if (empty($acl->rules->add_entry)) {
         return new xmlrpcresp(0, $xmlrpcerruser + 2, JText::_('ACCESS DENIED'));
     }
     jimport('joomla.application.component.model');
     // JTable::addIncludePath( JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'tables' );
     // JModel::addIncludePath( JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'models' );
     // create a new blog jtable object
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($postid);
     if (empty($blog->title)) {
         return new xmlrpcresp(0, $xmlrpcerruser + 1, JText::_('Blog post not found.'));
     }
     $catId = empty($blog->category_id) ? '1' : $blog->category_id;
     $category = EasyBlogHelper::getTable('Category', 'Table');
     $category->load($catId);
     //publishing
     $publish = 'publish';
     switch ($blog->published) {
         case 1:
             $publish = 'publish';
             break;
         case 3:
             $publish = 'draft';
             break;
         case 2:
         default:
             $publish = 'pending';
     }
     //tags /* to do */
     $modelPT = EasyBlogHelper::getModel('PostTag');
     $blogTags = $modelPT->getBlogTags($blog->id);
     $arrBlogTags = array();
     $tagnames = '';
     if (!empty($blogTags)) {
         foreach ($blogTags as $bt) {
             $arrBlogTags[] = $bt->title;
         }
         $tagnames = implode(',', $arrBlogTags);
     }
     $tagnames = array(new xmlrpcval($tagnames, $xmlrpcString));
     $tzoffset = EasyBlogDateHelper::getOffSet();
     $dateCreated = EasyBlogHelper::getDate($blog->created, $tzoffset);
     $postURL = 'index.php?option=com_easyblog&view=entry&id=' . $blog->id;
     $articleLink = EasyBlogRouter::getRoutedURL($postURL, false, true);
     $struct = new xmlrpcval(array('link' => new xmlrpcval($articleLink), 'permaLink' => new xmlrpcval($articleLink), 'userid' => new xmlrpcval($my->id), 'title' => new xmlrpcval($blog->title), 'description' => new xmlrpcval($blog->intro), 'more_text' => new xmlrpcval($blog->content), 'mt_text_more' => new xmlrpcval($blog->content), 'dateCreated' => new xmlrpcval($dateCreated->toISO8601(), 'dateTime.iso8601'), 'categories' => new xmlrpcval(array(new xmlrpcval($category->title)), $xmlrpcArray), 'mt_excerpt' => new xmlrpcval($blog->intro), 'mt_text_more' => new xmlrpcval($blog->content), 'mt_allow_comments' => new xmlrpcval($blog->allowcomment), 'mt_allow_pings' => new xmlrpcval('0'), 'mt_keywords' => new xmlrpcval($tagnames, $xmlrpcArray), 'post_status' => new xmlrpcval($publish), 'postid' => new xmlrpcval($blog->id), 'date_created_gmt' => new xmlrpcval($dateCreated->toISO8601()), 'wp_slug' => new xmlrpcval($blog->permalink)), $xmlrpcStruct);
     return new xmlrpcresp($struct);
 }
Beispiel #20
0
 function addCategorySubscription($categoryId, $email, $userId = '0', $fullname = '')
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EasyBlogACLHelper::getRuleSet();
     $my = JFactory::getUser();
     if ($acl->rules->allow_subscription || empty($my->id) && $config->get('main_allowguestsubscribe')) {
         $date = EasyBlogHelper::getDate();
         $subscriber = EasyBlogHelper::getTable('CategorySubscription', 'Table');
         $subscriber->category_id = $categoryId;
         $subscriber->email = $email;
         if ($userId != '0') {
             $subscriber->user_id = $userId;
         }
         $subscriber->fullname = $fullname;
         $subscriber->created = $date->toMySQL();
         $state = $subscriber->store();
         if ($state) {
             $category = EasyBlogHelper::getTable('Category', 'Table');
             $category->load($categoryId);
             // lets send confirmation email to subscriber.
             $helper = EasyBlogHelper::getHelper('Subscription');
             $template = $helper->getTemplate();
             $template->uid = $subscriber->id;
             $template->utype = 'categorysubscription';
             $template->user_id = $subscriber->user_id;
             $template->uemail = $email;
             $template->ufullname = $fullname;
             $template->ucreated = $subscriber->created;
             $template->targetname = $category->title;
             $template->targetlink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $categoryId, false, true);
             $helper->addMailQueue($template);
         }
         return $state;
     }
 }
Beispiel #21
0
</th>
		<?php 
}
?>
	</tr>
</thead>
<tbody>
<?php 
if ($this->blogs) {
    $k = 0;
    $x = 0;
    $config = JFactory::getConfig();
    for ($i = 0, $n = count($this->blogs); $i < $n; $i++) {
        $row = $this->blogs[$i];
        $user = JFactory::getUser($row->created_by);
        $previewLink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $row->id, true, true);
        $preview = '<a href="' . $previewLink . '" target="_blank"><img src="' . JURI::base() . '/images/preview_f2.png"/ style="width:20px; height:20px; "></a>';
        $editLink = JRoute::_('index.php?option=com_easyblog&c=blogs&task=edit&blogid=' . $row->id);
        $published = JHTML::_('grid.published', $row, $i);
        $date = EasyBlogDateHelper::getDate($row->created);
        $extGroupName = '';
        if (!empty($row->external_group_id)) {
            $blog_contribute_source = EasyBlogHelper::getHelper('Groups')->getGroupSourceType();
            $extGroupName = EasyBlogHelper::getHelper('Groups')->getGroupContribution($row->id, $blog_contribute_source, 'name');
            $extGroupName = $extGroupName . ' (' . ucfirst($blog_contribute_source) . ')';
        }
        if (!empty($row->external_event_id)) {
            $blog_contribute_source = EasyBlogHelper::getHelper('Event')->getSourceType();
            $extEventName = EasyBlogHelper::getHelper('Event')->getContribution($row->id, $blog_contribute_source, 'name');
            $extEventName = $extEventName . ' (' . ucfirst($blog_contribute_source) . ')';
        }
Beispiel #22
0
 public function store($updateNulls = false)
 {
     $state = parent::store();
     // @rule: Process notifications for admins when the blog post is pending approvals
     if ($this->pending_approval) {
         $user = EasyBlogHelper::getTable('Profile');
         $user->load($this->created_by);
         $date = EasyBlogDateHelper::dateWithOffSet($this->created);
         $data = array('blogTitle' => $this->title, 'blogAuthor' => $user->getName(), 'blogAuthorLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $user->id, false, true), 'blogIntro' => $this->intro, 'blogContent' => $this->content, 'blogAuthorAvatar' => $user->getAvatar(), 'blogDate' => EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'), 'reviewLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=dashboard&layout=pending&draft_id=' . $this->id, false, true));
         // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
         $sh404exists = EasyBlogRouter::isSh404Enabled();
         if (JFactory::getApplication()->isAdmin() && $sh404exists) {
             $data['blogAuthorLink'] = JURI::root() . 'index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $user->id;
             $data['reviewLink'] = JURI::root() . 'index.php?option=com_easyblog&view=dashboard&layout=pending&draft_id' . $this->id;
         }
         $emailTitle = JText::_('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_PENDING_REVIEW');
         $emails = array();
         $notification = EasyBlogHelper::getHelper('Notification');
         $config = EasyBlogHelper::getConfig();
         // @rule: if custom_email_as_admin is enabled, use custom email as admin email
         if ($config->get('custom_email_as_admin')) {
             // @rule: Send to custom email addresses
             $notification->getCustomEmails($emails);
         } else {
             // @rule: Send to administrator's on the site.
             $notification->getAdminEmails($emails);
         }
         $notification->send($emails, $emailTitle, 'email.blog.review', $data);
     }
     return $state;
 }
Beispiel #23
0
 function addBlogSubscription($blogId, $email, $userId = '0', $fullname = '')
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EB::acl();
     $my = JFactory::getUser();
     if ($acl->get('allow_subscription') || empty($my->id) && $config->get('main_allowguestsubscribe')) {
         $date = EB::date();
         $subscriber = EB::table('Subscriptions');
         $subscriber->uid = $blogId;
         $subscriber->utype = EBLOG_SUBSCRIPTION_ENTRY;
         $subscriber->email = $email;
         if ($userId != '0') {
             $subscriber->user_id = $userId;
         }
         $subscriber->fullname = $fullname;
         $subscriber->created = $date->toMySQL();
         $state = $subscriber->store();
         if ($state) {
             $blog = EB::table('Blog');
             $blog->load($blogId);
             // lets send confirmation email to subscriber.
             $helper = EasyBlogHelper::getHelper('Subscription');
             $template = $helper->getTemplate();
             $template->uid = $subscriber->id;
             $template->utype = 'subscription';
             $template->user_id = $subscriber->user_id;
             $template->uemail = $email;
             $template->ufullname = $fullname;
             $template->ucreated = $subscriber->created;
             $template->targetname = $blog->title;
             $template->targetlink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blogId, false, true);
             if ($blog->created_by != $subscriber->user_id) {
                 $helper->addMailQueue($template);
             }
         }
         return $state;
     }
     return false;
 }
Beispiel #24
0
 function addBloggerSubscription($bloggerId, $email, $userId = '0', $fullname = '')
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EB::acl();
     $my = JFactory::getUser();
     if ($acl->get('allow_subscription') || empty($my->id) && $config->get('main_allowguestsubscribe')) {
         $date = EB::date();
         $subscriber = EB::table('Subscriptions');
         $subscriber->uid = $bloggerId;
         $subscriber->utype = EBLOG_SUBSCRIPTION_BLOGGER;
         $subscriber->email = $email;
         if ($userId != '0') {
             $subscriber->user_id = $userId;
         }
         $subscriber->fullname = $fullname;
         $subscriber->created = $date->toMySQL();
         $state = $subscriber->store();
         if ($state) {
             $profile = EB::user($bloggerId);
             // lets send confirmation email to subscriber.
             $helper = EB::subscription();
             $template = $helper->getTemplate();
             $template->uid = $subscriber->id;
             $template->utype = 'bloggersubscription';
             $template->user_id = $subscriber->user_id;
             $template->uemail = $email;
             $template->ufullname = $fullname;
             $template->ucreated = $subscriber->created;
             $template->targetname = $profile->getName();
             $template->targetlink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $bloggerId, false, true);
             $helper->addMailQueue($template);
         }
     }
 }
Beispiel #25
0
 private function _getDataURL()
 {
     $dataURL = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $this->blog->id, false, true);
     return $dataURL;
 }
Beispiel #26
0
 public static function getUnsubscribeLink($subdata, $external = false)
 {
     $easyblogItemId = EasyBlogRouter::getItemId('latest');
     $unsubdata = base64_encode("type=" . $subdata->type . "\r\nsid=" . $subdata->id . "\r\nuid=" . $subdata->user_id . "\r\ntoken=" . md5($subdata->id . $subdata->created));
     return EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&controller=subscription&task=unsubscribe&data=' . $unsubdata . '&Itemid=' . $easyblogItemId, false, $external);
 }
					<td class="center">
						<?php 
        echo $this->getPostCount($row->id);
        ?>
					</td>

					<td class="center">
						<?php 
        echo $row->id;
        ?>
					</td>

					<td class="center">
						<a href="<?php 
        echo EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $row->id, true, true);
        ?>
" target="_blank" class="preview"><?php 
        echo JText::_('COM_EASYBLOG_PREVIEW');
        ?>
</a>
					</td>
				</tr>
				<?php 
    }
    ?>

			<?php 
} else {
    ?>
			<?php 
Beispiel #28
0
 /**
  * Process message
  **/
 function processMessage($MsgTemplate, $blog)
 {
     $config = EasyBlogHelper::getConfig();
     $message = empty($MsgTemplate) ? $config->get('main_twitter_message') : $MsgTemplate;
     $search = array();
     $replace = array();
     //replace title
     if (preg_match_all("/.*?(\\{title\\})/is", $message, $matches)) {
         $search[] = '{title}';
         $replace[] = $blog->title;
     }
     //replace title
     if (preg_match_all("/.*?(\\{introtext\\})/is", $message, $matches)) {
         $introtext = empty($blog->intro) ? '' : strip_tags($blog->intro);
         $search[] = '{introtext}';
         $replace[] = $introtext;
     }
     //replace category
     if (preg_match_all("/.*?(\\{category\\})/is", $message, $matches)) {
         $category = EasyBlogHelper::getTable('Category', 'Table');
         $category->load($blog->category_id);
         $search[] = '{category}';
         $replace[] = $category->title;
     }
     $message = JString::str_ireplace($search, $replace, $message);
     //replace link
     if (preg_match_all("/.*?(\\{link\\})/is", $message, $matches)) {
         // @task: Twitter now has auto shorten URL so the link will have a max of 20 chars which leaves us to a balance of 120 chars.
         $linkLength = 20;
         $link = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
         // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
         $mainframe = JFactory::getApplication();
         $sh404exists = EasyBlogRouter::isSh404Enabled();
         if ($mainframe->isAdmin() && $sh404exists) {
             $link = rtrim(JURI::root(), '/') . '/index.php?option=com_easyblog&view=entry&id=' . $blog->id;
         }
         if ($config->get('main_twitter_shorten_url')) {
             $shortenerLogin = $config->get('main_twitter_urlshortener_login');
             $shortenerApiKey = $config->get('main_twitter_urlshortener_apikey');
             if (!empty($shortenerLogin) && !empty($shortenerApiKey)) {
                 require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'urlshortener.php';
                 $urlshortener = new EasyBlogURLShortenerHelper();
                 $result = $urlshortener->get_short_url($shortenerLogin, $shortenerApiKey, $link, 'bitly');
                 if (!empty($result)) {
                     $link = $result;
                     $linkLength = strlen($link);
                 }
             }
         }
         // @task: Get the remaining length that we can use.
         $remainingLength = 140 - 3 - $linkLength;
         //split the message
         $tempMsg = explode('{link}', $message);
         for ($i = 0; $i < count($tempMsg); $i++) {
             $temp =& $tempMsg[$i];
             $tempLength = strlen($temp);
             if ($tempLength > $remainingLength) {
                 if ($remainingLength <= 0) {
                     $temp = JString::substr($temp, 0, 0);
                 } else {
                     if ($remainingLength < 6) {
                         $temp = JString::substr($temp, 0, $remainingLength);
                     } else {
                         $temp = JString::substr($temp, 0, $remainingLength - 3);
                         $temp .= '.. ';
                     }
                     $remainingLength = 0;
                 }
             } else {
                 $remainingLength -= $tempLength;
             }
         }
         $message = implode($link, $tempMsg);
     } else {
         $message = JString::substr($message, 0, 136) . '...';
     }
     // since we know now twitter has it own shortener, we no longer
     // need to substr as the above algorithm already taken care the
     // lenght of the message ( excluded link length )
     // so we just need to pass the processed message together with the full url link.
     return $message;
     // return JString::substr($message, 0, 140);
 }
Beispiel #29
0
 function listings()
 {
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $acl = EasyBlogACLHelper::getRuleSet();
     $sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
     $bId = JRequest::getCmd('id', '0');
     $blogger = EasyBlogHelper::getTable('Profile', 'Table');
     $blogger->load($bId);
     if (!$config->get('main_nonblogger_profile')) {
         if (!EasyBlogHelper::isBlogger($blogger->id)) {
             $redirect = EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false);
             $mainframe->redirect($redirect);
             $mainframe->close();
         }
     }
     // If blogger does not exist, redirect
     if (!$blogger->id) {
         $redirect = EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false);
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     if ($acl->rules->allow_seo) {
         EasyBlogHelper::setMeta($blogger->id, META_TYPE_BLOGGER, true);
     }
     if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id)) {
         if (!EasyBlogRouter::isCurrentActiveMenu('blogger')) {
             $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger'));
         }
         $this->setPathway($blogger->getName());
     }
     $model = $this->getModel('Blog');
     $data = $model->getBlogsBy('blogger', $blogger->id, $sort);
     $pagination = $model->getPagination();
     $data = EasyBlogHelper::formatBlog($data, false, true, true, true);
     $rssURL = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&task=rss');
     // @task: Add canonical URLs.
     if ($config->get('main_canonical_entry')) {
         $canonicalUrl = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $blogger->id, false, true, true);
         $document->addCustomTag('<link rel="canonical" href="' . $canonicalUrl . '"/>');
     }
     if ($config->get('layout_showcomment', false)) {
         for ($i = 0; $i < count($data); $i++) {
             $row =& $data[$i];
             $maxComment = $config->get('layout_showcommentcount', 3);
             $comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc');
             $comments = EasyBlogHelper::formatBlogCommentsLite($comments);
             $row->comments = $comments;
         }
     }
     if ($config->get('main_rss')) {
         if ($config->get('main_feedburner') && $config->get('main_feedburnerblogger')) {
             $document->addHeadLink(EasyBlogHelper::getHelper('String')->escape($blogger->getRSS()), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         } else {
             // Add rss feed link
             $document->addHeadLink($blogger->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
             $document->addHeadLink($blogger->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
         }
     }
     $title = EasyBlogHelper::getPageTitle($blogger->getName());
     // @task: Set the page title
     parent::setPageTitle($title, $pagination, $config->get('main_pagetitle_autoappend'));
     $theme = new CodeThemes();
     $theme->set('twitterLink', $blogger->getTwitterLink());
     $theme->set('blogger', $blogger);
     $theme->set('sort', $sort);
     $theme->set('blogs', $data);
     $theme->set('pagination', $pagination->getPagesLinks());
     $theme->set('my', $my);
     $theme->set('acl', $acl);
     $theme->set('currentURL', $blogger->getProfileLink());
     $theme->set('showAvatar', false);
     echo $theme->fetch('blog.blogger.php');
     echo EasyBlogHelper::getFBInitScript();
 }
Beispiel #30
0
 /**
  * Allows caller to add like on a comment
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public static function like($id, $userId = null)
 {
     $config = EasyBlogHelper::getConfig();
     $user = JFactory::getUser($userId);
     $userId = $user->id;
     $date = EB::date();
     $likes = EB::table('Likes');
     // Check if the likes already exists
     $state = $likes->load(array('type' => 'comment', 'content_id' => $id, 'created_by' => $userId));
     if ($state) {
         return false;
     }
     $likes->type = 'comment';
     $likes->content_id = $id;
     $likes->created_by = $userId;
     $likes->created = $date->toSql();
     $likes->store();
     // @rule: Send notification to comment authors.
     if ($config->get('notification_commentlike')) {
         //send notification to comment's author
         $likeActor = EB::user($userId);
         $model = EB::model('Comment');
         $notification = EasyBlogHelper::getHelper('Notification');
         $commentObj = $model->getComment($id);
         $commentAuthor = JFactory::getUser($commentObj->created_by);
         $obj = new stdClass();
         $obj->unsubscribe = false;
         $obj->email = $commentAuthor->email;
         $emails[$commentAuthor->email] = $obj;
         $data = array('commentLikedActor' => $likeActor->getName(), 'commentContent' => $commentObj->comment, 'commentLikedActorAvatar' => $likeActor->getAvatar(), 'commentDate' => $date->toSql(), 'commentLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $commentObj->post_id, false, true) . '#comment-' . $id);
         $notification->send($emails, JText::_('COM_EASYBLOG_NOTIFICATION_NEW_LIKE'), 'email.comment.like', $data);
     }
     return $likes;
 }