Index: trunk/phase3/includes/Autopromote.php |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | |
89 | 89 | if ( is_array( $cond ) && count( $cond ) >= 2 && in_array( $cond[0], $validOps ) ) { |
90 | 90 | # Recursive condition |
91 | | - if ( $cond[0] == '&' ) { |
| 91 | + if ( $cond[0] == '&' ) { // AND (all conds pass) |
92 | 92 | foreach ( array_slice( $cond, 1 ) as $subcond ) { |
93 | 93 | if ( !self::recCheckCondition( $subcond, $user ) ) { |
94 | 94 | return false; |
— | — | @@ -95,7 +95,7 @@ |
96 | 96 | } |
97 | 97 | |
98 | 98 | return true; |
99 | | - } elseif ( $cond[0] == '|' ) { |
| 99 | + } elseif ( $cond[0] == '|' ) { // OR (at least one cond passes) |
100 | 100 | foreach ( array_slice( $cond, 1 ) as $subcond ) { |
101 | 101 | if ( self::recCheckCondition( $subcond, $user ) ) { |
102 | 102 | return true; |
— | — | @@ -103,18 +103,20 @@ |
104 | 104 | } |
105 | 105 | |
106 | 106 | return false; |
107 | | - } elseif ( $cond[0] == '^' ) { |
108 | | - $res = null; |
| 107 | + } elseif ( $cond[0] == '^' ) { // XOR (exactly one cond passes) |
| 108 | + $res = false; |
109 | 109 | foreach ( array_slice( $cond, 1 ) as $subcond ) { |
110 | | - if ( is_null( $res ) ) { |
111 | | - $res = self::recCheckCondition( $subcond, $user ); |
112 | | - } else { |
113 | | - $res = ( $res xor self::recCheckCondition( $subcond, $user ) ); |
| 110 | + if ( self::recCheckCondition( $subcond, $user ) ) { |
| 111 | + if ( $res ) { |
| 112 | + return false; |
| 113 | + } else { |
| 114 | + $res = true; |
| 115 | + } |
114 | 116 | } |
115 | 117 | } |
116 | 118 | |
117 | 119 | return $res; |
118 | | - } elseif ( $cond[0] == '!' ) { |
| 120 | + } elseif ( $cond[0] == '!' ) { // NOT (no conds pass) |
119 | 121 | foreach ( array_slice( $cond, 1 ) as $subcond ) { |
120 | 122 | if ( self::recCheckCondition( $subcond, $user ) ) { |
121 | 123 | return false; |