Overview

Packages

  • None
  • Yaga

Classes

  • ActedModel
  • ActionController
  • ActionModel
  • AwardCombo
  • BadgeAwardModel
  • BadgeController
  • BadgeModel
  • BadgesController
  • BadgesModule
  • BestController
  • BestFilterModule
  • CakeDayPost
  • CommentCount
  • CommentMarathon
  • DiscussionBodyLength
  • DiscussionCategory
  • DiscussionCount
  • DiscussionPageCount
  • HasMentioned
  • HolidayVisit
  • LeaderBoardModule
  • LengthOfService
  • ManualAward
  • NecroPost
  • NewbieComment
  • PhotoExists
  • PostCount
  • PostReactions
  • QnAAnserCount
  • RankController
  • RankModel
  • ReactController
  • ReactionCount
  • ReactionModel
  • ReflexComment
  • RulesController
  • SocialConnection
  • Yaga
  • YagaController
  • YagaHooks

Interfaces

  • YagaRule
  • Overview
  • Package
  • Class
  • Tree
  • Todo
  • Download
 1: <?php if(!defined('APPLICATION')) exit();
 2: 
 3: /**
 4:  * This rule awards badges if a comment is placed on a discussion within a short amount of time
 5:  *
 6:  * @author Zachary Doll
 7:  * @since 1.0
 8:  * @package Yaga
 9:  */
10: class ReflexComment implements YagaRule{
11: 
12:   public function Award($Sender, $User, $Criteria) {
13:     $Discussion = $Sender->EventArguments['Discussion'];
14:     $Comment = $Sender->EventArguments['Comment'];
15:     
16:     // Don't award a user for commenting on their own discussion
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: 
Yaga API documentation generated by ApiGen 2.8.0