Skip to content

Commit

Permalink
Merge 1.1 development into master
Browse files Browse the repository at this point in the history
  • Loading branch information
hgtonight committed Mar 25, 2016
2 parents 0a10a8a + 1b83ac5 commit 4d99c42
Show file tree
Hide file tree
Showing 68 changed files with 3,724 additions and 3,707 deletions.
836 changes: 252 additions & 584 deletions LICENSE.md

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

**Y**​et **A**​nother **G**​amification **A**​pplication is a Garden application that provides a gamification platform for Vanilla Forums and other Garden applications. It integrates by default with Vanilla Forums. Out of the box, it provides Reactions, Badges, and Ranks.

It is released under the GPLv3 and may be released under a different license _**with permission**_.
It is released under the GPLv2 and may be released under a different license _**with permission**_.

## Requirements

Yaga requires:

* Vanilla 2.2.x (Garden is the actual requirement)
* Pretty URLs enabled

## Contributing

Expand All @@ -13,4 +20,4 @@ Please contribute fixes against the `develop` branch.
Yaga's [main documentation page is here](http://hgtonight.github.io/Application-Yaga/).

---
Copyright 2013 - 2014 © Zachary Doll
Copyright 2013 - 2016 © Zachary Doll
20 changes: 20 additions & 0 deletions cla.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
These terms apply to your contribution of materials to a product or project owned or managed by us ('project'), and set out the intellectual property rights you grant to us (Zachary Doll) in the contributed materials. If this contribution is on behalf of a company, the term 'you' will also mean the company for which you are making the contribution. If you agree to be bound by these terms, check the box below.

Read this agreement carefully before agreeing.

1. The term 'contribution' means any source code, object code, patch, tool, sample, graphic, specification, manual, documentation, or any other material posted or submitted by you to a project.
2. With respect to any worldwide copyrights, or copyright applications and registrations, in your contribution:
* you hereby assign to us joint ownership, and to the extent that such assignment is or becomes invalid, ineffective or unenforceable, you hereby grant to us a perpetual, irrevocable, non-exclusive, worldwide, no-charge, royalty-free, unrestricted license to exercise all rights under those copyrights. This includes, at our option, the right to sublicense these same rights to third parties through multiple levels of sublicensees or other licensing arrangements;
* you agree that each of us can do all things in relation to your contribution as if each of us were the sole owners, and if one of us makes a derivative work of your contribution, the one who makes the derivative work (or has it made) will be the sole owner of that derivative work;
* you agree that you will not assert any moral rights in your contribution against us, our licensees or transferees;
* you agree that we may register a copyright in your contribution and exercise all ownership rights associated with it; and
* you agree that neither of us has any duty to consult with, obtain the consent of, pay or render an accounting to the other for any use or distribution of your contribution.
3. With respect to any patents you own, or that you can license without payment to any third party, you hereby grant to us a perpetual, irrevocable, non-exclusive, worldwide, no-charge, royalty-free license to:
* make, have made, use, sell, offer to sell, import, and otherwise transfer your contribution in whole or in part, alone or in combination with or included in any product, work or materials arising out of the project to which your contribution was submitted, and
* at our option, to sublicense these same rights to third parties through multiple levels of sublicensees or other licensing arrangements.
4. Except as set out above, you keep all right, title, and interest in your contribution. The rights that you grant to us under these terms are effective on the date you first submitted a contribution to us, even if your submission took place before the date you sign these terms. Any contribution we make available under any license will also be made available under a suitable FSF (Free Software Foundation) or OSI (Open Source Initiative) approved license.
5. With respect to your contribution, you represent that:
* it is an original work and that you can legally grant the rights set out in these terms;
* it does not to the best of your knowledge violate any third party's copyrights, trademarks, patents, or other intellectual property rights; and
* you are authorized to sign this contract on behalf of your company (if you are making the contribution on behalf of a company).
6. These terms will be governed by the laws of the State of North Dakota and applicable US Federal law. Any choice of law rules will not apply.
18 changes: 7 additions & 11 deletions controllers/class.actioncontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function Initialize() {
$this->AddJsFile('jquery-ui-1.10.0.custom.min.js');
$this->AddJsFile('admin.actions.js');
$this->AddCssFile('reactions.css');
$this->removeCssFile('magnific-popup.css');
}

