• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP set_user_notification_setting函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中set_user_notification_setting函数的典型用法代码示例。如果您正苦于以下问题:PHP set_user_notification_setting函数的具体用法?PHP set_user_notification_setting怎么用?PHP set_user_notification_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_user_notification_setting函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: theme_haarlem_intranet_site_join_event

/**
 * Listen to the join 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_join_event($event, $type, $object)
{
    if (empty($object) || !$object instanceof ElggRelationship) {
        return;
    }
    $user_guid = (int) $object->guid_one;
    // enable site notifications for the new user
    set_user_notification_setting($user_guid, 'site', true);
    // enable mentions notifications for the new user
    elgg_set_plugin_user_setting('notify', '1', $user_guid, 'mentions');
}
开发者ID:Twizanex,项目名称:theme_haarlem_intranet,代码行数:20,代码来源:events.php


示例2: set_no_notifications_clear_user_meta

/**
 * This function checks and if necessary sets the email notifications to disabled the first time a user logs in
 * @param String $event
 * @param String $object_type
 * @param Object $object
 */
function set_no_notifications_clear_user_meta($event, $object_type, $object)
{
    // check if the user should be considered
    if (elgg_get_plugin_setting('setNoNotif_time', 'set_no_notifications') < $object->time_created) {
        if ($event == 'login:after' && $object_type == 'user' && $object instanceof ElggUser) {
            $time = elgg_get_plugin_setting('setNoNotif_time', 'set_no_notifications');
            if (!$object->set_no_notifications && $object->time_created > $time) {
                $method = array('email' => 'no');
                $result = false;
                foreach ($method as $k => $v) {
                    $result = set_user_notification_setting($object['user']->guid, $k, $v == 'yes' ? true : false);
                    if (!$result) {
                        $object->set_no_notifications = false;
                    } else {
                        $object->set_no_notifications = true;
                    }
                }
            }
        }
    }
    return true;
}
开发者ID:iionly,项目名称:set_no_notifications,代码行数:28,代码来源:start.php


示例3: update_user_personal_notifications_settings

