本文整理汇总了PHP中elgg_set_plugin_user_setting函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_set_plugin_user_setting函数的具体用法?PHP elgg_set_plugin_user_setting怎么用?PHP elgg_set_plugin_user_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_set_plugin_user_setting函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveUserNotificationsSettings
/**
* 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');
}
示例2: theme_haarlem_intranet_site_leave_event
/**
* Listen to the leave site event
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied object
*
* @return void
*/
function theme_haarlem_intranet_site_leave_event($event, $type, $object)
{
if (empty($object) || !$object instanceof ElggRelationship) {
return;
}
// disable mentions notifications for the leaving user
$user_guid = (int) $object->guid_one;
elgg_set_plugin_user_setting('notify', '0', $user_guid, 'mentions');
}
示例3: simplesaml_save_authentication_attributes
/**
* 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');
}
}
示例4: ElggUser
$useremail = $user_profile->email;
$user = new ElggUser();
$user->username = $userlogin;
$user->name = $username;
$user->access_id = ACCESS_PUBLIC;
$user->email = $user_profile->email;
$user->salt = generate_random_cleartext_password();
$user->password = generate_user_password($user, $password);
$user->owner_guid = 0;
$user->container_guid = 0;
if (!$user->save()) {
register_error(elgg_echo('registerbad'));
}
// register user && provider
elgg_set_plugin_user_setting('uid', $user_uid, $user->guid, 'elgg_social_login');
elgg_set_plugin_user_setting('provider', $provider, $user->guid, 'elgg_social_login');
// notice && login
if (elgg_get_plugin_setting("social_login_notify", "social_login") == "yes") {
if (strtolower($provider) == "facebook" || strtolower($provider) == "linkedin") {
if (empty($user->last_login)) {
$message = elgg_echo('social:register:joined');
$adapter->setUserStatus($message);
}
}
}
system_message(elgg_echo('A new user account has been created from your ' . $provider . ' account.'));
login($user);
# {{{ update user profile
// access_id 1 => Logged in users
// 1. About me
create_metadata($user->guid, "description", html_entity_decode($user_profile->description, ENT_COMPAT, 'UTF-8'), "text", $user->guid, 1);
示例5: content_subscriptions_notifications_settings_save_hook
/**
* 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");
}
示例6: elgg_get_config
if ($photo_url) {
$icon_sizes = elgg_get_config('icon_sizes');
$filehandler = new ElggFile();
$filehandler->owner_guid = $new_user->guid;
foreach ($icon_sizes as $size => $dimensions) {
$image = get_resized_image_from_existing_file($photo_url, $dimensions[0], $dimensions[1], $dimensions[2]);
$image = get_resized_image_from_existing_file($photo_url, $dimensions['w'], $dimensions['h'], $dimensions['square'], 0, 0, 0, 0, $dimensions['upscale']);
$filehandler->setFilename("profile/{$new_user->guid}{$size}.jpg");
$filehandler->open('write');
$filehandler->write($image);
$filehandler->close();
}
$new_user->icontime = time();
}
if ($provider && $provider_uid) {
elgg_set_plugin_user_setting("{$provider}:uid", $provider_uid, $new_user->guid, 'elgg_hybridauth');
elgg_trigger_plugin_hook('hybridauth:authenticate', $provider, array('entity' => $new_user));
}
$params = array_merge($params, $metadata);
// @todo should registration be allowed no matter what the plugins return?
if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
$ia = elgg_set_ignore_access(true);
$new_user->delete();
elgg_set_ignore_access($ia);
// @todo this is a generic messages. We could have plugins
// throw a RegistrationException, but that is very odd
// for the plugin hooks system.
throw new RegistrationException(elgg_echo('registerbad'));
}
$subject = elgg_echo('useradd:subject');
$body = elgg_echo('useradd:body', array($name, elgg_get_site_entity()->name, elgg_get_site_entity()->url, $username, $password));
示例7: twitter_api_authorize
/**
* User-initiated Twitter authorization
*
* Callback action from Twitter registration. Registers a single Elgg user with
* the authorization tokens. Will revoke access from previous users when a
* conflict exists.
*
* Depends upon {@link twitter_api_get_authorize_url} being called previously
* to establish session request tokens.
*/
function twitter_api_authorize()
{
$token = twitter_api_get_access_token(get_input('oauth_verifier'));
if (!isset($token['oauth_token']) || !isset($token['oauth_token_secret'])) {
register_error(elgg_echo('twitter_api:authorize:error'));
forward('settings/plugins', 'twitter_api');
}
// make sure no other users are registered to this twitter account.
$options = array('type' => 'user', 'plugin_id' => 'twitter_api', 'plugin_user_setting_name_value_pairs' => array('access_key' => $token['oauth_token'], 'access_secret' => $token['oauth_token_secret']), 'limit' => 0);
$users = elgg_get_entities_from_plugin_user_settings($options);
/* @var ElggUser[] $users */
if ($users) {
foreach ($users as $user) {
// revoke access
elgg_unset_plugin_user_setting('twitter_name', $user->getGUID(), 'twitter_api');
elgg_unset_plugin_user_setting('access_key', $user->getGUID(), 'twitter_api');
elgg_unset_plugin_user_setting('access_secret', $user->getGUID(), 'twitter_api');
}
}
// register user's access tokens
elgg_set_plugin_user_setting('twitter_name', $token['screen_name'], 0, 'twitter_api');
elgg_set_plugin_user_setting('access_key', $token['oauth_token'], 0, 'twitter_api');
elgg_set_plugin_user_setting('access_secret', $token['oauth_token_secret'], 0, 'twitter_api');
// trigger authorization hook
elgg_trigger_plugin_hook('authorize', 'twitter_api', array('token' => $token));
system_message(elgg_echo('twitter_api:authorize:success'));
forward('settings/plugins', 'twitter_api');
}
示例8: au_subgroups_join_group
/**
* Prevents users from joining a subgroup if they're not a member of the parent
*
* @param type $event
* @param type $type
* @param ElggRelationship $object
* @return boolean
*/
function au_subgroups_join_group($event, $type, $object)
{
if ($object instanceof ElggRelationship) {
$user = get_entity($object->guid_one);
$group = get_entity($object->guid_two);
$parent = au_subgroups_get_parent_group($group);
// use temp global config to decide if we should prevent joining
// prevent joining if not a member of the parent group
// except during a subgroup move invitation
$au_subgroups_ignore_join = elgg_get_config('au_subgroups_ignore_join');
if ($parent && !$au_subgroups_ignore_join) {
// cover the case of moved subgroups
// user will have been invited, and have a plugin setting saying which other groups to join
$invited = check_entity_relationship($group->guid, 'invited', $user->guid);
$children_to_join = elgg_get_plugin_user_setting('invitation_' . $group->guid, $user->guid, 'au_subgroups');
if (!empty($children_to_join)) {
$children_to_join = unserialize($children_to_join);
}
if ($invited) {
elgg_set_config('au_subgroups_ignore_join', true);
// we have been invited in through the back door by a subgroup move
// join this user to all parent groups fo this group
if (au_subgroups_join_parents_recursive($group, $user)) {
// we're in, now lets rejoin the children
if (is_array($children_to_join)) {
$children_guids = au_subgroups_get_all_children_guids($group);
foreach ($children_to_join as $child) {
if (in_array($child, $children_guids)) {
$child_group = get_entity($child);
$child_group->join($user);
}
}
}
// delete plugin setting
elgg_set_plugin_user_setting('invitation_' . $group->guid, '', $user->guid, 'au_subgroups');
} else {
// something went wrong with joining the groups
// lets stop everything now
return false;
}
} elseif (!$parent->isMember($user)) {
register_error(elgg_echo('au_subgroups:error:notparentmember'));
return false;
}
}
}
}
示例9: addAuthRecord
/**
* Adds auth records that signify that user is connected to the provider
*
* @param \Elgg\HybridAuth\Provider $provider Provider
* @param mixed $profile Profile object or id
* @return bool
*/
public function addAuthRecord(Provider $provider, $profile)
{
if ($this->handle == Session::DEFAULT_HANDLE) {
elgg_trigger_plugin_hook('hybridauth:authenticate', $provider->getName(), array('provider' => $provider, 'entity' => $this->user, 'profile' => $profile));
} else {
elgg_trigger_plugin_hook('hybridauth:authenticate:session', $provider->getName(), array('profile' => $profile, 'provider' => $provider, 'session' => $this));
}
$uid = is_object($profile) ? $profile->identifier : $profile;
return elgg_set_plugin_user_setting($this->getAuthRecordName($provider), $uid, $this->user->guid, 'elgg_hybridauth');
}
示例10: elgg_set_plugin_user_setting
} 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();
示例11: facebook_connect_authorize
/**
* User-initiated facebook authorization
*
* Callback action from facebook registration. Registers a single Elgg user with
* the authorization tokens. Will revoke access from previous users when a
* conflict exists.
*
*/
function facebook_connect_authorize()
{
$facebook = facebookservice_api();
$access_token = $facebook->getAccessToken();
if (!($userID = $facebook->getUser())) {
register_error(elgg_echo('facebook_connect:authorize:error'));
forward('settings/plugins', 'facebook_connect');
}
// make sure no other users are registered to this facebook account.
$options = array('type' => 'user', 'plugin_user_setting_name_value_pairs' => array('uid' => $userID, 'access_token' => $access_token), 'plugin_user_setting_name_value_pairs_operator' => 'OR', 'limit' => 0);
$users = elgg_get_entities_from_plugin_user_settings($options);
if ($users) {
foreach ($users as $user) {
// revoke access
elgg_unset_plugin_user_setting('uid', $user->getGUID());
elgg_unset_plugin_user_setting('access_token', $user->getGUID());
}
}
// register user's access tokens
elgg_set_plugin_user_setting('uid', $userID);
elgg_set_plugin_user_setting('access_token', $access_token);
system_message(elgg_echo('facebook_connect:authorize:success'));
forward('settings/plugins', 'facebook_connect');
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:32,代码来源:facebook_connect.php
示例12: social_connect_user
function social_connect_user($user_uid, $user, $user_profile, $provider)
{
// register user && provider
elgg_set_plugin_user_setting("{$provider}/uid", $user_uid, $user->guid, 'social_connect');
login($user);
# {{{ user image
if ($user_profile->photoURL) {
$sizes = array('topbar' => array(16, 16, TRUE), 'tiny' => array(25, 25, TRUE), 'small' => array(40, 40, TRUE), 'medium' => array(100, 100, TRUE), 'large' => array(200, 200, FALSE), 'master' => array(550, 550, FALSE));
$filehandler = new ElggFile();
$filehandler->owner_guid = $user->guid;
foreach ($sizes as $size => $dimensions) {
$image = get_resized_image_from_existing_file($user_profile->photoURL, $dimensions[0], $dimensions[1], $dimensions[2]);
$filehandler->setFilename("profile/{$user->guid}{$size}.jpg");
if (!$filehandler->exists()) {
$filehandler->open('write');
$filehandler->write($image);
$filehandler->close();
}
}
$user->icontime = time();
}
# }}} user image
}
示例13: socialink_facebook_create_user
/**
* Create a user based on Facebook information
*
* @param string $token Facebook access token
*
* @return bool|ElggUser
*/
function socialink_facebook_create_user($token)
{
if (empty($token)) {
return false;
}
if (!socialink_facebook_available()) {
return false;
}
$session = new Facebook\FacebookSession($token);
if (empty($session)) {
return false;
}
$request = new FaceBook\FacebookRequest($session, "GET", "/me");
// set correct proxy settings (if needed)
$curl_http_client = socialink_facebook_get_curl_http_client();
$request->setHttpClientHandler($curl_http_client);
try {
$api_result = $request->execute()->getGraphObject(Facebook\GraphUser::className());
} catch (Exception $e) {
}
if (empty($api_result)) {
return false;
}
// get user information
$name = $api_result->getName();
$email = $api_result->getEmail();
if (get_user_by_email($email)) {
register_error(elgg_echo("socialink:networks:create_user:error:email"));
return false;
}
$pwd = generate_random_cleartext_password();
$username = socialink_create_username_from_email($email);
try {
$user_guid = register_user($username, $pwd, $name, $email);
if (empty($user_guid)) {
return false;
}
// show hidden entities
$access = access_get_show_hidden_status();
access_show_hidden_entities(true);
$user = get_user($user_guid);
if (empty($user)) {
access_show_hidden_entities($access);
return false;
}
// register user's access tokens
elgg_set_plugin_user_setting("facebook_access_token", $token, $user_guid, "socialink");
elgg_set_plugin_user_setting("facebook_user_id", $api_result->getId(), $user_guid, "socialink");
// no need for uservalidationbyemail
elgg_unregister_plugin_hook_handler("register", "user", "uservalidationbyemail_disable_new_user");
// sync user data
socialink_facebook_sync_profile_metadata($user->getGUID());
// trigger hook for registration
$params = array("user" => $user, "password" => $pwd, "friend_guid" => 0, "invitecode" => "");
if (elgg_trigger_plugin_hook("register", "user", $params, true) !== false) {
access_show_hidden_entities($access);
// return the user
return $user;
}
// restore hidden entities
access_show_hidden_entities($access);
} catch (Exception $e) {
}
return false;
}
示例14: set_time_limit
<?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);
示例15: unset
$thumb->write($thumbsmall);
$thumb->close();
$file->smallthumb = $prefix . "smallthumb" . $filestorename;
unset($thumbsmall);
}
$thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 600, 600, false);
if ($thumblarge) {
$thumb->setFilename($prefix . "largethumb" . $filestorename);
$thumb->open("write");
$thumb->write($thumblarge);
$thumb->close();
$file->largethumb = $prefix . "largethumb" . $filestorename;
unset($thumblarge);
}
}
}
/**
* Set file folder guids as plugin setting
*/
$folders = new ElggBatch('elgg_get_entities_from_metadata', array('types' => 'object', 'subtypes' => 'hjfilefolder', 'metadata_name_value_pairs' => array('name' => 'handler', 'value' => 'hjwall'), 'limit' => false));
foreach ($folders as $folder) {
elgg_set_plugin_user_setting('wall_collection', $folder->guid, $folder->owner_guid, PLUGIN_ID);
}
/**
* Convert 'hjfilefolder' to 'wall_collection'
*/
$subtypeIdFrom = add_subtype('object', 'hjfilefolder');
$subtypeIdTo = add_subtype('object', 'wallcollection');
$dbprefix = elgg_get_config('dbprefix');
$query = "\tUPDATE {$dbprefix}entities e\r\n\t\t\t\tJOIN {$dbprefix}metadata md ON md.entity_guid = e.guid\r\n\t\t\t\tJOIN {$dbprefix}metastrings msn ON msn.id = md.name_id\r\n\t\t\t\tJOIN {$dbprefix}metastrings msv ON msv.id = md.value_id\r\n\t\t\t\tSET e.subtype = {$subtypeIdTo}\r\n\t\t\t\tWHERE e.subtype = {$subtypeIdFrom} AND msn.string = 'handler' AND msv.string = 'hjwall' ";
elgg_set_ignore_access($ia);