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 sign in date
 5:  *
 6:  * @author Zachary Doll
 7:  * @since 1.0
 8:  * @package Yaga
 9:  */
10: class HolidayVisit implements YagaRule {
11: 
12:   public function Award($Sender, $User, $Criteria) {
13:     // Determine if today is the target day
14:     $Month = date('n');
15:     $Day = date('j');
16: 
17:     if($Criteria->Month == $Month
18:             && $Criteria->Day == $Day) {
19:       return TRUE;
20:     }
21:     else {
22:       return FALSE;
23:     }
24:   }
25: 
26:   public function Form($Form) {
27:     $Months = array();
28:     $Days = array();
29:     for($i = 1; $i <= 12; $i++) {
30:       $Months[$i] = date('F', mktime(0,0,0,$i));
31:     }
32:     for($i = 1; $i <= 31; $i++) {
33:       $Days[$i] = $i;
34:     }
35: 
36:     $String = $Form->Label('Yaga.Rules.HolidayVisit.Criteria.Head', 'HolidayVisit');
37:     $String .= $Form->DropDown('Month', $Months) . ' ';
38:     $String .= $Form->DropDown('Day', $Days);
39:     return $String;
40:   }
41: 
42:   public function Validate($Criteria, $Form) {
43:     $Validation = new Gdn_Validation();
44:     $Validation->ApplyRules(array(
45:         array(
46:           'Name' => 'Month', 'Validation' => array('Required', 'Integer')
47:         ),
48:         array(
49:           'Name' => 'Day', 'Validation' => array('Required', 'Integer')
50:         )
51:     ));
52:     $Validation->Validate($Criteria);
53:     $Form->SetValidationResults($Validation->Results());
54:   }
55: 
56:   public function Hooks() {
57:     return array('Gdn_Dispatcher_AppStartup');
58:   }
59: 
60:   public function Description() {
61:     $Description = T('Yaga.Rules.HolidayVisit.Desc');
62:     return Wrap($Description, 'div', array('class' => 'InfoMessage'));
63:   }
64: 
65:   public function Name() {
66:     return T('Yaga.Rules.HolidayVisit');
67:   }
68:   
69:   public function Interacts() {
70:     return FALSE;
71:   }
72: }
73: 
Yaga API documentation generated by ApiGen 2.8.0