Esempio n. 1
0
 /**
  * listen to the remove admin event to unset the toggle admin flag
  *
  * @param string     $event  the event
  * @param string     $type   the type of the event
  * @param ElggEntity $entity the affected entity
  *
  * @return void
  */
 public static function removeAdmin($event, $type, $entity)
 {
     if (!$entity instanceof \ElggUser) {
         return;
     }
     elgg_unset_plugin_user_setting('switched_admin', $entity->getGUID(), 'admin_tools');
 }
Esempio n. 2
0
 /**
  * Save the wire_tools preferences for the user
  *
  * @param string $hook         the name of the hook
  * @param stirng $type         the type of the hook
  * @param array  $return_value the current return value
  * @param array  $params       supplied values
  *
  * @return void
  */
 public static function saveUserNotificationsSettings($hook, $type, $return_value, $params)
 {
     $NOTIFICATION_HANDLERS = _elgg_services()->notifications->getMethods();
     if (empty($NOTIFICATION_HANDLERS) || !is_array($NOTIFICATION_HANDLERS)) {
         return;
     }
     $user_guid = (int) get_input('guid');
     if (empty($user_guid)) {
         return;
     }
     $user = get_user($user_guid);
     if (empty($user) || !$user->canEdit()) {
         return;
     }
     $methods = [];
     foreach ($NOTIFICATION_HANDLERS as $method) {
         $setting = get_input("thewire_tools_{$method}");
         if (!empty($setting)) {
             $methods[] = $method;
         }
     }
     if (!empty($methods)) {
         elgg_set_plugin_user_setting('notification_settings', implode(',', $methods), $user->getGUID(), 'thewire_tools');
     } else {
         elgg_unset_plugin_user_setting('notification_settings', $user->getGUID(), 'thewire_tools');
     }
     // set flag for correct fallback behaviour
     elgg_set_plugin_user_setting('notification_settings_saved', '1', $user->getGUID(), 'thewire_tools');
 }
Esempio n. 3
0
 */
$user_guid = (int) get_input('user_guid');
if (empty($user_guid) || $user_guid != elgg_get_logged_in_user_guid()) {
    register_error(elgg_echo('actionunauthorized'));
    forward(REFERER);
}
$user = get_user($user_guid);
if (empty($user)) {
    forward(REFERER);
}
if (!admin_tools_is_admin_user($user)) {
    register_error(elgg_echo('actionunauthorized'));
    forward(REFERER);
}
if ($user->isAdmin()) {
    // make the user a normal user
    $secret = admin_tools_make_switch_admin_secret($user);
    if (!empty($secret)) {
        $user->removeAdmin();
        elgg_set_plugin_user_setting('switched_admin', $secret, $user->getGUID(), 'admin_tools');
        system_message(elgg_echo('admin_tools:action:toggle_admin:success:user'));
    } else {
        register_error(elgg_echo('save:fail'));
    }
} else {
    // make the user an admin
    $user->makeAdmin();
    elgg_unset_plugin_user_setting('switched_admin', $user->getGUID(), 'admin_tools');
    system_message(elgg_echo('admin_tools:action:toggle_admin:success:admin'));
}
forward(REFERER);
Esempio n. 4
0
/**
 * Save the authenticaion attributes provided by the Service Provider (SP) for later use.
 *
 * @param ElggUser    $user        the user to store the attributes for
 * @param string      $saml_source the name of the Service Provider which provided the attributes
 * @param array|false $attributes  the attributes to save, false to remove all attributes
 *
 * @return void
 */
function simplesaml_save_authentication_attributes(ElggUser $user, $saml_source, $attributes = false)
{
    if (!empty($user) && elgg_instanceof($user, "user") && !empty($saml_source) && simplesaml_is_enabled_source($saml_source)) {
        // remove the current attrributes
        elgg_unset_plugin_user_setting($saml_source . "_attributes", $user->getGUID(), "simplesaml");
        // are we allowed to save the attributes
        if (elgg_get_plugin_setting($saml_source . "_save_attributes", "simplesaml")) {
            // save settings
            if (!empty($attributes) && is_array($attributes)) {
                // filter some keys out of the attributes
                unset($attributes["elgg:firstname"]);
                unset($attributes["elgg:lastname"]);
                unset($attributes["elgg:email"]);
                unset($attributes["elgg:external_id"]);
                unset($attributes["elgg:username"]);
                unset($attributes["elgg:auto_link"]);
                elgg_set_plugin_user_setting($saml_source . "_attributes", json_encode($attributes), $user->getGUID(), "simplesaml");
            }
        }
    }
}
Esempio n. 5
0
<?php

