Index: branches/RC/core/units/users/users_event_handler.php =================================================================== diff -u -N -r10539 -r10941 --- branches/RC/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 10539) +++ branches/RC/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 10941) @@ -248,6 +248,10 @@ if ($user_id) { $object->Load($user_id); + if (!$this->checkBanRules($object)) { + $event->status = erFAIL; + return false; + } if ($object->GetDBField('Status') == STATUS_ACTIVE) { $groups = $object->getMembershipGroups(true); if(!$groups) $groups = Array(); @@ -690,6 +694,10 @@ { $email_as_login = $this->Application->ConfigValue('Email_As_Login'); $object =& $event->getObject(); + if (!$this->checkBanRules($object)) { + $event->status = erFAIL; + return false; + } if ($email_as_login) { $object->Fields['Email']['error_msgs']['unique'] = $this->Application->Phrase('lu_user_and_email_already_exist'); } @@ -1646,6 +1654,78 @@ $image_helper->SaveItemImages($object); } } + + /** + * Check user fields + * + * @param kDBItem $object + */ + function checkBanRules(&$object) + { + $sql = 'SELECT * FROM '.TABLE_PREFIX.'BanRules WHERE ItemType=6 AND Status=1 ORDER BY Priority DESC'; + $a_rules = $this->Conn->Query($sql); + $found = FALSE; + foreach($a_rules as $a_rule) { + $field = $a_rule['ItemField']; + if(isset($object->Fields[$field])) { + $ThisValue = strtolower($object->GetDBField($field)); + $TestValue = strtolower($a_rule['ItemValue']); + switch($a_rule['ItemVerb']) + { +// case 0: /* any */ +// $found = TRUE; +// break; + case 1: /* is */ + if ($ThisValue==$TestValue) { + $found = TRUE; + } + break; +// case 2: /* is not */ +// if($ThisValue != $TestValue) +// $found = TRUE; +// break; + case 3: /* contains */ + if(strstr($ThisValue,$TestValue)) { + $found = TRUE; + } + break; +// case 4: /* not contains */ +// if(!strstr($ThisValue,$TestValue)) +// $found = TRUE; +// break; +// case 5: /* Greater Than */ +// if($TestValue > $ThisValue) +// $found = TRUE; +// break; +// case 6: /* Less Than */ +// if($TestValue < $ThisValue) +// $found = TRUE; +// break; +// case 7: /* exists */ +// if(strlen($ThisValue)>0) +// $found = TRUE; +// break; +// case 8: /* unique */ +// if($this->ValueExists($field,$ThisValue)) +// $found = TRUE; +// break; + } + } + if($found) + { +// if($b->Get("RuleType")==0) +// { +// $MatchedRule = $b->Get("RuleId"); +// } +// else +// { +// $MatchedRule = 0; +// } + break; + } + } + return !$found; + } } ?> \ No newline at end of file