示例#1
0
 /**
  * Gets the user profile url of selected <code>system</code>. Currently supported systems are <br><br> 
  * 
  * JomSocial - jomsocial, Community Builder - cb, Touch - touch, Kunena - kunena, Alpha User Points - aup
  * 
  * @param string $system User profile system
  * @param int $userid user id
  * @param string $username User name to be used to display with link
  * @param array $links array of links for mighty touch
  * @param path_only boolean want to retrive just the url or the full html hyperlink markup?
  * 
  * @return string user profile url
  */
 public static function get_user_profile_url($system, $userid = 0, $username = '******', $path_only = true, $attribs = array())
 {
     $link = null;
     switch ($system) {
         case 'cjforum':
             $api = JPATH_ROOT . '/components/com_cjforum/helpers/api.php';
             if (file_exists($api)) {
                 require_once $api;
                 $link = CjForumApi::get_user_profile_url($userid, $path_only, $attribs);
             }
             break;
         case 'cjblog':
             $api = JPATH_ROOT . DS . 'components' . DS . 'com_cjblog' . DS . 'api.php';
             if (file_exists($api)) {
                 require_once $api;
                 $link = CjBlogApi::get_user_profile_url($userid, 'name', $path_only, $attribs);
             }
             break;
         case 'jomsocial':
             $jspath = JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
             if (file_exists($jspath)) {
                 include_once $jspath;
                 if ($path_only) {
                     $link = CRoute::_('index.php? option=com_community&view=profile&userid=' . $userid);
                 } else {
                     $link = JHtml::link(CRoute::_('index.php? option=com_community&view=profile&userid=' . $userid), $username, $attribs);
                 }
             }
             break;
         case 'cb':
             global $_CB_framework, $_CB_database, $ueConfig, $mainframe;
             $api = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php';
             if (!is_file($api)) {
                 return;
             }
             require_once $api;
             cbimport('cb.database');
             cbimport('cb.tables');
             cbimport('language.front');
             cbimport('cb.field');
             $url = cbSef('index.php?option=com_comprofiler&amp;task=userProfile&amp;user='******'kunena':
             if (CJFunctions::_initialize_kunena() && $userid > 0) {
                 $user = KunenaFactory::getUser($userid);
                 if ($user === false) {
                     break;
                 }
                 if ($path_only) {
                     $link = KunenaRoute::_('index.php?option=com_kunena&func=profile&userid=' . $user->userid, true);
                 } else {
                     $link = JHtml::link(KunenaRoute::_('index.php?option=com_kunena&func=profile&userid=' . $user->userid, true), $user->name, $attribs);
                 }
             }
             break;
         case 'aup':
             $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
             if (file_exists($api_AUP)) {
                 require_once $api_AUP;
                 if ($path_only) {
                     $link = AlphaUserPointsHelper::getAupLinkToProfil($userid);
                 } else {
                     $link = JHtml::link(AlphaUserPointsHelper::getAupLinkToProfil($userid), $username, $attribs);
                 }
             }
             break;
         case 'easysocial':
             $api = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_easysocial' . DS . 'includes' . DS . 'foundry.php';
             if (file_exists($api)) {
                 require_once $api;
                 $my = Foundry::user($userid);
                 $link = FRoute::profile(array('id' => $my->getAlias()));
                 if (!$path_only) {
                     $username = $my->getName();
                     $link = JHtml::link($link, $username, $attribs);
                 }
             }
             break;
     }
     return null == $link ? $username : $link;
 }
示例#2
0
文件: api.php 项目: pguilford/vcomcc
 public function getUserProfileUrl($system, $userId, $urlOnly = true, $name = 'Guest', $attribs = array())
 {
     $url = '#';
     if ($userId) {
         switch ($system) {
             case 'cjforum':
                 $api = JPATH_ROOT . '/components/com_cjforum/lib/api.php';
                 if (file_exists($api)) {
                     require_once $api;
                     $profileApi = CjForumApi::getProfileApi();
                     $url = $profileApi->getUserProfileLink($userId, 'name', true);
                 }
                 break;
             case 'cjblog':
                 $api = JPATH_ROOT . '/components/com_cjblog/api.php';
                 if (file_exists($api)) {
                     require_once $api;
                     $url = CjBlogApi::get_user_profile_url($userId, 'name', true, $attribs);
                 }
                 break;
             case 'easyprofile':
                 $api = JPATH_ROOT . '/components/com_jsn/helpers/helper.php';
                 if (file_exists($api)) {
                     require_once $api;
                     $user = new JsnUser($userId);
                     $url = $user->getLink();
                 }
                 break;
             case 'jomsocial':
                 $jspath = JPATH_BASE . '/components/com_community/libraries/core.php';
                 if (file_exists($jspath)) {
                     include_once $jspath;
                     $url = CRoute::_('index.php? option=com_community&view=profile&userid=' . $userId);
                 }
                 break;
             case 'cb':
                 global $_CB_framework, $_CB_database, $ueConfig, $mainframe;
                 $api = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php';
                 if (!is_file($api)) {
                     return;
                 }
                 require_once $api;
                 cbimport('cb.database');
                 cbimport('cb.tables');
                 cbimport('language.front');
                 cbimport('cb.field');
                 $url = cbSef('index.php?option=com_comprofiler&amp;task=userProfile&amp;user='******'kunena':
                 if ($this->_initialize_kunena() && $userId > 0) {
                     $user = KunenaFactory::getUser($userId);
                     if ($user === false) {
                         break;
                     }
                     $url = KunenaRoute::_('index.php?option=com_kunena&func=profile&userid=' . $user->userid, true);
                 }
                 break;
             case 'aup':
                 $api_AUP = JPATH_SITE . '/components/com_alphauserpoints/helper.php';
                 if (file_exists($api_AUP)) {
                     require_once $api_AUP;
                     $url = AlphaUserPointsHelper::getAupLinkToProfil($userId);
                 }
                 break;
             case 'easysocial':
                 $api = JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php';
                 if (file_exists($api)) {
                     require_once $api;
                     $my = Foundry::user($userId);
                     $url = FRoute::profile(array('id' => $my->getAlias()));
                     $name = $my->getName();
                 }
                 break;
         }
     }
     if ($url && !$urlOnly) {
         $url = JHtml::link($url, $name, $attribs);
     }
     return null == $url ? $name : $url;
 }