$tags = get_input('tags');
$user_guid = (int) get_input('user_guid');
if (empty($user_guid)) {
    register_error(elgg_echo('error:missing_data'));
    forward(REFERER);
}
$user = get_user($user_guid);
if (empty($user) || !elgg_instanceof($user, 'user')) {
    register_error(elgg_echo('error:missing_data'));
    forward(REFERER);
}
if (!$user->canEdit()) {
    register_error(elgg_echo('noaccess'));
    forward(REFERER);
}
if (empty($tags)) {
    elgg_unset_plugin_user_setting('notifications', $user->getGUID(), 'tags_tools');
} else {
    elgg_set_plugin_user_setting('notifications', json_encode($tags), $user->getGUID(), 'tag_tools');
}
system_message(elgg_echo('save:success'));
forward(REFERER);
Esempio n. 6
0
/**
 * Save the content subscriptions preferences for the user
 *
 * @param string $hook         the name of the hook
 * @param stirng $type         the type of the hook
 * @param array  $return_value the current return value
 * @param array  $params       supplied values
 *
 * @return void
 */
function content_subscriptions_notifications_settings_save_hook($hook, $type, $return_value, $params)
{
    $NOTIFICATION_HANDLERS = _elgg_services()->notifications->getMethods();
    if (empty($NOTIFICATION_HANDLERS) || !is_array($NOTIFICATION_HANDLERS)) {
        return;
    }
    $user_guid = (int) get_input("guid");
    if (empty($user_guid)) {
        return;
    }
    $user = get_user($user_guid);
    if (empty($user) || !$user->canEdit()) {
        return;
    }
    $methods = array();
    foreach ($NOTIFICATION_HANDLERS as $method) {
        $setting = get_input("content_subscriptions_" . $method);
        if (!empty($setting)) {
            $methods[] = $method;
        }
    }
    if (!empty($methods)) {
        elgg_set_plugin_user_setting("notification_settings", implode(",", $methods), $user->getGUID(), "content_subscriptions");
    } else {
        elgg_unset_plugin_user_setting("notification_settings", $user->getGUID(), "content_subscriptions");
    }
    // set flag for correct fallback behaviour
    elgg_set_plugin_user_setting("notification_settings_saved", "1", $user->getGUID(), "content_subscriptions");
}
/**
 * Used to Remove facebook access for the currently logged in user.
 *
 * @access public
 * @return void
 */
function facebook_connect_revoke()
{
    // unregister user's access tokens
    elgg_unset_plugin_user_setting('uid');
    elgg_unset_plugin_user_setting('access_token');
    $user = get_loggedin_user();
    system_message(elgg_echo('facebook_connect:revoke:success'));
    forward('settings/plugins/' . $user->username . '/facebook_connect', 'facebook_connect');
}
/**
 * Remove twitter access for the currently logged in user.
 */
function twitter_api_revoke()
{
    // unregister user's access tokens
    elgg_unset_plugin_user_setting('twitter_name', 0, 'twitter_api');
    elgg_unset_plugin_user_setting('access_key', 0, 'twitter_api');
    elgg_unset_plugin_user_setting('access_secret', 0, 'twitter_api');
    system_message(elgg_echo('twitter_api:revoke:success'));
    forward('settings/plugins', 'twitter_api');
}
Esempio n. 9
0
<?php

