forked from GNUsocial/gnu-social
Events on user registrations now strictly typed
This commit is contained in:
parent
482296561e
commit
83b852312a
@ -781,12 +781,10 @@ SendImConfirmationCode: Send a confirmation code to confirm a user owns an IM sc
|
|||||||
- $user: user requesting the confirmation
|
- $user: user requesting the confirmation
|
||||||
|
|
||||||
StartUserRegister: When a new user is being registered
|
StartUserRegister: When a new user is being registered
|
||||||
- &$profile: new profile data (no ID)
|
- $profile: Profile object with new profile data (no ID yet)
|
||||||
- &$user: new user account (no ID or URI)
|
|
||||||
|
|
||||||
EndUserRegister: When a new user has been registered
|
EndUserRegister: When a new user has been registered
|
||||||
- &$profile: new profile data
|
- $profile: Profile object with new profile data
|
||||||
- &$user: new user account
|
|
||||||
|
|
||||||
StartRobotsTxt: Before outputting the robots.txt page
|
StartRobotsTxt: Before outputting the robots.txt page
|
||||||
- &$action: RobotstxtAction being shown
|
- &$action: RobotstxtAction being shown
|
||||||
|
@ -335,7 +335,7 @@ class User extends Managed_DataObject
|
|||||||
|
|
||||||
$user->created = common_sql_now();
|
$user->created = common_sql_now();
|
||||||
|
|
||||||
if (Event::handle('StartUserRegister', array(&$user, &$profile))) {
|
if (Event::handle('StartUserRegister', array($profile))) {
|
||||||
|
|
||||||
$profile->query('BEGIN');
|
$profile->query('BEGIN');
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ class User extends Managed_DataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::handle('EndUserRegister', array(&$profile, &$user));
|
Event::handle('EndUserRegister', array($profile));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
@ -90,11 +90,11 @@ class AutoSandboxPlugin extends Plugin
|
|||||||
$action->elementEnd('div');
|
$action->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndUserRegister(&$profile,&$user)
|
public function onEndUserRegister(Profile $profile)
|
||||||
{
|
{
|
||||||
$profile->sandbox();
|
$profile->sandbox();
|
||||||
if ($this->debug) {
|
if ($this->debug) {
|
||||||
common_log(LOG_WARNING, "AutoSandbox: sandboxed of $user->nickname");
|
common_log(LOG_WARNING, "AutoSandbox: sandboxed of $profile->nickname");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,24 +55,23 @@ class FollowEveryonePlugin extends Plugin
|
|||||||
* the new user to them. Exceptions (like silenced users or whatever)
|
* the new user to them. Exceptions (like silenced users or whatever)
|
||||||
* are caught, logged, and ignored.
|
* are caught, logged, and ignored.
|
||||||
*
|
*
|
||||||
* @param Profile &$newProfile The new user's profile
|
* @param Profile $profile The new user's profile
|
||||||
* @param User &$newUser The new user
|
|
||||||
*
|
*
|
||||||
* @return boolean hook value
|
* @return boolean hook value
|
||||||
*/
|
*/
|
||||||
function onEndUserRegister(&$newProfile, &$newUser)
|
public function onEndUserRegister(Profile $profile)
|
||||||
{
|
{
|
||||||
$otherUser = new User();
|
$otherUser = new User();
|
||||||
$otherUser->whereAdd('id != ' . $newUser->id);
|
$otherUser->whereAdd('id != ' . $profile->id);
|
||||||
|
|
||||||
if ($otherUser->find()) {
|
if ($otherUser->find()) {
|
||||||
while ($otherUser->fetch()) {
|
while ($otherUser->fetch()) {
|
||||||
$otherProfile = $otherUser->getProfile();
|
$otherProfile = $otherUser->getProfile();
|
||||||
try {
|
try {
|
||||||
if (User_followeveryone_prefs::followEveryone($otherUser->id)) {
|
if (User_followeveryone_prefs::followEveryone($otherUser->id)) {
|
||||||
Subscription::start($otherProfile, $newProfile);
|
Subscription::start($otherProfile, $profile);
|
||||||
}
|
}
|
||||||
Subscription::start($newProfile, $otherProfile);
|
Subscription::start($profile, $otherProfile);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_WARNING, $e->getMessage());
|
common_log(LOG_WARNING, $e->getMessage());
|
||||||
continue;
|
continue;
|
||||||
@ -82,7 +81,7 @@ class FollowEveryonePlugin extends Plugin
|
|||||||
|
|
||||||
$ufep = new User_followeveryone_prefs();
|
$ufep = new User_followeveryone_prefs();
|
||||||
|
|
||||||
$ufep->user_id = $newUser->id;
|
$ufep->user_id = $profile->id;
|
||||||
$ufep->followeveryone = true;
|
$ufep->followeveryone = true;
|
||||||
|
|
||||||
$ufep->insert();
|
$ufep->insert();
|
||||||
|
@ -61,9 +61,8 @@ class ForceGroupPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndUserRegister($profile, $user)
|
public function onEndUserRegister(Profile $profile)
|
||||||
{
|
{
|
||||||
$profile = $user->getProfile();
|
|
||||||
foreach ($this->join as $nickname) {
|
foreach ($this->join as $nickname) {
|
||||||
$group = User_group::getForNickname($nickname);
|
$group = User_group::getForNickname($nickname);
|
||||||
if ($group && !$profile->isMember($group)) {
|
if ($group && !$profile->isMember($group)) {
|
||||||
@ -73,7 +72,7 @@ class ForceGroupPlugin extends Plugin
|
|||||||
// TRANS: Server exception.
|
// TRANS: Server exception.
|
||||||
// TRANS: %1$s is a user nickname, %2$s is a group nickname.
|
// TRANS: %1$s is a user nickname, %2$s is a group nickname.
|
||||||
throw new ServerException(sprintf(_m('Could not join user %1$s to group %2$s.'),
|
throw new ServerException(sprintf(_m('Could not join user %1$s to group %2$s.'),
|
||||||
$user->nickname, $group->nickname));
|
$profile->nickname, $group->nickname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,11 +142,10 @@ class RegisterThrottlePlugin extends Plugin
|
|||||||
* We record the successful registration and IP address.
|
* We record the successful registration and IP address.
|
||||||
*
|
*
|
||||||
* @param Profile $profile new user's profile
|
* @param Profile $profile new user's profile
|
||||||
* @param User $user new user
|
|
||||||
*
|
*
|
||||||
* @return boolean hook value
|
* @return boolean hook value
|
||||||
*/
|
*/
|
||||||
function onEndUserRegister($profile, $user)
|
public function onEndUserRegister(Profile $profile)
|
||||||
{
|
{
|
||||||
$ipaddress = $this->_getIpAddress();
|
$ipaddress = $this->_getIpAddress();
|
||||||
|
|
||||||
@ -157,7 +156,7 @@ class RegisterThrottlePlugin extends Plugin
|
|||||||
|
|
||||||
$reg = new Registration_ip();
|
$reg = new Registration_ip();
|
||||||
|
|
||||||
$reg->user_id = $user->id;
|
$reg->user_id = $profile->id;
|
||||||
$reg->ipaddress = $ipaddress;
|
$reg->ipaddress = $ipaddress;
|
||||||
|
|
||||||
$result = $reg->insert();
|
$result = $reg->insert();
|
||||||
|
@ -49,7 +49,7 @@ class UserLimitPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
public $maxUsers = null;
|
public $maxUsers = null;
|
||||||
|
|
||||||
function onStartUserRegister(&$user, &$profile)
|
public function onStartUserRegister(Profile $profile)
|
||||||
{
|
{
|
||||||
$this->_checkMaxUsers();
|
$this->_checkMaxUsers();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user