当前位置: 首页>>代码示例>>PHP>>正文


PHP DiscussRouter::getRoutedUrl方法代码示例

本文整理汇总了PHP中DiscussRouter::getRoutedUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussRouter::getRoutedUrl方法的具体用法?PHP DiscussRouter::getRoutedUrl怎么用?PHP DiscussRouter::getRoutedUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DiscussRouter的用法示例。


在下文中一共展示了DiscussRouter::getRoutedUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: autopost

 /**
  * Sends an auto post request to social networks such as Facebook, Twitter etc.
  *
  * @since	3.0
  * @access	public
  * @param	null
  * @return	boolean	True if success, false otherwise.
  */
 public function autopost()
 {
     // Only allow post that are really published.
     if (!$this->published) {
         return false;
     }
     $category = DiscussHelper::getTable('Category');
     $category->load($this->category_id);
     // Only allow post that are posted in a public category.
     if (!$category->canPublicAccess()) {
         return false;
     }
     $config = DiscussHelper::getConfig();
     // Set generic callback URL.
     $callback = DiscussRouter::getRoutedUrl('index.php?option=com_easydiscuss&view=post&id=' . $this->id, false, true);
     // These are the default social sites which we need to ping.
     $sites = array('facebook', 'twitter');
     foreach ($sites as $site) {
         if ($config->get('main_autopost_' . $site)) {
             $oauth = DiscussHelper::getTable('OAuth');
             $state = $oauth->loadByType($site);
             // Determine if this discussion is already shared on the social site.
             $oauthPost = DiscussHelper::getTable('OauthPosts');
             $shared = $oauthPost->exists($this->id, $oauth->id);
             if (!$shared && $state && !empty($oauth->access_token)) {
                 $consumer = DiscussHelper::getHelper('OAuth')->getConsumer($site, $config->get('main_autopost_' . $site . '_id'), $config->get('main_autopost_' . $site . '_secret'), $callback);
                 // Set access token for the social site.
                 $consumer->setAccess($oauth->access_token);
                 // Try to share the post to the site.
                 $status = $consumer->share($this);
                 // @TODO: Add error logging when something fail here.
                 // When the psot is shared we need to keep a record of this to prevent from sending duplicate updates.
                 $oauthPost->post_id = $this->id;
                 $oauthPost->oauth_id = $oauth->id;
                 $oauthPost->store();
             }
         }
     }
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:47,代码来源:post.php

示例2: publish

 function publish()
 {
     $config = DiscussHelper::getConfig();
     $post = JRequest::getVar('cid', array(0), 'POST');
     $pid = JRequest::getString('pid', '', 'POST');
     $message = '';
     $type = 'message';
     if (count($post) <= 0) {
         $message = JText::_('COM_EASYDISCUSS_INVALID_POST_ID');
         $type = 'error';
     } else {
         //send notification:
         //so we are publising posts.
         foreach ($post as $postId) {
             $item = JTable::getInstance('posts', 'Discuss');
             $item->load($postId);
             if ($item->published == DISCUSS_ID_PENDING) {
                 $callback = DiscussRouter::getRoutedUrl('index.php?option=com_easydiscuss&view=post&id=' . $item->id, false, true);
                 $sites = array('facebook', 'twitter');
                 foreach ($sites as $site) {
                     if ($config->get('main_autopost_' . $site)) {
                         $oauth = DiscussHelper::getTable('Oauth');
                         $exists = $oauth->loadByType($site);
                         $oauthPost = DiscussHelper::getTable('OauthPosts');
                         if ($exists && !empty($oauth->access_token) && !$oauthPost->exists($item->id, $oauth->id)) {
                             $consumer = DiscussHelper::getHelper('OAuth')->getConsumer($site, $config->get('main_autopost_' . $site . '_id'), $config->get('main_autopost_' . $site . '_secret'), $callback);
                             $consumer->setAccess($oauth->access_token);
                             $consumer->share($item);
                             // @rule: Store this as sent
                             $oauthPost->set('post_id', $item->id);
                             $oauthPost->set('oauth_id', $oauth->id);
                             $oauthPost->store();
                         }
                     }
                 }
                 // @rule: Send out notifications when the pending moderation items are being published.
                 DiscussHelper::sendNotification($item, $item->parent_id, true, $item->user_id, $item->published);
                 // only if the post is a discussion
                 if ($config->get('integration_pingomatic') && empty($item->parent_id)) {
                     $pingo = DiscussHelper::getHelper('Pingomatic');
                     $pingo->ping($item->title, DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $item->id, true, true));
                 }
                 $user = JFactory::getUser($item->user_id);
                 if ($item->parent_id) {
                     DiscussHelper::getHelper('jomsocial')->addActivityReply($item);
                     DiscussHelper::getHelper('easysocial')->replyDiscussionStream($item);
                 } else {
                     DiscussHelper::getHelper('jomsocial')->addActivityQuestion($item);
                     DiscussHelper::getHelper('easysocial')->createDiscussionStream($item);
                 }
                 if ($user->id) {
                     // Add logging for user.
                     DiscussHelper::getHelper('History')->log('easydiscuss.new.discussion', $user->id, JText::sprintf('COM_EASYDISCUSS_BADGES_HISTORY_NEW_POST', $item->title), $item->id);
                     DiscussHelper::getHelper('Badges')->assign('easydiscuss.new.discussion', $user->id);
                     DiscussHelper::getHelper('Points')->assign('easydiscuss.new.discussion', $user->id);
                     // Assign badge for EasySocial
                     DiscussHelper::getHelper('EasySocial')->assignBadge('create.question', $user->id, JText::sprintf('COM_EASYDISCUSS_BADGES_HISTORY_NEW_POST', $item->title));
                     // assign new ranks.
                     DiscussHelper::getHelper('ranks')->assignRank($user->id, $config->get('main_ranking_calc_type'));
                     // aup
                     DiscussHelper::getHelper('Aup')->assign(DISCUSS_POINTS_NEW_DISCUSSION, $user->id, $item->title);
                 }
             }
         }
         //$model		= $this->getModel( 'Posts' );
         $model = DiscussHelper::getModel('Posts', true);
         if ($model->publish($post, 1)) {
             $message = JText::_('COM_EASYDISCUSS_POSTS_PUBLISHED');
         } else {
             $message = JText::_('COM_EASYDISCUSS_ERROR_PUBLISHING');
             $type = 'error';
         }
     }
     $pidLink = '';
     if (!empty($pid)) {
         $pidLink = '&pid=' . $pid;
     }
     DiscussHelper::setMessageQueue($message, $type);
     $this->setRedirect('index.php?option=com_easydiscuss&view=posts' . $pidLink);
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:80,代码来源:posts.php


注:本文中的DiscussRouter::getRoutedUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。