function update_user_personal_notifications_settings($guid, $metodos)
{
    switch ($metodos) {
        case 'email':
            set_user_notification_setting($guid, 'site', false);
            set_user_notification_setting($guid, 'email', true);
            break;
        case 'site':
            set_user_notification_setting($guid, 'site', true);
            set_user_notification_setting($guid, 'email', false);
            break;
        case 'todos':
            set_user_notification_setting($guid, 'site', true);
            set_user_notification_setting($guid, 'email', true);
            break;
        case 'ninguno':
            set_user_notification_setting($guid, 'site', false);
            set_user_notification_setting($guid, 'email', false);
        default:
            // (metodo = nocambiar)
            break;
    }
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:23,代码来源:start.php


示例4: register_user

/**
 * Registers a user, returning false if the username already exists
 *
 * @param string $username The username of the new user
 * @param string $password The password
 * @param string $name The user's display name
 * @param string $email Their email address
 * @param bool $allow_multiple_emails Allow the same email address to be registered multiple times?
 * @param int $friend_guid Optionally, GUID of a user this user will friend once fully registered 
 * @return int|false The new user's GUID; false on failure
 */
function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $friend_guid = 0, $invitecode = '')
{
    // Load the configuration
    global $CONFIG;
    $username = trim($username);
    $password = trim($password);
    $name = trim($name);
    $email = trim($email);
    // A little sanity checking
    if (empty($username) || empty($password) || empty($name) || empty($email)) {
        return false;
    }
    // See if it exists and is disabled
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // Validate email address
    if (!validate_email_address($email)) {
        throw new RegistrationException(elgg_echo('registration:emailnotvalid'));
    }
    // Validate password
    if (!validate_password($password)) {
        throw new RegistrationException(elgg_echo('registration:passwordnotvalid'));
    }
    // Validate the username
    if (!validate_username($username)) {
        throw new RegistrationException(elgg_echo('registration:usernamenotvalid'));
    }
    // Check to see if $username exists already
    if ($user = get_user_by_username($username)) {
        //return false;
        throw new RegistrationException(elgg_echo('registration:userexists'));
    }
    // If we're not allowed multiple emails then see if this address has been used before
    if (!$allow_multiple_emails && get_user_by_email($email)) {
        throw new RegistrationException(elgg_echo('registration:dupeemail'));
    }
    access_show_hidden_entities($access_status);
    // Check to see if we've registered the first admin yet.
    // If not, this is the first admin user!
    $admin = datalist_get('admin_registered');
    // Otherwise ...
    $user = new ElggUser();
    $user->username = $username;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = ACCESS_PUBLIC;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->owner_guid = 0;
    // Users aren't owned by anyone, even if they are admin created.
    $user->container_guid = 0;
    // Users aren't contained by anyone, even if they are admin created.
    $user->save();
    // If $friend_guid has been set, make mutual friends
    if ($friend_guid) {
        if ($friend_user = get_user($friend_guid)) {
            if ($invitecode == generate_invite_code($friend_user->username)) {
                $user->addFriend($friend_guid);
                $friend_user->addFriend($user->guid);
            }
        }
    }
    global $registering_admin;
    if (!$admin) {
        $user->admin = true;
        datalist_set('admin_registered', 1);
        $registering_admin = true;
    } else {
        $registering_admin = false;
    }
    // Turn on email notifications by default
    set_user_notification_setting($user->getGUID(), 'email', true);
    return $user->getGUID();
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:86,代码来源:users.php


示例5: register_user

/**
 * Registers a user, returning false if the username already exists
 *
 * @param string $username              The username of the new user
 * @param string $password              The password
 * @param string $name                  The user's display name
 * @param string $email                 Their email address
 * @param bool   $allow_multiple_emails Allow the same email address to be
 *                                      registered multiple times?
 * @param int    $friend_guid           GUID of a user to friend once fully registered
 * @param string $invitecode            An invite code from a friend
 *
 * @return int|false The new user's GUID; false on failure
 */
function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $friend_guid = 0, $invitecode = '')
{
    // Load the configuration
    global $CONFIG;
    // no need to trim password.
    $username = trim($username);
    $name = trim(strip_tags($name));
    $email = trim($email);
    // A little sanity checking
    if (empty($username) || empty($password) || empty($name) || empty($email)) {
        return false;
    }
    // Make sure a user with conflicting details hasn't registered and been disabled
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    if (!validate_email_address($email)) {
        throw new RegistrationException(elgg_echo('registration:emailnotvalid'));
    }
    if (!validate_password($password)) {
        throw new RegistrationException(elgg_echo('registration:passwordnotvalid'));
    }
    if (!validate_username($username)) {
        throw new RegistrationException(elgg_echo('registration:usernamenotvalid'));
    }
    if ($user = get_user_by_username($username)) {
        throw new RegistrationException(elgg_echo('registration:userexists'));
    }
    if (!$allow_multiple_emails && get_user_by_email($email)) {
        throw new RegistrationException(elgg_echo('registration:dupeemail'));
    }
    access_show_hidden_entities($access_status);
    // Create user
    $user = new ElggUser();
    $user->username = $username;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = ACCESS_PUBLIC;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->owner_guid = 0;
    // Users aren't owned by anyone, even if they are admin created.
    $user->container_guid = 0;
    // Users aren't contained by anyone, even if they are admin created.
    $user->language = get_current_language();
    $user->save();
    // If $friend_guid has been set, make mutual friends
    if ($friend_guid) {
        if ($friend_user = get_user($friend_guid)) {
            if ($invitecode == generate_invite_code($friend_user->username)) {
                $user->addFriend($friend_guid);
                $friend_user->addFriend($user->guid);
                // @todo Should this be in addFriend?
                add_to_river('river/relationship/friend/create', 'friend', $user->getGUID(), $friend_guid);
                add_to_river('river/relationship/friend/create', 'friend', $friend_guid, $user->getGUID());
            }
        }
    }
    // Turn on email notifications by default
    set_user_notification_setting($user->getGUID(), 'email', true);
    return $user->getGUID();
}
开发者ID:riggo,项目名称:Elgg,代码行数:76,代码来源:users.php


示例6: set_time_limit

<?php

/**
 * Reset all mentions settings to enable notifications
 */
