public function applyApplicationSearchConstraintToQuery(PhabricatorApplicationSearchEngine $engine, PhabricatorCursorPagedPolicyAwareQuery $query, $value) { if (is_string($value) && !strlen($value)) { return; } $value = (array) $value; if ($value) { $query->withApplicationSearchContainsConstraint($this->newStringIndex(null), $value); } }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids); } if ($this->objectPHIDs !== null) { $where[] = qsprintf($conn, 'objectPHID IN (%Ls)', $this->objectPHIDs); } if ($this->keys !== null) { $sql = array(); foreach ($this->keys as $key) { $sql[] = qsprintf($conn, '(keyType = %s AND keyIndex = %s)', $key->getType(), $key->getHash()); } $where[] = implode(' OR ', $sql); } if ($this->isActive !== null) { if ($this->isActive) { $where[] = qsprintf($conn, 'isActive = %d', 1); } else { $where[] = qsprintf($conn, 'isActive IS NULL'); } } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->tokenResources !== null) { $where[] = qsprintf($conn, 'tokenResource IN (%Ls)', $this->tokenResources); } if ($this->tokenTypes !== null) { $where[] = qsprintf($conn, 'tokenType IN (%Ls)', $this->tokenTypes); } if ($this->expired !== null) { if ($this->expired) { $where[] = qsprintf($conn, 'tokenExpires <= %d', time()); } else { $where[] = qsprintf($conn, 'tokenExpires > %d', time()); } } if ($this->tokenCodes !== null) { $where[] = qsprintf($conn, 'tokenCode IN (%Ls)', $this->tokenCodes); } if ($this->userPHIDs !== null) { $where[] = qsprintf($conn, 'userPHID IN (%Ls)', $this->userPHIDs); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids) { $where[] = qsprintf($conn, 'p.id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf($conn, 'p.phid IN (%Ls)', $this->phids); } if ($this->bloggerPHIDs) { $where[] = qsprintf($conn, 'p.bloggerPHID IN (%Ls)', $this->bloggerPHIDs); } if ($this->phameTitles) { $where[] = qsprintf($conn, 'p.phameTitle IN (%Ls)', $this->phameTitles); } if ($this->visibility !== null) { $where[] = qsprintf($conn, 'p.visibility = %d', $this->visibility); } if ($this->publishedAfter !== null) { $where[] = qsprintf($conn, 'p.datePublished > %d', $this->publishedAfter); } if ($this->blogPHIDs) { $where[] = qsprintf($conn, 'p.blogPHID in (%Ls)', $this->blogPHIDs); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->callerPHIDs !== null) { $where[] = qsprintf($conn, 'callerPHID IN (%Ls)', $this->callerPHIDs); } if ($this->methods !== null) { $where[] = qsprintf($conn, 'method IN (%Ls)', $this->methods); } if ($this->methodStatuses !== null) { $statuses = array_fuse($this->methodStatuses); $methods = id(new PhabricatorConduitMethodQuery())->setViewer($this->getViewer())->execute(); $method_names = array(); foreach ($methods as $method) { $status = $method->getMethodStatus(); if (isset($statuses[$status])) { $method_names[] = $method->getAPIMethodName(); } } if (!$method_names) { throw new PhabricatorEmptyQueryException(); } $where[] = qsprintf($conn, 'method IN (%Ls)', $method_names); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'mail.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'mail.phid IN (%Ls)', $this->phids); } if ($this->actorPHIDs !== null) { $where[] = qsprintf($conn, 'mail.actorPHID IN (%Ls)', $this->actorPHIDs); } if ($this->recipientPHIDs !== null) { $where[] = qsprintf($conn, 'recipient.dst IN (%Ls)', $this->recipientPHIDs); } if ($this->actorPHIDs === null && $this->recipientPHIDs === null) { $viewer = $this->getViewer(); if (!$viewer->isOmnipotent()) { $where[] = qsprintf($conn, 'edge.dst = %s OR actorPHID = %s', $viewer->getPHID(), $viewer->getPHID()); } } if ($this->createdMin !== null) { $where[] = qsprintf($conn, 'mail.dateCreated >= %d', $this->createdMin); } if ($this->createdMax !== null) { $where[] = qsprintf($conn, 'mail.dateCreated <= %d', $this->createdMax); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'q.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'q.phid IN (%Ls)', $this->phids); } if ($this->authorPHIDs !== null) { $where[] = qsprintf($conn, 'q.authorPHID IN (%Ls)', $this->authorPHIDs); } if ($this->status !== null) { switch ($this->status) { case self::STATUS_ANY: break; case self::STATUS_OPEN: $where[] = qsprintf($conn, 'q.status = %d', PonderQuestionStatus::STATUS_OPEN); break; case self::STATUS_CLOSED: $where[] = qsprintf($conn, 'q.status = %d', PonderQuestionStatus::STATUS_CLOSED); break; default: throw new Exception(pht("Unknown status query '%s'!", $this->status)); } } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids); } if ($this->repositoryPHIDs !== null) { $where[] = qsprintf($conn, 'repositoryPHID IN (%Ls)', $this->repositoryPHIDs); } if ($this->refTypes !== null) { $where[] = qsprintf($conn, 'refType IN (%Ls)', $this->refTypes); } if ($this->refNames !== null) { $name_hashes = array(); foreach ($this->refNames as $name) { $name_hashes[] = PhabricatorHash::digestForIndex($name); } $where[] = qsprintf($conn, 'refNameHash IN (%Ls)', $name_hashes); } if (strlen($this->datasourceQuery)) { $where[] = qsprintf($conn, 'refNameRaw LIKE %>', $this->datasourceQuery); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->badgePHIDs !== null) { $where[] = qsprintf($conn, 'badgePHID IN (%Ls)', $this->badgePHIDs); } if ($this->recipientPHIDs !== null) { $where[] = qsprintf($conn, 'recipientPHID IN (%Ls)', $this->recipientPHIDs); } if ($this->awarderPHIDs !== null) { $where[] = qsprintf($conn, 'awarderPHID IN (%Ls)', $this->awarderPHIDs); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->repositoryPHIDs !== null) { $where[] = qsprintf($conn, 'repositoryPHID IN (%Ls)', $this->repositoryPHIDs); } if ($this->oldCommitIdentifiers !== null) { $where[] = qsprintf($conn, 'oldCommitIdentifier IN (%Ls)', $this->oldCommitIdentifiers); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->authorPHIDs !== null) { $where[] = qsprintf($conn, 'authorPHID IN (%Ls)', $this->authorPHIDs); } if ($this->objectPHIDs !== null) { $where[] = qsprintf($conn, 'objectPHID IN (%Ls)', $this->objectPHIDs); } if ($this->tokenPHIDs !== null) { $where[] = qsprintf($conn, 'tokenPHID IN (%Ls)', $this->tokenPHIDs); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids); } if ($this->archived !== null) { $where[] = qsprintf($conn, 'isArchived = %d', (int) $this->archived); } if ($this->panelTypes !== null) { $where[] = qsprintf($conn, 'panelType IN (%Ls)', $this->panelTypes); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids); } if ($this->authorPHIDs !== null) { $where[] = qsprintf($conn, 'authorPHID in (%Ls)', $this->authorPHIDs); } if ($this->upcoming !== null) { $where[] = qsprintf($conn, 'epoch >= %d', PhabricatorTime::getNow()); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->buildTargetPHIDs !== null) { $where[] = qsprintf($conn, 'buildTargetPHID IN (%Ls)', $this->buildTargetPHIDs); } if ($this->artifactTypes !== null) { $where[] = qsprintf($conn, 'artifactType in (%Ls)', $this->artifactTypes); } if ($this->artifactIndexes !== null) { $where[] = qsprintf($conn, 'artifactIndex IN (%Ls)', $this->artifactIndexes); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'mock.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'mock.phid IN (%Ls)', $this->phids); } if ($this->authorPHIDs !== null) { $where[] = qsprintf($conn, 'mock.authorPHID in (%Ls)', $this->authorPHIDs); } if ($this->statuses !== null) { $where[] = qsprintf($conn, 'mock.status IN (%Ls)', $this->statuses); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'import.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'import.phid IN (%Ls)', $this->phids); } if ($this->authorPHIDs !== null) { $where[] = qsprintf($conn, 'import.authorPHID IN (%Ls)', $this->authorPHIDs); } if ($this->isDisabled !== null) { $where[] = qsprintf($conn, 'import.isDisabled = %d', (int) $this->isDisabled); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids); } if ($this->names !== null) { $name_indexes = array(); foreach ($this->names as $name) { $name_indexes[] = PhabricatorHash::digestForIndex($name); } $where[] = qsprintf($conn, 'nameIndex IN (%Ls)', $name_indexes); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'url.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'url.phid IN (%Ls)', $this->phids); } if ($this->authorPHIDs !== null) { $where[] = qsprintf($conn, 'url.authorPHID IN (%Ls)', $this->authorPHIDs); } if ($this->names !== null) { $where[] = qsprintf($conn, 'url.name IN (%Ls)', $this->names); } if ($this->longURLs !== null) { $where[] = qsprintf($conn, 'url.longURL IN (%Ls)', $this->longURLs); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->addresses !== null) { $where[] = qsprintf($conn, 'appemail.address IN (%Ls)', $this->addresses); } if ($this->addressPrefix !== null) { $where[] = qsprintf($conn, 'appemail.address LIKE %>', $this->addressPrefix); } if ($this->applicationPHIDs !== null) { $where[] = qsprintf($conn, 'appemail.applicationPHID IN (%Ls)', $this->applicationPHIDs); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'appemail.phid IN (%Ls)', $this->phids); } if ($this->ids !== null) { $where[] = qsprintf($conn, 'appemail.id IN (%Ld)', $this->ids); } return $where; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids); } if ($this->isDefaultNamespace !== null) { if ($this->isDefaultNamespace) { $where[] = qsprintf($conn, 'isDefaultNamespace = 1'); } else { $where[] = qsprintf($conn, 'isDefaultNamespace IS NULL'); } } if ($this->isArchived !== null) { $where[] = qsprintf($conn, 'isArchived = %d', (int) $this->isArchived); } return $where; }
public function applyApplicationSearchConstraintToQuery(PhabricatorApplicationSearchEngine $engine, PhabricatorCursorPagedPolicyAwareQuery $query, $value) { $viewer = $this->getViewer(); if (!is_array($value)) { $value = array(); } $min_str = idx($value, 'min', ''); if (strlen($min_str)) { $min = PhabricatorTime::parseLocalTime($min_str, $viewer); } else { $min = null; } $max_str = idx($value, 'max', ''); if (strlen($max_str)) { $max = PhabricatorTime::parseLocalTime($max_str, $viewer); } else { $max = null; } if ($min !== null || $max !== null) { $query->withApplicationSearchRangeConstraint($this->newNumericIndex(null), $min, $max); } }
protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { $joins = parent::buildJoinClauseParts($conn); if ($this->memberPHIDs !== null) { $joins[] = qsprintf($conn, 'JOIN %T e ON e.src = p.phid AND e.type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorProjectMaterializedMemberEdgeType::EDGECONST); } if ($this->watcherPHIDs !== null) { $joins[] = qsprintf($conn, 'JOIN %T w ON w.src = p.phid AND w.type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorObjectHasWatcherEdgeType::EDGECONST); } if ($this->slugs !== null) { $joins[] = qsprintf($conn, 'JOIN %T slug on slug.projectPHID = p.phid', id(new PhabricatorProjectSlug())->getTableName()); } if ($this->nameTokens !== null) { foreach ($this->nameTokens as $key => $token) { $token_table = 'token_' . $key; $joins[] = qsprintf($conn, 'JOIN %T %T ON %T.projectID = p.id AND %T.token LIKE %>', PhabricatorProject::TABLE_DATASOURCE_TOKEN, $token_table, $token_table, $token_table, $token); } } return $joins; }
protected function setQueryProjects(PhabricatorCursorPagedPolicyAwareQuery $query, PhabricatorSavedQuery $saved) { $datasource = id(new PhabricatorProjectLogicalDatasource())->setViewer($this->requireViewer()); $projects = $saved->getParameter('projects', array()); $constraints = $datasource->evaluateTokens($projects); if ($constraints) { $query->withEdgeLogicConstraints(PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, $constraints); } return $this; }
public function getOrderableColumns() { return parent::getOrderableColumns() + array('name' => array('table' => $this->getPrimaryTableAlias(), 'column' => 'name', 'type' => 'string', 'unique' => true, 'reverse' => true)); }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids); } if ($this->credentialTypes !== null) { $where[] = qsprintf($conn, 'credentialType in (%Ls)', $this->credentialTypes); } if ($this->providesTypes !== null) { $where[] = qsprintf($conn, 'providesType IN (%Ls)', $this->providesTypes); } if ($this->isDestroyed !== null) { $where[] = qsprintf($conn, 'isDestroyed = %d', (int) $this->isDestroyed); } if ($this->allowConduit !== null) { $where[] = qsprintf($conn, 'allowConduit = %d', (int) $this->allowConduit); } if (strlen($this->nameContains)) { $where[] = qsprintf($conn, 'LOWER(name) LIKE %~', phutil_utf8_strtolower($this->nameContains)); } return $where; }
protected function shouldGroupQueryResultRows() { if ($this->inviteePHIDs !== null) { return true; } return parent::shouldGroupQueryResultRows(); }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf($conn, 'r.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf($conn, 'r.phid IN (%Ls)', $this->phids); } if ($this->callsigns !== null) { $where[] = qsprintf($conn, 'r.callsign IN (%Ls)', $this->callsigns); } if ($this->numericIdentifiers || $this->callsignIdentifiers || $this->phidIdentifiers || $this->monogramIdentifiers || $this->slugIdentifiers) { $identifier_clause = array(); if ($this->numericIdentifiers) { $identifier_clause[] = qsprintf($conn, 'r.id IN (%Ld)', $this->numericIdentifiers); } if ($this->callsignIdentifiers) { $identifier_clause[] = qsprintf($conn, 'r.callsign IN (%Ls)', $this->callsignIdentifiers); } if ($this->phidIdentifiers) { $identifier_clause[] = qsprintf($conn, 'r.phid IN (%Ls)', $this->phidIdentifiers); } if ($this->monogramIdentifiers) { $monogram_callsigns = array(); $monogram_ids = array(); foreach ($this->monogramIdentifiers as $identifier) { if ($identifier[0] == 'r') { $monogram_callsigns[] = substr($identifier, 1); } else { $monogram_ids[] = substr($identifier, 1); } } if ($monogram_ids) { $identifier_clause[] = qsprintf($conn, 'r.id IN (%Ld)', $monogram_ids); } if ($monogram_callsigns) { $identifier_clause[] = qsprintf($conn, 'r.callsign IN (%Ls)', $monogram_callsigns); } } if ($this->slugIdentifiers) { $identifier_clause[] = qsprintf($conn, 'r.repositorySlug IN (%Ls)', $this->slugIdentifiers); } $where = array('(' . implode(' OR ', $identifier_clause) . ')'); } if ($this->types) { $where[] = qsprintf($conn, 'r.versionControlSystem IN (%Ls)', $this->types); } if ($this->uuids) { $where[] = qsprintf($conn, 'r.uuid IN (%Ls)', $this->uuids); } if (strlen($this->nameContains)) { $where[] = qsprintf($conn, 'r.name LIKE %~', $this->nameContains); } if (strlen($this->datasourceQuery)) { // This handles having "rP" match callsigns starting with "P...". $query = trim($this->datasourceQuery); if (preg_match('/^r/', $query)) { $callsign = substr($query, 1); } else { $callsign = $query; } $where[] = qsprintf($conn, 'r.name LIKE %> OR r.callsign LIKE %> OR r.repositorySlug LIKE %>', $query, $callsign, $query); } if ($this->slugs !== null) { $where[] = qsprintf($conn, 'r.repositorySlug IN (%Ls)', $this->slugs); } if ($this->uris !== null) { $try_uris = $this->getNormalizedPaths(); $try_uris = array_fuse($try_uris); $where[] = qsprintf($conn, 'uri.repositoryURI IN (%Ls)', $try_uris); } return $where; }
public function getOrderableColumns() { return array('quality' => array('table' => $this->getPrimaryTableAlias(), 'column' => 'quality', 'reverse' => true, 'type' => 'int')) + parent::getOrderableColumns(); }
public function applyApplicationSearchConstraintToQuery(PhabricatorApplicationSearchEngine $engine, PhabricatorCursorPagedPolicyAwareQuery $query, $value) { if (strlen($value)) { $query->withApplicationSearchContainsConstraint($this->newNumericIndex(null), $value); } }