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 discussion body reaches the target length
 5:  *
 6:  * @author Zachary Doll
 7:  * @since 1.0
 8:  * @package Yaga
 9:  */
10: class DiscussionBodyLength implements YagaRule{
11: 
12:   public function Award($Sender, $User, $Criteria) {
13:     $Discussion = $Sender->EventArguments['Discussion'];
14:     $Length = strlen($Discussion->Body);
15:     
16:     if($Length >= $Criteria->Length) {
17:       return $Discussion->InsertUserID;
18:     }
19:     else {
20:       return FALSE;
21:     }
22:   }
23: 
24:   public function Form($Form) {
25:     $String = $Form->Label('Yaga.Rules.DiscussionBodyLength.Criteria.Head', 'DiscussionBodyLength');
26:     $String .= $Form->Textbox('Length', array('class' => 'SmallInput'));
27:     return $String;
28:   }
29: 
30:   public function Validate($Criteria, $Form) {
31:     $Validation = new Gdn_Validation();
32:     $Validation->ApplyRules(array(
33:         array(
34:           'Name' => 'Length', 'Validation' => array('Required', 'Integer')
35:         )
36:     ));
37:     $Validation->Validate($Criteria);
38:     $Form->SetValidationResults($Validation->Results());
39:   }
40: 
41:   public function Hooks() {
42:     return array('DiscussionModel_AfterSaveDiscussion');
43:   }
44: 
45:   public function Description() {
46:     $Description = sprintf(T('Yaga.Rules.DiscussionBodyLength.Desc'), C('Vanilla.Comment.MaxLength'));
47:     return Wrap($Description, 'div', array('class' => 'InfoMessage'));
48:   }
49: 
50:   public function Name() {
51:     return T('Yaga.Rules.DiscussionBodyLength');
52:   }
53:   
54:   public function Interacts() {
55:     return FALSE;
56:   }
57: }
58: 
Yaga API documentation generated by ApiGen 2.8.0