// may take a while
set_time_limit(0);
$options = array('type' => 'user', 'limit' => false, 'relationship' => 'member_of_site', 'relationship_guid' => elgg_get_site_entity()->getGUID(), 'inverse_relationship' => true);
$counter = 0;
$users = new ElggBatch('elgg_get_entities_from_relationship', $options);
foreach ($users as $user) {
    $counter++;
    elgg_set_plugin_user_setting('notify', '1', $user->getGUID(), 'mentions');
    set_user_notification_setting($user->getGUID(), 'site', true);
}
system_message(elgg_echo('theme_haarlem_intranet:action:mentions:reset', array($counter)));
forward(REFERER);
开发者ID:Twizanex,项目名称:theme_haarlem_intranet,代码行数:17,代码来源:reset_mentions.php


示例7: get_input

<?php

/**
 * Elgg notifications user preference save acion.
 *
 * @package Elgg
 * @subpackage Core
 * @author Curverider Ltd
 * @link http://elgg.org/
 */
// Method
$method = get_input('method');
gatekeeper();
$result = false;
foreach ($method as $k => $v) {
    $result = set_user_notification_setting($_SESSION['user']->guid, $k, $v == 'yes' ? true : false);
    if (!$result) {
        register_error(elgg_echo('notifications:usersettings:save:fail'));
    }
}
if ($result) {
    system_message(elgg_echo('notifications:usersettings:save:ok'));
} else {
    register_error(elgg_echo('notifications:usersettings:save:fail'));
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:25,代码来源:save.php


示例8: _elgg_save_notification_user_settings

/**
 * Save personal notification settings - input comes from request
 *
 * @return void
 * @access private
 */
function _elgg_save_notification_user_settings()
{
    $method = get_input('method');
    $current_settings = get_user_notification_settings();
    $result = false;
    foreach ($method as $k => $v) {
        // check if setting has changed and skip if not
        if ($current_settings->{$k} == ($v == 'yes')) {
            continue;
        }
        $result = set_user_notification_setting(elgg_get_logged_in_user_guid(), $k, $v == 'yes' ? true : false);
        if (!$result) {
            register_error(elgg_echo('notifications:usersettings:save:fail'));
        }
    }
    if ($result) {
        system_message(elgg_echo('notifications:usersettings:save:ok'));
    }
}
开发者ID:sephiroth88,项目名称:Elgg,代码行数:25,代码来源:notification.php


示例9: elgg_get_logged_in_user_entity

<?php

/**
 * Elgg notifications
 *
 * @package ElggNotifications
 */
$user = elgg_get_logged_in_user_entity();
$result = false;
$changed = false;
$old_settings = get_user_notification_settings($user->guid);
global $NOTIFICATION_HANDLERS;
foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
    $personal[$method] = get_input($method . 'personal');
    if ($old_settings->{$method} && $personal[$method] == '1' || !$old_settings->{$method} && $personal[$method] != '1') {
        continue;
    }
    $result = set_user_notification_setting($user->guid, $method, $personal[$method] == '1' ? true : false);
    if (!$result) {
        register_error(elgg_echo('notifications:usersettings:save:fail') . elgg_echo("zhaohu:sorry"));
        elgg_log("ZHError , error calling set_user_notification_setting, user id " . $user->guid, "ERROR");
        forward(REFERER);
    } else {
        $changed = true;
    }
}
if ($changed) {
    system_message(elgg_echo('notifications:subscriptions:success'));
}
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:29,代码来源:save.php


