当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorProject类代码示例

本文整理汇总了PHP中PhabricatorProject的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorProject类的具体用法?PHP PhabricatorProject怎么用?PHP PhabricatorProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PhabricatorProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: materializeProject

 private function materializeProject(PhabricatorProject $project)
 {
     if ($project->isMilestone()) {
         return;
     }
     $material_type = PhabricatorProjectMaterializedMemberEdgeType::EDGECONST;
     $member_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST;
     $project_phid = $project->getPHID();
     $descendants = id(new PhabricatorProjectQuery())->setViewer($this->getViewer())->withAncestorProjectPHIDs(array($project->getPHID()))->withIsMilestone(false)->withHasSubprojects(false)->execute();
     $descendant_phids = mpull($descendants, 'getPHID');
     if ($descendant_phids) {
         $source_phids = $descendant_phids;
         $has_subprojects = true;
     } else {
         $source_phids = array($project->getPHID());
         $has_subprojects = false;
     }
     $conn_w = $project->establishConnection('w');
     $project->openTransaction();
     // Delete any existing materialized member edges.
     queryfx($conn_w, 'DELETE FROM %T WHERE src = %s AND type = %s', PhabricatorEdgeConfig::TABLE_NAME_EDGE, $project_phid, $material_type);
     // Copy current member edges to create new materialized edges.
     queryfx($conn_w, 'INSERT IGNORE INTO %T (src, type, dst, dateCreated, seq)
       SELECT %s, %d, dst, dateCreated, seq FROM %T
       WHERE src IN (%Ls) AND type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, $project_phid, $material_type, PhabricatorEdgeConfig::TABLE_NAME_EDGE, $source_phids, $member_type);
     // Update the hasSubprojects flag.
     queryfx($conn_w, 'UPDATE %T SET hasSubprojects = %d WHERE id = %d', $project->getTableName(), (int) $has_subprojects, $project->getID());
     $project->saveTransaction();
 }
开发者ID:phpengineer,项目名称:phabricator,代码行数:29,代码来源:PhabricatorProjectsMembershipIndexEngineExtension.php