set_time_limit(0);
$options = array('type' => 'user', 'plugin_id' => 'elgg_social_login', 'plugin_user_setting_names' => array('uid'), 'limit' => 0);
$users = new ElggBatch('elgg_get_entities_from_plugin_user_settings', $options);
foreach ($users as $user) {
    $setting = elgg_get_plugin_user_setting('uid', $user->guid, 'elgg_social_login');
    list($provider, $uid) = explode('_', $setting);
    // Check to see if another record has been created with elgg_hybridauth
    $elgg_hybridauth_options = array('type' => 'user', 'plugin_id' => 'elgg_hybridauth', 'plugin_user_setting_name_value_pairs' => array("{$provider}:uid" => $uid), 'limit' => 0);
    $elgg_hybridauth_users = elgg_get_entities_from_plugin_user_settings($elgg_hybridauth_options);
    if ($elgg_hybridauth_users) {
        $elgg_hybridauth_user = $elgg_hybridauth_users[0];
        if ($user->time_created < $elgg_hybridauth_user->time_created) {
            // elgg_social_login user was created earlier, so give that user the ability to login in with this provider uid
            elgg_unset_plugin_user_setting("{$provider}:uid", $elgg_hybridauth_user->guid, 'elgg_hybridauth');
        }
    } else {
        elgg_set_plugin_user_setting("{$provider}:uid", $uid, $user->guid, 'elgg_hybridauth');
    }
    // keep a backup record
    elgg_unset_plugin_user_setting('uid', $user->guid, 'elgg_social_login');
    elgg_set_plugin_user_setting('elgg_social_login_uid', "{$provider}_{$uid}", 'elgg_hybridauth');
    $i++;
}
system_message(elgg_echo('hybridauth:admin:elgg_social_login:action', array($i)));
forward(REFERER);
Esempio n. 10
0
/**
 * Save the authenticaion attributes provided by the Service Provider (SP) for later use.
 *
 * @param ElggUser    $user        the user to store the attributes for
 * @param string      $saml_source the name of the Service Provider which provided the attributes
 * @param array|false $attributes  the attributes to save, false to remove all attributes
 *
 * @return void
 */
function simplesaml_save_authentication_attributes(ElggUser $user, $saml_source, $attributes = false)
{
    if (!$user instanceof ElggUser || empty($saml_source) || !simplesaml_is_enabled_source($saml_source)) {
        return;
    }
    // remove the current attributes
    elgg_unset_plugin_user_setting("{$saml_source}_attributes", $user->getGUID(), 'simplesaml');
    if (empty($attributes)) {
        // no new attributes to save
        return;
    }
    // are we allowed to save the attributes
    if (elgg_get_plugin_setting("{$saml_source}_save_attributes", 'simplesaml')) {
        // filter some keys out of the attributes
        unset($attributes["elgg:firstname"]);
        unset($attributes["elgg:lastname"]);
        unset($attributes["elgg:email"]);
        unset($attributes["elgg:external_id"]);
        unset($attributes["elgg:username"]);
        unset($attributes["elgg:auto_link"]);
        // save attributes
        elgg_set_plugin_user_setting("{$saml_source}_attributes", json_encode($attributes), $user->getGUID(), 'simplesaml');
    }
}
Esempio n. 11
0
/**
 * Remove facebook access for the currently logged in user.
 */
function facebook_api_revoke()
{
    // unregister user's access tokens
    elgg_unset_plugin_user_setting('uid');
    elgg_unset_plugin_user_setting('access_token');
    system_message(elgg_echo('facebook_api:revoke:success'));
    forward('settings/plugins', 'facebook_api');
}
Esempio n. 12
0
<?php
/**
  Save Custom Background
*/

$user = elgg_get_logged_in_user_entity();
    
$avatar = get_input('avatar_panel');
	if ($avatar) {
		elgg_set_plugin_user_setting('avatar_panel', 1, $user->guid, 'deyan');
	} else {
		elgg_unset_plugin_user_setting('avatar_panel', $user->guid, 'deyan');
	}
	
