mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-22 19:49:02 +01:00
Phriction - make the check for project sub pages more fine-grained
Summary: we were just checking if projects/ was in the URI before barfing. Use some more fun utility functions such that we only complain if there is no project. Fixes T4071. Test Plan: made a subpage under a project - success! tried to make a project wiki page where there was no project - successful failure! tried to make a project wiki sub page where there was no project - successful failure! Reviewers: epriestley, chad Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T4071 Differential Revision: https://secure.phabricator.com/D7527
This commit is contained in:
parent
0e65740c2d
commit
9084f1fe8c
4 changed files with 32 additions and 18 deletions
|
@ -40,9 +40,11 @@ final class PhrictionDocumentController
|
|||
$document = new PhrictionDocument();
|
||||
|
||||
if (PhrictionDocument::isProjectSlug($slug)) {
|
||||
$project = id(new PhabricatorProject())->loadOneWhere(
|
||||
'phrictionSlug = %s',
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug));
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($user)
|
||||
->withPhrictionSlugs(array(
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug)))
|
||||
->executeOne();
|
||||
if (!$project) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
@ -214,9 +216,11 @@ final class PhrictionDocumentController
|
|||
|
||||
$project_phid = null;
|
||||
if (PhrictionDocument::isProjectSlug($slug)) {
|
||||
$project = id(new PhabricatorProject())->loadOneWhere(
|
||||
'phrictionSlug = %s',
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug));
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withPhrictionSlugs(array(
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug)))
|
||||
->executeOne();
|
||||
if ($project) {
|
||||
$project_phid = $project->getPHID();
|
||||
}
|
||||
|
|
|
@ -51,9 +51,11 @@ final class PhrictionEditController
|
|||
$content = id(new PhrictionContent())->load($document->getContentID());
|
||||
} else {
|
||||
if (PhrictionDocument::isProjectSlug($slug)) {
|
||||
$project = id(new PhabricatorProject())->loadOneWhere(
|
||||
'phrictionSlug = %s',
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug));
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($user)
|
||||
->withPhrictionSlugs(array(
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug)))
|
||||
->executeOne();
|
||||
if (!$project) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
|
|
@ -33,7 +33,13 @@ final class PhrictionNewController extends PhrictionController {
|
|||
->addSubmitButton(pht('Edit Document'));
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
} elseif (substr($slug, 0, 9) == 'projects/') {
|
||||
} else if (PhrictionDocument::isProjectSlug($slug)) {
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($user)
|
||||
->withPhrictionSlugs(array(
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug)))
|
||||
->executeOne();
|
||||
if (!$project) {
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog->setSubmitURI('/w/')
|
||||
->setTitle(pht('Oops!'))
|
||||
|
@ -44,12 +50,12 @@ final class PhrictionNewController extends PhrictionController {
|
|||
Create a new project with this name first.'))
|
||||
->addCancelButton('/w/', 'Okay');
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
|
||||
} else {
|
||||
$uri = '/phriction/edit/?slug='.$slug;
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($uri);
|
||||
}
|
||||
}
|
||||
|
||||
$uri = '/phriction/edit/?slug='.$slug;
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($uri);
|
||||
}
|
||||
|
||||
if ($slug == '/') {
|
||||
|
|
|
@ -240,9 +240,11 @@ final class PhrictionDocumentEditor extends PhabricatorEditor {
|
|||
$project_phid = null;
|
||||
$slug = $document->getSlug();
|
||||
if (PhrictionDocument::isProjectSlug($slug)) {
|
||||
$project = id(new PhabricatorProject())->loadOneWhere(
|
||||
'phrictionSlug = %s',
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug));
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($this->requireActor())
|
||||
->withPhrictionSlugs(array(
|
||||
PhrictionDocument::getProjectSlugIdentifier($slug)))
|
||||
->executeOne();
|
||||
if ($project) {
|
||||
$project_phid = $project->getPHID();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue