1: <?php if(!defined('APPLICATION')) exit();
2:
3: 4: 5: 6: 7: 8: 9:
10: class implements YagaRule{
11:
12: public function Award($Sender, $User, $Criteria) {
13: $Discussion = $Sender->EventArguments['Discussion'];
14: $Comment = $Sender->EventArguments['Comment'];
15:
16:
17: if($Discussion->InsertUserID == $User->UserID) {
18: return FALSE;
19: }
20: $DiscussionDate = strtotime($Discussion->DateInserted);
21: $CommentDate = strtotime($Comment['DateInserted']);
22:
23: $Difference = $CommentDate - $DiscussionDate;
24:
25: if($Difference <= $Criteria->Seconds) {
26: return $User->UserID;
27: }
28: else {
29: return FALSE;
30: }
31: }
32:
33: public function Form($Form) {
34: $String = $Form->Label('Yaga.Rules.ReflexComment.Criteria.Head', 'ReflexComment');
35: $String .= $Form->Textbox('Seconds', array('class' => 'SmallInput'));
36:
37: return $String;
38: }
39:
40: public function Validate($Criteria, $Form) {
41: $Validation = new Gdn_Validation();
42: $Validation->ApplyRules(array(
43: array(
44: 'Name' => 'Seconds', 'Validation' => array('Required', 'Integer')
45: )
46: ));
47: $Validation->Validate($Criteria);
48: $Form->SetValidationResults($Validation->Results());
49: }
50:
51: public function Hooks() {
52: return array('CommentModel_BeforeNotification');
53: }
54:
55: public function Description() {
56: $Description = T('Yaga.Rules.ReflexComment.Desc');
57: return Wrap($Description, 'div', array('class' => 'InfoMessage'));
58: }
59:
60: public function Name() {
61: return T('Yaga.Rules.ReflexComment');
62: }
63:
64: public function Interacts() {
65: return FALSE;
66: }
67: }
68: