Subversion Repositories Mediboard

Rev

Rev 41692 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 41692 Rev 41734
Line 34... Line 34...
34
  /** @var CKeychain */
34
  /** @var CKeychain */
35
  public $_ref_keychain;
35
  public $_ref_keychain;
36
36
37
  /** @var string */
37
  /** @var string */
38
  public $_rule;
38
  public $_rule;
-
 
39
-
 
40
  /** @var array */
-
 
41
  public $_triggered_rules = array();
39
42
40
  /** @var date */
43
  /** @var date */
41
  public $_date;
44
  public $_date;
42
45
43
  /** @var date */
46
  /** @var date */
Line 126... Line 129...
126
    $this->_reference_date = CMbDT::date($reference_date);
129
    $this->_reference_date = CMbDT::date($reference_date);
127
130
128
    $rules = $this->checkRules();
131
    $rules = $this->checkRules();
129
132
130
    foreach ($rules as $_rule => $_match) {
133
    foreach ($rules as $_rule => $_match) {
131
      if ($_match) {
-
 
132
        return ($this->_rule == $_rule);
-
 
-
 
134
      if ($this->inTriggeredRules($_rule)) {
-
 
135
        $this->_rule = $_rule;
-
 
136
-
 
137
        return $_match;
133
      }
138
      }
134
    }
139
    }
135
140
136
    return false;
141
    return false;
137
  }
142
  }
Line 157... Line 162...
157
   * @param string $rule Rule to trigger
162
   * @param string $rule Rule to trigger
158
   *
163
   *
159
   * @return void
164
   * @return void
160
   */
165
   */
161
  private function triggerRule($rule) {
166
  private function triggerRule($rule) {
162
    $this->_rule = $rule;
-
 
-
 
167
    $this->_triggered_rules[$rule] = true;
-
 
168
  }
-
 
169
-
 
170
  /**
-
 
171
   * Checks if given rule triggered
-
 
172
   *
-
 
173
   * @param string $rule Rule to check
-
 
174
   *
-
 
175
   * @return bool
-
 
176
   */
-
 
177
  private function inTriggeredRules($rule) {
-
 
178
    return ($rule && isset($this->_triggered_rules[$rule]) && $this->_triggered_rules[$rule]);
163
  }
179
  }
164
180
165
  /**
181
  /**
166
   * "No success" rule checking
182
   * "No success" rule checking
167
   *
183
   *
168
   * @param string $rule Rule
184
   * @param string $rule Rule
169
   *
185
   *
170
   * @return bool
186
   * @return bool
171
   */
187
   */
172
  private function checkRuleNoSuccess($rule) {
188
  private function checkRuleNoSuccess($rule) {
173
    $this->triggerRule($rule);
-
 
174
-
 
175
    // Jamais utilisé à partir de l'abonnement
189
    // Jamais utilisé à partir de l'abonnement
176
    return (!$this->last_success_date);
-
 
-
 
190
    if (!$this->last_success_date) {
-
 
191
      $this->triggerRule($rule);
-
 
192
-
 
193
      return true;
-
 
194
    }
-
 
195
-
 
196
    return false;
177
  }
197
  }
178
198
179
  /**
199
  /**
180
   * "Weekly" rule checking
200
   * "Weekly" rule checking
181
   *
201
   *