Пример #1
0
function acceptConnection($userid, $connectionid, $act = 'connections')
{
    global $_CB_framework, $ueConfig, $_PLUGINS;
    if (!$ueConfig['allowConnections']) {
        $msg = CBTxt::Th('UE_FUNCTIONALITY_DISABLED', 'This functionality is currently disabled.');
    } elseif (!($_CB_framework->myId() > 0)) {
        cbNotAuth(true);
        return;
    } else {
        $msg = null;
    }
    $_PLUGINS->loadPluginGroup('user');
    $_PLUGINS->trigger('onBeforeAcceptConnectionRequest', array($userid, $connectionid, &$msg, $act));
    if ($msg) {
        $_CB_framework->enqueueMessage($msg, 'error');
        return;
    }
    $cbCon = new cbConnection($userid);
    if ($cbCon->isConnectionPending($userid, $connectionid) === false) {
        $_CB_framework->enqueueMessage(CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!'), 'error');
        return;
    } else {
        if (!$cbCon->acceptConnection($userid, $connectionid)) {
            $msg = $cbCon->getErrorMSG();
        } else {
            $msg = $cbCon->getUserMSG();
        }
    }
    if ($act == 'connections') {
        cbRedirectToProfile($userid, $msg, null, 'getConnectionTab');
    } elseif ($act == 'manage') {
        cbRedirectToProfile($connectionid, $msg, 'manageconnections', 'cbtabconnections');
    } else {
        cbRedirectToProfile($connectionid, $msg);
    }
}