Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Basic plumbing for Badges application. - You can make Badges. - You can look at a list of them. - They can be edited. - They can be assigned to people. - You can revoke them from people. - You can subscribe to them. Test Plan: Make Badges with various options. Give them to people. Take them away from people. Reviewers: lpriestley, epriestley Reviewed By: epriestley Subscribers: tycho.tatitscheff, johnny-bit, epriestley, Korvin Maniphest Tasks: T6526 Differential Revision: https://secure.phabricator.com/D13626
- Loading branch information
Chad Little
committed
Jul 22, 2015
1 parent
fdd6351
commit ffadf64
Showing
34 changed files
with
2,317 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
CREATE TABLE {$NAMESPACE}_badges.badges_badge ( | ||
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
phid VARBINARY(64) NOT NULL, | ||
name VARCHAR(255) NOT NULL COLLATE {$COLLATE_TEXT}, | ||
flavor VARCHAR(255) NOT NULL COLLATE {$COLLATE_TEXT}, | ||
description LONGTEXT NOT NULL, | ||
icon VARCHAR(255) NOT NULL, | ||
quality VARCHAR(255) NOT NULL, | ||
status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT}, | ||
dateCreated INT UNSIGNED NOT NULL, | ||
dateModified INT UNSIGNED NOT NULL, | ||
viewPolicy VARBINARY(64) NOT NULL, | ||
editPolicy VARBINARY(64) NOT NULL, | ||
creatorPHID varbinary(64) NOT NULL, | ||
UNIQUE KEY `key_phid` (phid), | ||
KEY `key_creator` (creatorPHID, dateModified) | ||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT}; | ||
|
||
CREATE TABLE {$NAMESPACE}_badges.badges_transaction ( | ||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, | ||
phid VARBINARY(64) NOT NULL, | ||
authorPHID VARBINARY(64) NOT NULL, | ||
objectPHID VARBINARY(64) NOT NULL, | ||
viewPolicy VARBINARY(64) NOT NULL, | ||
editPolicy VARBINARY(64) NOT NULL, | ||
commentPHID VARBINARY(64), | ||
commentVersion INT UNSIGNED NOT NULL, | ||
transactionType VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT}, | ||
oldValue LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, | ||
newValue LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, | ||
contentSource LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, | ||
metadata LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, | ||
dateCreated INT UNSIGNED NOT NULL, | ||
dateModified INT UNSIGNED NOT NULL, | ||
UNIQUE KEY `key_phid` (phid), | ||
KEY `key_object` (objectPHID) | ||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT}; | ||
|
||
CREATE TABLE {$NAMESPACE}_badges.edge ( | ||
src VARBINARY(64) NOT NULL, | ||
type INT UNSIGNED NOT NULL, | ||
dst VARBINARY(64) NOT NULL, | ||
dateCreated INT UNSIGNED NOT NULL, | ||
seq INT UNSIGNED NOT NULL, | ||
dataID INT UNSIGNED, | ||
PRIMARY KEY (src, type, dst), | ||
KEY `src` (src, type, dateCreated, seq), | ||
UNIQUE KEY `key_dst` (dst, type, src) | ||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT}; | ||
|
||
CREATE TABLE {$NAMESPACE}_badges.edgedata ( | ||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, | ||
data LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT} | ||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/applications/badges/application/PhabricatorBadgesApplication.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
final class PhabricatorBadgesApplication extends PhabricatorApplication { | ||
|
||
public function getName() { | ||
return pht('Badges'); | ||
} | ||
|
||
public function getBaseURI() { | ||
return '/badges/'; | ||
} | ||
|
||
public function getShortDescription() { | ||
return pht('Achievements and Notority'); | ||
} | ||
|
||
public function getFontIcon() { | ||
return 'fa-trophy'; | ||
} | ||
|
||
public function getFlavorText() { | ||
return pht('Build self esteem through gamification.'); | ||
} | ||
|
||
public function getApplicationGroup() { | ||
return self::GROUP_UTILITIES; | ||
} | ||
|
||
public function canUninstall() { | ||
return true; | ||
} | ||
|
||
public function isPrototype() { | ||
return true; | ||
} | ||
|
||
public function getRoutes() { | ||
return array( | ||
'/badges/' => array( | ||
'(?:query/(?P<queryKey>[^/]+)/)?' | ||
=> 'PhabricatorBadgesListController', | ||
'create/' | ||
=> 'PhabricatorBadgesEditController', | ||
'edit/(?:(?P<id>\d+)/)?' | ||
=> 'PhabricatorBadgesEditController', | ||
'view/(?:(?P<id>\d+)/)?' | ||
=> 'PhabricatorBadgesViewController', | ||
'icon/(?P<id>[1-9]\d*)/' | ||
=> 'PhabricatorBadgesEditIconController', | ||
'icon/' | ||
=> 'PhabricatorBadgesEditIconController', | ||
'recipients/(?P<id>[1-9]\d*)/' | ||
=> 'PhabricatorBadgesEditRecipientsController', | ||
'recipients/(?P<id>[1-9]\d*)/remove/' | ||
=> 'PhabricatorBadgesRemoveRecipientsController', | ||
|
||
), | ||
); | ||
} | ||
|
||
protected function getCustomCapabilities() { | ||
return array( | ||
PhabricatorBadgesCreateCapability::CAPABILITY => array( | ||
'default' => PhabricatorPolicies::POLICY_ADMIN, | ||
'caption' => pht('Default create policy for badges.'), | ||
), | ||
PhabricatorBadgesDefaultEditCapability::CAPABILITY => array( | ||
'default' => PhabricatorPolicies::POLICY_ADMIN, | ||
'caption' => pht('Default edit policy for badges.'), | ||
'template' => PhabricatorBadgesPHIDType::TYPECONST, | ||
), | ||
PhabricatorBadgesDefaultViewCapability::CAPABILITY => array( | ||
'caption' => pht('Default view policy for badges.'), | ||
'template' => PhabricatorBadgesPHIDType::TYPECONST, | ||
), | ||
); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/applications/badges/capability/PhabricatorBadgesCreateCapability.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
final class PhabricatorBadgesCreateCapability | ||
extends PhabricatorPolicyCapability { | ||
|
||
const CAPABILITY = 'badges.default.create'; | ||
|
||
public function getCapabilityName() { | ||
return pht('Can Create Badges'); | ||
} | ||
|
||
public function describeCapabilityRejection() { | ||
return pht('You do not have permission to create badges.'); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
final class PhabricatorBadgesDefaultEditCapability | ||
extends PhabricatorPolicyCapability { | ||
|
||
const CAPABILITY = 'badges.default.edit'; | ||
|
||
public function getCapabilityName() { | ||
return pht('Default Edit Badges'); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/applications/badges/capability/PhabricatorBadgesDefaultViewCapability.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
final class PhabricatorBadgesDefaultViewCapability extends | ||
PhabricatorPolicyCapability { | ||
|
||
const CAPABILITY = 'badges.default.view'; | ||
|
||
public function getCapabilityName() { | ||
return pht('Default View Policy'); | ||
} | ||
|
||
public function shouldAllowPublicPolicySetting() { | ||
return true; | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
src/applications/badges/controller/PhabricatorBadgesController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
abstract class PhabricatorBadgesController extends PhabricatorController {} |
Oops, something went wrong.