Here is my patch please feel free to comment....
public function onCollectProfileActionTools( BASE_CLASS_EventCollector $event )
{
$params = $event->getParams();
if ( empty($params['userId']) )
{
return;
}
$userId = (int) $params['userId'];
if ( !OW::getUser()->isAuthenticated() || OW::getUser()->getId() == $userId )
{
return;
}
$language = OW::getLanguage();
$router = OW::getRouter();
$dto = $this->service->findFriendship($userId, OW::getUser()->getId());
$linkId = 'friendship' . rand(10, 1000000);
$extra_label = null;
if ( $dto === null )
{
if( !OW::getUser()->isAuthorized('friends', 'add_friend') )
{
$status = BOL_AuthorizationService::getInstance()->getActionStatus('friends', 'add_friend');
if ( $status['status'] == BOL_AuthorizationService::STATUS_PROMOTED )
{
$href = 'javascript://';
$script = '$({$link}).click(function(){
window.OW.error({$message});
});';
$script = UTIL_JsGenerator::composeJsString($script, array('link' => '#'.$linkId, 'message' => $status['msg'] ));
OW::getDocument()->addOnloadScript($script);
}
else if ( $status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE )
{
return;
}
}
else if ( BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId) )
{
$href = 'javascript://';
$script = '$({$link}).click(function(){
window.OW.error({$message});
});';
$script = UTIL_JsGenerator::composeJsString($script, array('link' => '#'.$linkId, 'message' => OW::getLanguage()->text('base', 'user_block_message') ));
OW::getDocument()->addOnloadScript($script);
}
else
{
$href = $router->urlFor('FRIENDS_CTRL_Action', 'request', array('id' => $userId));
}
$label = OW::getLanguage()->text('friends', 'add_to_friends');
}
elseif ( $dto === null )
{
$status = BOL_AuthorizationService::getInstance()->getActionStatus('friends', 'add_friend');
if($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED)
{
$href = $router->urlFor('FRIENDS_CTRL_Action', 'request', array('id' => $userId));
$label = OW::getLanguage()->text('friends', 'add_to_friends');
}
else
{
return;
}
}
else
{
switch ( $dto->getStatus() )
{
case FRIENDS_BOL_Service::STATUS_ACTIVE:
$label = $language->text('friends', 'remove_from_friends');
$href = $router->urlFor('FRIENDS_CTRL_Action', 'cancel', array('id' => $userId, 'redirect'=>true));
break;
case FRIENDS_BOL_Service::STATUS_PENDING:
if ( $dto->getUserId() == OW::getUser()->getId() )
{
$label = $language->text('friends', 'friend_request_was_sent');
$href = $router->urlFor('FRIENDS_CTRL_Action', 'cancel', array('id' => $userId, 'redirect'=>true));
$extra_label = $language->text('friends', 'cancel_request');
}
else
{
if ( !OW::getUser()->isAuthorized('friends', 'add_friend') )
{
return;
}
$label = $language->text('friends', 'add_to_friends');
$href = $router->urlFor('FRIENDS_CTRL_Action', 'accept', array('id' => $userId));
}
break;
case FRIENDS_BOL_Service::STATUS_IGNORED:
if ( $dto->getUserId() == OW::getUser()->getId() )
{
$label = $language->text('friends', 'remove_from_friends');
$href = $router->urlFor('FRIENDS_CTRL_Action', 'cancel', array('id' => $userId));
}
else
{
if ( !OW::getUser()->isAuthorized('friends', 'add_friend') )
{
return;
}
$label = $language->text('friends', 'add_to_friends');
$href = $router->urlFor('FRIENDS_CTRL_Action', 'activate', array('id' => $userId));
}
}
}
// my fix start
$script = UTIL_JsGenerator::composeJsString('
$("#' . $linkId . '").click(function()
{
window.location.href="'.$href.'";
}
);');
OW::getDocument()->addOnloadScript($script);
// my fix end
$resultArray = array(
BASE_CMP_ProfileActionToolbar::DATA_KEY_LABEL => $label,
BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_HREF => 'javascript://',
BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ID => $linkId,
BASE_CMP_ProfileActionToolbar::DATA_KEY_ITEM_KEY => 'friends.action',
BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ORDER => 1,
BASE_CMP_ProfileActionToolbar::DATA_KEY_EXTRA_LABEL => $extra_label
);
$event->add($resultArray);
}