| 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/controllers/ |
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\Document\HtmlDocument;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Version;
// Disallow direct access to this file
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.controller' );
/**
* JomSocial Base Controller
*/
class CommunityController extends BaseController
{
public function __construct()
{
parent::__construct();
$jinput = Factory::getApplication()->input;
// Only process this if task != azrul_ajax
$task = $jinput->get( 'task' , '' );
$document = Factory::getDocument();
if( $document instanceof HtmlDocument)
{
$app = Factory::getApplication();
$template = $app->getTemplate();
// Add some javascript that may be needed
// Add some javascript that may be needed
if( $task != 'azrul_ajax' )
{
$version = new Version();
if($version->getHelpVersion() <='0.25') {
// load jquery if joomla 2.5.x
$document->addScript( COMMUNITY_ASSETS_URL . '/js/jquery.min.js' );
$document->addScript( COMMUNITY_ASSETS_URL . '/js/bootstrap.min.js' );
$document->addScript( COMMUNITY_ASSETS_URL . '/js/joomla25.min.js' );
// load css if joomla 2.5.x
$document->addStyleSheet( COMMUNITY_ASSETS_URL . '/css/joomla25.css' );
}
//$document->addScript( COMMUNITY_ASSETS_URL . '/js/jquery.min.js' );
//$document->addScript( COMMUNITY_ASSETS_URL . '/js/bootstrap.min.js' );
//$document->addScript( COMMUNITY_ASSETS_URL . '/js/ace-elements.min.js' );
//$document->addScript( COMMUNITY_ASSETS_URL . '/js/ace.min.js' );
//dont load in installer
if($jinput->get('view','community') !== 'installer')
{
require_once JPATH_COMPONENT.'/helpers/community.php';
}
}
$document->addScript(COMMUNITY_ASSETS_URL.'/admin.js');
$document->addScript( Uri::root() . 'components/com_community/assets/window-1.0.js' );
if($jinput->get('view','community') !== 'installer') {
$document->addStyleSheet(CPath::getInstance()->toUrl(CFactory::getPath('assets://css/bootstrap.min.css')));
$document->addStyleSheet(CPath::getInstance()->toUrl(CFactory::getPath('assets://css/font-awesome.min.css')));
$document->addStyleSheet(CPath::getInstance()->toUrl(CFactory::getPath('assets://css/ace-fonts.css')));
$document->addStyleSheet(CPath::getInstance()->toUrl(CFactory::getPath('assets://css/ace.min.css')));
$document->addStyleSheet(CPath::getInstance()->toUrl(CFactory::getPath('assets://css/fullcalendar.css')));
$document->addStyleSheet(CPath::getInstance()->toUrl(CFactory::getPath('assets://css/jomsocial.css')));
}
}
}
/**
* Method to display the specific view
*
**/
public function display($cachable = false, $urlparams = array())
{
$jinput = Factory::getApplication()->input;
$viewName = $jinput->get( 'view' , 'community' );
// Set the default layout and view name
$layout = $jinput->get( 'layout' , 'default' );
// Get the document object
$document = Factory::getDocument();
// Get the view type
$viewType = $document->getType();
// Get the view
$view = $this->getView( $viewName , $viewType );
$model = $this->getModel( $viewName );
if( $model )
{
$view->setModel( $model , $viewName );
}
// Set the layout
$view->setLayout( $layout );
// Display the view
$view->display();
// Display Toolbar. View must have setToolBar method
if( method_exists( $view , 'setToolBar') )
{
$view->setToolBar();
}
}
/**
* Save the publish status
*
* @access public
*
**/
public function savePublish( $tableClass = 'CommunityTable' )
{
$mainframe = Factory::getApplication();
$jinput = $mainframe->input;
$status = $jinput->get('status');
// Determine the view.
$viewName = $jinput->get( 'view' , 'configuration' );
if (($viewName == 'groups' && !CFactory::getUser()->authorise('community.groupeditstate', 'com_community')) || ($viewName == 'events' && !CFactory::getUser()->authorise('community.eventeditstate', 'com_community')) || ($viewName == 'videos' && !CFactory::getUser()->authorise('community.videoeditstate', 'com_community')) || ($viewName == 'photos' && !CFactory::getUser()->authorise('community.videoeditstate', 'com_community'))) {
Factory::getApplication()->enqueueMessage(Text::_('COM_COMMUNITY_ACCESS_FORBIDDEN'), 'error');
return $this->setRedirect( 'index.php?option=com_community&view=' . $viewName);
}
// Determine whether to publish or unpublish
$state = ( $jinput->get( 'task' ) == 'publish' ) ? 1 : 0;
$id = $jinput->get( 'cid', array(), 'array' );
$count = count($id);
$table = Table::getInstance( $viewName , $tableClass );
$table->publish( $id , $state );
switch ($state)
{
case 1:
$message = Text::sprintf('COM_COMMUNITY_ITEM_SUCCESSFULLY_PUBLISHED_COUNT', $count);
break;
case 0:
$message = Text::sprintf('COM_COMMUNITY_ITEM_SUCCESSFULLY_UNPUBLISHED_COUNT', $count);
break;
}
$extendURL = '';
if(isset($status))
{
$extendURL = '&status='.$status;
}
$this->setRedirect( 'index.php?option=com_community&view=' . $viewName . $extendURL , $message ,'message');
}
/**
* AJAX method to toggle publish status
*
* @param int id Current field id
* @param string field The field publish type
*
* @return JAXResponse object Azrul's AJAX Response object
**/
public function ajaxTogglePublish( $id, $field , $viewName )
{
$user = Factory::getUser();
// @rule: Disallow guests.
if ( $user->get('guest'))
{
Factory::getApplication()->enqueueMessage(Text::_('COM_COMMUNITY_ACCESS_FORBIDDEN'), 'error');
return;
}
$response = new JAXResponse();
// Load the JTable Object.
$row = Table::getInstance( $viewName , 'CommunityTable' );
$row->load( $id );
if( $row->$field == 1)
{
$row->$field = 0;
$row->store();
$image = 'publish_x.png';
}
else
{
$row->$field = 1;
$row->store();
$image = 'tick.png';
}
// Get the view
$view = $this->getView( $viewName , 'html' );
$html = $view->getPublish( $row , $field , $viewName . ',ajaxTogglePublish' );
$response->addAssign( $field . $id , 'innerHTML' , $html );
if ( $viewName == 'videos' && $row->$field == 0) {
$params = new CParameter('');
$params->set('url', '');
$params->set('target', $row->creator);
CNotificationLibrary::add(
'system_messaging',
NULL,
$row->creator,
Text::sprintf('COM_COMMUNITY_VIDEO_UNPUBLISHED', $row->title),
'',
'',
$params) ;
}
return $response->sendResponse();
}
public function cacheClean($cacheId){
$cache = CFactory::getFastCache();
$cache->clean($cacheId);
}
public function _getCurrentVersionData()
{
$component_name = "com_community_std";
$data = 'http://www.jomsocial.com/ijoomla_latest_version.txt';
$installed_version = $this->_getLocalVersionNumber();
$session = Session::getInstance('ijoomla_latest_version',array());
$data = $session->get('ijoomla_latest_version');
if(isset($data->version)){
return $data;
}
$version = "";
$ch = @curl_init($data);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$version = @curl_exec($ch);
if(isset($version) && trim($version) != ""){
$pattern = "";
if(version_compare(JVERSION, '3.0', 'ge')){
$pattern = "/3.0_".$component_name."=(.*);/msU";
} else {
$pattern = "/1.6_com_community=(.*);/msU";
}
if($installed_version != 0 && $installed_version != ""){// on Joomla 2.5 and need to check available version, 2.8 or 3.0
if(strpos($installed_version, "2.6") !== FALSE){
$pattern = "/1.6_com_community=(.*);/msU";
}
elseif(strpos($installed_version, "2.8") !== FALSE){
$pattern = "/3.0_com_community_std=(.*);/msU";
}
else{
$pattern = "/3.0_".$component_name."=(.*);/msU";
}
} else {
$pattern = "/3.0_".$component_name."=(.*);/msU";
}
preg_match($pattern, $version, $result);
if(is_array($result) && count($result) > 0){
$version = trim($result["1"]);
}
}
$data = new stdClass();
$data->version = (string)$version;
$session->set('ijoomla_latest_version', $data);
return $data;
}
public function _getLocalVersionNumber()
{
$xml = JPATH_COMPONENT . '/community.xml';
$parser = new SimpleXMLElement( $xml , false , true );
$version = $parser->version;
return $version;
}
}