/** * Listen to the login event * * @param string $event the name of the event * @param string $type the type of the event * @param ElggUser $entity supplied entity * * @return void */ function socialink_login_user_handler($event, $type, $entity) { if (empty($entity) || !elgg_instanceof($entity, "user")) { return; } // check if the user wishes to link a network $link_network = get_input("socialink_link_network"); if (!empty($link_network) && socialink_is_available_network($link_network)) { switch ($link_network) { case "twitter": socialink_twitter_authorize($entity->getGUID()); break; case "facebook": socialink_facebook_authorize($entity->getGUID()); break; case "linkedin": socialink_linkedin_authorize($entity->getGUID()); break; case "wordpress": socialink_wordpress_authorize($entity->getGUID()); break; } unset($_SESSION["socialink_token"]); // sync network data elgg_trigger_plugin_hook("socialink:sync", "user", array("user" => $entity, "network" => $link_network)); } // check if network connections are still valid $networks = socialink_get_user_networks($entity->getGUID()); if (empty($networks)) { return; } foreach ($networks as $network) { $response = socialink_validate_network($network, $entity->getGUID()); if ($response === false) { // disconnect from this network and report to user $function = "socialink_" . $network . "_remove_connection"; if (is_callable($function)) { call_user_func($function, $entity->getGUID()); register_error(sprintf(elgg_echo("socialink:network_invalid"), elgg_echo("socialink:network:" . $network))); } } } }
<?php $user_guid = elgg_get_logged_in_user_guid(); if (empty($user_guid)) { return; } $networks = socialink_get_user_networks($user_guid); if (empty($networks)) { return; } // load fancybox elgg_load_js("lightbox"); elgg_load_css("lightbox"); $current_url = elgg_extract("current_url", $vars, current_page_url()); $entity = elgg_extract("entity", $vars); echo "<div id='socialink_share_actions'>"; foreach ($networks as $network) { $href = elgg_normalize_url("socialink/share?network=" . $network . "&url=" . $current_url); $icon = elgg_normalize_url("mod/socialink/_graphics/" . $network . "/login.png"); echo "<div>"; echo "<a href='" . $href . "'>"; echo "<img src='" . $icon . "' />"; echo elgg_echo("socialink:share:" . $network); echo "</a>"; echo "</div>"; } echo "</div>"; ?> <script type="text/javascript"> $(document).ready(function() { $("#socialink_share_actions a").click(function() {