<?php
/**
* @version 1.0.0
* @category Anahita Social Engineâ¢
* @copyright Copyright (C) 2008 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @link http://www.anahitapolis.com
*/
class AnUikitPeopleActions extends KObject
{
protected $_viewer;
/**
*
* @return
* @param $options Object
*/
public function __construct($options)
{
parent::__construct($options);
$this->_viewer = AnModelAnahita::getSessionViewer();
}
/**
*
* @return
* @param $person Object
*/
public function add($person)
{
$this->_addViewSocialgraphActions($person);
$this->_addSocialgraphActions($person);
}
/**
*
* @return
*/
protected function _addViewSocialgraphActions($person)
{
if ( !$person->getAcl()->canViewSocialgraph() )
return false;
$person->addAction( AnUikitHtmlTag::link(JText::_('AN-SE-SOCIALGRAPH-VIEW-GRAPH'),
JRoute::_('index.php?option=com_socialengine&view=socialgraph&oid='.$person->id)
)->setId('an-se-socialgraph-action-'.$person->id)
);
}
/**
*
* @return
*/
protected function _addSocialgraphActions($person)
{
$pid = $person->id;
$actions = array();
if ( $this->_viewer->canFollow($person) ) {
$actions[] = AnUikitHtmlTag::link(JText::_('AN-SE-SOCIALGRAPH-FOLLOW'),'index.php?option=com_socialengine&view=socialgraph.confirm&layout=follow&pid='.$pid)
->setId('an-se-socialgraph-action-follow-'.$pid)
->setClass('an-se-socialgraph-action');
} else if ( $this->_viewer->isFollowing($person) )
$actions[] = AnUikitHtmlTag::link(JText::_('AN-SE-SOCIALGRAPH-UNFOLLOW'),'index.php?option=com_socialengine&view=socialgraph.confirm&layout=unfollow&pid='.$pid)
->setId('an-se-socialgraph-action-unfollow-'.$pid)
->setClass('an-se-socialgraph-action');
if ( $this->_viewer->canBlock($person) )
$actions[] = AnUikitHtmlTag::link(JText::_('AN-SE-SOCIALGRAPH-BLOCK'),'index.php?option=com_socialengine&view=socialgraph.confirm&layout=block&pid='.$pid)
->setId('an-se-socialgraph-action-block-'.$pid)
->setClass('an-se-socialgraph-action');
else if ( $this->_viewer->isBlocking($person) )
$actions[] = AnUikitHtmlTag::link(JText::_('AN-SE-SOCIALGRAPH-UNBLOCK'),'index.php?option=com_socialengine&view=socialgraph.confirm&layout=unblock&pid='.$pid)
->setId('an-se-socialgraph-action-unblock-'.$pid)
->setClass('an-se-socialgraph-action');
$person->addAction($actions);
}
}