| 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/administrator/components/com_community/models/ |
Upload File : |
<?php
/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <webmaster@ijoomla.com>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Pagination\Pagination;
// Disallow direct access to this file
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.model' );
class CommunityModelMultiProfile extends BaseDatabaseModel
{
/**
* Configuration data
*
* @var object JPagination object
**/
var $_pagination;
/**
* Constructor
*/
public function __construct()
{
$mainframe = Factory::getApplication();
// Call the parents constructor
parent::__construct();
// Get the pagination request variables
$limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->get('list_limit'), 'int' );
$limitstart = $mainframe->getUserStateFromRequest( 'com_community.multiprofile.limitstart', 'limitstart', 0, 'int' );
// In case limit has been changed, adjust limitstart accordingly
$limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
/**
* Retrieves the JPagination object
*
* @return object JPagination object
**/
public function &getPagination()
{
if ($this->_pagination == null)
{
$this->getFields();
}
return $this->_pagination;
}
/**
* Returns multi profiles
*
**/
public function getMultiProfiles()
{
$mainframe = Factory::getApplication();
static $fields;
if( isset( $fields ) )
{
return $fields;
}
// Initialize variables
$db = Factory::getDBO();
// Get the limit / limitstart
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->get('list_limit'), 'int');
$limitstart = $mainframe->getUserStateFromRequest('com_community.multiprofile.limitstart', 'limitstart', 0, 'int');
// In case limit has been changed, adjust limitstart accordingly
$limitstart = ($limit != 0) ? ($limitstart / $limit ) * $limit : 0;
// Get the total number of records for pagination
$query = 'SELECT COUNT(*) FROM ' . $db->quoteName( '#__community_profiles' );
$db->setQuery( $query );
$total = $db->loadResult();
jimport('joomla.html.pagination');
// Get the pagination object
$this->_pagination = new Pagination( $total , $limitstart , $limit );
$query = 'SELECT * FROM ' . $db->quoteName( '#__community_profiles' ) . ' '
. 'ORDER BY ' . $db->quoteName( 'ordering' );
$db->setQuery( $query , $this->_pagination->limitstart , $this->_pagination->limit );
$fields = $db->loadObjectList();
return $fields;
}
public function &getGroups()
{
static $fieldGroups;
if( isset( $fieldGroups ) )
{
return $fieldGroups;
}
$db = Factory::getDBO();
$query = 'SELECT * '
. 'FROM ' . $db->quoteName( '#__community_fields' )
. 'WHERE ' . $db->quoteName( 'type' ) . '=' . $db->Quote( 'group' );
$db->setQuery( $query );
$fieldGroups = $db->loadObjectList();
return $fieldGroups;
}
public function &getFieldGroup( $fieldId )
{
static $fieldGroup;
if( isset( $fieldGroup ) )
{
return $fieldGroup;
}
$db = Factory::getDBO();
$query = 'SELECT * FROM ' . $db->quoteName( '#__community_fields' )
. 'WHERE ' . $db->quoteName( 'ordering' ) . '<' . $db->Quote( $fieldId ) . ' '
. 'AND ' . $db->quoteName( 'type' ) . '=' . $db->Quote( 'group' )
. 'ORDER BY ordering DESC '
. 'LIMIT 1';
$db->setQuery( $query );
$fieldGroup = $db->loadObject();
return $fieldGroup;
}
public function getGroupFields( $groupOrderingId )
{
$fieldArray = array();
$db = Factory::getDBO();
$query = 'SELECT * FROM ' . $db->quoteName( '#__community_fields' )
. ' WHERE ' . $db->quoteName( 'ordering' ) . '>' . $db->Quote( $groupOrderingId )
. ' AND '.$db->quoteName('published').'=' . $db->Quote( 1 )
. ' AND '.$db->quoteName('registration').'=' . $db->Quote( 1 )
. ' ORDER BY '.$db->quoteName('ordering').' ASC ';
$db->setQuery( $query );
$fieldGroup = $db->loadObjectList();
if(count($fieldGroup) > 0)
{
foreach($fieldGroup as $field)
{
if($field->type == 'group')
break;
else
$fieldArray[] = $field;
}
}
return $fieldArray;
}
public function getProfileTypes()
{
static $types = false;
if( !$types )
{
$path = JPATH_ROOT . '/components/com_community/libraries/fields/customfields.xml';
$parser = new SimpleXMLElement( $path , NULL , true );
$fields = $parser->fields;
//to accomodate xipt component
$xipt = CSystemHelper::isComponentExists('com_xipt') ? ComponentHelper::getComponent('com_xipt', true)->enabled : false;
$filterField = array('Profiletypes','Templates');
foreach($fields->children() as $field)
{
//if xipt component is not enabled, filter the field
if(!$xipt && in_array($field->name,$filterField)){
continue;
}
$data[(string) $field->type] = $field->name;
}
$types = $data;
}
return $types;
}
public function getFieldsByProfileID($profileId)
{
$db = Factory::getDbo();
$query = "SELECT field_id FROM ".$db->quoteName('#__community_profiles_fields')." WHERE ".$db->quoteName('parent')."=".$db->quote($profileId);
$db->setQuery($query);
return $db->loadColumn();
}
/**
* Return the list of users for specific profile
**/
public function getUserList($profileId)
{
$db = Factory::getDBO();
$query = 'SELECT userid FROM ' . $db->quoteName('#__community_users') . ' WHERE ' . $db->quoteName('profile_id') . '=' . $db->Quote( $profileId );
$db->setQuery( $query );
return $db->loadObjectList();
}
}