Skip to content

Commit

Permalink
Badges v0.1
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 34 changed files with 2,317 additions and 8 deletions.
10 changes: 5 additions & 5 deletions resources/celerity/map.php
Expand Up @@ -7,7 +7,7 @@
*/
return array(
'names' => array(
'core.pkg.css' => 'b5cc2f39',
'core.pkg.css' => 'f79ebe46',
'core.pkg.js' => 'a590b451',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '9451634c',
Expand Down Expand Up @@ -142,10 +142,10 @@
'rsrc/css/phui/phui-info-view.css' => '5b16bac6',
'rsrc/css/phui/phui-list.css' => '125599df',
'rsrc/css/phui/phui-object-box.css' => '407eaf5a',
'rsrc/css/phui/phui-object-item-list-view.css' => 'fc19bfc1',
'rsrc/css/phui/phui-object-item-list-view.css' => 'a1b990b7',
'rsrc/css/phui/phui-pager.css' => 'bea33d23',
'rsrc/css/phui/phui-pinboard-view.css' => '2495140e',
'rsrc/css/phui/phui-property-list-view.css' => '1baf23eb',
'rsrc/css/phui/phui-property-list-view.css' => 'aeb09581',
'rsrc/css/phui/phui-remarkup-preview.css' => '867f85b3',
'rsrc/css/phui/phui-spacing.css' => '042804d6',
'rsrc/css/phui/phui-status.css' => '888cedb8',
Expand Down Expand Up @@ -797,10 +797,10 @@
'phui-inline-comment-view-css' => '9fadd6b8',
'phui-list-view-css' => '125599df',
'phui-object-box-css' => '407eaf5a',
'phui-object-item-list-view-css' => 'fc19bfc1',
'phui-object-item-list-view-css' => 'a1b990b7',
'phui-pager-css' => 'bea33d23',
'phui-pinboard-view-css' => '2495140e',
'phui-property-list-view-css' => '1baf23eb',
'phui-property-list-view-css' => 'aeb09581',
'phui-remarkup-preview-css' => '867f85b3',
'phui-spacing-css' => '042804d6',
'phui-status-list-view-css' => '888cedb8',
Expand Down
54 changes: 54 additions & 0 deletions resources/sql/autopatches/20150712.badges.1.sql
@@ -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};
55 changes: 55 additions & 0 deletions src/__phutil_library_map__.php
Expand Up @@ -1617,6 +1617,29 @@
'PhabricatorAuthValidateController' => 'applications/auth/controller/PhabricatorAuthValidateController.php',
'PhabricatorAuthenticationConfigOptions' => 'applications/config/option/PhabricatorAuthenticationConfigOptions.php',
'PhabricatorAutoEventListener' => 'infrastructure/events/PhabricatorAutoEventListener.php',
'PhabricatorBadgeHasRecipientEdgeType' => 'applications/badges/edge/PhabricatorBadgeHasRecipientEdgeType.php',
'PhabricatorBadgesApplication' => 'applications/badges/application/PhabricatorBadgesApplication.php',
'PhabricatorBadgesBadge' => 'applications/badges/storage/PhabricatorBadgesBadge.php',
'PhabricatorBadgesController' => 'applications/badges/controller/PhabricatorBadgesController.php',
'PhabricatorBadgesCreateCapability' => 'applications/badges/capability/PhabricatorBadgesCreateCapability.php',
'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php',
'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php',
'PhabricatorBadgesDefaultViewCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultViewCapability.php',
'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php',
'PhabricatorBadgesEditIconController' => 'applications/badges/controller/PhabricatorBadgesEditIconController.php',
'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php',
'PhabricatorBadgesEditor' => 'applications/badges/editor/PhabricatorBadgesEditor.php',
'PhabricatorBadgesIcon' => 'applications/badges/icon/PhabricatorBadgesIcon.php',
'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php',
'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php',
'PhabricatorBadgesQuery' => 'applications/badges/query/PhabricatorBadgesQuery.php',
'PhabricatorBadgesRecipientsListView' => 'applications/badges/view/PhabricatorBadgesRecipientsListView.php',
'PhabricatorBadgesRemoveRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRemoveRecipientsController.php',
'PhabricatorBadgesSchemaSpec' => 'applications/badges/storage/PhabricatorBadgesSchemaSpec.php',
'PhabricatorBadgesSearchEngine' => 'applications/badges/query/PhabricatorBadgesSearchEngine.php',
'PhabricatorBadgesTransaction' => 'applications/badges/storage/PhabricatorBadgesTransaction.php',
'PhabricatorBadgesTransactionQuery' => 'applications/badges/query/PhabricatorBadgesTransactionQuery.php',
'PhabricatorBadgesViewController' => 'applications/badges/controller/PhabricatorBadgesViewController.php',
'PhabricatorBarePageUIExample' => 'applications/uiexample/examples/PhabricatorBarePageUIExample.php',
'PhabricatorBarePageView' => 'view/page/PhabricatorBarePageView.php',
'PhabricatorBaseURISetupCheck' => 'applications/config/check/PhabricatorBaseURISetupCheck.php',
Expand Down Expand Up @@ -2561,6 +2584,7 @@
'PhabricatorQueryOrderTestCase' => 'infrastructure/query/order/__tests__/PhabricatorQueryOrderTestCase.php',
'PhabricatorQueryOrderVector' => 'infrastructure/query/order/PhabricatorQueryOrderVector.php',
'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php',
'PhabricatorRecipientHasBadgeEdgeType' => 'applications/badges/edge/PhabricatorRecipientHasBadgeEdgeType.php',
'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php',
'PhabricatorRefreshCSRFController' => 'applications/auth/controller/PhabricatorRefreshCSRFController.php',
'PhabricatorRegistrationProfile' => 'applications/people/storage/PhabricatorRegistrationProfile.php',
Expand Down Expand Up @@ -5339,6 +5363,36 @@
'PhabricatorAuthValidateController' => 'PhabricatorAuthController',
'PhabricatorAuthenticationConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorAutoEventListener' => 'PhabricatorEventListener',
'PhabricatorBadgeHasRecipientEdgeType' => 'PhabricatorEdgeType',
'PhabricatorBadgesApplication' => 'PhabricatorApplication',
'PhabricatorBadgesBadge' => array(
'PhabricatorBadgesDAO',
'PhabricatorPolicyInterface',
'PhabricatorApplicationTransactionInterface',
'PhabricatorSubscribableInterface',
'PhabricatorFlaggableInterface',
'PhabricatorDestructibleInterface',
),
'PhabricatorBadgesController' => 'PhabricatorController',
'PhabricatorBadgesCreateCapability' => 'PhabricatorPolicyCapability',
'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO',
'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability',
'PhabricatorBadgesDefaultViewCapability' => 'PhabricatorPolicyCapability',
'PhabricatorBadgesEditController' => 'PhabricatorBadgesController',
'PhabricatorBadgesEditIconController' => 'PhabricatorBadgesController',
'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController',
'PhabricatorBadgesEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorBadgesIcon' => 'Phobject',
'PhabricatorBadgesListController' => 'PhabricatorBadgesController',
'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType',
'PhabricatorBadgesQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorBadgesRecipientsListView' => 'AphrontTagView',
'PhabricatorBadgesRemoveRecipientsController' => 'PhabricatorBadgesController',
'PhabricatorBadgesSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorBadgesSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorBadgesTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorBadgesTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorBadgesViewController' => 'PhabricatorBadgesController',
'PhabricatorBarePageUIExample' => 'PhabricatorUIExample',
'PhabricatorBarePageView' => 'AphrontPageView',
'PhabricatorBaseURISetupCheck' => 'PhabricatorSetupCheck',
Expand Down Expand Up @@ -6448,6 +6502,7 @@
'Iterator',
),
'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorRecipientHasBadgeEdgeType' => 'PhabricatorEdgeType',
'PhabricatorRedirectController' => 'PhabricatorController',
'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController',
'PhabricatorRegistrationProfile' => 'Phobject',
Expand Down
@@ -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,
),
);
}

}
@@ -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.');
}

}
@@ -0,0 +1,12 @@
<?php

final class PhabricatorBadgesDefaultEditCapability
extends PhabricatorPolicyCapability {

const CAPABILITY = 'badges.default.edit';

public function getCapabilityName() {
return pht('Default Edit Badges');
}

}
@@ -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;
}

}
@@ -0,0 +1,3 @@
<?php

abstract class PhabricatorBadgesController extends PhabricatorController {}

0 comments on commit ffadf64

Please sign in to comment.