Page MenuHomestyx hydra

No OneTemporary

diff --git a/resources/sql/patches/048.relationshipkeys.sql b/resources/sql/patches/048.relationshipkeys.sql
new file mode 100644
index 0000000000..85cf1bd869
--- /dev/null
+++ b/resources/sql/patches/048.relationshipkeys.sql
@@ -0,0 +1,2 @@
+ALTER TABLE search_documentrelationship add key (relatedPHID, relation);
+ALTER TABLE search_documentrelationship add key (relation, relatedPHID);
diff --git a/src/applications/project/controller/list/PhabricatorProjectListController.php b/src/applications/project/controller/list/PhabricatorProjectListController.php
index 0243bae9cf..852e5868c7 100644
--- a/src/applications/project/controller/list/PhabricatorProjectListController.php
+++ b/src/applications/project/controller/list/PhabricatorProjectListController.php
@@ -1,130 +1,146 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProjectListController
extends PhabricatorProjectController {
public function processRequest() {
$projects = id(new PhabricatorProject())->loadAllWhere(
'1 = 1 ORDER BY id DESC limit 100');
+ $project_phids = mpull($projects, 'getPHID');
+
+ $profiles = array();
+ if ($projects) {
+ $profiles = id(new PhabricatorProjectProfile())->loadAllWhere(
+ 'projectPHID in (%Ls)',
+ $project_phids);
+ $profiles = mpull($profiles, null, 'getProjectPHID');
+ }
+
+ $affil_groups = array();
+ if ($projects) {
+ $affil_groups = PhabricatorProjectAffiliation::loadAllForProjectPHIDs(
+ $project_phids);
+ }
$author_phids = mpull($projects, 'getAuthorPHID');
$handles = id(new PhabricatorObjectHandleData($author_phids))
->loadHandles();
$rows = array();
foreach ($projects as $project) {
+ $profile = $profiles[$project->getPHID()];
+ $affiliations = $affil_groups[$project->getPHID()];
+
$documents = new PhabricatorProjectTransactionSearch($project->getPHID());
// search all open documents by default
$documents->setSearchOptions();
$documents = $documents->executeSearch();
- $documents_types = igroup($documents,'documentType');
+ $documents_types = igroup($documents, 'documentType');
$tasks = idx(
$documents_types,
PhabricatorPHIDConstants::PHID_TYPE_TASK);
$tasks_amount = count($tasks);
// TODO: set up a relationship between the project and the arcanist's
// project, to be able get the revisions.
$revisions = idx(
$documents_types,
PhabricatorPHIDConstants::PHID_TYPE_DREV);
$revisions_amount = count($revisions);
- $profile = $project->getProfile();
- $affiliations = $project->loadAffiliations();
$population = count($affiliations);
$status = PhabricatorProjectStatus::getNameForStatus(
$project->getStatus());
$blurb = nonempty(
$profile->getBlurb(),
'Oops!, nothing is known about this elusive project.');
$blurb = $this->textWrap($blurb, $columns = 100);
$rows[] = array(
phutil_escape_html($project->getName()),
phutil_escape_html($blurb),
$handles[$project->getAuthorPHID()]->renderLink(),
phutil_escape_html($population),
phutil_escape_html($status),
phutil_escape_html($tasks_amount),
// phutil_escape_html($revisions_amount),
phutil_render_tag(
'a',
array(
'class' => 'small grey button',
'href' => '/project/view/'.$project->getID().'/',
),
'View Project Profile'),
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Project',
'Blurb',
'Mastermind',
'Population',
'Status',
'Open Tasks',
// 'Open Revisions',
'',
));
$table->setColumnClasses(
array(
'pri',
'wide',
'',
'right',
'pri',
'right',
// 'right',
'action',
));
$panel = new AphrontPanelView();
$panel->appendChild($table);
$panel->setHeader('Project');
$panel->setCreateButton('Create New Project', '/project/edit/');
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Projects',
));
}
private function textWrap($text, $length) {
if (strlen($text) <= $length) {
return $text;
} else {
// TODO: perhaps this could be improved, adding the ability to get the
// last letter and suppress it, if it is one of [(,:; ,etc.
// making "blurb" looks a little bit better. :)
$wrapped = wordwrap($text, $length, '__#END#__');
$end_position = strpos($wrapped, '__#END#__');
$wrapped = substr($text, 0, $end_position).'...';
return $wrapped;
}
}
}
diff --git a/src/applications/project/controller/list/__init__.php b/src/applications/project/controller/list/__init__.php
index 72b8bf175b..c7ff3c35e3 100644
--- a/src/applications/project/controller/list/__init__.php
+++ b/src/applications/project/controller/list/__init__.php
@@ -1,22 +1,24 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/project/constants/status');
phutil_require_module('phabricator', 'applications/project/controller/base');
+phutil_require_module('phabricator', 'applications/project/storage/affiliation');
+phutil_require_module('phabricator', 'applications/project/storage/profile');
phutil_require_module('phabricator', 'applications/project/storage/project');
phutil_require_module('phabricator', 'applications/project/transactions/search');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorProjectListController.php');
diff --git a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php
index ace47f9f27..e2e5ed65ac 100644
--- a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php
+++ b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php
@@ -1,187 +1,187 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProjectProfileController
extends PhabricatorProjectController {
private $id;
private $page;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
$this->page = idx($data, 'page');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$uri = $request->getRequestURI();
$project = id(new PhabricatorProject())->load($this->id);
if (!$project) {
return new Aphront404Response();
}
- $profile = $project->getProfile();
+ $profile = $project->loadProfile();
if (!$profile) {
$profile = new PhabricatorProjectProfile();
}
$src_phid = $profile->getProfileImagePHID();
if (!$src_phid) {
$src_phid = $user->getProfileImagePHID();
}
$picture = PhabricatorFileURI::getViewURIForPHID($src_phid);
$pages = array(
/*
'<h2>Active Documents</h2>',
'tasks' => 'Maniphest Tasks',
'revisions' => 'Differential Revisions',
'<hr />',
'<h2>Workflow</h2>',
'goals' => 'Goals',
'statistics' => 'Statistics',
'<hr />', */
'<h2>Information</h2>',
'edit' => 'Edit Profile',
'affiliation' => 'Edit Affiliation',
);
if (empty($pages[$this->page])) {
$this->page = 'action'; // key($pages);
}
switch ($this->page) {
default:
$content = $this->renderBasicInformation($project, $profile);
break;
}
$profile = new PhabricatorProfileView();
$profile->setProfilePicture($picture);
$profile->setProfileNames($project->getName());
foreach ($pages as $page => $name) {
if (is_integer($page)) {
$profile->addProfileItem(
phutil_render_tag(
'span',
array(),
$name));
} else {
$uri->setPath('/project/'.$page.'/'.$project->getID().'/');
$profile->addProfileItem(
phutil_render_tag(
'a',
array(
'href' => $uri,
'class' => ($this->page == $page)
? 'phabricator-profile-item-selected'
: null,
),
phutil_escape_html($name)));
}
}
$profile->appendChild($content);
return $this->buildStandardPageResponse(
$profile,
array(
'title' => $project->getName(),
));
}
private function renderBasicInformation($project, $profile) {
$blurb = nonempty(
$profile->getBlurb(),
'//Nothing is known about this elusive project.//');
$factory = new DifferentialMarkupEngineFactory();
$engine = $factory->newDifferentialCommentMarkupEngine();
$blurb = $engine->markupText($blurb);
$affiliations = $project->loadAffiliations();
$phids = array_merge(
array($project->getAuthorPHID()),
mpull($affiliations, 'getUserPHID'));
$handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles();
$affiliated = array();
foreach ($affiliations as $affiliation) {
$user = $handles[$affiliation->getUserPHID()]->renderLink();
$role = phutil_escape_html($affiliation->getRole());
$status = null;
if ($affiliation->getStatus() == 'former') {
$role = '<em>Former '.$role.'</em>';
}
$affiliated[] = '<li>'.$user.' &mdash; '.$role.$status.'</li>';
}
if ($affiliated) {
$affiliated = '<ul>'.implode("\n", $affiliated).'</ul>';
} else {
$affiliated = '<p><em>No one is affiliated with this project.</em></p>';
}
$timestamp = phabricator_format_timestamp($project->getDateCreated());
$status = PhabricatorProjectStatus::getNameForStatus(
$project->getStatus());
$content =
'<div class="phabricator-profile-info-group">
<h1 class="phabricator-profile-info-header">Basic Information</h1>
<div class="phabricator-profile-info-pane">
<table class="phabricator-profile-info-table">
<tr>
<th>Creator</th>
<td>'.$handles[$project->getAuthorPHID()]->renderLink().'</td>
</tr>
<tr>
<th>Status</th>
<td><strong>'.phutil_escape_html($status).'</strong></td>
</tr>
<tr>
<th>Created</th>
<td>'.$timestamp.'</td>
</tr>
<tr>
<th>PHID</th>
<td>'.phutil_escape_html($project->getPHID()).'</td>
</tr>
<tr>
<th>Blurb</th>
<td>'.$blurb.'</td>
</tr>
</table>
</div>
</div>';
$content .=
'<div class="phabricator-profile-info-group">
<h1 class="phabricator-profile-info-header">Resources</h1>
<div class="phabricator-profile-info-pane">'.
$affiliated.
'</div>
</div>';
return $content;
}
}
diff --git a/src/applications/project/storage/affiliation/PhabricatorProjectAffiliation.php b/src/applications/project/storage/affiliation/PhabricatorProjectAffiliation.php
index b53d073ccf..23c73254a8 100644
--- a/src/applications/project/storage/affiliation/PhabricatorProjectAffiliation.php
+++ b/src/applications/project/storage/affiliation/PhabricatorProjectAffiliation.php
@@ -1,26 +1,39 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProjectAffiliation extends PhabricatorProjectDAO {
protected $projectPHID;
protected $userPHID;
protected $role;
protected $status;
+ public static function loadAllForProjectPHIDs($phids) {
+ if (!$phids) {
+ return array();
+ }
+ $default = array_fill_keys($phids, array());
+
+ $affiliations = id(new PhabricatorProjectAffiliation())->loadAllWhere(
+ 'projectPHID IN (%Ls) ORDER BY IF(status = "former", 1, 0), dateCreated',
+ $phids);
+
+ return mgroup($affiliations, 'getProjectPHID') + $default;
+ }
+
}
diff --git a/src/applications/project/storage/affiliation/__init__.php b/src/applications/project/storage/affiliation/__init__.php
index f6cf277138..0c83cc12fb 100644
--- a/src/applications/project/storage/affiliation/__init__.php
+++ b/src/applications/project/storage/affiliation/__init__.php
@@ -1,12 +1,14 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/project/storage/base');
+phutil_require_module('phutil', 'utils');
+
phutil_require_source('PhabricatorProjectAffiliation.php');
diff --git a/src/applications/project/storage/project/PhabricatorProject.php b/src/applications/project/storage/project/PhabricatorProject.php
index b8cd85ec28..d9da01e716 100644
--- a/src/applications/project/storage/project/PhabricatorProject.php
+++ b/src/applications/project/storage/project/PhabricatorProject.php
@@ -1,50 +1,49 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProject extends PhabricatorProjectDAO {
protected $name;
protected $phid;
protected $status = PhabricatorProjectStatus::UNKNOWN;
protected $authorPHID;
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_PROJ);
}
- public function getProfile() {
+ public function loadProfile() {
$profile = id(new PhabricatorProjectProfile())->loadOneWhere(
'projectPHID = %s',
$this->getPHID());
return $profile;
}
public function loadAffiliations() {
- $affiliations = id(new PhabricatorProjectAffiliation())->loadAllWhere(
- 'projectPHID = %s ORDER BY IF(status = "former", 1, 0), dateCreated',
- $this->getPHID());
- return $affiliations;
+ $affils = PhabricatorProjectAffiliation::loadAllForProjectPHIDs(
+ array($this->getPHID()));
+ return $affils[$this->getPHID()];
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Apr 28, 10:32 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
107926
Default Alt Text
(16 KB)

Event Timeline