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 based on a user's join date
 5:  *
 6:  * @author Zachary Doll
 7:  * @since 1.0
 8:  * @package Yaga
 9:  */
10: class LengthOfService implements YagaRule {
11: 
12:   public function Award($Sender, $User, $Criteria) {
13:     $InsertDate = strtotime($User->DateInserted);
14:     $TargetDate = strtotime($Criteria->Duration . ' ' . $Criteria->Period . ' ago');
15:     if($InsertDate < $TargetDate) {
16:       return TRUE;
17:     }
18:     else {
19:       return FALSE;
20:     }
21:   }
22: 
23:   public function Form($Form) {
24:     $Lengths = array(
25:         'day' => T('Days'),
26:         'week' => T('Weeks'),
27:         'year' => T('Years')
28:     );
29: 
30:     $String = $Form->Label('Yaga.Rules.LengthOfService.Criteria.Head', 'LengthOfService');
31:     $String .= $Form->Textbox('Duration', array('class' => 'SmallInput')) . ' ';
32:     $String .= $Form->DropDown('Period', $Lengths);
33: 
34:     return $String;
35:   }
36: 
37:   public function Validate($Criteria, $Form) {
38:     $Validation = new Gdn_Validation();
39:     $Validation->ApplyRules(array(
40:         array(
41:           'Name' => 'Duration', 'Validation' => array('Required', 'Integer')
42:         ),
43:         array(
44:           'Name' => 'Period', 'Validation' => 'Required'
45:         )
46:     ));
47:     $Validation->Validate($Criteria);
48:     $Form->SetValidationResults($Validation->Results());
49:   }
50: 
51:   public function Hooks() {
52:     return array('Gdn_Dispatcher_AppStartup');
53:   }
54: 
55:   public function Description() {
56:     $Description = T('Yaga.Rules.LengthOfService.Desc');
57:     return Wrap($Description, 'div', array('class' => 'InfoMessage'));
58:   }
59: 
60:   public function Name() {
61:     return T('Yaga.Rules.LengthOfService');
62:   }
63:   
64:   public function Interacts() {
65:     return FALSE;
66:   }
67: }
68: 
Yaga API documentation generated by ApiGen 2.8.0