registerFunction( 'onAfterDeleteUser', 'userDeleted', 'getConnectionTab' );
/**
* Connections Tab Class for handling the Shortest Connections Path CB tab in head by default (other parts are still in core CB)
* @package Community Builder
* @subpackage Connections CB core module
* @author JoomlaJoe and Beat
*/
class getConnectionPathsTab extends cbTabHandler {
/**
* Constructor
*/
function getConnectionPathsTab( ) {
$this->cbTabHandler();
}
/**
* Generates the HTML to display the user profile tab
* @param moscomprofilerTab $tab the tab database entry
* @param moscomprofilerUser $user the user being displayed
* @param int $ui 1 for front-end, 2 for back-end
* @return mixed either string HTML for tab content, or false if ErrorMSG generated
*/
function getDisplayTab( $tab, $user, $ui ) {
global $_CB_framework, $_CB_database, $ueConfig;
// Display shortest connection path / Degree of relationship:
$return = "";
if ( $_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0 && isset( $ueConfig['connectionPath'] ) && $ueConfig['connectionPath'] && $ueConfig['allowConnections'] ) {
$return .= $this->_writeTabDescription( $tab, $user );
$return .= "\t\t
";
$i = 0;
$cbCon = new cbConnection( $_CB_framework->myId() );
$congroups = $cbCon->getDegreeOfSepPath( $_CB_framework->myId(), $user->id );
$directConDetails = $cbCon->getConnectionDetails( $_CB_framework->myId(), $user->id );
if ( is_array( $congroups ) && ( count( $congroups ) > 2 ) ) {
cbArrayToInts( $congroups );
$query = "SELECT u.name,u.email,u.username,c.avatar,c.avatarapproved, u.id " . "\n FROM #__comprofiler AS c" . "\n LEFT JOIN #__users AS u ON c.id=u.id" . "\n WHERE c.id IN (" . implode( ',', $congroups ) . ")" . "\n AND c.approved=1 AND c.confirmed=1 AND c.banned=0 AND u.block=0";
$_CB_database->setQuery( $query );
$connections = $_CB_database->loadObjectList( 'id' );
$prevConID = null;
$prevConName = null;
if ( isset( $connections[$user->id] ) ) {
$live_site = $_CB_framework->getCfg( 'live_site' );
$return .= _UE_CONNECTIONPATH1 . getNameFormat( $connections[$user->id]->name, $connections[$user->id]->username, $ueConfig['name_format'] ) . " ( " . $cbCon->getDegreeOfSep() . _UE_CONNECTIONPATH2;
foreach ( $congroups as $congroup ) {
if ( $i != 0 ) {
$return .= '
';
}
$conName = getNameFormat( $connections[$congroup]->name, $connections[$congroup]->username, $ueConfig['name_format'] );
if ( ( $congroup != $_CB_framework->myId() ) && ( isset( $connections[$congroup] ) ) ) {
$conDetail = $cbCon->getConnectionDetails( $prevConID, $congroup );
$conAvatar = getFieldValue( 'image', $connections[$congroup]->avatar, $connections[$congroup] );
$tipField = "
" . _UE_CONNECTEDSINCE . " : " . dateConverter( $conDetail->membersince, 'Y-m-d', $ueConfig['date_format'] );
if ( getLangDefinition( $conDetail->type ) != null ) {
$tipField .= "
" . _UE_CONNECTIONTYPE . " : " . getConnectionTypes( $conDetail->type );
}
if ( $conDetail->description != null ) {
$tipField .= "
" . _UE_CONNECTEDCOMMENT . " : " . htmlspecialchars( $conDetail->description );
}
$tipField .= "
" . htmlspecialchars( preg_replace( '/onclick\s*=\s*".+"/Uis', "", $conAvatar ), ENT_QUOTES ) . "
";
$tipTitle = $prevConName . _UE_DETAILSABOUT . str_replace( "'", "'", $conName );
$htmltext = $conName;
$href = 'javascript:void(0)';
if ( $congroup != $user->id ) {
$href = cbSef( "index.php?option=com_comprofiler&task=userProfile&user=" . $congroup );
}
$width = '250';
$style = '';
$icon = '';
$olparams = '';
$tooltip = cbFieldTip( $ui, $tipField, $tipTitle, $width, $icon, $htmltext, $href, $style, $olparams, false );
$return .= $tooltip;
} else {
$return .= $conName;
}
$i++;
$prevConID = $congroup;
$prevConName = $conName;
}
if ( $directConDetails !== false && $directConDetails->pending ) {
$return .= "
" . sprintf( _UE_DIRECTCONNECTIONPENDINGACCEPTANCE, getNameFormat( $user->name, $user->username, $ueConfig['name_format'] ) );
}
} else {
$return .= _UE_NOESTABLISHEDCONNECTION . getNameFormat( $user->name, $user->username, $ueConfig['name_format'] );
}
} elseif ( is_array( $congroups ) && ( count( $congroups ) == 2 ) ) {
$return .= _UE_DIRECTCONNECTION . getNameFormat( $user->name, $user->username, $ueConfig['name_format'] );
} else {
if ( $directConDetails !== false && $directConDetails->pending ) {
$return .= "
" . sprintf( _UE_DIRECTCONNECTIONPENDINGACCEPTANCE, getNameFormat( $user->name, $user->username, $ueConfig['name_format'] ) );
} else {
$return .= _UE_NOESTABLISHEDCONNECTION . getNameFormat( $user->name, $user->username, $ueConfig['name_format'] );
}
}
$return .= "
";
}
return $return;
}
} // end class getConnectionPathsTab
/**
* Connections Tab Class for handling the Connections List CB tab (other parts are still in core CB)
* @package Community Builder
* @subpackage Connections CB core module
* @author JoomlaJoe and Beat
*/
class getConnectionTab extends cbTabHandler {
/**
* Constructor
*/
function getConnectionTab( ) {
$this->cbTabHandler();
}
function _getUserNumberOfConnections( $user ) {
global $_CB_framework;
$cbCon = new cbConnection( $_CB_framework->myId() );
return $cbCon->getConnectionsCount( $user->id );
}
/*
/*
* Generates the menu and user status to display on the user profile by calling back $this->addMenu
* @param moscomprofilerTab $tab the tab database entry
* @param moscomprofilerUser $user the user being displayed
* @param int $ui 1 for front-end, 2 for back-end
* @return boolean either true, or false if ErrorMSG generated
*
function getMenuAndStatus($tab,$user,$ui) {
global $ueConfig;
$params = $this->params;
$con_StatDisplay = $params->get('con_StatDisplay', '1');
if ( $ueConfig['allowConnections'] && $con_StatDisplay ) {
//------------------- User Status items for User Status Window:
// Connections:
$contotal = $this->_getUserNumberOfConnections( $user );
$mi = array(); $mi["_UE_MENU_STATUS"]["_UE_CONNECTION"]["_UE_CONNECTION"]=null;
$dat = cbFormatDate($user->registerDate);
if ( ! $dat ) {
$dat = "?";
}
$this->addMenu( array( "position" => "menuList" , // "menuBar", "menuList"
"arrayPos" => $mi ,
"caption" => $contotal ,
"url" => "" , // can also be "" . "
" . $actionIMG . '
' . "
" . $tooltipAvatar . '
' . "
" . $onlineIMG . " " . getNameFormat( $connection->name, $connection->username, $ueConfig['name_format'] ) . "
memberid ) . '"> " . $emailIMG . " " . $pmIMG . "\n";
} else {
$return .= "
" . "
" . $tooltipAvatar . '
' . "
" . $onlineIMG . " " . getNameFormat( $connection->name, $connection->username, $ueConfig['name_format'] ) . "\n";
}
$return .= "
\n";
}
$return .= "
";
// Add paging control at end of list if paging enabled
if ( $showpaging && ( $con_entriesperpage < $contotal ) ) {
$return .= "
" . $this->_writePaging( $pagingParams, "connshow_", $con_entriesperpage, $contotal ) . "
";
}
if ( $con_ShowSummary && ( $_CB_framework->myId() == $user->id ) || ( $summaryMode && ( $con_entriesperpage < $contotal ) ) ) {
$return .= "" . "
";
}
return $return;
}
/**
* UserBot Called when a user is deleted from backend (prepare future unregistration)
* @param moscomprofilerUser $user reflecting the user being deleted
* @param int $success 1 for successful deleting
* @return boolean true if all is ok, or false if ErrorMSG generated
*/
function userDeleted( $user, $success ) {
global $_CB_database, $ueConfig;
$sql = "DELETE FROM #__comprofiler_members WHERE referenceid = " . (int) $user->id;
$_CB_database->SetQuery( $sql );
if ( ! $_CB_database->query() ) {
$this->_setErrorMSG( "SQL error cb.connections:userDelted-1" . $_CB_database->stderr( true ) );
return false;
}
if ( $ueConfig['autoAddConnections'] ) {
$sql = "DELETE FROM #__comprofiler_members WHERE memberid = " . (int) $user->id;
$_CB_database->SetQuery( $sql );
if ( ! $_CB_database->query() ) {
$this->_setErrorMSG( "SQL error cb.connections:userDelted-2" . $_CB_database->stderr( true ) );
return false;
}
}
return true;
}
} // end class getConnectionTab.
?>