本文整理汇总了PHP中ElggUser::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggUser::setPassword方法的具体用法?PHP ElggUser::setPassword怎么用?PHP ElggUser::setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggUser
的用法示例。
在下文中一共展示了ElggUser::setPassword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Called before each test object.
*/
public function __construct()
{
parent::__construct();
$this->user = new \ElggUser();
$this->user->username = 'fake_user_' . rand();
$this->user->email = 'fake_email@fake.com' . rand();
$this->user->name = 'fake user ' . rand();
$this->user->access_id = ACCESS_PUBLIC;
$this->user->setPassword(rand());
$this->user->owner_guid = 0;
$this->user->container_guid = 0;
$this->user->save();
}
示例2: testUpdateACL
public function testUpdateACL()
{
// another fake user to test with
$user = new \ElggUser();
$user->username = 'test_user_' . rand();
$user->email = 'fake_email@fake.com' . rand();
$user->name = 'fake user';
$user->access_id = ACCESS_PUBLIC;
$user->setPassword(rand());
$user->owner_guid = 0;
$user->container_guid = 0;
$user->save();
$acl_id = create_access_collection('test acl');
$member_lists = array(array($this->user->guid, $user->guid), array($user->guid), array($this->user->guid), array());
foreach ($member_lists as $members) {
$result = update_access_collection($acl_id, $members);
$this->assertTrue($result);
if ($result) {
$q = "SELECT * FROM {$this->dbPrefix}access_collection_membership\n\t\t\t\t\tWHERE access_collection_id = {$acl_id}";
$data = get_data($q);
if (count($members) == 0) {
$this->assertFalse($data);
} else {
$this->assertEqual(count($members), count($data));
}
foreach ($data as $row) {
$this->assertTrue(in_array($row->user_guid, $members));
}
}
}
delete_access_collection($acl_id);
$user->delete();
}
示例3: twitter_api_create_user
/**
* Create a new user from Twitter information
*
* @param object $twitter Twitter OAuth response
* @return ElggUser
*/
function twitter_api_create_user($twitter)
{
// check new registration allowed
if (!twitter_api_allow_new_users_with_twitter()) {
register_error(elgg_echo('registerdisabled'));
forward();
}
// Elgg-ify Twitter credentials
$username = $twitter->screen_name;
while (get_user_by_username($username)) {
// @todo I guess we just hope this is good enough
$username = $twitter->screen_name . '_' . rand(1000, 9999);
}
$password = generate_random_cleartext_password();
$name = $twitter->name;
$user = new ElggUser();
$user->username = $username;
$user->name = $name;
$user->access_id = ACCESS_PUBLIC;
$user->setPassword($password);
$user->owner_guid = 0;
$user->container_guid = 0;
if (!$user->save()) {
register_error(elgg_echo('registerbad'));
forward();
}
return $user;
}
示例4: 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();
}