Merge branch 'flagdel' into 0.9.x

This commit is contained in:
Brion Vibber 2010-01-06 11:16:06 -08:00
commit 7ed5a38fca
2 changed files with 44 additions and 8 deletions

View File

@ -504,6 +504,7 @@ class Profile extends Memcached_DataObject
'Reply',
'Group_member',
);
Event::handle('ProfileDeleteRelated', array($this, &$related));
foreach ($related as $cls) {
$inst = new $cls();

View File

@ -102,20 +102,20 @@ class UserFlagPlugin extends Plugin
function onAutoload($cls)
{
switch ($cls)
switch (strtolower($cls))
{
case 'FlagprofileAction':
case 'AdminprofileflagAction':
case 'ClearflagAction':
case 'flagprofileaction':
case 'adminprofileflagaction':
case 'clearflagaction':
include_once INSTALLDIR.'/plugins/UserFlag/' .
strtolower(mb_substr($cls, 0, -6)) . '.php';
return false;
case 'FlagProfileForm':
case 'ClearFlagForm':
case 'flagprofileform':
case 'clearflagform':
include_once INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php');
return false;
case 'User_flag_profile':
include_once INSTALLDIR.'/plugins/UserFlag/'.$cls.'.php';
case 'user_flag_profile':
include_once INSTALLDIR.'/plugins/UserFlag/'.ucfirst(strtolower($cls)).'.php';
return false;
default:
return true;
@ -258,4 +258,39 @@ class UserFlagPlugin extends Plugin
}
return true;
}
/**
* Ensure that flag entries for a profile are deleted
* along with the profile when deleting users.
* This prevents breakage of the admin profile flag UI.
*
* @param Profile $profile
* @param array &$related list of related tables; entries
* with matching profile_id will be deleted.
*
* @return boolean hook result
*/
function onProfileDeleteRelated($profile, &$related)
{
$related[] = 'user_flag_profile';
return true;
}
/**
* Ensure that flag entries created by a user are deleted
* when that user gets deleted.
*
* @param User $user
* @param array &$related list of related tables; entries
* with matching user_id will be deleted.
*
* @return boolean hook result
*/
function onUserDeleteRelated($user, &$related)
{
$related[] = 'user_flag_profile';
return true;
}
}