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 when the user connects social accounts
 5:  *
 6:  * @author Zachary Doll
 7:  * @since 1.0
 8:  * @package Yaga
 9:  */
10: class SocialConnection implements YagaRule{
11: 
12:   public function Award($Sender, $User, $Criteria) {
13:     $Network = $Sender->EventArguments['Provider'];
14: 
15:     if($Network == $Criteria->SocialNetwork) {
16:       return TRUE;
17:     }
18:     else {
19:       return FALSE;
20:     }
21:   }
22: 
23:   public function Form($Form) {
24:     $SocialNetworks = array(
25:         'Twitter' => 'Twitter',
26:         'Facebook' => 'Facebook'
27:     );
28: 
29:     $String = $Form->Label('Yaga.Rules.SocialConnection.Criteria.Head', 'SocialConnection');
30:     $String .= $Form->DropDown('SocialNetwork', $SocialNetworks);
31: 
32:     return $String;
33:   }
34: 
35:   public function Validate($Criteria, $Form) {
36:     $Validation = new Gdn_Validation();
37:     $Validation->ApplyRules(array(
38:         array(
39:           'Name' => 'SocialNetwork', 'Validation' => array('Required')
40:         )
41:     ));
42:     $Validation->Validate($Criteria);
43:     $Form->SetValidationResults($Validation->Results());
44:   }
45: 
46:   public function Hooks() {
47:     return array('Base_AfterConnection');
48:   }
49: 
50:   public function Description() {
51:     $Description = T('Yaga.Rules.SocialConnection.Desc');
52:     return Wrap($Description, 'div', array('class' => 'InfoMessage'));
53:   }
54: 
55:   public function Name() {
56:     return T('Yaga.Rules.SocialConnection');
57:   }
58:   
59:   public function Interacts() {
60:     return FALSE;
61:   }
62: }
63: 
Yaga API documentation generated by ApiGen 2.8.0