Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/badges/application/PhabricatorBadgesApplication.php b/src/applications/badges/application/PhabricatorBadgesApplication.php
index 0de150ee2d..5423609fda 100644
--- a/src/applications/badges/application/PhabricatorBadgesApplication.php
+++ b/src/applications/badges/application/PhabricatorBadgesApplication.php
@@ -1,77 +1,77 @@
<?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 getIcon() {
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',
'award/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesAwardController',
'create/'
=> 'PhabricatorBadgesEditController',
'comment/(?P<id>[1-9]\d*)/'
=> 'PhabricatorBadgesCommentController',
- 'edit/(?:(?P<id>\d+)/)?'
- => 'PhabricatorBadgesEditController',
+ $this->getEditRoutePattern('edit/')
+ => 'PhabricatorBadgesEditController',
'archive/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesArchiveController',
'view/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesViewController',
'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,
),
);
}
}
diff --git a/src/applications/badges/controller/PhabricatorBadgesListController.php b/src/applications/badges/controller/PhabricatorBadgesListController.php
index c47f38fc5d..5c462e8341 100644
--- a/src/applications/badges/controller/PhabricatorBadgesListController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesListController.php
@@ -1,33 +1,26 @@
<?php
final class PhabricatorBadgesListController
extends PhabricatorBadgesController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
return id(new PhabricatorBadgesSearchEngine())
->setController($this)
->buildResponse();
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
- $can_create = $this->hasApplicationCapability(
- PhabricatorBadgesCreateCapability::CAPABILITY);
-
- $crumbs->addAction(
- id(new PHUIListItemView())
- ->setName(pht('Create Badge'))
- ->setHref($this->getApplicationURI('create/'))
- ->setIcon('fa-plus-square')
- ->setDisabled(!$can_create)
- ->setWorkflow(!$can_create));
+ id(new PhabricatorBadgesEditEngine())
+ ->setViewer($this->getViewer())
+ ->addActionToCrumbs($crumbs);
return $crumbs;
}
}
diff --git a/src/applications/badges/controller/PhabricatorBadgesViewController.php b/src/applications/badges/controller/PhabricatorBadgesViewController.php
index 9b61e10b44..4539440588 100644
--- a/src/applications/badges/controller/PhabricatorBadgesViewController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesViewController.php
@@ -1,177 +1,159 @@
<?php
final class PhabricatorBadgesViewController
extends PhabricatorBadgesController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$badge = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
->withIDs(array($id))
->needRecipients(true)
->executeOne();
if (!$badge) {
return new Aphront404Response();
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($badge->getName());
$crumbs->setBorder(true);
$title = $badge->getName();
if ($badge->isArchived()) {
$status_icon = 'fa-ban';
$status_color = 'dark';
} else {
$status_icon = 'fa-check';
$status_color = 'bluegrey';
}
$status_name = idx(
PhabricatorBadgesBadge::getStatusNameMap(),
$badge->getStatus());
$header = id(new PHUIHeaderView())
->setHeader($badge->getName())
->setUser($viewer)
->setPolicyObject($badge)
->setStatus($status_icon, $status_color, $status_name)
->setHeaderIcon('fa-trophy');
$curtain = $this->buildCurtain($badge);
$details = $this->buildDetailsView($badge);
$timeline = $this->buildTransactionTimeline(
$badge,
new PhabricatorBadgesTransactionQuery());
$awards = $badge->getAwards();
$recipient_phids = mpull($awards, 'getRecipientPHID');
$recipient_phids = array_reverse($recipient_phids);
$handles = $this->loadViewerHandles($recipient_phids);
$recipient_list = id(new PhabricatorBadgesRecipientsListView())
->setBadge($badge)
->setHandles($handles)
->setUser($viewer);
- $add_comment = $this->buildCommentForm($badge);
+ $comment_view = id(new PhabricatorBadgesEditEngine())
+ ->setViewer($viewer)
+ ->buildEditEngineCommentView($badge);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$recipient_list,
$timeline,
- $add_comment,
+ $comment_view,
))
->addPropertySection(pht('DESCRIPTION'), $details);
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setPageObjectPHIDs(array($badge->getPHID()))
->appendChild($view);
}
private function buildDetailsView(
PhabricatorBadgesBadge $badge) {
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())
->setUser($viewer);
$description = $badge->getDescription();
if (strlen($description)) {
$view->addTextContent(
new PHUIRemarkupView($viewer, $description));
}
$badge = id(new PHUIBadgeView())
->setIcon($badge->getIcon())
->setHeader($badge->getName())
->setSubhead($badge->getFlavor())
->setQuality($badge->getQuality());
$view->addTextContent($badge);
return $view;
}
private function buildCurtain(PhabricatorBadgesBadge $badge) {
$viewer = $this->getViewer();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$badge,
PhabricatorPolicyCapability::CAN_EDIT);
$id = $badge->getID();
$edit_uri = $this->getApplicationURI("/edit/{$id}/");
$archive_uri = $this->getApplicationURI("/archive/{$id}/");
$award_uri = $this->getApplicationURI("/recipients/{$id}/");
$curtain = $this->newCurtainView($badge);
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Badge'))
->setIcon('fa-pencil')
->setDisabled(!$can_edit)
->setHref($edit_uri));
if ($badge->isArchived()) {
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Activate Badge'))
->setIcon('fa-check')
->setDisabled(!$can_edit)
->setWorkflow($can_edit)
->setHref($archive_uri));
} else {
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Archive Badge'))
->setIcon('fa-ban')
->setDisabled(!$can_edit)
->setWorkflow($can_edit)
->setHref($archive_uri));
}
$curtain->addAction(
id(new PhabricatorActionView())
->setName('Add Recipients')
->setIcon('fa-users')
->setDisabled(!$can_edit)
->setWorkflow(true)
->setHref($award_uri));
return $curtain;
}
- private function buildCommentForm(PhabricatorBadgesBadge $badge) {
- $viewer = $this->getViewer();
-
- $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
-
- $add_comment_header = $is_serious
- ? pht('Add Comment')
- : pht('Render Honors');
-
- $draft = PhabricatorDraft::newFromUserAndKey($viewer, $badge->getPHID());
-
- return id(new PhabricatorApplicationTransactionCommentView())
- ->setUser($viewer)
- ->setObjectPHID($badge->getPHID())
- ->setDraft($draft)
- ->setHeaderText($add_comment_header)
- ->setAction($this->getApplicationURI('/comment/'.$badge->getID().'/'))
- ->setSubmitButtonName(pht('Add Comment'));
- }
-
}
diff --git a/src/applications/badges/editor/PhabricatorBadgesEditEngine.php b/src/applications/badges/editor/PhabricatorBadgesEditEngine.php
index 28f07a6dad..8c569b5fbb 100644
--- a/src/applications/badges/editor/PhabricatorBadgesEditEngine.php
+++ b/src/applications/badges/editor/PhabricatorBadgesEditEngine.php
@@ -1,102 +1,115 @@
<?php
final class PhabricatorBadgesEditEngine
extends PhabricatorEditEngine {
const ENGINECONST = 'badges.badge';
public function getEngineName() {
return pht('Badges');
}
public function getEngineApplicationClass() {
return 'PhabricatorBadgesApplication';
}
public function getSummaryHeader() {
return pht('Configure Badges Forms');
}
public function getSummaryText() {
return pht('Configure creation and editing forms in Badges.');
}
protected function newEditableObject() {
return PhabricatorBadgesBadge::initializeNewBadge($this->getViewer());
}
protected function newObjectQuery() {
return new PhabricatorBadgesQuery();
}
protected function getObjectCreateTitleText($object) {
return pht('Create New Badge');
}
protected function getObjectEditTitleText($object) {
return pht('Edit Badge: %s', $object->getName());
}
protected function getObjectEditShortText($object) {
return $object->getName();
}
protected function getObjectCreateShortText() {
return pht('Create Badge');
}
protected function getObjectName() {
return pht('Badge');
}
+ protected function getObjectCreateCancelURI($object) {
+ return $this->getApplication()->getApplicationURI('/');
+ }
+
+ protected function getEditorURI() {
+ return $this->getApplication()->getApplicationURI('edit/');
+ }
+
protected function getCommentViewHeaderText($object) {
- return pht('Add Comment');
+ return pht('Render Honors');
}
protected function getCommentViewButtonText($object) {
- return pht('Submit');
+ return pht('Salute');
}
protected function getObjectViewURI($object) {
return $object->getViewURI();
}
+ protected function getCreateNewObjectPolicy() {
+ return $this->getApplication()->getPolicy(
+ PhabricatorBadgesCreateCapability::CAPABILITY);
+ }
+
protected function buildCustomEditFields($object) {
return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setDescription(pht('Badge name.'))
->setTransactionType(PhabricatorBadgesTransaction::TYPE_NAME)
->setValue($object->getName()),
id(new PhabricatorTextEditField())
->setKey('flavor')
->setLabel(pht('Flavor text'))
->setDescription(pht('Short description of the badge.'))
->setValue($object->getFlavor())
->setTransactionType(PhabricatorBadgesTransaction::TYPE_FLAVOR),
id(new PhabricatorIconSetEditField())
->setKey('icon')
->setLabel(pht('Icon'))
->setIconSet(new PhabricatorBadgesIconSet())
->setTransactionType(PhabricatorBadgesTransaction::TYPE_ICON)
->setConduitDescription(pht('Change the badge icon.'))
->setConduitTypeDescription(pht('New badge icon.'))
->setValue($object->getIcon()),
id(new PhabricatorSelectEditField())
->setKey('quality')
->setLabel(pht('Quality'))
->setValue($object->getQuality())
->setTransactionType(PhabricatorBadgesTransaction::TYPE_QUALITY)
->setOptions(PhabricatorBadgesQuality::getDropdownQualityMap()),
id(new PhabricatorRemarkupEditField())
->setKey('description')
->setLabel(pht('Description'))
->setDescription(pht('Badge long description.'))
->setTransactionType(PhabricatorBadgesTransaction::TYPE_DESCRIPTION)
->setValue($object->getDescription()),
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Mar 16, 11:54 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
963687
Default Alt Text
(13 KB)

Event Timeline