/**
  * 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;
     $return = null;
     if (!$ueConfig['allowConnections'] || isset($ueConfig['connectionDisplay']) && $ueConfig['connectionDisplay'] == 1 && $_CB_framework->myId() != $user->id) {
         return null;
     }
     $params = $this->params;
     $con_ShowTitle = $params->get('con_ShowTitle', '1');
     $con_ShowSummary = $params->get('con_ShowSummary', '0');
     $con_SummaryEntries = $params->get('con_SummaryEntries', '4');
     $con_pagingenabled = $params->get('con_PagingEnabled', '1');
     $con_entriesperpage = $params->get('con_EntriesPerPage', '10');
     $pagingParams = $this->_getPaging(array(), array("connshow_"));
     $showall = $this->_getReqParam("showall", false);
     if ($con_ShowSummary && !$showall && $pagingParams["connshow_limitstart"] === null) {
         $summaryMode = true;
         $showpaging = false;
         $con_entriesperpage = $con_SummaryEntries;
     } else {
         $summaryMode = false;
         $showpaging = $con_pagingenabled;
     }
     $isVisitor = null;
     if ($_CB_framework->myId() != $user->id) {
         $isVisitor = "\n AND m.pending=0 AND m.accepted=1";
     }
     if ($showpaging || $summaryMode) {
         //select a count of all applicable entries for pagination
         if ($isVisitor) {
             $contotal = $this->_getUserNumberOfConnections($user);
         } else {
             $query = "SELECT COUNT(*)" . "\n FROM #__comprofiler_members AS m" . "\n LEFT JOIN #__comprofiler AS c ON m.memberid=c.id" . "\n LEFT JOIN #__users AS u ON m.memberid=u.id" . "\n WHERE m.referenceid=" . (int) $user->id . "\n AND c.approved=1 AND c.confirmed=1 AND c.banned=0 AND u.block=0" . $isVisitor . "\n ";
             $_CB_database->setQuery($query);
             $contotal = $_CB_database->loadResult();
             if (!is_numeric($contotal)) {
                 $contotal = 0;
             }
         }
     }
     if (!$showpaging || $pagingParams["connshow_limitstart"] === null || $con_entriesperpage > $contotal) {
         $pagingParams["connshow_limitstart"] = "0";
     }
     $query = "SELECT m.*,u.name,u.email,u.username,c.avatar,c.avatarapproved, u.id " . "\n FROM #__comprofiler_members AS m" . "\n LEFT JOIN #__comprofiler AS c ON m.memberid=c.id" . "\n LEFT JOIN #__users AS u ON m.memberid=u.id" . "\n WHERE m.referenceid=" . (int) $user->id . "" . "\n AND c.approved=1 AND c.confirmed=1 AND c.banned=0 AND u.block=0" . $isVisitor . "\n ORDER BY m.membersince DESC, m.memberid ASC";
     $_CB_database->setQuery($query, (int) ($pagingParams["connshow_limitstart"] ? $pagingParams["connshow_limitstart"] : 0), (int) $con_entriesperpage);
     $connections = $_CB_database->loadObjectList();
     if (!count($connections) > 0) {
         $return .= _UE_NOCONNECTIONS;
         return $return;
     }
     if ($con_ShowTitle) {
         if ($_CB_framework->myId() == $user->id) {
             $return .= "<h3 class=\"cbConTitle\">" . _UE_YOURCONNECTIONS . "</h3>";
         } else {
             $return .= "<h3 class=\"cbConTitle\">" . sprintf(_UE_USERSNCONNECTIONS, getNameFormat($user->name, $user->username, $ueConfig['name_format'])) . "</h3>";
         }
     }
     $return .= $this->_writeTabDescription($tab, $user);
     $live_site = $_CB_framework->getCfg('live_site');
     $boxHeight = $ueConfig['thumbHeight'] + 46;
     $boxWidth = $ueConfig['thumbWidth'] + 28;
     foreach ($connections as $connection) {
         $conAvatar = getFieldValue('image', $connection->avatar, $connection);
         $emailIMG = getFieldValue('primaryemailaddress', $connection->email, $connection, null, 1);
         $pmIMG = getFieldValue('pm', $connection->username, $connection, null, 1);
         $onlineIMG = $ueConfig['allow_onlinestatus'] == 1 ? getFieldValue('status', null, $connection, null, 1) : "";
         if ($connection->accepted == 1 && $connection->pending == 1) {
             $actionIMG = '<img src="' . $live_site . '/components/com_comprofiler/images/pending.png" border="0" alt="' . _UE_CONNECTIONPENDING . "\" title=\"" . _UE_CONNECTIONPENDING . "\" /> <a href=\"" . cbSef("index.php?option=com_comprofiler&amp;act=connections&amp;task=removeConnection&amp;connectionid=" . $connection->memberid) . "\" onclick=\"return confirmSubmit();\" ><img src=\"" . $live_site . "/components/com_comprofiler/images/publish_x.png\" border=\"0\" alt=\"" . _UE_REMOVECONNECTION . "\" title=\"" . _UE_REMOVECONNECTION . "\" /></a>";
         } elseif ($connection->accepted == 1 && $connection->pending == 0) {
             $actionIMG = "<a href=\"" . cbSef("index.php?option=com_comprofiler&amp;act=connections&amp;task=removeConnection&amp;connectionid=" . $connection->memberid) . "\" onclick=\"return confirmSubmit();\" ><img src=\"" . $live_site . "/components/com_comprofiler/images/publish_x.png\" border=\"0\" alt=\"" . _UE_REMOVECONNECTION . "\" title=\"" . _UE_REMOVECONNECTION . "\" /></a>";
         } elseif ($connection->accepted == 0) {
             $actionIMG = "<a href=\"" . cbSef("index.php?option=com_comprofiler&amp;act=connections&amp;task=acceptConnection&amp;connectionid=" . $connection->memberid) . '"><img src="' . $live_site . "/components/com_comprofiler/images/tick.png\" border=\"0\" alt=\"" . _UE_ACCEPTCONNECTION . "\" title=\"" . _UE_ACCEPTCONNECTION . "\" /></a> <a href=\"" . cbSef("index.php?option=com_comprofiler&amp;act=connections&amp;task=removeConnection&amp;connectionid=" . $connection->memberid) . '"><img src="' . $live_site . "/components/com_comprofiler/images/publish_x.png\" border=\"0\" alt=\"" . _UE_REMOVECONNECTION . "\" title=\"" . _UE_DECLINECONNECTION . "\" /></a>";
         }
         $tipField = "<b>" . _UE_CONNECTEDSINCE . "</b> : " . dateConverter($connection->membersince, 'Y-m-d', $ueConfig['date_format']);
         if (getLangDefinition($connection->type) != null) {
             $tipField .= "<br /><b>" . _UE_CONNECTIONTYPE . "</b> : " . getConnectionTypes($connection->type);
         }
         if ($connection->description != null) {
             $tipField .= "<br /><b>" . _UE_CONNECTEDCOMMENT . "</b> : " . htmlspecialchars($connection->description);
         }
         $tipTitle = _UE_CONNECTEDDETAIL;
         $htmltext = $conAvatar;
         $style = "style=\"padding:5px;\"";
         $tooltipAvatar = cbFieldTip($ui, $tipField, $tipTitle, '250', '', $htmltext, '', $style, '', false);
         if ($_CB_framework->myId() == $user->id) {
             $return .= "<div class=\"connectionBox\" style=\"position:relative;height:" . ($boxHeight + 24) . "px;width:" . $boxWidth . "px;\">" . "<div style=\"position:absolute; top:3px; width:auto;left:5px;right:5px;\">" . $actionIMG . '</div>' . "<div style=\"position:absolute; top:18px; width:auto;left:5px;right:5px;\">" . $tooltipAvatar . '</div>' . "<div style=\"position:absolute; bottom:0px; width:auto;left:5px;right:5px;\">" . $onlineIMG . " " . getNameFormat($connection->name, $connection->username, $ueConfig['name_format']) . "<br /><a href=\"" . cbSef("index.php?option=com_comprofiler&amp;task=userProfile&amp;user="******"><img src="' . $live_site . "/components/com_comprofiler/images/profiles.gif\" border=\"0\" alt=\"" . _UE_VIEWPROFILE . "\" title=\"" . _UE_VIEWPROFILE . "\" /></a> " . $emailIMG . " " . $pmIMG . "\n";
         } else {
             $return .= "<div class=\"connectionBox\" style=\"position:relative;height:" . $boxHeight . "px;width:" . $boxWidth . "px;\">" . "<div style=\"position:absolute; top:10px; width:auto;left:5px;right:5px;\">" . $tooltipAvatar . '</div>' . "<div style=\"position:absolute; bottom:0px; width:auto;left:5px;right:5px;\">" . $onlineIMG . " " . getNameFormat($connection->name, $connection->username, $ueConfig['name_format']) . "\n";
         }
         $return .= "</div></div>\n";
     }
     $return .= "<div style=\"clear:both;\">&nbsp;</div>";
     // Add paging control at end of list if paging enabled
     if ($showpaging && $con_entriesperpage < $contotal) {
         $return .= "<div style='width:95%;text-align:center;'>" . $this->_writePaging($pagingParams, "connshow_", $con_entriesperpage, $contotal) . "</div>";
     }
     if ($con_ShowSummary && $_CB_framework->myId() == $user->id || $summaryMode && $con_entriesperpage < $contotal) {
         $return .= "<div class=\"connSummaryFooter\" style=\"width:100%;clear:both;\">";
         if ($_CB_framework->myId() == $user->id) {
             // Manage connections link:
             $return .= "<div id=\"connSummaryFooterManage\" style=\"float:left;\">" . "<a href=\"" . cbSef('index.php?option=com_comprofiler&amp;task=manageConnections') . "\" >[" . _UE_MANAGECONNECTIONS . "]</a>" . "</div>";
         }
         if ($summaryMode && $con_entriesperpage < $contotal) {
             // See all of user's ## connections
             $return .= "<div id=\"connSummaryFooterSeeConnections\" style=\"float:right;\">" . "<a href=\"" . $this->_getAbsURLwithParam(array("showall" => "1")) . "\">";
             if ($_CB_framework->myId() == $user->id) {
                 $return .= sprintf(_UE_SEEALLNCONNECTIONS, $contotal);
             } else {
                 $return .= sprintf(_UE_SEEALLOFUSERSNCONNECTIONS, getNameFormat($user->name, $user->username, $ueConfig['name_format']), "<strong>" . $contotal . "</strong>");
             }
             $return .= "</a>" . "</div>";
         }
         $return .= "&nbsp;</div>" . "<div style=\"clear:both;\">&nbsp;</div>";
     }
     return $return;
 }
    static function manageConnections($connections, $actions, $total, &$connMgmtTabs, &$pagingParams, $perpage, $connecteds = null)
    {
        global $_CB_framework, $ueConfig, $_REQUEST;
        $Itemid = $_CB_framework->itemid();
        $ui = 1;
        outputCbTemplate($ui);
        initToolTip(1);
        ob_start();
        ?>
var tabPanemyCon;
function showCBTabPaneMy( sName ) {
	if (typeof tabPanemyCon != "undefined" ) {
		switch ( sName.toLowerCase() ) {
			case "<?php 
        echo strtolower(_UE_MANAGEACTIONS);
        ?>
":
			case "manageactions":
			case "0":
				tabPanemyCon.setSelectedIndex( 0 );
				break;
			case "<?php 
        echo strtolower(_UE_MANAGECONNECTIONS);
        ?>
":
			case "manageconnections":
			case "1":
				tabPanemyCon.setSelectedIndex( 1 );
				break;
			case "<?php 
        echo strtolower(_UE_CONNECTEDWITH);
        ?>
":
			case "connectedfrom":
			case "2":
				tabPanemyCon.setSelectedIndex( 2 );
				break;
		}
	}
}
<?php 
        $cbjavascript = ob_get_contents();
        ob_end_clean();
        $_CB_framework->outputCbJQuery($cbjavascript);
        ob_start();
        ?>
function confirmSubmit() {
	if (confirm("<?php 
        echo _UE_CONFIRMREMOVECONNECTION;
        ?>
"))
		return true ;
	else
		return false ;
}
<?php 
        $cbjavascript = ob_get_contents();
        ob_end_clean();
        $_CB_framework->document->addHeadScriptDeclaration($cbjavascript);
        $tabs = new cbTabs(0, $ui);
        $cTypes = explode("\n", $ueConfig['connection_categories']);
        $connectionTypes = array();
        foreach ($cTypes as $cType) {
            if (trim($cType) != null && trim($cType) != "") {
                $connectionTypes[] = moscomprofilerHTML::makeOption(trim($cType), getLangDefinition(trim($cType)));
            }
        }
        ?>
<div class="contentheading"><?php 
        echo _UE_MANAGECONNECTIONS;
        ?>
</div><br />
<br />
<?php 
        echo $tabs->startPane("myCon");
        // Tab 0: Manange Actions:
        echo $tabs->startTab("myCon", _UE_MANAGEACTIONS . " (" . count($actions) . ")", "action");
        if (!count($actions) > 0) {
            echo "\t\t<div class=\"tab_Description\">" . _UE_NOACTIONREQUIRED . "</div>\n";
        } else {
            echo '<form method="post" action="' . cbSef('index.php?option=com_comprofiler&amp;task=processConnectionActions' . ($Itemid ? "&amp;Itemid=" . (int) $Itemid : "")) . '">';
            echo "\t\t<div class=\"tab_Description\">" . _UE_CONNECT_ACTIONREQUIRED . "</div>\n";
            // echo "<div style=\"width:100%;text-align:right;\"><input type=\"submit\" class=\"inputbox\"  value=\""._UE_UPDATE."\" /></div>";
            echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"95%\">";
            echo "<tr>";
            echo "<td>";
            foreach ($actions as $action) {
                $conAvatar = null;
                $conAvatar = getFieldValue('image', $action->avatar, $action);
                $onlineIMG = $ueConfig['allow_onlinestatus'] == 1 ? getFieldValue('status', $action->isOnline, $action, null, 1) : "";
                $tipField = "<b>" . _UE_CONNECTIONREQUIREDON . "</b> : " . dateConverter($action->membersince, 'Y-m-d', $ueConfig['date_format']);
                if ($action->reason != null) {
                    $tipField .= "<br /><b>" . _UE_CONNECTIONMESSAGE . "</b> :<br />" . htmlspecialchars($action->reason, ENT_QUOTES);
                }
                $tipTitle = _UE_CONNECTIONREQUESTDETAIL;
                $htmltext = $conAvatar;
                $style = "style=\"padding:5px;\"";
                $tooltip = cbFieldTip($ui, $tipField, $tipTitle, '250', '', $htmltext, '', $style, '', false);
                echo "<div class=\"connectionBox\">";
                echo $onlineIMG . ' ' . getNameFormat($action->name, $action->username, $ueConfig['name_format']) . "<br />" . $tooltip . "<br /><img src=\"components/com_comprofiler/images/tick.png\" border=\"0\" alt=\"" . _UE_ACCEPTCONNECTION . "\" title=\"" . _UE_ACCEPTCONNECTION . "\" /><input type=\"radio\"  value=\"a\" checked=\"checked\" name=\"" . $action->id . "action\"/> <img src=\"components/com_comprofiler/images/publish_x.png\" border=\"0\" alt=\"" . _UE_DECLINECONNECTION . "\" title=\"" . _UE_DECLINECONNECTION . "\" /><input type=\"radio\" value=\"d\" name=\"" . $action->id . "action\"/><input type=\"hidden\" name=\"uid[]\" value=\"" . $action->id . "\" />";
                echo " </div>\n";
            }
            echo "</td>";
            echo "</tr>";
            echo "</table>";
            echo "<div style=\"width:100%;text-align:right;\"><input type=\"submit\" class=\"button\"  value=\"" . _UE_UPDATE . "\" /></div>";
            echo cbGetSpoofInputTag('manageConnections');
            echo "</form>";
        }
        echo $tabs->endTab();
        // Tab 1: Manange Connections:
        echo $tabs->startTab("myCon", _UE_MANAGECONNECTIONS, "connections");
        if (!count($connections) > 0) {
            echo "\t\t<div class=\"tab_Description\">" . _UE_NOCONNECTIONS . "</div>\n";
        } else {
            ?>
	<form action='<?php 
            echo cbSef('index.php?option=com_comprofiler&amp;task=saveConnections' . ($Itemid ? "&amp;Itemid=" . (int) $Itemid : ""));
            ?>
' method='post' name='userAdmin'>
	<div class="tab_Description"><?php 
            echo _UE_CONNECT_MANAGECONNECTIONS;
            ?>
</div>
	<table cellpadding="5" cellspacing="0" border="0" width="95%">
	  <thead><tr>
		<th style='text-align:center;'><?php 
            echo _UE_CONNECTION;
            ?>
</th>
		<th style='text-align:center;'><?php 
            echo _UE_CONNECTIONTYPE;
            ?>
</th>
		<th style='text-align:center;'><?php 
            echo _UE_CONNECTIONCOMMENT;
            ?>
</th>
	  </tr></thead>
	  <tbody>
<?php 
            $i = 1;
            foreach ($connections as $connection) {
                $k = explode('|*|', trim($connection->type));
                $list = array();
                $list['connectionType'] = moscomprofilerHTML::selectList($connectionTypes, $connection->id . 'connectiontype[]', 'class="inputbox" multiple="multiple" size="5"', 'value', 'text', $k, 0);
                $conAvatar = null;
                $conAvatar = getFieldValue('image', $connection->avatar, $connection);
                $emailIMG = getFieldValue('primaryemailaddress', $connection->email, $connection, null, 1);
                $pmIMG = getFieldValue('pm', $connection->username, $connection, null, 1);
                $onlineIMG = $ueConfig['allow_onlinestatus'] == 1 ? getFieldValue('status', $connection->isOnline, $connection, null, 1) : "";
                if ($connection->accepted == 1 && $connection->pending == 1) {
                    $actionIMG = "<img src=\"components/com_comprofiler/images/pending.png\" border=\"0\" alt=\"" . _UE_CONNECTIONPENDING . "\" title=\"" . _UE_CONNECTIONPENDING . "\" /> <a href=\"" . cbSef("index.php?option=com_comprofiler&amp;act=connections&amp;task=removeConnection&amp;connectionid=" . $connection->memberid . ($Itemid ? "&amp;Itemid=" . (int) $Itemid : "")) . "\" onclick=\"return confirmSubmit();\" ><img src=\"components/com_comprofiler/images/publish_x.png\" border=\"0\" alt=\"" . _UE_REMOVECONNECTION . "\" title=\"" . _UE_REMOVECONNECTION . "\" /></a>";
                } elseif ($connection->accepted == 1 && $connection->pending == 0) {
                    $actionIMG = "<a href=\"" . cbSef("index.php?option=com_comprofiler&amp;act=connections&amp;task=removeConnection&amp;connectionid=" . $connection->memberid . ($Itemid ? "&amp;Itemid=" . (int) $Itemid : "")) . "\" onclick=\"return confirmSubmit();\" ><img src=\"components/com_comprofiler/images/publish_x.png\" border=\"0\" alt=\"" . _UE_REMOVECONNECTION . "\" title=\"" . _UE_REMOVECONNECTION . "\" /></a>";
                } elseif ($connection->accepted == 0) {
                    $actionIMG = "<a href=\"" . cbSef("index.php?option=com_comprofiler&amp;act=connections&amp;task=acceptConnection&amp;connectionid=" . $connection->memberid . ($Itemid ? "&amp;Itemid=" . (int) $Itemid : "")) . "\"><img src=\"components/com_comprofiler/images/tick.png\" border=\"0\" alt=\"" . _UE_ACCEPTCONNECTION . "\" title=\"" . _UE_ACCEPTCONNECTION . "\" /></a> <a href=\"" . cbSef("index.php?option=com_comprofiler&amp;act=connections&amp;task=removeConnection&amp;connectionid=" . $connection->memberid . ($Itemid ? "&amp;Itemid=" . (int) $Itemid : "")) . "\"><img src=\"components/com_comprofiler/images/publish_x.png\" border=\"0\" alt=\"" . _UE_REMOVECONNECTION . "\" title=\"" . _UE_DECLINECONNECTION . "\" /></a>";
                }
                $tipField = "<b>" . _UE_CONNECTEDSINCE . "</b> : " . dateConverter($connection->membersince, 'Y-m-d', $ueConfig['date_format']);
                if ($connection->type != null) {
                    $tipField .= "<br /><b>" . _UE_CONNECTIONTYPE . "</b> : " . getConnectionTypes($connection->type);
                }
                if ($connection->description != null) {
                    $tipField .= "<br /><b>" . _UE_CONNECTEDCOMMENT . "</b> : " . htmlspecialchars($connection->description);
                }
                $tipTitle = _UE_CONNECTEDDETAIL;
                $htmltext = $conAvatar;
                $style = "style=\"padding:5px;\"";
                $tooltip = cbFieldTip($ui, $tipField, $tipTitle, '200', '', $htmltext, '', $style, '', false);
                echo "\n<tr style='vertical-align:top;' class='sectiontableentry" . $i . "'>";
                echo "\n\t<td style='text-align:center;'>" . $onlineIMG . ' ' . getNameFormat($connection->name, $connection->username, $ueConfig['name_format']) . "<br />" . $tooltip . "<br />" . $actionIMG . " <a href=\"" . cbSef("index.php?option=com_comprofiler&amp;task=userProfile&amp;user="******"&amp;Itemid=" . (int) $Itemid : "")) . "\"><img src=\"components/com_comprofiler/images/profiles.gif\" border=\"0\" alt=\"" . _UE_VIEWPROFILE . "\" title=\"" . _UE_VIEWPROFILE . "\" /></a> " . $emailIMG . " " . $pmIMG . "</td>";
                echo "\n\t<td style='text-align:center;'>" . $list['connectionType'] . "</td>";
                echo "\n\t<td style='text-align:center;'><textarea cols=\"25\" class=\"inputbox\"  rows=\"5\" name=\"" . $connection->id . "description\">" . htmlspecialchars($connection->description) . "</textarea><input type=\"hidden\" name=\"uid[]\" value=\"" . $connection->id . "\" /></td>";
                echo "\n</tr>";
                $i = $i == 1 ? 2 : 1;
            }
            echo "</tbody>";
            echo "</table><br />";
            if ($perpage < $total) {
                echo "<div style='width:95%;text-align:center;'>" . $connMgmtTabs->_writePaging($pagingParams, 'connections_', $perpage, $total, 'manageConnections') . "</div>";
            }
            echo "<div style=\"width:100%;text-align:right;\"><input type=\"submit\" class=\"button\"  value=\"" . _UE_UPDATE . "\" /></div>";
            echo cbGetSpoofInputTag('manageConnections');
            echo "</form>";
        }
        echo $tabs->endTab();
        // Tab 2: Users connected with me:
        if ($ueConfig['autoAddConnections'] == 0) {
            echo $tabs->startTab('myCon', _UE_CONNECTEDWITH, 'connected');
            if (!count($connecteds) > 0) {
                echo _UE_NOCONNECTEDWITH;
            } else {
                // tooltip params:
                $width = '200';
                $icon = '';
                $href = '';
                echo '<table cellpadding="5" cellspacing="0" border="0" width="95%">';
                echo '<tr>';
                echo '<td>';
                foreach ($connecteds as $connected) {
                    $conAvatar = null;
                    $conAvatar = getFieldValue('image', $connected->avatar, $connected);
                    $emailIMG = getFieldValue('primaryemailaddress', $connected->email, $connected, null, 1);
                    $pmIMG = getFieldValue('pm', $connected->username, $connected, null, 1);
                    $onlineIMG = $ueConfig['allow_onlinestatus'] == 1 ? getFieldValue('status', $connected->isOnline, $connected, null, 1) : '';
                    if ($connected->accepted == 1 && $connected->pending == 1) {
                        $actionIMG = '<img src="components/com_comprofiler/images/pending.png" border="0" alt="' . _UE_CONNECTIONPENDING . '" title="' . _UE_CONNECTIONPENDING . '" /> ' . '<a href="' . cbSef('index.php?option=com_comprofiler&amp;act=connections&amp;task=denyConnection&amp;connectionid=' . $connected->memberid . ($Itemid ? '&amp;Itemid=' . (int) $Itemid : '')) . '" onclick="return confirmSubmit();">' . '<img src="components/com_comprofiler/images/publish_x.png" border="0" alt="' . _UE_REMOVECONNECTION . '" title="' . _UE_REMOVECONNECTION . '" /></a>';
                    } elseif ($connected->accepted == 1 && $connected->pending == 0) {
                        $actionIMG = '<a href="' . cbSef('index.php?option=com_comprofiler&amp;act=connections&amp;task=denyConnection&amp;connectionid=' . $connected->referenceid . ($Itemid ? '&amp;Itemid=' . (int) $Itemid : '')) . '" onclick="return confirmSubmit();">' . '<img src="components/com_comprofiler/images/publish_x.png" border="0" alt="' . _UE_REMOVECONNECTION . '" title="' . _UE_REMOVECONNECTION . '" /></a>';
                    } elseif ($connected->accepted == 0) {
                        $actionIMG = '<a href="' . cbSef('index.php?option=com_comprofiler&amp;act=connections&amp;task=acceptConnection&amp;connectionid=' . $connected->referenceid . ($Itemid ? '&amp;Itemid=' . (int) $Itemid : '')) . '">' . '<img src="components/com_comprofiler/images/tick.png" border="0" alt="' . _UE_ACCEPTCONNECTION . '" title="' . _UE_ACCEPTCONNECTION . '" /></a> ' . '<a href="' . cbSef('index.php?option=com_comprofiler&amp;act=connections&amp;task=denyConnection&amp;connectionid=' . $connected->referenceid . ($Itemid ? '&amp;Itemid=' . (int) $Itemid : '')) . '" onclick="return confirmSubmit();">' . '<img src="components/com_comprofiler/images/publish_x.png" border="0" alt="' . _UE_REMOVECONNECTION . '" title="' . _UE_DECLINECONNECTION . '" /></a>';
                    }
                    $tipField = '<b>' . _UE_CONNECTEDSINCE . '</b> : ' . dateConverter($connected->membersince, 'Y-m-d', $ueConfig['date_format']);
                    if (getLangDefinition($connected->type) != null) {
                        $tipField .= '<br /><b>' . _UE_CONNECTIONTYPE . '</b> : ' . getLangDefinition($connected->type);
                    }
                    if ($connected->description != null) {
                        $tipField .= '<br /><b>' . _UE_CONNECTEDCOMMENT . '</b> : ' . htmlspecialchars($connected->description);
                    }
                    $tipTitle = _UE_CONNECTEDDETAIL;
                    $htmltext = $conAvatar;
                    $style = 'style="padding:5px;"';
                    $tooltip = cbFieldTip($ui, $tipField, $tipTitle, $width, $icon, $htmltext, $href, $style, '', false);
                    echo '<div class="connectionBox">';
                    echo $actionIMG . '<br />';
                    echo $tooltip . '<br />';
                    echo $onlineIMG . ' ' . getNameFormat($connected->name, $connected->username, $ueConfig['name_format']);
                    echo '<br /><a href="' . cbSef('index.php?option=com_comprofiler&amp;task=userProfile&amp;user='******'&amp;Itemid=' . (int) $Itemid : '')) . '"><img src="components/com_comprofiler/images/profiles.gif" border="0" alt="' . _UE_VIEWPROFILE . '" title="' . _UE_VIEWPROFILE . '" /></a> ' . $emailIMG . ' ' . $pmIMG . "\n";
                    echo " </div>\n";
                }
                echo '</td>';
                echo '</tr>';
                echo '</table>';
            }
            echo $tabs->endTab();
        }
        echo $tabs->endPane();
        if (isset($_REQUEST['tab'])) {
            $_CB_framework->outputCbJQuery("showCBTabPaneMy( '" . addslashes(urldecode(stripslashes(cbGetParam($_REQUEST, 'tab')))) . "' );");
        } elseif (!(count($actions) > 0)) {
            $_CB_framework->outputCbJQuery("tabPanemyCon.setSelectedIndex( 1 );");
        }
        echo '<div style="clear:both;padding:5px"><a href="' . cbSef('index.php?option=com_comprofiler' . getCBprofileItemid(true)) . '">' . _UE_BACK_TO_YOUR_PROFILE . '</a></div>';
    }
 /**
  * Renders the tooltip for a connection
  *
  * @param  \CB\Database\Table\MemberTable  $connection  Connection to render field tip for
  * @return string                                       HTML for the description of the connection
  */
 public static function renderConnectionToolTip($connection)
 {
     $tipField = CBTxt::Th('CONNECTION_TIP_CONNECTED_SINCE_CONNECTION_DATE', 'Connected Since [CONNECTION_DATE]', array('[CONNECTION_DATE]' => cbFormatDate($connection->membersince)));
     if ($connection->type != null) {
         $tipField .= '<br />' . CBTxt::Th('CONNECTION_TIP_TYPES_LIST', '{1} Type: [CONNECTIONS_TYPES]|]1,Inf] Types: [CONNECTIONS_TYPES]|%%COUNT%%', array('%%COUNT%%' => count(explode("|*|", $connection->type)), '[CONNECTIONS_TYPES]' => getConnectionTypes($connection->type)));
     }
     if ($connection->description != null) {
         $tipField .= '<br />' . CBTxt::Th('CONNECTION_TIP_CONNECTION_COMMENT', 'Comment: [CONNECTION_DESCRIPTION]', array('[CONNECTION_DESCRIPTION]' => htmlspecialchars($connection->description)));
     }
     return $tipField;
 }
 /**
  * @param  array       $connections
  * @param  array       $actions
  * @param  int         $total
  * @param  cbTabs      $connMgmtTabs
  * @param  array       $pagingParams
  * @param  int         $perpage
  * @param  array|null  $connecteds
  */
 static function manageConnections($connections, $actions, $total, &$connMgmtTabs, &$pagingParams, $perpage, $connecteds = null)
 {
     global $_CB_framework, $ueConfig, $_PLUGINS, $_REQUEST;
     $results = $_PLUGINS->trigger('onBeforeManageConnectionsFormDisplay', array(&$connections, &$actions, &$total, &$connMgmtTabs, &$pagingParams, &$perpage, &$connecteds));
     if ($_PLUGINS->is_errors()) {
         echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n";
         exit;
     }
     outputCbTemplate(1);
     initToolTip(1);
     cbValidator::loadValidation();
     $js = "if ( typeof confirmSubmit != 'function' ) {" . "function confirmSubmit() {" . "if ( confirm( '" . addslashes(CBTxt::T('UE_CONFIRMREMOVECONNECTION', 'Are you sure you want to remove this connection?')) . "' ) ) {" . "return true;" . "} else {" . "return false;" . "}" . "};" . "}";
     $_CB_framework->document->addHeadScriptDeclaration($js);
     $connectionCategories = explode("\n", $ueConfig['connection_categories']);
     $connectionTypes = array();
     if ($connectionCategories) {
         foreach ($connectionCategories as $connectionCategory) {
             if (trim($connectionCategory) != null && trim($connectionCategory) != "") {
                 $connectionTypes[] = moscomprofilerHTML::makeOption(trim($connectionCategory), CBTxt::T(trim($connectionCategory)));
             }
         }
     }
     $tabs = new cbTabs(0, 1);
     $pageClass = $_CB_framework->getMenuPageClass();
     $return = '<div class="cbManageConnections cb_template cb_template_' . selectTemplate('dir') . ($pageClass ? ' ' . htmlspecialchars($pageClass) : null) . '">';
     if (is_array($results)) {
         $return .= implode('', $results);
     }
     $return .= '<div class="page-header"><h3>' . CBTxt::Th('UE_MANAGECONNECTIONS', 'Manage Connections') . '</h3></div>' . $tabs->startPane('myCon') . $tabs->startTab('myCon', CBTxt::Th('UE_MANAGEACTIONS', 'Manage Actions') . ' <span class="badge">' . count($actions) . '</span>', 'action');
     if (!count($actions) > 0) {
         $return .= '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_NOACTIONREQUIRED', 'No Pending Actions') . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>';
     } else {
         $return .= '<form action="' . $_CB_framework->viewUrl('processconnectionactions') . '" method="post" id="adminForm" name="adminForm" class="cb_form form-auto cbValidation">' . '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_CONNECT_ACTIONREQUIRED', 'Below you see users proposing to connect with you. You have the choice to accept or decline their request.') . '</div>' . '<div class="table">';
         foreach ($actions as $action) {
             $cbUser = CBuser::getInstance((int) $action->id, false);
             $tipField = '<b>' . CBTxt::Th('UE_CONNECTIONREQUIREDON', 'Connection Required on') . '</b>: ' . $_CB_framework->getUTCDate(array($ueConfig['date_format'], 'Y-m-d'), $action->membersince);
             if ($action->reason != null) {
                 $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTIONMESSAGE', 'Personal message included') . '</b>: <br />' . htmlspecialchars($action->reason, ENT_QUOTES);
             }
             $tipTitle = CBTxt::Th('UE_CONNECTIONREQUESTDETAIL', 'Connection Request Details');
             $htmlText = $cbUser->getField('avatar', null, 'html', 'none', 'list', 0, true);
             $tooltip = cbTooltip(1, $tipField, $tipTitle, 300, null, $htmlText, null, 'style="display: inline-block; padding: 5px;"');
             $return .= '<div class="containerBox img-thumbnail">' . '<div class="containerBoxInner" style="min-height: 130px; min-width: 90px;">' . $cbUser->getField('onlinestatus', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('formatname', null, 'html', 'none', 'list', 0, true) . '<br />' . $tooltip . '<br />' . '<span class="fa fa-check" title="' . htmlspecialchars(CBTxt::T('UE_ACCEPTCONNECTION', 'Accept Connection')) . '"></span>' . ' <input type="radio" name="' . (int) $action->id . 'action" value="a" checked="checked" />' . ' <span class="fa fa-times" title="' . htmlspecialchars(CBTxt::T('UE_DECLINECONNECTION', 'Decline Connection')) . '"></span>' . ' <input type="radio" name="' . (int) $action->id . 'action" value="d" />' . '<input type="hidden" name="uid[]" value="' . (int) $action->id . '" />' . '</div>' . '</div>';
         }
         $return .= '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbMngConnSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_UPDATE', 'Update')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>' . cbGetSpoofInputTag('manageconnections') . '</form>';
     }
     $return .= $tabs->endTab() . $tabs->startTab('myCon', CBTxt::Th('UE_MANAGECONNECTIONS', 'Manage Connections'), 'connections');
     if (!count($connections) > 0) {
         $return .= '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_NOCONNECTIONS', 'This user has no current connections.') . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>';
     } else {
         $return .= '<form action="' . $_CB_framework->viewUrl('saveconnections') . '" method="post" id="adminForm" name="adminForm" class="cb_form form-auto cbValidation">' . '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_CONNECT_MANAGECONNECTIONS', 'Below you see users to whom you are connected directly. ') . '</div>' . '<table class="table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th style="width: 25%;" class="text-center">' . CBTxt::Th('UE_CONNECTION', 'Connections') . '</th>' . '<th style="width: 35%;" class="text-center">' . CBTxt::Th('UE_CONNECTIONTYPE', 'Type') . '</th>' . '<th style="width: 40%;" class="text-center">' . CBTxt::Th('UE_CONNECTIONCOMMENT', 'Comment') . '</th>' . '</tr>' . '</thead>' . '<tbody>';
         $i = 1;
         foreach ($connections as $connection) {
             $cbUser = CBuser::getInstance((int) $connection->id, false);
             $tipField = '<b>' . CBTxt::Th('UE_CONNECTEDSINCE', 'Connected Since') . '</b>: ' . $_CB_framework->getUTCDate(array($ueConfig['date_format'], 'Y-m-d'), $connection->membersince);
             if ($connection->type != null) {
                 $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTIONTYPE', 'Type') . '</b>: ' . getConnectionTypes($connection->type);
             }
             if ($connection->description != null) {
                 $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTEDCOMMENT', 'Comment') . '</b>: ' . htmlspecialchars($connection->description);
             }
             $tipTitle = CBTxt::Th('UE_CONNECTEDDETAIL', 'Connection Details');
             $htmlText = $cbUser->getField('avatar', null, 'html', 'none', 'list', 0, true);
             $tooltip = cbTooltip(1, $tipField, $tipTitle, 300, null, $htmlText, null, 'style="display: inline-block; padding: 5px;"');
             if ($connection->accepted == 1 && $connection->pending == 1) {
                 $actionImg = '<span class="fa fa-clock-o" title="' . htmlspecialchars(CBTxt::T('UE_CONNECTIONPENDING', 'Connection Pending')) . '"></span>' . ' <a href="' . $_CB_framework->viewUrl('removeconnection', true, array('act' => 'manage', 'connectionid' => (int) $connection->memberid)) . '" onclick="return confirmSubmit();" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
             } elseif ($connection->accepted == 1 && $connection->pending == 0) {
                 $actionImg = '<a href="' . $_CB_framework->viewUrl('removeconnection', true, array('act' => 'manage', 'connectionid' => (int) $connection->memberid)) . '" onclick="return confirmSubmit();" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
             } elseif ($connection->accepted == 0) {
                 $actionImg = '<a href="' . $_CB_framework->viewUrl('acceptconnection', true, array('act' => 'manage', 'connectionid' => (int) $connection->memberid)) . '" onclick="return confirmSubmit();" >' . '<span class="fa fa-check-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_ACCEPTCONNECTION', 'Accept Connection')) . '"></span>' . '</a>' . ' <a href="' . $_CB_framework->viewUrl('removeconnection', true, array('act' => 'manage', 'connectionid' => (int) $connection->memberid)) . '" onclick="return confirmSubmit();" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
             } else {
                 $actionImg = null;
             }
             $return .= '<tr>' . '<td class="text-center">' . $cbUser->getField('onlinestatus', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('formatname', null, 'html', 'none', 'list', 0, true) . '<br />' . $tooltip . '<br />' . $actionImg . ' <a href="' . $_CB_framework->userProfileUrl((int) $connection->memberid) . '">' . '<span class="fa fa-user" title="' . htmlspecialchars(CBTxt::T('UE_VIEWPROFILE', 'View Profile')) . '"></span>' . '</a>' . ' ' . $cbUser->getField('email', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('pm', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . '</td>' . '<td class="text-center">' . moscomprofilerHTML::selectList($connectionTypes, $connection->id . 'connectiontype[]', 'class="form-control" multiple="multiple" size="5"', 'value', 'text', explode('|*|', trim($connection->type)), 0) . '</td>' . '<td class="text-center">' . '<textarea cols="25" class="form-control"  rows="5" name="' . (int) $connection->id . 'description">' . htmlspecialchars($connection->description) . '</textarea>' . '<input type="hidden" name="uid[]" value="' . (int) $connection->id . '" />' . '</td>' . '</tr>';
             $i = $i == 1 ? 2 : 1;
         }
         $return .= '</tbody>' . '</table>';
         if ($perpage < $total) {
             $return .= '<div class="form-group cb_form_line text-center clearfix">' . $connMgmtTabs->_writePaging($pagingParams, 'connections_', $perpage, $total, 'manageconnections') . '</div>';
         }
         $return .= '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbMngConnSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_UPDATE', 'Update')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>' . cbGetSpoofInputTag('manageconnections') . '</form>';
     }
     $return .= $tabs->endTab();
     if ($ueConfig['autoAddConnections'] == 0) {
         $return .= $tabs->startTab('myCon', CBTxt::Th('UE_CONNECTEDWITH', 'Manage Connections With Me'), 'connected');
         if (!count($connecteds) > 0) {
             $return .= '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_NOCONNECTEDWITH', 'There are currently no users connected with you.') . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>';
         } else {
             $htmlConnectedWidth = CBTxt::Th('UE_CONNECT_CONNECTEDWITH', '');
             $return .= ($htmlConnectedWidth ? '<div class="form-group cb_form_line clearfix tab_description">' . $htmlConnectedWidth . '</div>' : null) . '<div class="table">';
             foreach ($connecteds as $connected) {
                 $cbUser = CBuser::getInstance((int) $connected->id, false);
                 $tipField = '<b>' . CBTxt::Th('UE_CONNECTEDSINCE', 'Connected Since') . '</b>: ' . $_CB_framework->getUTCDate(array($ueConfig['date_format'], 'Y-m-d'), $connected->membersince);
                 if ($connected->type != null) {
                     $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTIONTYPE', 'Type') . '</b>: ' . getConnectionTypes($connected->type);
                 }
                 if ($connected->description != null) {
                     $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTEDCOMMENT', 'Comment') . '</b>: ' . htmlspecialchars($connected->description);
                 }
                 $tipTitle = CBTxt::Th('UE_CONNECTEDDETAIL', 'Connection Details');
                 $htmlText = $cbUser->getField('avatar', null, 'html', 'none', 'list', 0, true);
                 $tooltip = cbTooltip(1, $tipField, $tipTitle, 300, null, $htmlText, null, 'style="padding: 5px;"');
                 if ($connected->accepted == 1 && $connected->pending == 1) {
                     $actionImg = '<span class="fa fa-clock-o" title="' . htmlspecialchars(CBTxt::T('UE_CONNECTIONPENDING', 'Connection Pending')) . '"></span>' . ' <a href="' . $_CB_framework->viewUrl('removeconnection', true, array('act' => 'manage', 'connectionid' => (int) $connected->memberid)) . '" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
                 } elseif ($connected->accepted == 1 && $connected->pending == 0) {
                     $actionImg = '<a href="' . $_CB_framework->viewUrl('denyconnection', true, array('act' => 'manage', 'connectionid' => (int) $connected->referenceid)) . '" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
                 } elseif ($connected->accepted == 0) {
                     $actionImg = '<a href="' . $_CB_framework->viewUrl('acceptconnection', true, array('act' => 'manage', 'connectionid' => (int) $connected->referenceid)) . '" >' . '<span class="fa fa-check-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_ACCEPTCONNECTION', 'Accept Connection')) . '"></span>' . '</a>' . ' <a href="' . $_CB_framework->viewUrl('denyconnection', true, array('act' => 'manage', 'connectionid' => (int) $connected->referenceid)) . '" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
                 } else {
                     $actionImg = null;
                 }
                 $return .= '<div class="containerBox img-thumbnail">' . '<div class="containerBoxInner" style="min-height: 130px; min-width: 90px;">' . $actionImg . '<br />' . $cbUser->getField('onlinestatus', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('formatname', null, 'html', 'none', 'list', 0, true) . '<br />' . $tooltip . '<br />' . ' <a href="' . $_CB_framework->userProfileUrl((int) $connected->referenceid) . '">' . '<span class="fa fa-user" title="' . htmlspecialchars(CBTxt::T('UE_VIEWPROFILE', 'View Profile')) . '"></span>' . '</a>' . ' ' . $cbUser->getField('email', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('pm', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . '</div>' . '</div>';
             }
             $return .= '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>';
         }
         $return .= $tabs->endTab();
     }
     $return .= $tabs->endPane() . '</div>' . cbPoweredBy();
     echo $return;
     $_CB_framework->setMenuMeta();
 }