1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Check if user can create project before showing shortcut

Summary: In Maniphest, we provide an additional caption shortcut if you can create projects, which has no use if you cant. Fixes T6969

Test Plan: Check page with and without a user's capability.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6969

Differential Revision: https://secure.phabricator.com/D11390
This commit is contained in:
Chad Little 2015-01-14 10:23:11 -08:00
parent 39406bd1f3
commit 498ce937e7

View file

@ -25,6 +25,10 @@ final class ManiphestTaskEditController extends ManiphestController {
ManiphestEditProjectsCapability::CAPABILITY);
$can_edit_status = $this->hasApplicationCapability(
ManiphestEditStatusCapability::CAPABILITY);
$can_create_projects = PhabricatorPolicyFilter::hasCapability(
$user,
PhabricatorApplication::getByClass('PhabricatorProjectApplication'),
ProjectCreateProjectsCapability::CAPABILITY);
$parent_task = null;
$template_id = null;
@ -664,6 +668,17 @@ final class ManiphestTaskEditController extends ManiphestController {
}
if ($can_edit_projects) {
$caption = null;
if ($can_create_projects) {
$caption = javelin_tag(
'a',
array(
'href' => '/project/create/',
'mustcapture' => true,
'sigil' => 'project-create',
),
pht('Create New Project'));
}
$form
->appendChild(
id(new AphrontFormTokenizerControl())
@ -671,15 +686,7 @@ final class ManiphestTaskEditController extends ManiphestController {
->setName('projects')
->setValue($projects_value)
->setID($project_tokenizer_id)
->setCaption(
javelin_tag(
'a',
array(
'href' => '/project/create/',
'mustcapture' => true,
'sigil' => 'project-create',
),
pht('Create New Project')))
->setCaption($caption)
->setDatasource(new PhabricatorProjectDatasource()));
}