Your IP : 216.73.216.224


Current Path : /var/www/html/administrator/components/com_community/views/multiprofile/
Upload File :
Current File : /var/www/html/administrator/components/com_community/views/multiprofile/view.html.php

<?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
*/
// Disallow direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Version;

jimport( 'joomla.application.component.view' );

class CommunityViewMultiProfile extends HtmlView
{
	/**
	 * The default method that will display the output of this view which is called by
	 * Joomla
	 *
	 * @param	string template	Template file name
	 **/
	public function display( $tpl = null )
	{

		if( $this->getLayout() == 'edit' )
		{
			$this->_displayEditLayout( $tpl );
			return;
		}


		// Set the titlebar text
		ToolbarHelper::title( Text::_('COM_COMMUNITY_CONFIGURATION_MULTIPROFILES'), 'multiprofile' );

		// Add the necessary buttons
		ToolBarHelper::publishList('publish', Text::_('COM_COMMUNITY_PUBLISH'));
		ToolBarHelper::unpublishList('unpublish', Text::_('COM_COMMUNITY_UNPUBLISH'));
		ToolBarHelper::divider();
		ToolBarHelper::trash('delete', Text::_('COM_COMMUNITY_DELETE'));
		ToolBarHelper::addNew('add', Text::_('COM_COMMUNITY_NEW'));

		$profiles	= $this->get( 'MultiProfiles' );
		$pagination	= $this->get( 'Pagination' );

		$mainframe			= Factory::getApplication();

		$ordering			= $mainframe->getUserStateFromRequest( "com_community.multiprofile.filter_order",		'filter_order',		'ordering',	'cmd' );
		$orderingDirection	= $mainframe->getUserStateFromRequest( "com_community.multiprofile.filter_order_Dir",	'filter_order_Dir',	'ASC',			'word' );

		$defaultUserGroup = ComponentHelper::getParams('com_users');

		$this->set( 'profiles'	, $profiles );
		$this->set( 'ordering'	, $ordering );
		$this->set( 'orderingDirection'	, $orderingDirection );
		$this->set( 'defaultUserGroup'	, $defaultUserGroup->get('new_usertype') );

		$this->set( 'pagination'	, $pagination );
		parent::display( $tpl );
	}

	public function _displayEditLayout( $tpl )
	{
		ToolBarHelper::title(  Text::_('COM_COMMUNITY_CONFIGURATION_MULTIPROFILES') , 'multiprofile' );

 		// Add the necessary buttons
 		ToolBarHelper::back(Text::_('COM_COMMUNITY_BACK') , 'index.php?option=com_community&view=multiprofile');
 		ToolBarHelper::divider();
		ToolBarHelper::apply();
		ToolBarHelper::save();

		$mainframe    = Factory::getApplication();
		$jinput       = $mainframe->input;
        $postedFields = $jinput->get('fields' , '', 'NONE');

		$id           = $jinput->request->get('id' , '', 'INT' );
		$multiprofile = Table::getInstance( 'MultiProfile' , 'CTable' );
		$multiprofile->load( $id );

		// get new user registration group from joomla config
		$defaultUserGroup = ComponentHelper::getParams('com_users');

		// load user groups list from multi profile params
		$params = new CParameter('');
		if(!empty($multiprofile->params)){
			$params->loadString($multiprofile->params);
		}
		$userGroup = $params->get('userGroup', array($defaultUserGroup->get('new_usertype')));

		$post = $jinput->post->getArray();
		$multiprofile->bind( $post );

		$profile = $this->getModel( 'Profiles' );
		$fields  = $profile->getFields();

		$groupsModel = $this->getModel('groups');
		$groups = $groupsModel->getAllGroups();

		$defaultAssignGroup = $params->get('groupid');

		$config  = CFactory::getConfig();

		$this->set( 'multiprofile', $multiprofile );
		$this->set( 'groups', $groups );
		$this->set( 'defaultAssignGroup', $defaultAssignGroup );
		$this->set( 'userGroup', $userGroup );
		$this->set( 'fields'		, $fields );
		$this->set( 'config'		, $config );
        $this->set( 'postedFields', $postedFields);

 		parent::display( $tpl );
	}

	public function getWatermarkLocations()
	{
		$locations	= array(
			HTMLHelper::_('select.option', 'top', 'Top'),
			HTMLHelper::_('select.option', 'right', 'Right'),
			HTMLHelper::_('select.option', 'bottom', 'Bottom'),
			HTMLHelper::_('select.option', 'left', 'Left'),
		);
		return $locations;
	}

	/**
	 * Return the total number of users for specific profile
	 **/
	public function getTotalUsers( $profileId )
	{
		$db		= Factory::getDBO();
		$query	= 'SELECT COUNT(1) FROM ' . $db->quoteName('#__community_users') . ' WHERE ' . $db->quoteName('profile_id') . '=' . $db->Quote( $profileId );
		$db->setQuery( $query );
		return $db->loadResult();
	}

	/**
	 * Method to get the publish status HTML
	 *
	 * @param	object	Field object
	 * @param	string	Type of the field
	 * @param	string	The ajax task that it should call
	 * @return	string	HTML source
	 **/
	public function getPublish( &$row , $type , $ajaxTask )
	{

		$version = new Version();
		$currentV = $version->getHelpVersion();

		$class = 'jgrid';

		$alt	= $row->$type ? Text::_('COM_COMMUNITY_PUBLISHED') : Text::_('COM_COMMUNITY_UNPUBLISH');
		$state = $row->$type == 1 ? 'publish' : 'unpublish';
		$span = '<span class="state '.$state.'"><span class="text">'.$alt.'</span></span></a>';

		if($currentV >= '0.30')
		{
			$class = $row->$type == 1 ? 'disabled jgrid': '';

			$span = '<i class="icon-'.$state.'""></i>';
		}

		$href = '<a class="'.$class.'" href="javascript:void(0);" onclick="azcommunity.togglePublish(\'' . $ajaxTask . '\',\'' . $row->id . '\',\'' . $type . '\');">';

		$href .= $span;

		return $href;
	}

	/**
	 * Method to get the publish status HTML
	 *
	 * @param	object	Field object
	 * @param	string	Type of the field
	 * @param	string	The ajax task that it should call
	 * @return	string	HTML source
	 **/
	public function getItemsPublish( $isPublished , $fieldId )
	{
		$imgY    = 'tick.png';
		$imgX	= 'publish_x.png';
		$image	= '';

		if( $isPublished )
		{
			$image	= $imgY;
		}
		else
		{
			$image	= $imgX;
		}

		$href = '<a href="javascript:void(0);" onclick="azcommunity.toggleMultiProfileChild(' . $fieldId . ');"><img src="images/' . $image . '" border="0" /></a>';
		return $href;
	}


	/**
	 * Private method to set the toolbar for this view
	 *
	 * @access private
	 *
	 * @return null
	 **/
	public function setToolBar()
	{
	}
}