Esempio n. 13
0
set_time_limit(0);
$providers = unserialize(elgg_get_plugin_setting('providers', 'elgg_hybridauth'));
foreach ($providers as $provider => $settings) {
    // Let's check to see if social_connect was used previoiusly to authenticate users
    $options = array('type' => 'user', 'plugin_id' => 'social_connect', 'plugin_user_setting_names' => array("{$provider}/uid"), 'limit' => 0);
    $users = new ElggBatch('elgg_get_entities_from_plugin_user_settings', $options);
    if ($users) {
        foreach ($users as $user) {
            $uid = elgg_get_plugin_user_setting("{$provider}/uid", $user->guid, 'social_connect');
            // Check to see if another record has been created with elgg_hybridauth
            $elgg_hybridauth_options = array('type' => 'user', 'plugin_id' => 'elgg_hybridauth', 'plugin_user_setting_name_value_pairs' => array("{$provider}:uid" => $uid), 'limit' => 0);
            $elgg_hybridauth_users = elgg_get_entities_from_plugin_user_settings($elgg_hybridauth_options);
            if ($elgg_hybridauth_users) {
                $elgg_hybridauth_user = $elgg_hybridauth_users[0];
                if ($user->time_created < $elgg_hybridauth_user->time_created) {
                    // elgg_social_login user was created earlier, so give that user the ability to login in with this provider uid
                    elgg_unset_plugin_user_setting("{$provider}:uid", $elgg_hybridauth_user->guid, 'elgg_hybridauth');
                }
            } else {
                elgg_set_plugin_user_setting("{$provider}:uid", $uid, $user->guid, 'elgg_hybridauth');
            }
            // keep a backup record
            elgg_unset_plugin_user_setting("{$provider}/uid", $user->guid, 'social_connect');
            elgg_set_plugin_user_setting("social_connect_{$provider}/uid", $uid, 'elgg_hybridauth');
            $i++;
        }
    }
}
system_message(elgg_echo('hybridauth:admin:social_connect:action', array($i)));
forward(REFERER);
Esempio n. 14
0
    foreach ($users as $user) {
        $setting = elgg_get_plugin_user_setting("notify_mention", $user->getGUID(), "thewire_tools");
        if ($setting == "yes") {
            $notification_settings = get_user_notification_settings($user->getGUID());
            if (!empty($notification_settings)) {
                $notification_settings = (array) $notification_settings;
                $methods = array();
                foreach ($notification_settings as $method => $value) {
                    if ($value == "yes") {
                        $methods[] = $method;
                    }
                }
                if (!empty($methods)) {
                    elgg_set_plugin_user_setting("notification_settings", implode(",", $methods), $user->getGUID(), "thewire_tools");
                }
            }
        }
        if (!elgg_unset_plugin_user_setting("notify_mention", $user->getGUID(), "thewire_tools")) {
            $error_count++;
        } else {
            $success_count++;
        }
    }
}
access_show_hidden_entities($access_status);
// replace events and hooks
_elgg_services()->events = $original_events;
_elgg_services()->hooks = $original_hooks;
_elgg_services()->db->enableQueryCache();
// Give some feedback for the UI
echo json_encode(array("numSuccess" => $success_count, "numErrors" => $error_count));
Esempio n. 15
0
<?php

$user_guid = (int) get_input('user_guid');
$user = get_user($user_guid);
if (empty($user)) {
    register_error(elgg_echo('error:missing_data'));
    forward(REFERER);
}
if ($user->isAdmin()) {
    register_error(elgg_echo('site_announcements:action:toggle_editor:error:is_admin', array($user->name)));
    forward(REFERER);
}
if (site_announcements_is_editor($user)) {
    elgg_unset_plugin_user_setting('editor', $user->getGUID(), 'site_announcements');
    system_message(elgg_echo('site_announcements:action:toggle_editor:unmake', array($user->name)));
} else {
    elgg_set_plugin_user_setting('editor', time(), $user->getGUID(), 'site_announcements');
    system_message(elgg_echo('site_announcements:action:toggle_editor:make', array($user->name)));
}
forward(REFERER);
Esempio n. 16
0
<?php

$tags = get_input("tags");
$user_guid = (int) get_input("user_guid");
if (empty($user_guid)) {
    register_error(elgg_echo("error:missing_data"));
    forward(REFERER);
}
$user = get_user($user_guid);
if (empty($user) || !elgg_instanceof($user, "user")) {
    register_error(elgg_echo("error:missing_data"));
    forward(REFERER);
}
if (!$user->canEdit()) {
    register_error(elgg_echo("noaccess"));
    forward(REFERER);
}
if (empty($tags)) {
    elgg_unset_plugin_user_setting("notifications", $user->getGUID(), "tags_tools");
} else {
    elgg_set_plugin_user_setting("notifications", json_encode($tags), $user->getGUID(), "tag_tools");
}
system_message(elgg_echo("save:success"));
forward(REFERER);
Esempio n. 17
0
/**
 * Remove the Facebook connection
 *
 * @param int $user_guid the user_guid to remove to connection for
 *
 * @return bool
 */
function socialink_facebook_remove_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;
    }
    if (!socialink_facebook_is_connected($user_guid)) {
        return false;
    }
    // remove plugin settings
    elgg_unset_plugin_user_setting("facebook_access_token", $user_guid, "socialink");
    elgg_unset_plugin_user_setting("facebook_user_id", $user_guid, "socialink");
    return true;
}
Esempio n. 18
0
	} else {
		elgg_unset_plugin_user_setting('background_fixed', $user->guid, 'deyan');
	}

    
