2011-02-21 03:41:23 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class PhabricatorProjectProfileEditController
|
2011-02-21 03:41:23 +01:00
|
|
|
extends PhabricatorProjectController {
|
|
|
|
|
2012-10-04 23:33:50 +02:00
|
|
|
private $id;
|
|
|
|
|
2011-02-21 03:41:23 +01:00
|
|
|
public function willProcessRequest(array $data) {
|
2011-06-26 17:37:47 +02:00
|
|
|
$this->id = $data['id'];
|
2011-02-21 03:41:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2012-08-15 19:44:58 +02:00
|
|
|
$project = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
2011-06-26 17:37:47 +02:00
|
|
|
if (!$project) {
|
|
|
|
return new Aphront404Response();
|
2011-02-21 03:41:23 +01:00
|
|
|
}
|
2012-08-15 19:44:58 +02:00
|
|
|
|
2011-06-26 17:37:47 +02:00
|
|
|
$profile = $project->loadProfile();
|
2011-02-21 03:41:23 +01:00
|
|
|
if (empty($profile)) {
|
|
|
|
$profile = new PhabricatorProjectProfile();
|
|
|
|
}
|
|
|
|
|
2012-06-26 17:14:15 +02:00
|
|
|
$img_src = $profile->loadProfileImageURI();
|
|
|
|
|
2011-06-18 10:13:56 +02:00
|
|
|
$options = PhabricatorProjectStatus::getStatusMap();
|
|
|
|
|
2012-03-14 20:41:33 +01:00
|
|
|
$supported_formats = PhabricatorFile::getTransformableImageFormats();
|
|
|
|
|
2011-02-21 03:41:23 +01:00
|
|
|
$e_name = true;
|
2012-03-14 20:41:33 +01:00
|
|
|
$e_image = null;
|
|
|
|
|
2011-02-21 03:41:23 +01:00
|
|
|
$errors = array();
|
|
|
|
if ($request->isFormPost()) {
|
Provide wiki pages for projects
Summary:
Provide tighter integration between Projects and Phriction. Partly, I have most
of a rewrite for the Projects homepage ready but it's not currently possible to
publish feed stories about a project so all the feeds are empty/boring. This
partly makes them more useful and partly just provides a tool integration point.
- When you create a project, all the wiki pages in projects/<project_name>/*
are associated with it.
- Publish updates to those pages as being related to the project so they'll
show up in project feeds.
- Show a project link on those pages.
This is very "convention over configuration" but I think it's the right
approach. We could provide some sort of, like, "@project=derp" tag to let you
associated arbitrary pages to projects later, but just letting you move pages is
probably far better.
Test Plan:
- Ran upgrade scripts against stupidly named projects ("der", " der", " der
", "der (2)", " der (2) (2)", etc). Ended up with uniquely named projects.
- Ran unit tests.
- Created /projects/ wiki documents and made sure they displayed correctly.
- Verified feed stories publish as project-related.
- Edited projects, including perfomring a name-colliding edit.
- Created projects, including performing a name-colliding create.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, epriestley, btrahan
Maniphest Tasks: T681
Differential Revision: 1231
2011-12-17 20:58:55 +01:00
|
|
|
try {
|
2012-01-24 16:11:37 +01:00
|
|
|
$xactions = array();
|
|
|
|
$xaction = new PhabricatorProjectTransaction();
|
|
|
|
$xaction->setTransactionType(
|
|
|
|
PhabricatorProjectTransactionType::TYPE_NAME);
|
|
|
|
$xaction->setNewValue($request->getStr('name'));
|
|
|
|
$xactions[] = $xaction;
|
|
|
|
|
2012-02-07 23:59:38 +01:00
|
|
|
$xaction = new PhabricatorProjectTransaction();
|
|
|
|
$xaction->setTransactionType(
|
|
|
|
PhabricatorProjectTransactionType::TYPE_STATUS);
|
|
|
|
$xaction->setNewValue($request->getStr('status'));
|
|
|
|
$xactions[] = $xaction;
|
|
|
|
|
2012-08-15 19:44:58 +02:00
|
|
|
$xaction = new PhabricatorProjectTransaction();
|
|
|
|
$xaction->setTransactionType(
|
|
|
|
PhabricatorProjectTransactionType::TYPE_CAN_VIEW);
|
|
|
|
$xaction->setNewValue($request->getStr('can_view'));
|
|
|
|
$xactions[] = $xaction;
|
|
|
|
|
|
|
|
$xaction = new PhabricatorProjectTransaction();
|
|
|
|
$xaction->setTransactionType(
|
|
|
|
PhabricatorProjectTransactionType::TYPE_CAN_EDIT);
|
|
|
|
$xaction->setNewValue($request->getStr('can_edit'));
|
|
|
|
$xactions[] = $xaction;
|
|
|
|
|
|
|
|
$xaction = new PhabricatorProjectTransaction();
|
|
|
|
$xaction->setTransactionType(
|
|
|
|
PhabricatorProjectTransactionType::TYPE_CAN_JOIN);
|
|
|
|
$xaction->setNewValue($request->getStr('can_join'));
|
|
|
|
$xactions[] = $xaction;
|
|
|
|
|
Provide wiki pages for projects
Summary:
Provide tighter integration between Projects and Phriction. Partly, I have most
of a rewrite for the Projects homepage ready but it's not currently possible to
publish feed stories about a project so all the feeds are empty/boring. This
partly makes them more useful and partly just provides a tool integration point.
- When you create a project, all the wiki pages in projects/<project_name>/*
are associated with it.
- Publish updates to those pages as being related to the project so they'll
show up in project feeds.
- Show a project link on those pages.
This is very "convention over configuration" but I think it's the right
approach. We could provide some sort of, like, "@project=derp" tag to let you
associated arbitrary pages to projects later, but just letting you move pages is
probably far better.
Test Plan:
- Ran upgrade scripts against stupidly named projects ("der", " der", " der
", "der (2)", " der (2) (2)", etc). Ended up with uniquely named projects.
- Ran unit tests.
- Created /projects/ wiki documents and made sure they displayed correctly.
- Verified feed stories publish as project-related.
- Edited projects, including perfomring a name-colliding edit.
- Created projects, including performing a name-colliding create.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, epriestley, btrahan
Maniphest Tasks: T681
Differential Revision: 1231
2011-12-17 20:58:55 +01:00
|
|
|
$editor = new PhabricatorProjectEditor($project);
|
2012-10-10 19:18:23 +02:00
|
|
|
$editor->setActor($user);
|
2012-01-24 16:11:37 +01:00
|
|
|
$editor->applyTransactions($xactions);
|
Provide wiki pages for projects
Summary:
Provide tighter integration between Projects and Phriction. Partly, I have most
of a rewrite for the Projects homepage ready but it's not currently possible to
publish feed stories about a project so all the feeds are empty/boring. This
partly makes them more useful and partly just provides a tool integration point.
- When you create a project, all the wiki pages in projects/<project_name>/*
are associated with it.
- Publish updates to those pages as being related to the project so they'll
show up in project feeds.
- Show a project link on those pages.
This is very "convention over configuration" but I think it's the right
approach. We could provide some sort of, like, "@project=derp" tag to let you
associated arbitrary pages to projects later, but just letting you move pages is
probably far better.
Test Plan:
- Ran upgrade scripts against stupidly named projects ("der", " der", " der
", "der (2)", " der (2) (2)", etc). Ended up with uniquely named projects.
- Ran unit tests.
- Created /projects/ wiki documents and made sure they displayed correctly.
- Verified feed stories publish as project-related.
- Edited projects, including perfomring a name-colliding edit.
- Created projects, including performing a name-colliding create.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, epriestley, btrahan
Maniphest Tasks: T681
Differential Revision: 1231
2011-12-17 20:58:55 +01:00
|
|
|
} catch (PhabricatorProjectNameCollisionException $ex) {
|
2013-05-22 01:13:34 +02:00
|
|
|
$e_name = pht('Not Unique');
|
Provide wiki pages for projects
Summary:
Provide tighter integration between Projects and Phriction. Partly, I have most
of a rewrite for the Projects homepage ready but it's not currently possible to
publish feed stories about a project so all the feeds are empty/boring. This
partly makes them more useful and partly just provides a tool integration point.
- When you create a project, all the wiki pages in projects/<project_name>/*
are associated with it.
- Publish updates to those pages as being related to the project so they'll
show up in project feeds.
- Show a project link on those pages.
This is very "convention over configuration" but I think it's the right
approach. We could provide some sort of, like, "@project=derp" tag to let you
associated arbitrary pages to projects later, but just letting you move pages is
probably far better.
Test Plan:
- Ran upgrade scripts against stupidly named projects ("der", " der", " der
", "der (2)", " der (2) (2)", etc). Ended up with uniquely named projects.
- Ran unit tests.
- Created /projects/ wiki documents and made sure they displayed correctly.
- Verified feed stories publish as project-related.
- Edited projects, including perfomring a name-colliding edit.
- Created projects, including performing a name-colliding create.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, epriestley, btrahan
Maniphest Tasks: T681
Differential Revision: 1231
2011-12-17 20:58:55 +01:00
|
|
|
$errors[] = $ex->getMessage();
|
|
|
|
}
|
|
|
|
|
2011-02-21 03:41:23 +01:00
|
|
|
$profile->setBlurb($request->getStr('blurb'));
|
|
|
|
|
|
|
|
if (!strlen($project->getName())) {
|
2013-02-13 18:22:14 +01:00
|
|
|
$e_name = pht('Required');
|
|
|
|
$errors[] = pht('Project name is required.');
|
2011-02-21 03:41:23 +01:00
|
|
|
} else {
|
|
|
|
$e_name = null;
|
|
|
|
}
|
|
|
|
|
2012-06-26 17:14:15 +02:00
|
|
|
$default_image = $request->getExists('default_image');
|
|
|
|
if ($default_image) {
|
|
|
|
$profile->setProfileImagePHID(null);
|
|
|
|
} else if (!empty($_FILES['image'])) {
|
2011-06-18 10:13:56 +02:00
|
|
|
$err = idx($_FILES['image'], 'error');
|
|
|
|
if ($err != UPLOAD_ERR_NO_FILE) {
|
2011-07-08 06:17:00 +02:00
|
|
|
$file = PhabricatorFile::newFromPHPUpload(
|
|
|
|
$_FILES['image'],
|
|
|
|
array(
|
|
|
|
'authorPHID' => $user->getPHID(),
|
|
|
|
));
|
2011-06-18 10:13:56 +02:00
|
|
|
$okay = $file->isTransformableImage();
|
|
|
|
if ($okay) {
|
2011-06-26 17:37:47 +02:00
|
|
|
$xformer = new PhabricatorImageTransformer();
|
2011-12-17 05:01:38 +01:00
|
|
|
$xformed = $xformer->executeThumbTransform(
|
2011-06-26 17:37:47 +02:00
|
|
|
$file,
|
2011-12-17 05:01:38 +01:00
|
|
|
$x = 50,
|
|
|
|
$y = 50);
|
2011-06-26 17:37:47 +02:00
|
|
|
$profile->setProfileImagePHID($xformed->getPHID());
|
2011-06-18 10:13:56 +02:00
|
|
|
} else {
|
2013-02-13 18:22:14 +01:00
|
|
|
$e_image = pht('Not Supported');
|
2011-06-18 10:13:56 +02:00
|
|
|
$errors[] =
|
2013-02-13 18:22:14 +01:00
|
|
|
pht('This server only supports these image formats:').' '.
|
2012-03-14 20:41:33 +01:00
|
|
|
implode(', ', $supported_formats).'.';
|
2011-06-18 10:13:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-21 03:41:23 +01:00
|
|
|
if (!$errors) {
|
|
|
|
$project->save();
|
|
|
|
$profile->setProjectPHID($project->getPHID());
|
|
|
|
$profile->save();
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI('/project/view/'.$project->getID().'/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$error_view = null;
|
|
|
|
if ($errors) {
|
|
|
|
$error_view = new AphrontErrorView();
|
2013-02-13 18:22:14 +01:00
|
|
|
$error_view->setTitle(pht('Form Errors'));
|
2011-02-21 03:41:23 +01:00
|
|
|
$error_view->setErrors($errors);
|
|
|
|
}
|
|
|
|
|
2013-02-13 18:22:14 +01:00
|
|
|
$header_name = pht('Edit Project');
|
|
|
|
$title = pht('Edit Project');
|
2011-06-26 17:37:47 +02:00
|
|
|
$action = '/project/edit/'.$project->getID().'/';
|
2011-02-21 03:41:23 +01:00
|
|
|
|
2012-09-13 19:15:08 +02:00
|
|
|
$policies = id(new PhabricatorPolicyQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->setObject($project)
|
|
|
|
->execute();
|
|
|
|
|
2011-02-21 03:41:23 +01:00
|
|
|
$form = new AphrontFormView();
|
|
|
|
$form
|
2011-07-16 07:30:55 +02:00
|
|
|
->setID('project-edit-form')
|
2011-02-21 03:41:23 +01:00
|
|
|
->setUser($user)
|
|
|
|
->setAction($action)
|
2011-06-18 10:13:56 +02:00
|
|
|
->setEncType('multipart/form-data')
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
->setFlexible(true)
|
2011-02-21 03:41:23 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
2013-02-13 18:22:14 +01:00
|
|
|
->setLabel(pht('Name'))
|
2011-02-21 03:41:23 +01:00
|
|
|
->setName('name')
|
|
|
|
->setValue($project->getName())
|
|
|
|
->setError($e_name))
|
2011-06-18 10:13:56 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
2013-02-13 18:22:14 +01:00
|
|
|
->setLabel(pht('Project Status'))
|
2011-06-18 10:13:56 +02:00
|
|
|
->setName('status')
|
|
|
|
->setOptions($options)
|
|
|
|
->setValue($project->getStatus()))
|
2011-02-21 03:41:23 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
2013-02-13 18:22:14 +01:00
|
|
|
->setLabel(pht('Blurb'))
|
2011-02-21 03:41:23 +01:00
|
|
|
->setName('blurb')
|
|
|
|
->setValue($profile->getBlurb()))
|
2013-02-13 22:26:30 +01:00
|
|
|
->appendChild(hsprintf(
|
|
|
|
'<p class="aphront-form-instructions">%s</p>',
|
|
|
|
pht(
|
|
|
|
'NOTE: Policy settings are not yet fully implemented. '.
|
|
|
|
'Some interfaces still ignore these settings, '.
|
|
|
|
'particularly "Visible To".')))
|
2012-08-15 19:44:58 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormPolicyControl())
|
|
|
|
->setUser($user)
|
|
|
|
->setName('can_view')
|
2013-02-13 18:22:14 +01:00
|
|
|
->setCaption(pht('Members can always view a project.'))
|
2012-08-15 19:44:58 +02:00
|
|
|
->setPolicyObject($project)
|
2012-09-13 19:15:08 +02:00
|
|
|
->setPolicies($policies)
|
2012-08-15 19:44:58 +02:00
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_VIEW))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormPolicyControl())
|
|
|
|
->setUser($user)
|
|
|
|
->setName('can_edit')
|
|
|
|
->setPolicyObject($project)
|
2012-09-13 19:15:08 +02:00
|
|
|
->setPolicies($policies)
|
2012-08-15 19:44:58 +02:00
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_EDIT))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormPolicyControl())
|
|
|
|
->setUser($user)
|
|
|
|
->setName('can_join')
|
|
|
|
->setCaption(
|
2013-02-13 18:22:14 +01:00
|
|
|
pht('Users who can edit a project can always join a project.'))
|
2012-08-15 19:44:58 +02:00
|
|
|
->setPolicyObject($project)
|
2012-09-13 19:15:08 +02:00
|
|
|
->setPolicies($policies)
|
2012-08-15 19:44:58 +02:00
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_JOIN))
|
2011-06-18 10:13:56 +02:00
|
|
|
->appendChild(
|
2012-06-26 17:14:15 +02:00
|
|
|
id(new AphrontFormMarkupControl())
|
2013-02-13 18:22:14 +01:00
|
|
|
->setLabel(pht('Profile Image'))
|
2012-06-26 17:14:15 +02:00
|
|
|
->setValue(
|
2013-01-18 03:39:02 +01:00
|
|
|
phutil_tag(
|
2012-06-26 17:14:15 +02:00
|
|
|
'img',
|
|
|
|
array(
|
|
|
|
'src' => $img_src,
|
|
|
|
))))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormImageControl())
|
2013-02-13 18:22:14 +01:00
|
|
|
->setLabel(pht('Change Image'))
|
2012-03-14 20:41:33 +01:00
|
|
|
->setName('image')
|
|
|
|
->setError($e_image)
|
2013-02-13 18:22:14 +01:00
|
|
|
->setCaption(
|
|
|
|
pht('Supported formats:').' '.implode(', ', $supported_formats)))
|
2011-02-21 03:41:23 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2011-06-18 10:13:56 +02:00
|
|
|
->addCancelButton('/project/view/'.$project->getID().'/')
|
2013-02-13 18:22:14 +01:00
|
|
|
->setValue(pht('Save')));
|
2011-02-21 03:41:23 +01:00
|
|
|
|
2012-08-07 20:57:38 +02:00
|
|
|
$nav = $this->buildLocalNavigation($project);
|
|
|
|
$nav->selectFilter('edit');
|
|
|
|
$nav->appendChild(
|
2011-02-21 03:41:23 +01:00
|
|
|
array(
|
|
|
|
$error_view,
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
$form,
|
2012-08-07 20:57:38 +02:00
|
|
|
));
|
|
|
|
|
2013-02-13 18:22:14 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName($project->getName())
|
2013-02-19 22:33:10 +01:00
|
|
|
->setHref('/project/view/'.$project->getID().'/'));
|
2013-02-13 18:22:14 +01:00
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName(pht('Edit Project'))
|
2013-02-19 22:33:10 +01:00
|
|
|
->setHref($this->getApplicationURI()));
|
2013-02-13 18:22:14 +01:00
|
|
|
$nav->setCrumbs($crumbs);
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
2012-08-07 20:57:38 +02:00
|
|
|
$nav,
|
2011-02-21 03:41:23 +01:00
|
|
|
array(
|
|
|
|
'title' => $title,
|
2013-02-13 18:22:14 +01:00
|
|
|
'device' => true,
|
2013-05-22 01:13:34 +02:00
|
|
|
'dust' => true,
|
2011-02-21 03:41:23 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|