mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 03:02:43 +01:00
330b0a3d4b
Summary: We managed to move enough Owners stuff aside to make this reasonable; make projects implement the policy interface and projectquery use cursor-based paging. Test Plan: - Grepped for ProjectQuery callsites. - Created an audit comment. - Used `project.query` to query projects. - Loaded homepage. - Viewed Maniphest task list, grouped by project. - Viewed project list. - Created / edited project. - Browsed Owners. Reviewers: vrana, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D3200
101 lines
2.7 KiB
PHP
101 lines
2.7 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright 2012 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.
|
|
*/
|
|
|
|
final class PhabricatorProject extends PhabricatorProjectDAO
|
|
implements PhabricatorPolicyInterface {
|
|
|
|
protected $name;
|
|
protected $phid;
|
|
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
|
protected $authorPHID;
|
|
protected $subprojectPHIDs = array();
|
|
protected $phrictionSlug;
|
|
|
|
private $subprojectsNeedUpdate;
|
|
private $memberPHIDs;
|
|
|
|
public function getCapabilities() {
|
|
return array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
);
|
|
}
|
|
|
|
public function getPolicy($capability) {
|
|
return PhabricatorPolicies::POLICY_USER;
|
|
}
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
return false;
|
|
}
|
|
|
|
public function getConfiguration() {
|
|
return array(
|
|
self::CONFIG_AUX_PHID => true,
|
|
self::CONFIG_SERIALIZATION => array(
|
|
'subprojectPHIDs' => self::SERIALIZATION_JSON,
|
|
),
|
|
) + parent::getConfiguration();
|
|
}
|
|
|
|
public function generatePHID() {
|
|
return PhabricatorPHID::generateNewPHID(
|
|
PhabricatorPHIDConstants::PHID_TYPE_PROJ);
|
|
}
|
|
|
|
public function loadProfile() {
|
|
$profile = id(new PhabricatorProjectProfile())->loadOneWhere(
|
|
'projectPHID = %s',
|
|
$this->getPHID());
|
|
return $profile;
|
|
}
|
|
|
|
public function attachMemberPHIDs(array $phids) {
|
|
$this->memberPHIDs = $phids;
|
|
return $this;
|
|
}
|
|
|
|
public function getMemberPHIDs() {
|
|
if ($this->memberPHIDs === null) {
|
|
throw new Exception("Call attachMemberPHIDs() first!");
|
|
}
|
|
return $this->memberPHIDs;
|
|
}
|
|
|
|
public function loadMemberPHIDs() {
|
|
if (!$this->getPHID()) {
|
|
return array();
|
|
}
|
|
return PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
$this->getPHID(),
|
|
PhabricatorEdgeConfig::TYPE_PROJ_MEMBER);
|
|
}
|
|
|
|
public function setPhrictionSlug($slug) {
|
|
|
|
// NOTE: We're doing a little magic here and stripping out '/' so that
|
|
// project pages always appear at top level under projects/ even if the
|
|
// display name is "Hack / Slash" or similar (it will become
|
|
// 'hack_slash' instead of 'hack/slash').
|
|
|
|
$slug = str_replace('/', ' ', $slug);
|
|
$slug = PhabricatorSlug::normalize($slug);
|
|
$this->phrictionSlug = $slug;
|
|
return $this;
|
|
}
|
|
|
|
}
|