Exemple #1
0
/**
 * Is the connection to Facebook still valid
 *
 * @param int $user_guid the user_guid to check
 *
 * @return bool
 */
function socialink_facebook_validate_connection($user_guid = 0)
{
    $user_guid = sanitise_int($user_guid, false);
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if (empty($user_guid)) {
        return false;
    }
    // can we get a user
    $session = socialink_facebook_is_connected($user_guid);
    if (empty($session)) {
        return false;
    }
    try {
        return $session->validate();
    } catch (Exceptions $e) {
    }
    return false;
}
Exemple #2
0
<?php

$user = elgg_get_page_owner_entity();
$plugin = elgg_extract("entity", $vars);
// for yes/no dropdowns
$yesno_options_values = array("no" => elgg_echo("option:no"), "yes" => elgg_echo("option:yes"));
echo "<div>";
echo "<div class='socialink_usersettings_network_icon' id='socialink_usersettings_facebook_icon'></div>";
echo "<div class='socialink_usersettings_network_config'>";
// is the user conntected
if (socialink_facebook_is_connected($user->getGUID())) {
    $facebook_remove_link = elgg_add_action_tokens_to_url("action/socialink/remove?service=facebook");
    $link_begin = "<a href='" . $facebook_remove_link . "'>";
    $link_end = "</a>";
    echo "<div>" . elgg_echo("socialink:usersettings:facebook:remove", array($link_begin, $link_end)) . "</div>";
    // configure profile synchronisation
    if ($fields = socialink_get_configured_network_fields("facebook")) {
        $network_name = elgg_echo("socialink:network:facebook");
        echo "<br />";
        echo "<div>";
        echo elgg_echo("socialink:usersettings:profile_sync", array($network_name));
        echo "&nbsp;" . elgg_view("input/dropdown", array("name" => "params[facebook_sync_allow]", "options_values" => array_reverse($yesno_options_values), "value" => $plugin->getUserSetting("facebook_sync_allow"), "js" => "onchange='socialink_toggle_network_configure(this, \"facebook\");'"));
        echo "&nbsp;<span id='socialink_facebook_sync_configure' ";
        if ($plugin->getUserSetting("facebook_sync_allow") != "no") {
            echo "class='socialink_network_sync_allow'";
        }
        echo "><a href='javascript:void(0);' onclick='\$(\"#socialink_facebook_sync_fields\").toggle();'>" . elgg_echo("socialink:configure") . "</a></span>";
        echo "</div>";
        echo "<table id='socialink_facebook_sync_fields' class='elgg-table'>";
        echo "<tr>";
        echo "<th>" . elgg_echo("socialink:usersettings:profile_field", array($network_name)) . "</th>";