Че то неосилил. Может носом тыкнешь?
<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
jimport( 'joomla.application.component.view');
jimport( 'joomla.utilities.arrayhelper');
jimport( 'joomla.html.html');
class CommunityViewFriends extends CommunityView
{
function _addSubmenu(){
$this->addSubmenuItem('index.php?option=com_community&view=friends', JText::_('CC SHOW ALL FRIENDS'));
$this->addSubmenuItem('index.php?option=com_community&view=search', JText::_('CC SEARCH FRIENDS'));
$this->addSubmenuItem('index.php?option=com_community&view=friends&task=invite', JText::_('CC INVITE FRIENDS'));
$this->addSubmenuItem('index.php?option=com_community&view=friends&task=sent', JText::_('CC REQUEST SENT'));
$this->addSubmenuItem('index.php?option=com_community&view=friends&task=pending', JText::_('CC PENDING APPROVAL'));
}
function showSubmenu(){
$this->_addSubmenu();
parent::showSubmenu();
}
function display($tpl = null)
{
$document =& JFactory::getDocument();
$document->setTitle(JText::_('CC_ALL_FRIENDS_TITLE'));
// get the friends data
$friends =& $this->get('data');
}
/**
* DIsplay list of friends
*
* if no $_GET['id'] is set, we're viewing our own friends
*/
function friends($data = null)
{
require_once( JPATH_COMPONENT . DS . 'libraries' . DS . 'sorting.php' );
global $mainframe;
$my =& CFactory::getUser();
$id = JRequest::getCmd('userid', $my->id);
// Display mini header if user is viewing other user's friend
if( $id != $my->id )
{
$this->attachMiniHeaderUser( $id );
}
if( $my->id == 0 )
{
$mainframe->enqueueMessage(JText::_('CC PLEASE LOGIN'), 'error');
return;
}
$view =& CFactory::getView( 'search' );
$people =& CFactory::getModel( 'search' );
$userModel =& CFactory::getModel( 'user' );
$avatar =& CFactory::getModel( 'avatar' );
$friends =& CFactory::getModel( 'friends' );
$sorted = JRequest::getVar( 'sort' , 'latest' , 'GET' );
CFactory::load('helpers', 'friends');
$user = CFactory::getActiveProfile();
$rows = $friends->getFriends( $id , $sorted );
$isMine = ( $id == $my->id );
$document =& JFactory::getDocument();
$pathway =& $mainframe->getPathway();
$pathway->addItem(JText::_('CC FRIENDS'), CRoute::_('index.php?option=com_community&view=friends'));
$pathway->addItem(JText::sprintf('CC ALL FRIENDS', $user->getDisplayName()));
// Hide submene if we are viewing other's friends
if( $isMine )
{
$this->showSubmenu();
$document->setTitle(JText::_('CC MY FRIENDS'));
}
else
{
$this->addSubmenuItem('index.php?option=com_community&view=profile&userid=' . $user->id , JText::_('CC BACK TO PROFILE'));
parent::showSubmenu ();
$document->setTitle(JText::sprintf('CC ALL FRIENDS', $user->getDisplayName()));
}
$sortItems = array(
'latest' => JText::_('CC RECENT FRIENDS') ,
'online' => JText::_('CC ONLINE') );
$tmpl = new CTemplate();
$resultRows = array();
foreach($rows as $row){
$user =& CFactory::getUser($row->id);
$obj = clone($row);
$obj->friendsCount = $user->getFriendCount();
//$obj->friendsCount = $friends->getFriendsCount($row->id);
$obj->profileLink = cUserLink($row->id);
$obj->isFriend = true;
$resultRows[] = $obj;
}
unset($rows);
$tmpl->set( 'isMine' , $isMine );
$tmpl->setRef( 'my' , $my );
$tmpl->setRef( 'friends' , $resultRows );
$tmpl->set( 'sortings' , CSorting::getHTML( JRequest::getURI(), $sortItems, 'latest') );
$html = $tmpl->fetch('friends.list');
$html .= '<div style="text-align: center;" class="sectiontablefooter">';
$pagination = $friends->getPagination();
$html .= $pagination->getPagesLinks();
$html .= '</div>';
echo $html;
}
function add($data = null){
$document =& JFactory::getDocument();
$document->setTitle(JText::_('Add new friend ?'));
?>
<div class="app-box">
<p>Add <?php echo $data->name; ?> as friend</p>
<form name="addfriend" method="post" action="">
<div>
<label>Add personal message to <?php echo $data->name; ?></label>
</div>
<div>
<textarea name="msg"></textarea>
</div>
<div>
<input type="submit" class="button" name="submit" value="Add friend"/>
<input type="submit" class="button" name="cancel" value="Cancel"/>
</div>
<input type="hidden" class="button" name="id" value="<?php echo $data->id; ?>"/>
</form>
</div>
<?php
}
function ajaxAdd($data = null){
?>
<div id="addFriendContainer">
<form name="addfriend" id="addfriend" method="post" action="">
<p>Add <strong><?php echo $data->name; ?></strong> as you friend? Add some introduction text below...</p>
<div class="newFriendAvatar">
<img class="avatar" src="<?php echo $data->avatar; ?>" width="50" />
</div>
<div class="newFriendName">
<textarea class="inputbox" style="height: 50px;" name="msg"></textarea>
</div>
<div style="clear: both;"></div>
<div>
<input type="hidden" class="button" name="userid" value="<?php echo $data->id; ?>"/>
</div>
</form>
</div>
<?php
}
function online($data = null)
{
// Load the toolbar
$this->showHeader(JText::_('CC ONLINE FRIENDS'), 'generic');
$document =& JFactory::getDocument();
$document->setTitle(JText::_('Welcome to JomCommunity'));
}
function sent($data = null){
global $mainframe;
$my =& JFactory::getUser();
if($my->id == 0){
$mainframe->enqueueMessage(JText::_('CC PLEASE LOGIN'), 'error');
return;
}
$pathway =& $mainframe->getPathway();
$pathway->addItem(JText::_('CC FRIENDS'), CRoute::_('index.php?option=com_community&view=friends'));
$pathway->addItem(JText::_("CC TITLE WAITING AUTHORIZATION"), '');
$document =& JFactory::getDocument();
$document->setTitle(JText::_('CC TITLE WAITING AUTHORIZATION'));
$this->showSubMenu();
$friends =& CFactory::getModel( 'friends' );
$rows = !empty($data->sent) ? $data->sent : array();
for( $i = 0; $i < count( $rows ); $i++ )
{
$row =& $rows[$i];
$row->user =& CFactory::getUser($row->id );
$row->user->friendsCount = $row->user->getFriendCount();
$row->user->profileLink = cUserLink($row->id);
}
$tmpl = new CTemplate();
$tmpl->setRef( 'my' , $my );
$tmpl->set( 'rows' , $rows );
echo $tmpl->fetch( 'friends.request' );
}
function deleteLink($controller,$method,$id){
$deleteLink = '<a class="remove" onClick="if(!confirm(\'' . JText::_('CC CONFIRM DELETE FRIEND') . '\'))return false;" href="'.CUrl::build($controller,$method).'&fid='.$id.'"> </a>';
return $deleteLink;
}
/**
* Display a list of pending friend requests
**/
function pending($data = null)
{
global $mainframe;
$my =& CFactory::getUser();
if($my->id == 0)
{
$mainframe->enqueueMessage( JText::_('CC PLEASE LOGIN'), 'error');
return;
}
// Set pathway
$pathway =& $mainframe->getPathway();
$pathway->addItem(JText::_('CC FRIENDS'), CRoute::_('index.php?option=com_community&view=friends'));
$pathway->addItem(JText::_('CC AWAITING AUTHORIZATION'), '');
// Set document title
$document =& JFactory::getDocument();
$document->setTitle(JText::_('CC AWAITING AUTHORIZATION'));
// Load submenu
$this->showSubMenu();
$friends =& CFactory::getModel( 'friends' );
$rows = !empty($data->pending) ? $data->pending : array();
for( $i = 0; $i < count( $rows ); $i++ )
{
$row =& $rows[$i];
$row->user =& CFactory::getUser($row->id );
$row->user->friendsCount = $row->user->getFriendCount();
$row->user->profileLink = cUserLink($row->id);
}
$tmpl = new CTemplate();
$tmpl->set( 'rows' , $rows );
$tmpl->setRef( 'my' , $my );
echo $tmpl->fetch( 'friends.pending' );
}
function addGroup($data = null)
{
$message=(isset($data["message"]))?$data["message"]:'';
($message!='')?$this->addInfo($message):""; //show message
$document =& JFactory::getDocument();
$document->setTitle(JText::_('Friend Groups'));
?>
<fieldset>
<form name="addfriendgroup" method="post" action="<?php echo CUrl::build('friends', 'addGroup'); ?>">
<div>
<input type="text" class="button" name="groupname">
</div>
<div>
<input type="submit" class="button" name="submit" value="Add Group"/>
<input type="submit" class="button" name="cancel" value="Cancel"/>
</div>
</form>
</fieldset>
<?php
$cms= & cmsInstance('CMSCore');
$cms->load('libraries','table');
$rows=$data['grouplist'];
foreach($rows as $row){
$data=array($row->group_name,
'<a href="'.CUrl::build('friends', 'deleteGroup').'&id='.$row->group_id.'">'.JText::_('Delete').'</a>');
$cms->table->add_row($data);
}
$cms->table->set_heading(JText::_('Group Name'),JText::_('Action'));
echo "<fieldset><legend>".JText::_("Group List")."</legend>";
echo $cms->table->generate();
echo "</fieldset>";
}
function addTag($data = null)
{
$document =& JFactory::getDocument();
$document->setTitle(JText::_('Welcome to JomCommunity'));
$rows = $data->tags;
$user_id = $data->user_id;
$checkbox = $data->checkbox;
// $rows = $data['tags'];
// $user_id = $data['user_id'];
// $checkbox = $data['checkbox'];
?>
<div id="tagList" style="border: 1px solid rgb(127, 157, 185);
padding: 4px; overflow: auto; background-color: rgb(255, 255, 255) width: 93%; height: 160px;">
<form method="post" action="" name="tagsForm" id="tagsForm">
<?php
echo $checkbox;
?>
<input type="hidden" name="user_id" value="<?php echo $user_id;?>" />
</form>
</div>
<div>
<p><?php echo JText::_('Add a new tag');?></p>
<input type="text" id="newtag" name="newtag" />
<a href="javascript:void(0);" onclick="cFriendSaveGroup('<?php echo $user_id;?>');"><?php echo JText::_('Add');?></a>
</div>
<div>
<button onclick="javascript:cWindowHide();" name="cancel">Cancel</button>
<button onclick="javascript:cFriendSaveTag();" name="submit"> Save </button>
</div>
<?php
}
function addSuccess($data = null)
{
$this->addInfo($data->name . ' will receive your request. Once approval is given you too will become friends!');
$document =& JFactory::getDocument();
$document->setTitle(JText::_('Add new friend ?'));
}
/**
* Show the invite window
*/
function invite()
{
global $mainframe;
$document =& JFactory::getDocument();
$config =& CFactory::getConfig();
$document->setTitle(JText::sprintf('CC INVITE FRIENDS TITLE', $config->get('sitename') ));
$my =& CFactory::getUser();
$this->showSubmenu();
$post = (JRequest::getVar('action', '', 'POST') == 'invite') ? JRequest::get('POST') : '';
$pathway =& $mainframe->getPathway();
$pathway->addItem(JText::_('CC FRIENDS'), CRoute::_('index.php?option=com_community&view=friends'));
$pathway->addItem(JText::_('CC INVITE FRIENDS') , '');
$tmpl = new CTemplate();
$tmpl->set( 'my' , $my );
$tmpl->set( 'post' , $post );
echo $tmpl->fetch( 'friends.invite' );
}
function news()
{
// Load the toolbar
$document =& JFactory::getDocument();
$document->setTitle(JText::_('CCC FRIENDS NEWS'));
}
// function browse()
// {
//
// $document =& JFactory::getDocument();
// $document->setTitle('none');
//
//
//
// $view =& CFactory::getView('search');
// $people =& CFactory::getModel('search');
// $userModel =& CFactory::getModel('user');
// $avatar =& CFactory::getModel('avatar');
// $friends =& CFactory::getModel('friends');
//
// $user = CFactory::getActiveProfile();
// $rows = $friends->getFriends($user->id);
//
// $tmpl = new CTemplate();
//
// $this->attachMiniHeaderUser( $user->id );
//
// $html = '';
// $resultRows = array();
//
// foreach($rows as $row){
// $usr =& CFactory::getUser($row->id);
// $obj = clone($row);
// $obj->avatarImg = $usr->getThumbAvatar(); //$avatar->getSmallImg($row->id);
// $obj->status = $usr->getStatus();
// $obj->friendsCount = $usr->getFriendCount();
// $obj->profileLink = cUserLink($row->id);
//
// if($usr->isOnline())
// $obj->isOnline = '<img style="vertical-align:middle;padding: 0px 4px;" src="'.JURI::base().'components/com_community/assets/status_online.png" />'. JText::_('CC ONLINE');
// else
// $obj->isOnline = '<img style="vertical-align:middle;padding: 0px 4px;" src="'.JURI::base().'components/com_community/assets/status_offline.png" />'.JText::_('CC OFFLINE');
//
// $resultRows[] = $obj;
// }
//
// $tmpl->set('data', $resultRows);
//
// $html = '<h2>'.$user->getDisplayName().'\'s Friends</h2>';
// $html .= $tmpl->fetch('people.browse');
//
// $html .= '<div style="text-align: center;" class="sectiontablefooter">';
// $pagination = $friends->getPagination();
// $html .= $pagination->getPagesLinks();
// $html .= '</div>';
//
// echo $html;
// }
}