本文整理汇总了PHP中ManiphestTask类的典型用法代码示例。如果您正苦于以下问题:PHP ManiphestTask类的具体用法?PHP ManiphestTask怎么用?PHP ManiphestTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ManiphestTask类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: performMerge
private function performMerge(ManiphestTask $task, PhabricatorObjectHandle $handle, array $phids)
{
$user = $this->getRequest()->getUser();
$response = id(new AphrontReloadResponse())->setURI($handle->getURI());
$phids = array_fill_keys($phids, true);
unset($phids[$task->getPHID()]);
// Prevent merging a task into itself.
if (!$phids) {
return $response;
}
$targets = id(new ManiphestTaskQuery())->setViewer($user)->withPHIDs(array_keys($phids))->execute();
if (empty($targets)) {
return $response;
}
$editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($this->getRequest())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
$cc_vector = array();
$cc_vector[] = $task->getCCPHIDs();
foreach ($targets as $target) {
$cc_vector[] = $target->getCCPHIDs();
$cc_vector[] = array($target->getAuthorPHID(), $target->getOwnerPHID());
$merged_into_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_INTO)->setNewValue($task->getPHID());
$editor->applyTransactions($target, array($merged_into_txn));
}
$all_ccs = array_mergev($cc_vector);
$all_ccs = array_filter($all_ccs);
$all_ccs = array_unique($all_ccs);
$add_ccs = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_CCS)->setNewValue($all_ccs);
$merged_from_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_FROM)->setNewValue(mpull($targets, 'getPHID'));
$editor->applyTransactions($task, array($add_ccs, $merged_from_txn));
return $response;
}
开发者ID:denghp,项目名称:phabricator,代码行数:31,代码来源:PhabricatorSearchAttachController.php
示例2: getPriorityTransactions
private function getPriorityTransactions(ManiphestTask $task, $after_phid, $before_phid)
{
list($after_task, $before_task) = $this->loadPriorityTasks($after_phid, $before_phid);
$must_move = false;
if ($after_task && !$task->isLowerPriorityThan($after_task)) {
$must_move = true;
}
if ($before_task && !$task->isHigherPriorityThan($before_task)) {
$must_move = true;
}
// The move doesn't require a priority change to be valid, so don't
// change the priority since we are not being forced to.
if (!$must_move) {
return array();
}
$try = array(array($after_task, true), array($before_task, false));
$pri = null;
$sub = null;
foreach ($try as $spec) {
list($task, $is_after) = $spec;
if (!$task) {
continue;
}
list($pri, $sub) = ManiphestTransactionEditor::getAdjacentSubpriority($task, $is_after);
}
$xactions = array();
if ($pri !== null) {
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)->setNewValue($pri);
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_SUBPRIORITY)->setNewValue($sub);
}
return $xactions;
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:32,代码来源:PhabricatorProjectMoveController.php
示例3: execute
protected function execute(ConduitAPIRequest $request)
{
$task = new ManiphestTask();
$task->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
$task->setAuthorPHID($request->getUser()->getPHID());
$this->applyRequest($task, $request, $is_new = true);
return $this->buildTaskInfoDictionary($task);
}
开发者ID:netcomtec,项目名称:phabricator,代码行数:8,代码来源:ConduitAPI_maniphest_createtask_Method.php
示例4: processRequest
public function processRequest()
{
$request = $this->getRequest();
$description = $request->getStr('description');
$task = new ManiphestTask();
$task->setDescription($description);
$output = PhabricatorMarkupEngine::renderOneObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION, $request->getUser());
$content = phutil_tag_div('phabricator-remarkup', $output);
return id(new AphrontAjaxResponse())->setContent($content);
}
开发者ID:denghp,项目名称:phabricator,代码行数:10,代码来源:ManiphestTaskDescriptionPreviewController.php
示例5: processRequest
public function processRequest()
{
$request = $this->getRequest();
$description = $request->getStr('description');
$task = new ManiphestTask();
$task->setDescription($description);
$output = PhabricatorMarkupEngine::renderOneObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION);
$content = '<div class="phabricator-remarkup">' . $output . '</div>';
return id(new AphrontAjaxResponse())->setContent($content);
}
开发者ID:nexeck,项目名称:phabricator,代码行数:10,代码来源:ManiphestTaskDescriptionPreviewController.php
示例6: renderSingleTask
protected function renderSingleTask(ManiphestTask $task)
{
$request = $this->getRequest();
$user = $request->getUser();
$phids = $task->getProjectPHIDs();
if ($task->getOwnerPHID()) {
$phids[] = $task->getOwnerPHID();
}
$handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs($phids)->execute();
$view = id(new ManiphestTaskListView())->setUser($user)->setShowSubpriorityControls(!$request->getStr('ungrippable'))->setShowBatchControls(true)->setHandles($handles)->setTasks(array($task));
return $view;
}
开发者ID:miaokuan,项目名称:phabricator,代码行数:12,代码来源:ManiphestController.php
示例7: updateTaskProjects
public static function updateTaskProjects(ManiphestTask $task)
{
$dao = new ManiphestTaskProject();
$conn = $dao->establishConnection('w');
$sql = array();
foreach ($task->getProjectPHIDs() as $project_phid) {
$sql[] = qsprintf($conn, '(%s, %s)', $task->getPHID(), $project_phid);
}
queryfx($conn, 'DELETE FROM %T WHERE taskPHID = %s', $dao->getTableName(), $task->getPHID());
if ($sql) {
queryfx($conn, 'INSERT INTO %T (taskPHID, projectPHID) VALUES %Q', $dao->getTableName(), implode(', ', $sql));
}
}
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:13,代码来源:ManiphestTaskProject.php
示例8: testFileVisibility
public function testFileVisibility()
{
$engine = new PhabricatorTestStorageEngine();
$data = Filesystem::readRandomCharacters(64);
$author = $this->generateNewTestUser();
$viewer = $this->generateNewTestUser();
$users = array($author, $viewer);
$params = array('name' => 'test.dat', 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'authorPHID' => $author->getPHID(), 'storageEngines' => array($engine));
$file = PhabricatorFile::newFromFileData($data, $params);
$filter = new PhabricatorPolicyFilter();
// Test bare file policies.
$this->assertEqual(array(true, false), $this->canViewFile($users, $file), pht('File Visibility'));
// Create an object and test object policies.
$object = ManiphestTask::initializeNewTask($author);
$object->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy());
$object->save();
$this->assertTrue($filter->hasCapability($author, $object, PhabricatorPolicyCapability::CAN_VIEW), pht('Object Visible to Author'));
$this->assertTrue($filter->hasCapability($viewer, $object, PhabricatorPolicyCapability::CAN_VIEW), pht('Object Visible to Others'));
// Attach the file to the object and test that the association opens a
// policy exception for the non-author viewer.
$file->attachToObject($object->getPHID());
// Test the attached file's visibility.
$this->assertEqual(array(true, true), $this->canViewFile($users, $file), pht('Attached File Visibility'));
// Create a "thumbnail" of the original file.
$params = array('name' => 'test.thumb.dat', 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'storageEngines' => array($engine));
$xform = PhabricatorFile::newFromFileData($data, $params);
id(new PhabricatorTransformedFile())->setOriginalPHID($file->getPHID())->setTransform('test-thumb')->setTransformedPHID($xform->getPHID())->save();
// Test the thumbnail's visibility.
$this->assertEqual(array(true, true), $this->canViewFile($users, $xform), pht('Attached Thumbnail Visibility'));
// Detach the object and make sure it affects the thumbnail.
$file->detachFromObject($object->getPHID());
// Test the detached thumbnail's visibility.
$this->assertEqual(array(true, false), $this->canViewFile($users, $xform), pht('Detached Thumbnail Visibility'));
}
开发者ID:hrb518,项目名称:phabricator,代码行数:34,代码来源:PhabricatorFileTestCase.php
示例9: updateTaskSubscribers
public static function updateTaskSubscribers(ManiphestTask $task)
{
$dao = new ManiphestTaskSubscriber();
$conn = $dao->establishConnection('w');
$sql = array();
$subscribers = $task->getCCPHIDs();
$subscribers[] = $task->getOwnerPHID();
$subscribers = array_unique($subscribers);
foreach ($subscribers as $subscriber_phid) {
$sql[] = qsprintf($conn, '(%s, %s)', $task->getPHID(), $subscriber_phid);
}
queryfx($conn, 'DELETE FROM %T WHERE taskPHID = %s', $dao->getTableName(), $task->getPHID());
if ($sql) {
queryfx($conn, 'INSERT INTO %T (taskPHID, subscriberPHID) VALUES %Q', $dao->getTableName(), implode(', ', $sql));
}
}
开发者ID:denghp,项目名称:phabricator,代码行数:16,代码来源:ManiphestTaskSubscriber.php
示例10: generateObject
public function generateObject()
{
$author_phid = $this->loadPhabrictorUserPHID();
$author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $author_phid);
$task = ManiphestTask::initializeNewTask($author)->setSubPriority($this->generateTaskSubPriority())->setTitle($this->generateTitle());
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_UNKNOWN, array());
$template = new ManiphestTransaction();
// Accumulate Transactions
$changes = array();
$changes[ManiphestTransaction::TYPE_TITLE] = $this->generateTitle();
$changes[ManiphestTransaction::TYPE_DESCRIPTION] = $this->generateDescription();
$changes[ManiphestTransaction::TYPE_OWNER] = $this->loadOwnerPHID();
$changes[ManiphestTransaction::TYPE_STATUS] = $this->generateTaskStatus();
$changes[ManiphestTransaction::TYPE_PRIORITY] = $this->generateTaskPriority();
$changes[PhabricatorTransactions::TYPE_SUBSCRIBERS] = array('=' => $this->getCCPHIDs());
$transactions = array();
foreach ($changes as $type => $value) {
$transaction = clone $template;
$transaction->setTransactionType($type);
$transaction->setNewValue($value);
$transactions[] = $transaction;
}
$transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($this->getProjectPHIDs())));
// Apply Transactions
$editor = id(new ManiphestTransactionEditor())->setActor($author)->setContentSource($content_source)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($task, $transactions);
return $task;
}
开发者ID:truSense,项目名称:phabricator,代码行数:27,代码来源:PhabricatorManiphestTaskTestDataGenerator.php
示例11: performMerge
private function performMerge(ManiphestTask $task, PhabricatorObjectHandle $handle, array $phids)
{
$user = $this->getRequest()->getUser();
$response = id(new AphrontReloadResponse())->setURI($handle->getURI());
$phids = array_fill_keys($phids, true);
unset($phids[$task->getPHID()]);
// Prevent merging a task into itself.
if (!$phids) {
return $response;
}
$targets = id(new ManiphestTaskQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withPHIDs(array_keys($phids))->needSubscriberPHIDs(true)->needProjectPHIDs(true)->execute();
if (empty($targets)) {
return $response;
}
$editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($this->getRequest())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
$cc_vector = array();
// since we loaded this via a generic object query, go ahead and get the
// attach the subscriber and project phids now
$task->attachSubscriberPHIDs(PhabricatorSubscribersQuery::loadSubscribersForPHID($task->getPHID()));
$task->attachProjectPHIDs(PhabricatorEdgeQuery::loadDestinationPHIDs($task->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST));
$cc_vector[] = $task->getSubscriberPHIDs();
foreach ($targets as $target) {
$cc_vector[] = $target->getSubscriberPHIDs();
$cc_vector[] = array($target->getAuthorPHID(), $target->getOwnerPHID());
$merged_into_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_INTO)->setNewValue($task->getPHID());
$editor->applyTransactions($target, array($merged_into_txn));
}
$all_ccs = array_mergev($cc_vector);
$all_ccs = array_filter($all_ccs);
$all_ccs = array_unique($all_ccs);
$add_ccs = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('=' => $all_ccs));
$merged_from_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_FROM)->setNewValue(mpull($targets, 'getPHID'));
$editor->applyTransactions($task, array($add_ccs, $merged_from_txn));
return $response;
}
开发者ID:barcelonascience,项目名称:phabricator,代码行数:35,代码来源:PhabricatorSearchAttachController.php
示例12: processReceivedMail
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender)
{
$task = ManiphestTask::initializeNewTask($sender);
$task->setOriginalEmailSource($mail->getHeader('From'));
$handler = PhabricatorEnv::newObjectFromConfig('metamta.maniphest.reply-handler');
$handler->setMailReceiver($task);
$handler->setActor($sender);
$handler->setExcludeMailRecipientPHIDs($mail->loadExcludeMailRecipientPHIDs());
$handler->processEmail($mail);
$mail->setRelatedPHID($task->getPHID());
}
开发者ID:denghp,项目名称:phabricator,代码行数:11,代码来源:ManiphestCreateMailReceiver.php
示例13: processReceivedMail
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender)
{
$task = ManiphestTask::initializeNewTask($sender);
$task->setOriginalEmailSource($mail->getHeader('From'));
$handler = new ManiphestReplyHandler();
$handler->setMailReceiver($task);
$handler->setActor($sender);
$handler->setExcludeMailRecipientPHIDs($mail->loadAllRecipientPHIDs());
if ($this->getApplicationEmail()) {
$handler->setApplicationEmail($this->getApplicationEmail());
}
$handler->processEmail($mail);
$mail->setRelatedPHID($task->getPHID());
}
开发者ID:pugong,项目名称:phabricator,代码行数:14,代码来源:ManiphestCreateMailReceiver.php
示例14: performMerge
private function performMerge(ManiphestTask $task, PhabricatorObjectHandle $handle, array $phids)
{
$user = $this->getRequest()->getUser();
$response = id(new AphrontReloadResponse())->setURI($handle->getURI());
$phids = array_fill_keys($phids, true);
unset($phids[$task->getPHID()]);
// Prevent merging a task into itself.
if (!$phids) {
return $response;
}
$targets = id(new ManiphestTaskQuery())->setViewer($user)->withPHIDs(array_keys($phids))->execute();
if (empty($targets)) {
return $response;
}
$editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($this->getRequest())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
$task_names = array();
$merge_into_name = 'T' . $task->getID();
$cc_vector = array();
$cc_vector[] = $task->getCCPHIDs();
foreach ($targets as $target) {
$cc_vector[] = $target->getCCPHIDs();
$cc_vector[] = array($target->getAuthorPHID(), $target->getOwnerPHID());
$close_task = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_STATUS)->setNewValue(ManiphestTaskStatus::getDuplicateStatus());
$merge_comment = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new ManiphestTransactionComment())->setContent("✘ Merged into {$merge_into_name}."));
$editor->applyTransactions($target, array($close_task, $merge_comment));
$task_names[] = 'T' . $target->getID();
}
$all_ccs = array_mergev($cc_vector);
$all_ccs = array_filter($all_ccs);
$all_ccs = array_unique($all_ccs);
$task_names = implode(', ', $task_names);
$add_ccs = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_CCS)->setNewValue($all_ccs);
$merged_comment = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new ManiphestTransactionComment())->setContent("◀ Merged tasks: {$task_names}."));
$editor->applyTransactions($task, array($add_ccs, $merged_comment));
return $response;
}
开发者ID:sethkontny,项目名称:phabricator,代码行数:36,代码来源:PhabricatorSearchAttachController.php
示例15: testCustomPolicyRuleLunarPhase
public function testCustomPolicyRuleLunarPhase()
{
$user_a = $this->generateNewTestUser();
$author = $this->generateNewTestUser();
$policy = id(new PhabricatorPolicy())->setRules(array(array('action' => PhabricatorPolicy::ACTION_ALLOW, 'rule' => 'PhabricatorPolicyRuleLunarPhase', 'value' => 'new')))->save();
$task = ManiphestTask::initializeNewTask($author);
$task->setViewPolicy($policy->getPHID());
$task->save();
$time_a = PhabricatorTime::pushTime(934354800, 'UTC');
$can_a_view = PhabricatorPolicyFilter::hasCapability($user_a, $task, PhabricatorPolicyCapability::CAN_VIEW);
$this->assertTrue($can_a_view);
unset($time_a);
$time_b = PhabricatorTime::pushTime(1116745200, 'UTC');
$can_a_view = PhabricatorPolicyFilter::hasCapability($user_a, $task, PhabricatorPolicyCapability::CAN_VIEW);
$this->assertFalse($can_a_view);
unset($time_b);
}
开发者ID:denghp,项目名称:phabricator,代码行数:17,代码来源:PhabricatorPolicyDataTestCase.php
示例16: addTask
function addTask($kan_task, $project_id)
{
$user = getAdmin();
$task = ManiphestTask::initializeNewTask($user);
$changes = array();
$transactions = array();
$changes[ManiphestTransaction::TYPE_TITLE] = $kan_task['title'];
$changes[ManiphestTransaction::TYPE_DESCRIPTION] = $kan_task['description'];
$changes[ManiphestTransaction::TYPE_STATUS] = ManiphestTaskStatus::getDefaultStatus();
$changes[PhabricatorTransactions::TYPE_COMMENT] = null;
$project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
$transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $project_type)->setNewValue(array('=' => array_fuse(array($project_id))));
$template = new ManiphestTransaction();
foreach ($changes as $type => $value) {
$transaction = clone $template;
$transaction->setTransactionType($type);
$transaction->setNewValue($value);
$transactions[] = $transaction;
}
$editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromConduitRequest(new ConduitAPIRequest(array()))->setContinueOnNoEffect(true);
$editor->applyTransactions($task, $transactions);
}
开发者ID:Wenzel,项目名称:kde-phabricator-import,代码行数:22,代码来源:test.php
示例17: execute
protected function execute(ConduitAPIRequest $request)
{
$task = new ManiphestTask();
$task->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
$task->setAuthorPHID($request->getUser()->getPHID());
$task->setTitle((string) $request->getValue('title'));
$task->setDescription((string) $request->getValue('description'));
$changes = array();
$changes[ManiphestTransactionType::TYPE_STATUS] = ManiphestTaskStatus::STATUS_OPEN;
$priority = $request->getValue('priority');
if ($priority !== null) {
$changes[ManiphestTransactionType::TYPE_PRIORITY] = $priority;
}
$owner_phid = $request->getValue('ownerPHID');
if ($owner_phid !== null) {
$changes[ManiphestTransactionType::TYPE_OWNER] = $owner_phid;
}
$ccs = $request->getValue('ccPHIDs');
if ($ccs !== null) {
$changes[ManiphestTransactionType::TYPE_CCS] = $ccs;
}
$project_phids = $request->getValue('projectPHIDs');
if ($project_phids !== null) {
$changes[ManiphestTransactionType::TYPE_PROJECTS] = $project_phids;
}
$file_phids = $request->getValue('filePHIDs');
if ($file_phids !== null) {
$file_map = array_fill_keys($file_phids, true);
$changes[ManiphestTransactionType::TYPE_ATTACH] = array(PhabricatorPHIDConstants::PHID_TYPE_FILE => $file_map);
}
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONDUIT, array());
$template = new ManiphestTransaction();
$template->setContentSource($content_source);
$template->setAuthorPHID($request->getUser()->getPHID());
$transactions = array();
foreach ($changes as $type => $value) {
$transaction = clone $template;
$transaction->setTransactionType($type);
$transaction->setNewValue($value);
$transactions[] = $transaction;
}
$editor = new ManiphestTransactionEditor();
$editor->applyTransactions($task, $transactions);
return $this->buildTaskInfoDictionary($task);
}
开发者ID:hwang36,项目名称:phabricator,代码行数:45,代码来源:ConduitAPI_maniphest_createtask_Method.php
示例18: execute
public function execute()
{
$task_dao = new ManiphestTask();
$conn = $task_dao->establishConnection('r');
if ($this->calculateRows) {
$calc = 'SQL_CALC_FOUND_ROWS';
} else {
$calc = '';
}
$where = array();
$where[] = $this->buildTaskIDsWhereClause($conn);
$where[] = $this->buildStatusWhereClause($conn);
$where[] = $this->buildPriorityWhereClause($conn);
$where[] = $this->buildAuthorWhereClause($conn);
$where[] = $this->buildOwnerWhereClause($conn);
$where[] = $this->buildSubscriberWhereClause($conn);
$where[] = $this->buildProjectWhereClause($conn);
$where[] = $this->buildXProjectWhereClause($conn);
$where[] = $this->buildFullTextWhereClause($conn);
$where = array_filter($where);
if ($where) {
$where = 'WHERE (' . implode(') AND (', $where) . ')';
} else {
$where = '';
}
$join = array();
$join[] = $this->buildProjectJoinClause($conn);
$join[] = $this->buildXProjectJoinClause($conn);
$join[] = $this->buildSubscriberJoinClause($conn);
$join = array_filter($join);
if ($join) {
$join = implode(' ', $join);
} else {
$join = '';
}
$having = '';
$count = '';
$group = '';
if (count($this->projectPHIDs) > 1) {
// If we're searching for more than one project:
// - We'll get multiple rows for tasks when they join the project table
// multiple times. We use GROUP BY to make them distinct again.
// - We want to treat the query as an intersection query, not a union
// query. We sum the project count and require it be the same as the
// number of projects we're searching for. (If 'anyProject' is set,
// we do union instead.)
$group = 'GROUP BY task.id';
if (!$this->anyProject) {
$count = ', COUNT(project.projectPHID) projectCount';
$having = qsprintf($conn, 'HAVING projectCount = %d', count($this->projectPHIDs));
}
}
$order = $this->buildOrderClause($conn);
$offset = (int) nonempty($this->offset, 0);
$limit = (int) nonempty($this->limit, self::DEFAULT_PAGE_SIZE);
if ($this->groupBy == self::GROUP_PROJECT) {
$limit = PHP_INT_MAX;
$offset = 0;
}
$data = queryfx_all($conn, 'SELECT %Q * %Q FROM %T task %Q %Q %Q %Q %Q LIMIT %d, %d', $calc, $count, $task_dao->getTableName(), $join, $where, $group, $having, $order, $offset, $limit);
if ($this->calculateRows) {
$count = queryfx_one($conn, 'SELECT FOUND_ROWS() N');
$this->rowCount = $count['N'];
} else {
$this->rowCount = null;
}
$tasks = $task_dao->loadAllFromArray($data);
if ($this->groupBy == self::GROUP_PROJECT) {
$tasks = $this->applyGroupByProject($tasks);
}
return $tasks;
}
开发者ID:nexeck,项目名称:phabricator,代码行数:72,代码来源:ManiphestTaskQuery.php
示例19: buildCardResponse
private function buildCardResponse(ManiphestTask $task)
{
$controller = $this->getController();
$request = $controller->getRequest();
$viewer = $request->getViewer();
$column_phid = $request->getStr('columnPHID');
$order = $request->getStr('order');
$column = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withPHIDs(array($column_phid))->executeOne();
if (!$column) {
return new Aphront404Response();
}
// If the workboard's project has been removed from the card's project
// list, we are going to remove it from the board completely.
$project_map = array_fuse($task->getProjectPHIDs());
$remove_card = empty($project_map[$column->getProjectPHID()]);
$positions = id(new PhabricatorProjectColumnPositionQuery())->setViewer($viewer)->withColumns(array($column))->execute();
$task_phids = mpull($positions, 'getObjectPHID');
$column_tasks = id(new ManiphestTaskQuery())->setViewer($viewer)->withPHIDs($task_phids)->execute();
if ($order == PhabricatorProjectColumn::ORDER_NATURAL) {
// TODO: This is a little bit awkward, because PHP and JS use
// slightly different sort order parameters to achieve the same
// effect. It would be good to unify this a bit at some point.
$sort_map = array();
foreach ($positions as $position) {
$sort_map[$position->getObjectPHID()] = array(-$position->getSequence(), $position->getID());
}
} else {
$sort_map = mpull($column_tasks, 'getPrioritySortVector', 'getPHID');
}
$data = array('removeFromBoard' => $remove_card, 'sortMap' => $sort_map);
// TODO: This should just use HandlePool once we get through the EditEngine
// transition.
$owner = null;
if ($task->getOwnerPHID()) {
$owner = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($task->getOwnerPHID()))->executeOne();
}
$tasks = id(new ProjectBoardTaskCard())->setViewer($viewer)->setTask($task)->setOwner($owner)->setCanEdit(true)->getItem();
$payload = array('tasks' => $tasks, 'data' => $data);
return id(new AphrontAjaxResponse())->setContent($payload);
}
开发者ID:fuding,项目名称:phabricator,代码行数:40,代码来源:ManiphestEditEngine.php
示例20: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$response_type = $request->getStr('responseType', 'task');
$order = $request->getStr('order', PhabricatorProjectColumn::DEFAULT_ORDER);
$can_edit_assign = $this->hasApplicationCapability(ManiphestEditAssignCapability::CAPABILITY);
$can_edit_policies = $this->hasApplicationCapability(ManiphestEditPoliciesCapability::CAPABILITY);
$can_edit_priority = $this->hasApplicationCapability(ManiphestEditPriorityCapability::CAPABILITY);
$can_edit_projects = $this->hasApplicationCapability(ManiphestEditProjectsCapability::CAPABILITY);
$can_edit_status = $this->hasApplicationCapability(ManiphestEditStatusCapability::CAPABILITY);
$parent_task = null;
$template_id = null;
if ($this->id) {
$task = id(new ManiphestTaskQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($this->id))->executeOne();
if (!$task) {
return new Aphront404Response();
}
} else {
$task = ManiphestTask::initializeNewTask($user);
// We currently do not allow you to set the task status when creating
// a new task, although now that statuses are custom it might make
// sense.
$can_edit_status = false;
// These allow task creation with defaults.
if (!$request->isFormPost()) {
$task->setTitle($request->getStr('title'));
if ($can_edit_projects) {
$projects = $request->getStr('projects');
if ($projects) {
$tokens = $request->getStrList('projects');
$type_project = PhabricatorProjectProjectPHIDType::TYPECONST;
foreach ($tokens as $key => $token) {
if (phid_get_type($token) == $type_project) {
// If this is formatted like a PHID, leave it as-is.
continue;
}
if (preg_match('/^#/', $token)) {
// If this already has a "#", leave it as-is.
continue;
}
// Add a "#" prefix.
$tokens[$key] = '#' . $token;
}
$default_projects = id(new PhabricatorObjectQuery())->setViewer($user)->withNames($tokens)->execute();
$default_projects = mpull($default_projects, 'getPHID');
if ($default_projects) {
$task->attachProjectPHIDs($default_projects);
}
}
}
if ($can_edit_priority) {
$priority = $request->getInt('priority');
if ($priority !== null) {
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
if (isset($priority_map[$priority])) {
$task->setPriority($priority);
}
}
}
$task->setDescription($request->getStr('description'));
if ($can_edit_assign) {
$assign = $request->getStr('assign');
if (strlen($assign)) {
$assign_user = id(new PhabricatorPeopleQuery())->setViewer($user)->withUsernames(array($assign))->executeOne();
if (!$assign_user) {
$assign_user = id(new PhabricatorPeopleQuery())->setViewer($user)->withPHIDs(array($assign))->executeOne();
}
if ($assign_user) {
$task->setOwnerPHID($assign_user->getPHID());
}
}
}
}
$template_id = $request->getInt('template');
// You can only have a parent task if you're creating a new task.
$parent_id = $request->getInt('parent');
if ($parent_id) {
$parent_task = id(new ManiphestTaskQuery())->setViewer($user)->withIDs(array($parent_id))->executeOne();
if (!$template_id) {
$template_id = $parent_id;
}
}
}
$errors = array();
$e_title = true;
$field_list = PhabricatorCustomField::getObjectFields($task, PhabricatorCustomField::ROLE_EDIT);
$field_list->setViewer($user);
$field_list->readFieldsFromStorage($task);
$aux_fields = $field_list->getFields();
if ($request->isFormPost()) {
$changes = array();
$new_title = $request->getStr('title');
$new_desc = $request->getStr('description');
$new_status = $request->getStr('status');
if (!$task->getID()) {
$workflow = 'create';
} else {
$workflow = '';
}
//.........这里部分代码省略.........
开发者ID:denghp,项目名称:phabricator,代码行数:101,代码来源:ManiphestTaskEditController.php
注:本文中的ManiphestTask类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论