Exemple #1
0
/**
 * listen to the object creation event
 *
 * @param string     $event       the name of the event
 * @param string     $entity_type the type of the event
 * @param ElggObject $entity      supplied entity
 *
 * @return void
 */
function socialink_create_object_handler($event, $entity_type, $entity)
{
    if (!empty($entity) && elgg_instanceof($entity, "object", "thewire")) {
        if ($networks = socialink_get_available_networks()) {
            foreach ($networks as $network) {
                $setting = elgg_get_plugin_user_setting("thewire_post_" . $network, $entity->getOwner(), "socialink");
                if ($setting == "yes") {
                    $connected = "socialink_" . $network . "_is_connected";
                    if (is_callable($connected) && call_user_func($connected)) {
                        $post_message = "socialink_" . $network . "_post_message";
                        if (is_callable($post_message)) {
                            call_user_func($post_message, $entity->description, $entity->getOwner());
                        }
                    }
                }
            }
        }
    }
}
Exemple #2
0
<?php

$user = elgg_get_page_owner_entity();
if ($user->getGUID() == elgg_get_logged_in_user_guid()) {
    echo "<div id='socialink_usersettings'>";
    // show settings ofr available networks
    if ($networks = socialink_get_available_networks()) {
        foreach ($networks as $network) {
            echo elgg_view("plugins/socialink/usersettings/" . $network, $vars);
        }
    }
    echo "</div>";
} else {
    echo elgg_echo("socialink:usersettings:no_access");
}
Exemple #3
0
/**
 * Returns all the networks the user is connected
 *
 * @param int $user_guid the user to check
 *
 * @return array
 */
function socialink_get_user_networks($user_guid)
{
    $result = array();
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if ($available_networks = socialink_get_available_networks()) {
        foreach ($available_networks as $network) {
            $function = "socialink_" . $network . "_is_connected";
            if (is_callable($function) && call_user_func($function, $user_guid)) {
                $result[] = $network;
            }
        }
    }
    return $result;
}