Index: branches/5.1.x/core/units/users/users_event_handler.php
===================================================================
diff -u -N -r13773 -r14106
--- branches/5.1.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 13773)
+++ branches/5.1.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14106)
@@ -1,6 +1,6 @@
checkBanRules($object)) {
- $event->status = erFAIL;
- return ;
+ $object->SetError('Login', 'banned');
}
}
Index: branches/5.1.x/core/admin_templates/ban_rules/ban_rule_edit.tpl
===================================================================
diff -u -N -r13949 -r14106
--- branches/5.1.x/core/admin_templates/ban_rules/ban_rule_edit.tpl (.../ban_rule_edit.tpl) (revision 13949)
+++ branches/5.1.x/core/admin_templates/ban_rules/ban_rule_edit.tpl (.../ban_rule_edit.tpl) (revision 14106)
@@ -66,9 +66,9 @@
-
-
-
+
+
+
Index: branches/5.1.x/core/units/helpers/user_helper.php
===================================================================
diff -u -N -r13870 -r14106
--- branches/5.1.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 13870)
+++ branches/5.1.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 14106)
@@ -1,6 +1,6 @@
Application->getUnitOption('ban-rule', 'TableName');
+
if (!$this->Conn->TableFound($table)) {
// when ban table not found -> assume user is ok by default
return true;
}
$sql = 'SELECT *
- FROM '.$table.'
+ FROM ' . $table . '
WHERE ItemType = 6 AND Status = ' . STATUS_ACTIVE . '
ORDER BY Priority DESC';
$rules = $this->Conn->Query($sql);
$found = false;
+
foreach ($rules as $rule) {
$field = $rule['ItemField'];
+ $this_value = mb_strtolower( $object->GetDBField($field) );
+ $test_value = mb_strtolower( $rule['ItemValue'] );
- $this_value = strtolower( $object->GetDBField($field) );
- $test_value = strtolower( $rule['ItemValue'] );
-
- switch ($rule['ItemVerb']) {
- /*case 0: // any
- $found = true;
- break;*/
-
+ switch ( $rule['ItemVerb'] ) {
case 1: // is
if ($this_value == $test_value) {
$found = true;
}
break;
- /*case 2: // is not
+ case 2: // is not
if ($this_value != $test_value) {
$found = true;
}
- break;*/
+ break;
case 3: // contains
- if (strstr($this_value, $test_value)) {
+ if ( strstr($this_value, $test_value) ) {
$found = true;
}
break;
-
- /*case 4: // not contains
- if (!strstr($this_value, $test_value)) {
+ case 4: // not contains
+ if ( !strstr($this_value, $test_value) ) {
$found = true;
}
break;
- case 5: // Greater Than
- if ($test_value > $this_value) {
- $found = true;
- }
- break;
-
- case 6: // Less Than
- if ($test_value < $this_value) {
- $found = true;
- }
- break;
-
case 7: // exists
- if (strlen($this_value) > 0) {
+ if ( strlen($this_value) > 0 ) {
$found = true;
}
break;
case 8: // unique
- if ($this->ValueExists($field, $this_value)) {
+ if ( $this->_checkValueExist($field, $this_value) ) {
$found = true;
}
- break;*/
+ break;
}
- if ($found) {
+ if ( $found ) {
+ // check ban rules, until one of them matches
+
+ if ( $rule['RuleType'] ) {
+ // invert rule type
+ $found = false;
+ }
+
break;
}
}
return !$found;
}
+
+ /**
+ * Checks if value is unique in Users table against the specified field
+ *
+ * @param string $field
+ * @param string $value
+ * @return string
+ */
+ function _checkValueExist($field, $value)
+ {
+ $sql = 'SELECT *
+ FROM ' . $this->Application->getUnitOption('u', 'TableName') . '
+ WHERE '. $field .' = ' . $this->Conn->qstr($value);
+
+ return $this->Conn->GetOne($sql);
+ }
}
Index: branches/5.1.x/core/units/users/users_config.php
===================================================================
diff -u -N -r14029 -r14106
--- branches/5.1.x/core/units/users/users_config.php (.../users_config.php) (revision 14029)
+++ branches/5.1.x/core/units/users/users_config.php (.../users_config.php) (revision 14106)
@@ -1,6 +1,6 @@
Array
(
'PortalUserId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
- 'Login' => Array ('type' => 'string', 'unique'=>Array('Login'), 'default' => null,'required'=>1, 'error_msgs' => Array('unique'=>'!lu_user_already_exist!')),
+ 'Login' => Array ('type' => 'string', 'unique'=>Array('Login'), 'default' => null,'required'=>1, 'error_msgs' => Array('unique'=>'!lu_user_already_exist!', 'banned' => '!la_error_UserBanned!')),
'Password' => Array ('type' => 'string', 'formatter' => 'kPasswordFormatter', 'encryption_method' => 'md5', 'verify_field' => 'VerifyPassword', 'skip_empty' => 1, 'default' => md5('')),
'FirstName' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
'LastName' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
Index: branches/5.1.x/core/units/ban_rules/ban_rules_config.php
===================================================================
diff -u -N -r13159 -r14106
--- branches/5.1.x/core/units/ban_rules/ban_rules_config.php (.../ban_rules_config.php) (revision 13159)
+++ branches/5.1.x/core/units/ban_rules/ban_rules_config.php (.../ban_rules_config.php) (revision 14106)
@@ -1,6 +1,6 @@
Array (
'RuleId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
- 'RuleType' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0, 'use_phrases' => 1, 'formatter'=>'kOptionsFormatter', 'options'=>Array(
- 0 => 'la_opt_Deny',
-// 1 => 'la_opt_Allow'
- )
+ 'RuleType' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array(0 => 'la_opt_Deny', 1 => 'la_opt_Allow'), 'use_phrases' => 1,
+ 'not_null' => 1, 'required' => 1, 'default' => 0
),
- 'ItemField' => Array ('type' => 'string', 'max_len' => 255, 'default' => NULL, 'use_phrases' => 1, 'formatter'=>'kOptionsFormatter', 'options' => Array(
+ 'ItemField' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter'=>'kOptionsFormatter', 'options' => Array(
'ip' => 'la_opt_IP_Address',
'Login' => 'la_opt_Username',
'Email' => 'la_opt_Email',
@@ -97,12 +99,21 @@
'State' => 'la_opt_State',
'Zip' => 'la_opt_Zip',
'Phone' => 'la_opt_Phone',
- )
+ ), 'use_phrases' => 1,
+ 'required' => 1,
+ 'default' => NULL,
),
- 'ItemVerb' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0, 'use_phrases' => 1, 'formatter'=>'kOptionsFormatter', 'options'=>Array(
+ 'ItemVerb' => Array (
+ 'type' => 'int',
+ 'formatter'=>'kOptionsFormatter', 'options'=>Array(
1 => 'la_opt_Exact',
- 3 => 'la_opt_Sub-match'
- )
+ 2 => 'la_opt_DoesntMatch',
+ 3 => 'la_opt_Sub-match',
+ 4 => 'la_opt_NotLike',
+ 7 => 'la_opt_NotEmpty',
+ 8 => 'la_opt_IsUnique',
+ ), 'use_phrases' => 1,
+ 'not_null' => 1, 'required' => 1, 'default' => 0,
),
'ItemValue' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'required' => 1, 'default' => ''),
'ItemType' => Array ('type' => 'int', 'not_null' => 1, 'default' => 6),
Index: branches/5.1.x/core/install/english.lang
===================================================================
diff -u -N -r14105 -r14106
--- branches/5.1.x/core/install/english.lang (.../english.lang) (revision 14105)
+++ branches/5.1.x/core/install/english.lang (.../english.lang) (revision 14106)
@@ -334,6 +334,7 @@
UmVjb3JkIGlzIG5vdCB1bmlxdWU=
U2VjdGlvbiBmaWVsZCBub3QgdW5pcXVl
VW5rbm93biBzZWN0aW9u
+ VXNlciBCYW5uZWQ=
dXNlciBub3QgZm91bmQ=
SW5jb3JyZWN0IGRhdGUgZm9ybWF0LCBwbGVhc2UgdXNlICglcykgZXguICglcyk=
SW5jb3JyZWN0IGRhdGEgZm9ybWF0LCBwbGVhc2UgdXNlICVz
@@ -793,6 +794,7 @@
RGVueQ==
RGVzY3JpcHRpb24=
RGlzYWJsZWQ=
+ RG9lc24ndCBtYXRjaA==
RWRpdG9yJ3MgUGljaw==
RS1tYWls
RS1tYWlsIEJvZHk=
@@ -808,12 +810,15 @@
aG91cihzKQ==
SW5oZXJpdCBmcm9tIFBhcmVudA==
SVAgQWRkcmVzcw==
+ SXMgdW5pcXVl
TGFzdCBOYW1l
TG9nZ2VkIE91dA==
bWludXRlKHMp
TW9kYWwgV2luZG93
bW9udGgocyk=
TmV3IEUtbWFpbA==
+ Tm90IGVtcHR5
+ Tm90IGxpa2U=
Tm90IFByb2Nlc3NlZA==
Tm90IFJlcGxpZWQ=
UGFydGlhbGx5IFByb2Nlc3NlZA==