/**
Expand Down Expand Up @@ -89,22 +90,17 @@ public function Edit($ActionID = NULL) {
}
}
else {
if($this->Form->Save()) {
if($Edit) {
$Action = $this->ActionModel->GetByID($this->Form->GetFormValue('ActionID'));
}
else {
$Action = $this->ActionModel->GetNewestAction();
}

$NewActionRow = ActionRow($Action);
$NewID = $this->Form->Save();
if($NewID) {
$Action = $this->ActionModel->GetByID($NewID);
$ActionRow = RenderActionRow($Action);

if($Edit) {
$this->JsonTarget('#ActionID_' . $this->Action->ActionID, $NewActionRow, 'ReplaceWith');
$this->JsonTarget('#ActionID_' . $this->Action->ActionID, $ActionRow, 'ReplaceWith');
$this->InformMessage(T('Yaga.ActionUpdated'));
}
else {
$this->JsonTarget('#Actions', $NewActionRow, 'Append');
$this->JsonTarget('#Actions', $ActionRow, 'Append');
$this->InformMessage(T('Yaga.Action.Added'));
}
}
Expand Down
31 changes: 29 additions & 2 deletions controllers/class.badgecontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public function Initialize() {
if($this->Menu) {
$this->Menu->HighlightRoute('/badge');
}
$this->AddJsFile('jquery-ui-1.10.0.custom.min.js');
$this->AddJsFile('admin.badges.js');
$this->AddCssFile('badges.css');
$this->removeCssFile('magnific-popup.css');
}

/**
Expand Down Expand Up @@ -95,12 +97,13 @@ public function Edit($BadgeID = NULL) {

if($TmpImage) {
// Generate the target image name
$TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS);
$TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS, FALSE);
$ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);

// Save the uploaded image
$Parts = $Upload->SaveAs($TmpImage, 'yaga' . DS . $ImageBaseName);
$RelativeUrl = StringBeginsWith($Parts['Url'], Gdn_Url::WebRoot(TRUE), TRUE, TRUE);
$AssetRoot = Gdn::Request()->UrlDomain(TRUE).Gdn::Request()->AssetRoot();
$RelativeUrl = StringBeginsWith($Parts['Url'], $AssetRoot, TRUE, TRUE);

$this->Form->SetFormValue('Photo', $RelativeUrl);
}
Expand Down Expand Up @@ -307,4 +310,28 @@ public function Award($UserID) {
$this->Render();
}

/**
* This takes in a sort array and updates the badge sort order.
*
* Renders the Save tree and/or the Result of the sort update.
*
* @since 1.1
*/
public function Sort() {
// Check permission
$this->Permission('Yaga.Badges.Manage');

$Request = Gdn::Request();
if($Request->IsPostBack()) {
$SortArray = $Request->GetValue('SortArray', NULL);
$Saves = $this->BadgeModel->SaveSort($SortArray);
$this->SetData('Result', TRUE);
$this->SetData('Saves', $Saves);
}
else {
$this->SetData('Result', FALSE);
}

$this->RenderData();
}
}
93 changes: 0 additions & 93 deletions controllers/class.badgescontroller.php

This file was deleted.

