public function processRequest() { $user = $this->getRequest()->getUser(); $nav = $this->buildNav(); $this->filter = $nav->selectFilter($this->filter, 'home'); switch ($this->filter) { case 'jump': case 'apps': break; case 'home': case 'feed': $project_query = new PhabricatorProjectQuery(); $project_query->setViewer($user); $project_query->withMemberPHIDs(array($user->getPHID())); $projects = $project_query->execute(); break; default: throw new Exception("Unknown filter '{$this->filter}'!"); } switch ($this->filter) { case 'feed': return $this->buildFeedResponse($nav, $projects); case 'jump': return $this->buildJumpResponse($nav); case 'apps': return $this->buildAppsResponse($nav); default: return $this->buildMainResponse($nav, $projects); } }
protected function execute(ConduitAPIRequest $request) { $query = new PhabricatorProjectQuery(); $query->needMembers(true); $ids = $request->getValue('ids'); if ($ids) { $query->withIDs($ids); } $status = $request->getValue('status'); if ($status) { $query->withStatus($status); } $phids = $request->getValue('phids'); if ($phids) { $query->withPHIDs($phids); } $members = $request->getValue('members'); if ($members) { $query->setMembers($members); } $limit = $request->getValue('limit'); if ($limit) { $query->setLimit($limit); } $offset = $request->getValue('offset'); if ($offset) { $query->setOffset($offset); } $results = $query->execute(); return $this->buildProjectInfoDictionaries($results); }
public static function loadAffiliatedPackages($user_phid) { $query = new PhabricatorProjectQuery(); $query->setMembers(array($user_phid)); $query->withStatus(PhabricatorProjectQuery::STATUS_ACTIVE); $projects = $query->execute(); $phids = mpull($projects, 'getPHID') + array($user_phid); return id(new PhabricatorOwnersOwner())->loadAllWhere('userPHID in (%Ls)', $phids); }
private function buildWhereClause(AphrontDatabaseConnection $conn_r) { $where = array(); if ($this->ownerPHIDs) { $base_phids = $this->ownerPHIDs; $query = new PhabricatorProjectQuery(); $query->setViewer($this->getViewer()); $query->withMemberPHIDs($base_phids); $projects = $query->execute(); $project_phids = mpull($projects, 'getPHID'); $all_phids = array_merge($base_phids, $project_phids); $where[] = qsprintf($conn_r, 'o.userPHID IN (%Ls)', $all_phids); } $where[] = $this->buildPagingClause($conn_r); return $this->formatWhereClause($where); }
public function processRequest() { $user = $this->getRequest()->getUser(); $dashboard = PhabricatorDashboardInstall::getDashboard($user, $user->getPHID(), get_class($this->getCurrentApplication())); if (!$dashboard) { $dashboard = PhabricatorDashboardInstall::getDashboard($user, PhabricatorHomeApplication::DASHBOARD_DEFAULT, get_class($this->getCurrentApplication())); } if ($dashboard) { $content = id(new PhabricatorDashboardRenderingEngine())->setViewer($user)->setDashboard($dashboard)->renderDashboard(); } else { $project_query = new PhabricatorProjectQuery(); $project_query->setViewer($user); $project_query->withMemberPHIDs(array($user->getPHID())); $projects = $project_query->execute(); $content = $this->buildMainResponse($projects); } if (!$this->only) { $nav = $this->buildNav(); $nav->appendChild(array($content, id(new PhabricatorGlobalUploadTargetView())->setUser($user))); $content = $nav; } return $this->buildApplicationPage($content, array('title' => 'Phabricator')); }
private function buildQueryFromRequest() { $request = $this->getRequest(); $user = $request->getUser(); $status = $this->getStatusValueFromRequest(); $group = $this->getGroupValueFromRequest(); $order = $this->getOrderValueFromRequest(); $user_phids = $request->getStrList('users', array($user->getPHID())); if ($this->view == 'projecttriage' || $this->view == 'projectall') { $project_query = new PhabricatorProjectQuery(); $project_query->setViewer($user); $project_query->withMemberPHIDs($user_phids); $projects = $project_query->execute(); $project_phids = mpull($projects, 'getPHID'); } else { $project_phids = $request->getStrList('projects'); } $exclude_project_phids = $request->getStrList('xprojects'); $task_ids = $request->getStrList('tasks'); if ($task_ids) { // We only need the integer portion of each task ID, so get rid of any // non-numeric elements $numeric_task_ids = array(); foreach ($task_ids as $task_id) { $task_id = preg_replace('/[a-zA-Z]+/', '', $task_id); if (!empty($task_id)) { $numeric_task_ids[] = $task_id; } } if (empty($numeric_task_ids)) { $numeric_task_ids = array(null); } $task_ids = $numeric_task_ids; } $owner_phids = $request->getStrList('owners'); $author_phids = $request->getStrList('authors'); $search_string = $request->getStr('search'); $low_priority = $request->getInt('lpriority'); $high_priority = $request->getInt('hpriority'); $page = $request->getInt('offset'); $page_size = self::DEFAULT_PAGE_SIZE; $query = new PhabricatorSearchQuery(); $query->setQuery('<<maniphest>>'); $query->setParameters(array('fullTextSearch' => $search_string, 'view' => $this->view, 'userPHIDs' => $user_phids, 'projectPHIDs' => $project_phids, 'excludeProjectPHIDs' => $exclude_project_phids, 'ownerPHIDs' => $owner_phids, 'authorPHIDs' => $author_phids, 'taskIDs' => $task_ids, 'lowPriority' => $low_priority, 'highPriority' => $high_priority, 'group' => $group, 'order' => $order, 'offset' => $page, 'limit' => $page_size, 'status' => $status)); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $query->save(); unset($unguarded); return $query; }
private function buildQueryFromRequest() { $request = $this->getRequest(); $user = $request->getUser(); $status = $this->getStatusValueFromRequest(); $group = $this->getGroupValueFromRequest(); $order = $this->getOrderValueFromRequest(); $user_phids = $request->getStrList('users', array($user->getPHID())); if ($this->view == 'projecttriage' || $this->view == 'projectall') { $project_query = new PhabricatorProjectQuery(); $project_query->setMembers($user_phids); $projects = $project_query->execute(); $project_phids = mpull($projects, 'getPHID'); } else { $project_phids = $request->getStrList('projects'); } $exclude_project_phids = $request->getStrList('xprojects'); $task_ids = $request->getStrList('tasks'); $owner_phids = $request->getStrList('owners'); $author_phids = $request->getStrList('authors'); $page = $request->getInt('offset'); $page_size = self::DEFAULT_PAGE_SIZE; $query = new PhabricatorSearchQuery(); $query->setQuery('<<maniphest>>'); $query->setParameters(array('view' => $this->view, 'userPHIDs' => $user_phids, 'projectPHIDs' => $project_phids, 'excludeProjectPHIDs' => $exclude_project_phids, 'ownerPHIDs' => $owner_phids, 'authorPHIDs' => $author_phids, 'taskIDs' => $task_ids, 'group' => $group, 'order' => $order, 'offset' => $page, 'limit' => $page_size, 'status' => $status)); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $query->save(); unset($unguarded); return $query; }
public function processRequest() { $request = $this->getRequest(); $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI('/project/filter/'))->addLabel('User')->addFilter('active', 'Active')->addFilter('owned', 'Owned')->addSpacer()->addLabel('All')->addFilter('all', 'All Projects'); $this->filter = $nav->selectFilter($this->filter, 'active'); $pager = new AphrontPagerView(); $pager->setPageSize(250); $pager->setURI($request->getRequestURI(), 'page'); $pager->setOffset($request->getInt('page')); $query = new PhabricatorProjectQuery(); $query->setOffset($pager->getOffset()); $query->setLimit($pager->getPageSize() + 1); $view_phid = $request->getUser()->getPHID(); switch ($this->filter) { case 'active': $table_header = 'Active Projects'; $query->setMembers(array($view_phid)); break; case 'owned': $table_header = 'Owned Projects'; $query->setOwners(array($view_phid)); break; case 'all': $table_header = 'All Projects'; break; } $projects = $query->execute(); $projects = $pager->sliceResults($projects); $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); } $tasks = array(); $groups = array(); if ($project_phids) { $query = id(new ManiphestTaskQuery())->withProjects($project_phids)->withAnyProject(true)->withStatus(ManiphestTaskQuery::STATUS_OPEN)->setLimit(PHP_INT_MAX); $tasks = $query->execute(); foreach ($tasks as $task) { foreach ($task->getProjectPHIDs() as $phid) { $groups[$phid][] = $task; } } } $rows = array(); foreach ($projects as $project) { $phid = $project->getPHID(); $profile = $profiles[$phid]; $affiliations = $affil_groups[$phid]; $group = idx($groups, $phid, array()); $task_count = count($group); $population = count($affiliations); $blurb = $profile->getBlurb(); $blurb = phutil_utf8_shorten($blurb, 64); $rows[] = array(phutil_render_tag('a', array('href' => '/project/view/' . $project->getID() . '/'), phutil_escape_html($project->getName())), phutil_escape_html($blurb), phutil_escape_html($population), phutil_render_tag('a', array('href' => '/maniphest/view/all/?projects=' . $phid), phutil_escape_html($task_count))); } $table = new AphrontTableView($rows); $table->setHeaders(array('Project', 'Description', 'Population', 'Open Tasks')); $table->setColumnClasses(array('pri', 'wide', '', '')); $panel = new AphrontPanelView(); $panel->setHeader($table_header); $panel->setCreateButton('Create New Project', '/project/create/'); $panel->appendChild($table); $panel->appendChild($pager); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Projects')); }
/** * Load the PHIDs for all objects the user has the authority to act as an * audit for. This includes themselves, and any packages they are an owner * of. */ public static function loadAuditPHIDsForUser(PhabricatorUser $user) { $phids = array(); // The user can audit on their own behalf. $phids[$user->getPHID()] = true; // The user can audit on behalf of all packages they own. $owned_packages = PhabricatorOwnersOwner::loadAffiliatedPackages($user->getPHID()); if ($owned_packages) { $packages = id(new PhabricatorOwnersPackage())->loadAllWhere('id IN (%Ld)', mpull($owned_packages, 'getPackageID')); foreach (mpull($packages, 'getPHID') as $phid) { $phids[$phid] = true; } } // The user can audit on behalf of all projects they are a member of. $query = new PhabricatorProjectQuery(); $query->setMembers(array($user->getPHID())); $projects = $query->execute(); foreach ($projects as $project) { $phids[$project->getPHID()] = true; } return array_keys($phids); }
/** * Load the PHIDs for all objects the user has the authority to act as an * audit for. This includes themselves, and any packages they are an owner * of. */ public static function loadAuditPHIDsForUser(PhabricatorUser $user) { $phids = array(); // TODO: This method doesn't really use the right viewer, but in practice we // never issue this query of this type on behalf of another user and are // unlikely to do so in the future. This entire method should be refactored // into a Query class, however, and then we should use a proper viewer. // The user can audit on their own behalf. $phids[$user->getPHID()] = true; $owned_packages = id(new PhabricatorOwnersPackageQuery())->setViewer($user)->withOwnerPHIDs(array($user->getPHID()))->execute(); foreach ($owned_packages as $package) { $phids[$package->getPHID()] = true; } // The user can audit on behalf of all projects they are a member of. $query = new PhabricatorProjectQuery(); // TODO: As above. $query->setViewer($user); $query->withMemberPHIDs(array($user->getPHID())); $projects = $query->execute(); foreach ($projects as $project) { $phids[$project->getPHID()] = true; } return array_keys($phids); }