| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/nice/plugins/kunena/comprofiler/ |
Upload File : |
<?php
/**
* Kunena Plugin
*
* @package Kunena.Plugins
* @subpackage Comprofiler
*
* @copyright Copyright (C) 2008 - 2025 Kunena Team. All rights reserved.
* @license https://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
namespace Kunena\Forum\Plugin\Kunena\Comprofiler;
\defined('_JEXEC') or die();
use CB\Database\Table\UserTable;
use Joomla\CMS\Factory;
use Kunena\Forum\Libraries\Error\KunenaError;
use Kunena\Forum\Libraries\Factory\KunenaFactory;
use Kunena\Forum\Libraries\Integration\KunenaProfile;
use Kunena\Forum\Libraries\Layout\KunenaLayout;
use Kunena\Forum\Libraries\User\KunenaUser;
use Exception;
use RuntimeException;
/**
* Class KunenaProfileComprofiler
*
* @since Kunena 5.0
*/
class KunenaProfileComprofiler extends KunenaProfile
{
/**
* @var null
* @since Kunena 5.0
*/
protected $params = null;
/**
* KunenaProfileComprofiler constructor.
*
* @param object $params params
*
* @since Kunena 5.0
*/
public function __construct(object $params)
{
$this->params = $params;
}
/**
* @param string $event event
* @param object $params params
*
* @return void
*
* @throws Exception
*
* @since Kunena 5.0
*/
public static function trigger(string $event, object $params): void
{
KunenaIntegrationComprofiler::trigger($event, $params);
}
/**
* @return void
*
* @throws Exception
*
* @since Kunena 5.0
*/
public function open(): void
{
KunenaIntegrationComprofiler::open();
}
/**
* @return void
*
* @throws Exception
*
* @since Kunena 5.0
*/
public function close(): void
{
KunenaIntegrationComprofiler::close();
}
/**
* Get the URL for userlist from CB
*
* @param string $action action
* @param bool $xhtml xhtml
*
* @return string
*
* @since Kunena 5.0
* @throws \Exception
*/
public function getUserListURL(string $action = '', bool $xhtml = true): string
{
global $_CB_framework;
$config = KunenaFactory::getConfig();
$my = Factory::getApplication()->getIdentity();
if ($config->userlistAllowed == 0 && $my->id == 0) {
return false;
}
return $_CB_framework->userProfilesListUrl(null, $xhtml);
}
/**
* Get the profile URL from CB
*
* @param int $userid userid
* @param string|null $task task
* @param bool $xhtml xhtml
* @param string $avatarTab avatarTab
*
* @return boolean|string
*
* @throws Exception
*
* @since Kunena 5.0
*/
public function getProfileURL(int $userid, $task = '', bool $xhtml = true, string $avatarTab = '')
{
global $_CB_framework;
$user = KunenaFactory::getUser($userid);
if (! $user->exists()) {
return false;
}
if ($task === 'edit') {
return $_CB_framework->userProfileEditUrl(null, $xhtml);
}
return $_CB_framework->userProfileUrl($user->userid, $xhtml);
}
/**
* @param KunenaLayout $view view
* @param object $params params
*
* @return string
*
* @since Kunena 5.0
*/
public function showProfile(KunenaLayout $view, object $params)
{
global $_PLUGINS;
$_PLUGINS->loadPluginGroup('user');
return implode(
' ',
$_PLUGINS->trigger(
'forumSideProfile',
['kunena', $view, $view->profile->userid,
['config' => &$view->config, 'userprofile' => &$view->profile, 'params' => &$params], ]
)
);
}
/**
* @param int $limit limit
*
* @return array
*
* @throws Exception
*
* @since Kunena 5.0
*/
public function getTopHits($limit = 0): array
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->createQuery();
$query->select('cu.user_id AS id, cu.hits AS count');
$query->from($db->quoteName('#__comprofiler', 'cu'));
$query->innerJoin($db->quoteName('#__users', 'u') . ' ON u.id = cu.user_id');
$query->where('cu.hits > 0');
$query->order('cu.hits DESC');
$query->setLimit($limit);
$db->setQuery($query);
try {
$top = (array) $db->loadObjectList();
} catch (RuntimeException $e) {
KunenaError::displayDatabaseError($e);
}
return $top;
}
/**
* @param int $userid userid
* @param bool $xhtml xhtml
*
* @return boolean
*
* @since Kunena 5.0
*/
public function getEditProfileURL(int $userid, bool $xhtml = true): string
{
global $_CB_framework;
return $_CB_framework->userProfileEditUrl(null, $xhtml);
}
/**
* Return name or username of user with community builder settings
*
* @param KunenaUser $user user
* @param string $visitorname name
* @param bool $escape escape
*
* @return string
*
* @since Kunena 5.2
*/
public function getProfileName(KunenaUser $user, string $visitorname = '', bool $escape = true): string
{
if ($user->exists()) {
return \CBuser::getUserDataInstance($user->userid)->getFormattedName();
}
if (! $visitorname) {
$guestUser = new UserTable();
$guestUser->set( 'name', $user->name );
$guestUser->set( 'username', $user->username );
return $guestUser->getFormattedName();
}
return $visitorname;
}
}