elgg_set_plugin_user_setting('background', $background, $user->guid, 'deyan');
    
    
    
$custom = get_input('background_custom');
	if ($custom) {
		elgg_set_plugin_user_setting('background_custom', 1, $user->guid, 'deyan');
	} else {
		elgg_unset_plugin_user_setting('background_custom', $user->guid, 'deyan');
	}
	

/*
Use windows scroll
*/	
$scroll = get_input('window_scroll');
	if ($scroll) {
		elgg_set_plugin_user_setting('window_scroll', 1, $user->guid, 'deyan');
	} else {
		elgg_unset_plugin_user_setting('window_scroll', $user->guid, 'deyan');
	}
	
/******************************
 UPGRADE SIMPLECACHE
******************************/
    elgg_regenerate_simplecache();
Esempio n. 19
0
File: Session.php Progetto: n8b/VMN
 /**
  * Removes auth records that signify that user is connected to the provider
  *
  * @param \Elgg\HybridAuth\Provider $provider Provider
  * @return bool
  */
 public function removeAuthRecord(Provider $provider)
 {
     if ($this->handle == Session::DEFAULT_HANDLE) {
         elgg_trigger_plugin_hook('hybridauth:deauthenticate', $provider->getName(), array('provider' => $provider, 'entity' => $this->user));
     } else {
         elgg_trigger_plugin_hook('hybridauth:deauthenticate:session', $provider->getName(), array('provider' => $provider, 'session' => $this));
     }
     return elgg_unset_plugin_user_setting($this->getAuthRecordName($provider), $this->user->guid, 'elgg_hybridauth');
 }
Esempio n. 20
0
/**
 * Remove the LinkedIn connection
 *
 * @param int $user_guid the user_guid to remove to connection for
 *
 * @return bool
 */
function socialink_linkedin_remove_connection($user_guid = 0)
{
    $result = false;
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if (!empty($user_guid) && ($keys = socialink_linkedin_is_connected($user_guid))) {
        if ($api = socialink_linkedin_get_api_object($keys)) {
            // remove LinkedIn subscription
            try {
                $api->revoke();
            } catch (Exception $e) {
            }
        }
        // remove plugin settings
        elgg_unset_plugin_user_setting("linkedin_oauth_token", $user_guid, "socialink");
        elgg_unset_plugin_user_setting("linkedin_oauth_secret", $user_guid, "socialink");
        $result = true;
    }
    return $result;
}
<?php

$user = elgg_get_logged_in_user_entity();
if (empty($user)) {
    return;
}
if (theme_haarlem_intranet_sidebar_collapsed()) {
    elgg_unset_plugin_user_setting('sidebar_collapsed', $user->guid, 'theme_haarlem_intranet');
} else {
    elgg_set_plugin_user_setting('sidebar_collapsed', true, $user->guid, 'theme_haarlem_intranet');
}
Esempio n. 22
0
/**
 * Clears a user-specific plugin setting
 *
 * @param str $name      Name of the plugin setting
 * @param int $user_guid Defaults to logged in user
 * @param str $plugin_id Defaults to contextual plugin name
 *
 * @deprecated 1.8 Use elgg_unset_plugin_user_setting or ElggPlugin->unsetUserSetting().
 * @return bool Success
 */
function clear_plugin_usersetting($name, $user_guid = 0, $plugin_id = '')
{
    elgg_deprecated_notice('clear_plugin_usersetting() is deprecated by elgg_unset_plugin_usersetting()', 1.8);
    return elgg_unset_plugin_user_setting($name, $user_guid, $plugin_id);
}
Esempio n. 23
0
/**
 * Remove the Twitter connection
 *
 * @param int $user_guid the user_guid to remove to connection for
 *
 * @return bool
 */
function socialink_twitter_remove_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;
    }
    if (!socialink_twitter_is_connected($user_guid)) {
        return false;
    }
    // cleanup all twitter user settings
    elgg_unset_plugin_user_setting("twitter_oauth_token", $user_guid, "socialink");
    elgg_unset_plugin_user_setting("twitter_oauth_secret", $user_guid, "socialink");
    elgg_unset_plugin_user_setting("twitter_screen_name", $user_guid, "socialink");
    elgg_unset_plugin_user_setting("twitter_user_id", $user_guid, "socialink");
    return true;
}