Permalink
Browse files

Fixed bug when restoring log entries.

Check deletion of spam entires and moderation entries.
Conflicts:

	applications/dashboard/models/class.logmodel.php
  • Loading branch information...
tburry committed Oct 23, 2011
1 parent 3a7d6b3 commit 5e4fd8323be54844e232292b04f51bc8a61626d5
Showing with 16 additions and 9 deletions.
  1. +16 −9 applications/dashboard/models/class.logmodel.php
@@ -22,7 +22,7 @@ public function Delete($LogIDs) {
$Models['Comment'] = new CommentModel();
foreach ($Logs as $Log) {
- if ($Log['Operation'] == 'Moderate' && array_key_exists($Log['RecordType'], $Models)) {
+ if (in_array($Log['Operation'], array('Spam', 'Moderate')) && array_key_exists($Log['RecordType'], $Models)) {
// Also delete the record.
$Model = $Models[$Log['RecordType']];
$Model->Delete($Log['RecordID'], array('Log' => FALSE));
@@ -386,14 +386,21 @@ public function Restore($Log, $DeleteLog = TRUE) {
}
// Insert the record back into the db.
- $ID = Gdn::SQL()
- ->Options('Ignore', TRUE)
- ->Insert($TableName, $Set);
- if (!$ID && isset($Log['RecordID']))
- $ID = $Log['RecordID'];
-
- if ($Log['Operation'] == 'Spam' && $Log['RecordType'] = 'Registration') {
- Gdn::UserModel()->SaveRoles($ID, Gdn::UserModel()->NewUserRoleIDs());
+
+ if ($Log['Operation'] == 'Spam' && $Log['RecordType'] == 'Registration') {
+ SaveToConfig(array('Garden.Registration.NameUnique' => FALSE, 'Garden.Registration.EmailUnique' => FALSE), '', FALSE);
+ $ID = Gdn::UserModel()->InsertForBasic($Set, FALSE, array('ValidateSpam' => FALSE));
+ if (!$ID) {
+ throw new Exception(Gdn::UserModel()->Validation->ResultsText());
+ } else {
+ Gdn::UserModel()->SendWelcomeEmail($ID, '', 'Register');
+ }
+ } else {
+ $ID = Gdn::SQL()
+ ->Options('Ignore', TRUE)
+ ->Insert($TableName, $Set);
+ if (!$ID && isset($Log['RecordID']))
+ $ID = $Log['RecordID'];
}
break;

0 comments on commit 5e4fd83

Please sign in to comment.