2 changes: 1 addition & 1 deletion controllers/class.bestcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function Initialize() {
public function Index($Page = 0) {
list($Offset, $Limit) = $this->_TranslatePage($Page);
$this->Title(T('Yaga.BestContent.Recent'));
$this->_Content = $this->ActedModel->GetRecent('week', $Limit, $Offset);
$this->_Content = $this->ActedModel->GetRecent($Limit, $Offset);
$this->_BuildPager($Offset, $Limit, '/best/%1$s/');
$this->SetData('ActiveFilter', 'Recent');
$this->Render('index');
Expand Down
10 changes: 6 additions & 4 deletions controllers/class.rankcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function Initialize() {
}
$this->AddJsFile('jquery-ui-1.10.0.custom.min.js');
$this->AddJsFile('admin.ranks.js');
$this->removeCssFile('magnific-popup.css');
}

/**
Expand All @@ -51,12 +52,13 @@ public function Settings() {

if($TmpImage) {
// Generate the target image name
$TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS);
$TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS, FALSE);
$ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);

// Save the uploaded image
$Parts = $Upload->SaveAs($TmpImage, 'yaga' . DS . $ImageBaseName);
$RelativeUrl = StringBeginsWith($Parts['Url'], Gdn_Url::WebRoot(TRUE), TRUE, TRUE);
$AssetRoot = Gdn::Request()->UrlDomain(TRUE).Gdn::Request()->AssetRoot();
$RelativeUrl = StringBeginsWith($Parts['Url'], $AssetRoot, TRUE, TRUE);
SaveToConfig('Yaga.Ranks.Photo', $RelativeUrl);

if(C('Yaga.Ranks.Photo') == $Parts['SaveName']) {
Expand Down Expand Up @@ -196,7 +198,7 @@ public function Toggle($RankID) {
$this->Permission('Yaga.Ranks.Manage');
$this->AddSideMenu('rank/settings');

$Rank = $this->RankModel->Get($RankID);
$Rank = $this->RankModel->GetByID($RankID);

if($Rank->Enabled) {
$Enable = FALSE;
Expand All @@ -211,7 +213,7 @@ public function Toggle($RankID) {

$Slider = Wrap(Wrap(Anchor($ToggleText, 'rank/toggle/' . $Rank->RankID, 'Hijack SmallButton'), 'span', array('class' => "ActivateSlider ActivateSlider-{$ActiveClass}")), 'td');
$this->RankModel->Enable($RankID, $Enable);
$this->JsonTarget('#RankID_' . $RankID . ' td:nth-child(5)', $Slider, 'ReplaceWith');
$this->JsonTarget('#RankID_' . $RankID . ' td:nth-child(6)', $Slider, 'ReplaceWith');
$this->Render('Blank', 'Utility', 'Dashboard');
}

Expand Down
49 changes: 28 additions & 21 deletions controllers/class.reactcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,35 @@ public function Index($Type, $ID, $ActionID) {
throw PermissionException();
}

switch($Type) {
case 'discussion':
$Model = new DiscussionModel();
$AnchorID = '#Discussion_';
break;
case 'comment':
$Model = new CommentModel();
$AnchorID = '#Comment_';
break;
case 'activity':
$Model = new ActivityModel();
$AnchorID = '#Activity_';
break;
default:
$Item = null;
$AnchorID = '#' . ucfirst($Type) . '_';
$ItemOwnerID = 0;

if(in_array($Type, array('discussion', 'comment'))) {
$Item = GetRecord($Type, $ID);
}
else if($Type == 'activity') {
$Model = new ActivityModel();
$Item = $Model->GetID($ID, DATASET_TYPE_ARRAY);
}
else {
$this->EventArguments = array(
'TypeFound' => FALSE,
'TargetType' => $Type,
'TargetID' => $ID,
'Item' => &$Item,
'AnchorID' => &$AnchorID,
'ItemOwnerID' => &$ItemOwnerID
);
$this->FireEvent('CustomType');

if(!$this->EventArguments['TypeFound']) {
throw new Gdn_UserException(T('Yaga.Action.InvalidTargetType'));
break;
}
}

$Item = $Model->GetID($ID);

if($Item) {
$Anchor = $AnchorID . $ID . ' .ReactMenu';
$Anchor = $AnchorID . $ID;
}
else {
throw new Gdn_UserException(T('Yaga.Action.InvalidTargetID'));
Expand All @@ -81,13 +88,12 @@ public function Index($Type, $ID, $ActionID) {
switch($Type) {
case 'comment':
case 'discussion':
$ItemOwnerID = $Item->InsertUserID;
$ItemOwnerID = $Item['InsertUserID'];
break;
case 'activity':
$ItemOwnerID = $Item['RegardingUserID'];
break;
default:
throw new Gdn_UserException(T('Yaga.Action.InvalidTargetType'));
break;
}

Expand All @@ -98,7 +104,8 @@ public function Index($Type, $ID, $ActionID) {
// It has passed through the gauntlet
$this->ReactionModel->Set($ID, $Type, $ItemOwnerID, $UserID, $ActionID);

$this->JsonTarget($Anchor, RenderReactionList($ID, $Type, FALSE), 'ReplaceWith');
$this->JsonTarget($Anchor . ' .ReactMenu', RenderReactionList($ID, $Type), 'ReplaceWith');
$this->JsonTarget($Anchor . ' .ReactionRecord', RenderReactionRecord($ID, $Type), 'ReplaceWith');

// Don't render anything
$this->Render('Blank', 'Utility', 'Dashboard');
Expand Down
8 changes: 8 additions & 0 deletions controllers/class.rulescontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public static function GetRules() {
$TempRules[$className] = $Rule->Name();
}
}

// TODO: Don't reuse badge model?
$Model = Yaga::BadgeModel();
$Model->EventArguments['Rules'] = &$TempRules;
$Model->FireAs = 'Yaga';
$Model->FireEvent('AfterGetRules');

asort($TempRules);
if(empty($TempRules)) {
$Rules = serialize(FALSE);
}
Expand Down
Loading

0 comments on commit 4d99c42

Please sign in to comment.