示例10: register

 /**
  * Registers a user, returning false if the username already exists
  *
  * @param string $username              The username of the new user
  * @param string $password              The password
  * @param string $name                  The user's display name
  * @param string $email                 The user's email address
  * @param bool   $allow_multiple_emails Allow the same email address to be
  *                                      registered multiple times?
  *
  * @return int|false The new user's GUID; false on failure
  * @throws \RegistrationException
  */
 function register($username, $password, $name, $email, $allow_multiple_emails = false)
 {
     // no need to trim password.
     $username = trim($username);
     $name = trim(strip_tags($name));
     $email = trim($email);
     // A little sanity checking
     if (empty($username) || empty($password) || empty($name) || empty($email)) {
         return false;
     }
     // Make sure a user with conflicting details hasn't registered and been disabled
     $access_status = access_get_show_hidden_status();
     access_show_hidden_entities(true);
     if (!validate_email_address($email)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:emailnotvalid'));
     }
     if (!validate_password($password)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:passwordnotvalid'));
     }
     if (!validate_username($username)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:usernamenotvalid'));
     }
     if ($user = get_user_by_username($username)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:userexists'));
     }
     if (!$allow_multiple_emails && get_user_by_email($email)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:dupeemail'));
     }
     access_show_hidden_entities($access_status);
     // Create user
     $user = new \ElggUser();
     $user->username = $username;
     $user->email = $email;
     $user->name = $name;
     $user->access_id = ACCESS_PUBLIC;
     $user->setPassword($password);
     $user->owner_guid = 0;
     // Users aren't owned by anyone, even if they are admin created.
     $user->container_guid = 0;
     // Users aren't contained by anyone, even if they are admin created.
     $user->language = _elgg_services()->translator->getCurrentLanguage();
     if ($user->save() === false) {
         return false;
     }
     // Turn on email notifications by default
     set_user_notification_setting($user->getGUID(), 'email', true);
     return $user->getGUID();
 }
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:61,代码来源:UsersTable.php


示例11: social_connect_handle_authentication

function social_connect_handle_authentication($user_profile, $provider)
{
    global $CONFIG;
    global $HA_SOCIAL_CONNECT_PROVIDERS_CONFIG;
    $ignore_access = elgg_get_ignore_access();
    $provider_name = $HA_SOCIAL_CONNECT_PROVIDERS_CONFIG[$provider]['provider_name'];
    $user_uid = $user_profile->identifier;
    // establish the value for the proceeding hook
    $default_proceed = elgg_get_plugin_setting("ha_settings_{$provider}_hook1_default", 'social_connect');
    if (!$default_proceed || $default_proceed == 'global') {
        $default_proceed = elgg_get_plugin_setting('ha_settings_hook1_default', 'social_connect');
    }
    if (!$default_proceed) {
        $default_proceed = SOCIAL_CONNECT_DEFAULT_PROCEED;
    } else {
        if ($default_proceed == 'true') {
            $default_proceed = true;
        } else {
            if ($default_proceed == 'false') {
                $default_proceed = false;
            }
        }
    }
    // the arguments for social connect events and hooks
    $args = array('mode' => null, 'userid' => $user_uid, 'provider' => $HA_SOCIAL_CONNECT_PROVIDERS_CONFIG[$provider], 'user' => null, 'profile' => $user_profile);
    // look for users that have already connected via this plugin
    $options = array('type' => 'user', 'plugin_id' => 'social_connect', 'plugin_user_setting_name_value_pairs' => array("{$provider}/uid" => $user_uid), 'plugin_user_setting_name_value_pairs_operator' => 'AND', 'limit' => 0);
    $users = elgg_get_entities_from_plugin_user_settings($options);
    if (!$users) {
        // user has not connected with plugin before
        $args['mode'] = 'connect';
        elgg_set_ignore_access(true);
        $proceed = elgg_trigger_plugin_hook('social_connect', 'user', $args, $default_proceed);
        elgg_set_ignore_access($ignore_access);
        if ($proceed === false) {
            // hook prevented social connection
            return;
        } else {
            if ($proceed === 'email' || $proceed === 'emailOnly') {
                // hook wants to try and connect via email address
                // check whether the user already exists with the email provided
                $useremail = $user_profile->email;
                if ($useremail && ($users = get_user_by_email($useremail))) {
                    social_connect_user($user_uid, $users[0], $user_profile, $provider);
                    system_message(sprintf(elgg_echo('social_connect:connect:ok'), $provider_name));
                    $args['mode'] = 'email';
                    $args['user'] = $users[0];
                    elgg_set_ignore_access(true);
                    elgg_trigger_event('social_connect', 'user', $args);
                    elgg_set_ignore_access($ignore_access);
                    return;
                }
                if ($proceed === 'emailOnly') {
                    // hook wants only email address connection or failure
                    register_error(sprintf(elgg_echo('social_connect:connect:emailnotfound'), $proceed));
                    return;
                }
            }
        }
        // email connection not required or failed, so register a new user
        $userlogin = str_replace(' ', '', $user_profile->displayName);
        if (!$userlogin) {
            $userlogin = $provider . '_user_' . rand(1000, 9999);
        }
        $org_userlogin = $userlogin;
        while (get_user_by_username($userlogin)) {
            $userlogin = $org_userlogin . '_' . rand(1000, 9999);
        }
        unset($org_userlogin);
        $password = generate_random_cleartext_password();
        $username = $user_profile->displayName;
        $user = new ElggUser();
        $user->username = $userlogin;
        $user->name = $username;
        $user->email = $user_profile->email;
        $user->access_id = ACCESS_PUBLIC;
        $user->salt = generate_random_cleartext_password();
        $user->password = generate_user_password($user, $password);
        $user->owner_guid = 0;
        $user->container_guid = 0;
        if ($user->save()) {
            if ($user->email && elgg_get_plugin_setting('notify_new_user', 'social_connect')) {
                $email = elgg_echo('email:social_connect:body', array($userlogin, $password));
                set_user_notification_setting($user->getGUID(), 'email', true);
                notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:social_connect:subject', array($provider_name)), $email, NULL, 'email');
            }
        } else {
            register_error(sprintf(elgg_echo('social_connect:register:bad'), $provider_name) . elgg_echo("zhaohu:sorry"));
            elgg_log("ZHError social_connect:register:bad , userlogin {$userlogin}", "ERROR");
            return;
        }
        system_message(sprintf(elgg_echo('social_connect:register:ok'), $provider_name));
        social_connect_user($user_uid, $user, $user_profile, $provider);
        $args['mode'] = 'register';
        $args['user'] = $user;
        elgg_set_ignore_access(true);
        elgg_trigger_event('social_connect', 'user', $args);
        elgg_set_ignore_access($ignore_access);
    } elseif (count($users) == 1) {
        // one user has already been registered on Elgg with this provider
//.........这里部分代码省略.........
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:101,代码来源:start.php


示例12: foreach

            }
            if ($avatar_error) {
                foreach ($files as $file) {
                    $file->delete();
                }
            } else {
                $user->x1 = 0;
                $user->x2 = 0;
                $user->y1 = 0;
                $user->y2 = 0;
                $user->icontime = time();
                elgg_create_river_item(array('view' => 'river/user/default/profileiconupdate', 'action_type' => 'update', 'subject_guid' => $user->guid, 'object_guid' => $user->guid));
            }
            $filehandler->delete();
        }
        elgg_set_user_validation_status($user->guid, true, 'FAKER');
        if ($user->save()) {
            $success++;
            set_user_notification_setting($user->guid, 'email', false);
            set_user_notification_setting($user->guid, 'site', true);
        } else {
            $error++;
        }
    }
}
if ($errors) {
    system_message(elgg_echo('faker:gen_users:error', array($success, $error, implode('<br />', $exceptions))));
} else {
    system_message(elgg_echo('faker:gen_users:success', array($success)));
}
forward(REFERER);
开发者ID:hypejunction,项目名称:hypefaker,代码行数:31,代码来源:gen_users.php