示例2: buildIconNavView

 public function buildIconNavView(PhabricatorProject $project)
 {
     $id = $project->getID();
     $nav = parent::buildIconNavView($project);
     $nav->selectFilter("board/{$id}/");
     return $nav;
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:7,代码来源:PhabricatorProjectBoardController.php

示例3: buildLocalNavigation

 protected function buildLocalNavigation(PhabricatorProject $project)
 {
     $id = $project->getID();
     $nav_view = new AphrontSideNavFilterView();
     $uri = new PhutilURI('/project/view/' . $id . '/');
     $nav_view->setBaseURI($uri);
     $external_arrow = "↗";
     $tasks_uri = '/maniphest/view/all/?projects=' . $project->getPHID();
     $slug = PhabricatorSlug::normalize($project->getName());
     $phriction_uri = '/w/projects/' . $slug;
     $edit_uri = '/project/edit/' . $id . '/';
     $members_uri = '/project/members/' . $id . '/';
     $nav_view->addFilter('dashboard', 'Dashboard');
     $nav_view->addSpacer();
     $nav_view->addFilter('feed', 'Feed');
     $nav_view->addFilter(null, 'Tasks ' . $external_arrow, $tasks_uri);
     $nav_view->addFilter(null, 'Wiki ' . $external_arrow, $phriction_uri);
     $nav_view->addFilter('people', 'People');
     $nav_view->addFilter('about', 'About');
     $user = $this->getRequest()->getUser();
     $can_edit = PhabricatorPolicyCapability::CAN_EDIT;
     $nav_view->addSpacer();
     if (PhabricatorPolicyFilter::hasCapability($user, $project, $can_edit)) {
         $nav_view->addFilter('edit', "Edit Project…", $edit_uri);
         $nav_view->addFilter('members', "Edit Members…", $members_uri);
     } else {
         $nav_view->addFilter('edit', "Edit Project…", $edit_uri, $relative = false, 'disabled');
         $nav_view->addFilter('members', "Edit Members…", $members_uri, $relative = false, 'disabled');
     }
     return $nav_view;
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:31,代码来源:PhabricatorProjectController.php

示例4: buildActionList

 private function buildActionList(PhabricatorProject $project, array $milestones, array $subprojects)
 {
     $viewer = $this->getViewer();
     $id = $project->getID();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $project, PhabricatorPolicyCapability::CAN_EDIT);
     $allows_milestones = $project->supportsMilestones();
     $allows_subprojects = $project->supportsSubprojects();
     $view = id(new PhabricatorActionListView())->setUser($viewer);
     if ($allows_milestones && $milestones) {
         $milestone_text = pht('Create Next Milestone');
     } else {
         $milestone_text = pht('Create Milestone');
     }
     $can_milestone = $can_edit && $allows_milestones;
     $milestone_href = "/project/edit/?milestone={$id}";
     $view->addAction(id(new PhabricatorActionView())->setName($milestone_text)->setIcon('fa-plus')->setHref($milestone_href)->setDisabled(!$can_milestone)->setWorkflow(!$can_milestone));
     $can_subproject = $can_edit && $allows_subprojects;
     // If we're offering to create the first subproject, we're going to warn
     // the user about the effects before moving forward.
     if ($can_subproject && !$subprojects) {
         $subproject_href = "/project/warning/{$id}/";
         $subproject_disabled = false;
         $subproject_workflow = true;
     } else {
         $subproject_href = "/project/edit/?parent={$id}";
         $subproject_disabled = !$can_subproject;
         $subproject_workflow = !$can_subproject;
     }
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Create Subproject'))->setIcon('fa-plus')->setHref($subproject_href)->setDisabled($subproject_disabled)->setWorkflow($subproject_workflow));
     return $view;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:31,代码来源:PhabricatorProjectSubprojectsController.php

示例5: loadPage

 public function loadPage()
 {
     $table = new PhabricatorProject();
     $conn_r = $table->establishConnection('r');
     // NOTE: Because visibility checks for projects depend on whether or not
     // the user is a project member, we always load their membership. If we're
     // loading all members anyway we can piggyback on that; otherwise we
     // do an explicit join.
     $select_clause = '';
     if (!$this->needMembers) {
         $select_clause = ', vm.dst viewerIsMember';
     }
     $data = queryfx_all($conn_r, 'SELECT p.* %Q FROM %T p %Q %Q %Q %Q %Q', $select_clause, $table->getTableName(), $this->buildJoinClause($conn_r), $this->buildWhereClause($conn_r), $this->buildGroupClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r));
     $projects = $table->loadAllFromArray($data);
     if ($projects) {
         $viewer_phid = $this->getViewer()->getPHID();
         if ($this->needMembers) {
             $etype = PhabricatorEdgeConfig::TYPE_PROJ_MEMBER;
             $members = id(new PhabricatorEdgeQuery())->withSourcePHIDs(mpull($projects, 'getPHID'))->withEdgeTypes(array($etype))->execute();
             foreach ($projects as $project) {
                 $phid = $project->getPHID();
                 $project->attachMemberPHIDs(array_keys($members[$phid][$etype]));
                 $project->setIsUserMember($viewer_phid, isset($members[$phid][$etype][$viewer_phid]));
             }
         } else {
             foreach ($data as $row) {
                 $projects[$row['id']]->setIsUserMember($viewer_phid, $row['viewerIsMember'] !== null);
             }
         }
     }
     return $projects;
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:32,代码来源:PhabricatorProjectQuery.php

示例6: buildActionListView

 private function buildActionListView(PhabricatorProject $project)
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $id = $project->getID();
     $view = id(new PhabricatorActionListView())->setUser($viewer)->setObject($project)->setObjectURI($request->getRequestURI());
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $project, PhabricatorPolicyCapability::CAN_EDIT);
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Details'))->setIcon('fa-pencil')->setHref($this->getApplicationURI("details/{$id}/"))->setDisabled(!$can_edit));
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Picture'))->setIcon('fa-picture-o')->setHref($this->getApplicationURI("picture/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     if ($project->isArchived()) {
         $view->addAction(id(new PhabricatorActionView())->setName(pht('Activate Project'))->setIcon('fa-check')->setHref($this->getApplicationURI("archive/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(true));
     } else {
         $view->addAction(id(new PhabricatorActionView())->setName(pht('Archive Project'))->setIcon('fa-ban')->setHref($this->getApplicationURI("archive/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(true));
     }
     $action = null;
     if (!$project->isUserMember($viewer->getPHID())) {
         $can_join = PhabricatorPolicyFilter::hasCapability($viewer, $project, PhabricatorPolicyCapability::CAN_JOIN);
         $action = id(new PhabricatorActionView())->setUser($viewer)->setRenderAsForm(true)->setHref('/project/update/' . $project->getID() . '/join/')->setIcon('fa-plus')->setDisabled(!$can_join)->setName(pht('Join Project'));
         $view->addAction($action);
     } else {
         $action = id(new PhabricatorActionView())->setWorkflow(true)->setHref('/project/update/' . $project->getID() . '/leave/')->setIcon('fa-times')->setName(pht('Leave Project...'));
         $view->addAction($action);
         if (!$project->isUserWatcher($viewer->getPHID())) {
             $action = id(new PhabricatorActionView())->setWorkflow(true)->setHref('/project/watch/' . $project->getID() . '/')->setIcon('fa-eye')->setName(pht('Watch Project'));
             $view->addAction($action);
         } else {
             $action = id(new PhabricatorActionView())->setWorkflow(true)->setHref('/project/unwatch/' . $project->getID() . '/')->setIcon('fa-eye-slash')->setName(pht('Unwatch Project'));
             $view->addAction($action);
         }
     }
     return $view;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:32,代码来源:PhabricatorProjectProfileController.php

示例7: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $project = new PhabricatorProject();
     $project->setAuthorPHID($user->getPHID());
     $profile = new PhabricatorProjectProfile();
     $e_name = true;
     $errors = array();
     if ($request->isFormPost()) {
         try {
             $editor = new PhabricatorProjectEditor($project);
             $editor->setUser($user);
             $editor->setName($request->getStr('name'));
             $editor->save();
         } catch (PhabricatorProjectNameCollisionException $ex) {
             $e_name = 'Not Unique';
             $errors[] = $ex->getMessage();
         }
         $project->setStatus(PhabricatorProjectStatus::ONGOING);
         $profile->setBlurb($request->getStr('blurb'));
         if (!$errors) {
             $project->save();
             $profile->setProjectPHID($project->getPHID());
             $profile->save();
             id(new PhabricatorProjectAffiliation())->setUserPHID($user->getPHID())->setProjectPHID($project->getPHID())->setRole('Owner')->setIsOwner(true)->save();
             if ($request->isAjax()) {
                 return id(new AphrontAjaxResponse())->setContent(array('phid' => $project->getPHID(), 'name' => $project->getName()));
             } else {
                 return id(new AphrontRedirectResponse())->setURI('/project/view/' . $project->getID() . '/');
             }
         }
     }
     $error_view = null;
     if ($errors) {
         $error_view = new AphrontErrorView();
         $error_view->setTitle('Form Errors');
         $error_view->setErrors($errors);
     }
     if ($request->isAjax()) {
         $form = new AphrontFormLayoutView();
     } else {
         $form = new AphrontFormView();
         $form->setUser($user);
     }
     $form->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($project->getName())->setError($e_name))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Blurb')->setName('blurb')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)->setValue($profile->getBlurb()));
     if ($request->isAjax()) {
         if ($error_view) {
             $error_view->setWidth(AphrontErrorView::WIDTH_DIALOG);
         }
         $dialog = id(new AphrontDialogView())->setUser($user)->setWidth(AphrontDialogView::WIDTH_FORM)->setTitle('Create a New Project')->appendChild($error_view)->appendChild($form)->addSubmitButton('Create Project')->addCancelButton('/project/');
         return id(new AphrontDialogResponse())->setDialog($dialog);
     } else {
         $form->appendChild(id(new AphrontFormSubmitControl())->setValue('Create')->addCancelButton('/project/'));
         $panel = new AphrontPanelView();
         $panel->setWidth(AphrontPanelView::WIDTH_FORM)->setHeader('Create a New Project')->appendChild($form);
         return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Create new Project'));
     }
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:59,代码来源:PhabricatorProjectCreateController.php

示例8: buildPropertyListView

 private function buildPropertyListView(PhabricatorProject $project, PhabricatorActionListView $actions)
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setActionList($actions);
     $view->addProperty(pht('Looks Like'), $viewer->renderHandle($project->getPHID())->setAsTag(true));
     return $view;
 }
开发者ID:chirag-goel,项目名称:phabricator,代码行数:8,代码来源:PhabricatorProjectManageController.php

示例9: buildPropertyListView

 private function buildPropertyListView(PhabricatorProject $project)
 {
     $viewer = $this->getViewer();
     $view = id(new PHUIPropertyListView())->setUser($viewer);
     $view->addProperty(pht('Looks Like'), $viewer->renderHandle($project->getPHID())->setAsTag(true));
     $field_list = PhabricatorCustomField::getObjectFields($project, PhabricatorCustomField::ROLE_VIEW);
     $field_list->appendFieldsToPropertyList($project, $viewer, $view);
     return $view;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:9,代码来源:PhabricatorProjectManageController.php

示例10: renderFeedPage

 private function renderFeedPage(PhabricatorProject $project)
 {
     $query = new PhabricatorFeedQuery();
     $query->setFilterPHIDs(array($project->getPHID()));
     $query->setViewer($this->getRequest()->getUser());
     $query->setLimit(100);
     $stories = $query->execute();
     if (!$stories) {
         return pht('There are no stories about this project.');
     }
     return $this->renderStories($stories);
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:12,代码来源:PhabricatorProjectFeedController.php

示例11: updateProjectSubproject

 public static function updateProjectSubproject(PhabricatorProject $project)
 {
     $dao = new PhabricatorProjectSubproject();
     $conn = $dao->establishConnection('w');
     $sql = array();
     foreach ($project->getSubprojectPHIDs() as $subproject_phid) {
         $sql[] = qsprintf($conn, '(%s, %s)', $project->getPHID(), $subproject_phid);
     }
     queryfx($conn, 'DELETE FROM %T WHERE projectPHID = %s', $dao->getTableName(), $project->getPHID());
     if ($sql) {
         queryfx($conn, 'INSERT INTO %T (projectPHID, subprojectPHID) VALUES %Q', $dao->getTableName(), implode(', ', $sql));
     }
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:13,代码来源:PhabricatorProjectSubproject.php

示例12: renderMemberList

 private function renderMemberList(PhabricatorProject $project, array $handles)
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $list = id(new PHUIObjectItemListView())->setNoDataString(pht('This project does not have any members.'));
     foreach ($handles as $handle) {
         $remove_uri = $this->getApplicationURI('/members/' . $project->getID() . '/remove/?phid=' . $handle->getPHID());
         $item = id(new PHUIObjectItemView())->setHeader($handle->getFullName())->setHref($handle->getURI())->setImageURI($handle->getImageURI());
         $item->addAction(id(new PHUIListItemView())->setIcon('fa-times')->setName(pht('Remove'))->setHref($remove_uri)->setWorkflow(true));
         $list->addItem($item);
     }
     return $list;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:13,代码来源:PhabricatorProjectMembersEditController.php

示例13: validateName

 private function validateName(PhabricatorProject $project)
 {
     $slug = $project->getPhrictionSlug();
     $name = $project->getName();
     if ($slug == '/') {
         throw new PhabricatorProjectNameCollisionException("Project names must be unique and contain some letters or numbers.");
     }
     $id = $project->getID();
     $collision = id(new PhabricatorProject())->loadOneWhere('(name = %s OR phrictionSlug = %s) AND id %Q %nd', $name, $slug, $id ? '!=' : 'IS NOT', $id ? $id : null);
     if ($collision) {
         $other_name = $collision->getName();
         $other_id = $collision->getID();
         throw new PhabricatorProjectNameCollisionException("Project names must be unique. The name '{$name}' is too similar to " . "the name of another project, '{$other_name}' (Project ID: " . "{$other_id}). Choose a unique name.");
     }
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:15,代码来源:PhabricatorProjectEditor.php

示例14: generate

 public function generate()
 {
     $title = $this->generateTitle();
     // Prepend or append 'Sprint'
     $title = mt_rand(0, 1) ? $title . ' Sprint' : 'Sprint ' . $title;
     $author = $this->loadPhabrictorUser();
     $authorPHID = $author->getPHID();
     $project = PhabricatorProject::initializeNewProject($author);
     $this->addTransaction(PhabricatorProjectTransaction::TYPE_NAME, $title);
     $this->addTransaction(PhabricatorProjectTransaction::TYPE_ICON, 'fa-briefcase');
     $this->addTransaction(PhabricatorProjectTransaction::TYPE_COLOR, 'blue');
     // $this->addTransaction(
     //   PhabricatorProjectTransaction::TYPE_MEMBERS,
     //   $this->loadMembersWithAuthor($authorPHID));
     $this->addTransaction(PhabricatorTransactions::TYPE_VIEW_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
     $this->addTransaction(PhabricatorTransactions::TYPE_EDIT_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
     $this->addTransaction(PhabricatorTransactions::TYPE_JOIN_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
     // Pick a date to be the start date for the sprint
     // Random between 4 weeks ago and one week from now
     $start = mt_rand(time() - 28 * 24 * 60 * 60, time() + 7 * 24 * 60 * 60);
     $this->xactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD)->setMetadataValue('customfield:key', 'isdc:sprint:startdate')->setOldValue(null)->setNewValue($start);
     // Pick a date to be the end date for the sprint
     // Sprint is between 3 days and 3 weeks long
     $end = $start + mt_rand(3 * 24 * 60 * 60, 21 * 24 * 60 * 60);
     $this->xactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD)->setMetadataValue('customfield:key', 'isdc:sprint:enddate')->setOldValue(null)->setNewValue($end);
     $editor = id(new PhabricatorProjectTransactionEditor())->setActor($author)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $this->xactions);
     $project->save();
     // Generate a bunch of tasks created the before the sprint starts
     for ($i = 0, $num = mt_rand(5, 40); $i <= $num; $i++) {
         echo ".";
         $this->generateTask($project, $start, $end);
     }
     return $project;
 }
开发者ID:yangming85,项目名称:phabricator-sprint,代码行数:34,代码来源:BurndownTestDataGenerator.php

示例15: buildColumnsList

 private function buildColumnsList(PhabricatorProject $board, array $columns)
 {
     assert_instances_of($columns, 'PhabricatorProjectColumn');
     $board_id = $board->getID();
     $view = id(new PHUIObjectItemListView())->setNoDataString(pht('This board has no columns.'));
     foreach ($columns as $column) {
         $column_id = $column->getID();
         $detail_uri = "/project/board/{$board_id}/column/{$column_id}/";
         $item = id(new PHUIObjectItemView())->setHeader($column->getDisplayName())->setHref($detail_uri);
         if ($column->isHidden()) {
             $item->setDisabled(true);
         }
         $view->addItem($item);
     }
     return id(new PHUIObjectBoxView())->setHeaderText(pht('Columns'))->setObjectList($view);
 }
开发者ID:psyclone241,项目名称:phabricator,代码行数:16,代码来源:PhabricatorProjectBoardManageController.php


注:本文中的PhabricatorProject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。