示例13: gatekeeper

 * Elgg notifications
 * 
 * @package ElggNotifications
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider Ltd
 * @copyright Curverider Ltd 2008-2009
 * @link http://elgg.com/
 */
// Restrict to logged in users
gatekeeper();
global $SESSION;
global $NOTIFICATION_HANDLERS;
foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
    $subscriptions[$method] = get_input($method . 'subscriptions');
    $personal[$method] = get_input($method . 'personal');
    $collections[$method] = get_input($method . 'collections');
    $metaname = 'collections_notifications_preferences_' . $method;
    $_SESSION['user']->{$metaname} = $collections[$method];
    set_user_notification_setting($_SESSION['user']->guid, $method, $personal[$method] == '1' ? true : false);
    remove_entity_relationships($SESSION['user']->guid, 'notify' . $method, false, 'user');
}
// Add new ones
foreach ($subscriptions as $key => $subscription) {
    if (is_array($subscription) && !empty($subscription)) {
        foreach ($subscription as $subscriptionperson) {
            add_entity_relationship($_SESSION['user']->guid, 'notify' . $key, $subscriptionperson);
        }
    }
}
system_message(elgg_echo('notifications:subscriptions:success'));
forward($_SERVER['HTTP_REFERER']);
开发者ID:eokyere,项目名称:elgg,代码行数:31,代码来源:save.php


示例14: elgg_set_context

elgg_set_context($context);
// we have no local users, create a new one
$user = new \ElggUser();
$user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
$user->email = $account->email;
$user->name = $account->fullName;
$user->access_id = ACCESS_PUBLIC;
$user->salt = _elgg_generate_password_salt();
// set invalid PW that will never work for local login.  This can be changed by the user later
// but won't leave a secondary local login by accident
$user->password = _elgg_generate_password_salt();
$user->owner_guid = 0;
// Users aren't owned by anyone, even if they are admin created.
$user->container_guid = 0;
// Users aren't contained by anyone, even if they are admin created.
$user->language = get_current_language();
$user->save();
$user->__stormpath_user = $account->href;
elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
// Turn on email notifications by default
set_user_notification_setting($user->getGUID(), 'email', true);
// done with our extra permissions
elgg_pop_context();
login($user, true);
if ($user[0]->language) {
    $message = elgg_echo('loginok', array(), $user[0]->language);
} else {
    $message = elgg_echo('loginok');
}
system_message($message);
forward($login_forward);
开发者ID:arckinteractive,项目名称:elgg_stormpath,代码行数:31,代码来源:idsite.php


示例15: get_input

<?php

/**
 * Elgg notifications user preference save acion.
 *
 * @package Elgg
 * @subpackage Core
 */
$method = get_input('method');
$current_settings = get_user_notification_settings();
$result = false;
foreach ($method as $k => $v) {
    // check if setting has changed and skip if not
    if ($current_settings->{$k} == ($v == 'yes')) {
        continue;
    }
    $result = set_user_notification_setting(elgg_get_logged_in_user_guid(), $k, $v == 'yes' ? true : false);
    if (!$result) {
        register_error(elgg_echo('notifications:usersettings:save:fail'));
    }
}
if ($result) {
    system_message(elgg_echo('notifications:usersettings:save:ok'));
}
开发者ID:duanhv,项目名称:mdg-social,代码行数:24,代码来源:save.php


示例16: pam_handler

/**
 * Can we allow the user with the credentials to log in?
 * Check stormpath, create the user if they can log in and don't exist
 * Enable the user if they can log in but were waiting for email verification
 * 
 * @param type $credentials
 * @return boolean
 */
function pam_handler($credentials)
{
    // try to authenticate first
    $application = get_application();
    $authResult = $application->authenticate($credentials['username'], $credentials['password']);
    $account = $authResult->account;
    if (!$account || strtolower($account->status) != 'enabled') {
        return false;
    }
    // we need to search hidden users too
    // in case of email confirmation disabling
    $show_hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // we have an account and it's enabled
    // see if we have a matching account here
    // check if logging in with email address
    if (strpos($credentials['username'], '@') !== false) {
        $users = get_user_by_email($credentials['username']);
        $user = $users[0];
    } else {
        $user = get_user_by_username($credentials['username']);
    }
    // custom context gives us permission to do this
    elgg_push_context('stormpath_validate_user');
    // if we don't have a user we need to create one
    if (!$user) {
        $user = new \ElggUser();
        $user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
        $user->email = $account->email;
        $user->name = $account->fullName;
        $user->access_id = ACCESS_PUBLIC;
        $user->salt = _elgg_generate_password_salt();
        $user->password = generate_user_password($user, $credentials['password']);
        $user->owner_guid = 0;
        // Users aren't owned by anyone, even if they are admin created.
        $user->container_guid = 0;
        // Users aren't contained by anyone, even if they are admin created.
        $user->language = get_current_language();
        $user->save();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
        // Turn on email notifications by default
        set_user_notification_setting($user->getGUID(), 'email', true);
    }
    // see if we need to enable/verify the user
    if (!$user->isEnabled() && in_array($user->disable_reason, array('stormpath_new_user', 'uservalidationbyemail_new_user'))) {
        $user->enable();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
    }
    elgg_pop_context();
    access_show_hidden_entities($show_hidden);
    if ($user && $user->isEnabled()) {
        return true;
    }
    return false;
}
开发者ID:arckinteractive,项目名称:elgg_stormpath,代码行数:65,代码来源:start.php



注:本文中的set_user_notification_setting函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP set_user_preference函数代码示例发布时间:2022-05-15
下一篇:
PHP set_user_config_option函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap