code
stringlengths
15
9.96M
docstring
stringlengths
1
10.1k
func_name
stringlengths
1
124
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
6
186
url
stringlengths
50
236
license
stringclasses
4 values
public function getRule() { return $this->rule; }
@return HeraldRule
getRule
php
phorgeit/phorge
src/applications/herald/engine/HeraldEffect.php
https://github.com/phorgeit/phorge/blob/master/src/applications/herald/engine/HeraldEffect.php
Apache-2.0
public function getReason() { return $this->reason; }
@return string Reason why Herald effect was applied, for example "Conditions were met for H123 RuleName"
getReason
php
phorgeit/phorge
src/applications/herald/engine/HeraldEffect.php
https://github.com/phorgeit/phorge/blob/master/src/applications/herald/engine/HeraldEffect.php
Apache-2.0
private function renderMustMatchSelector($rule) { return AphrontFormSelectControl::renderSelectTag( $rule->getMustMatchAll() ? 'all' : 'any', array( 'all' => pht('all of'), 'any' => pht('any of'), ), array( 'name' => 'must_match', )); }
Render the selector for the "When (all of | any of) these conditions are met:" element.
renderMustMatchSelector
php
phorgeit/phorge
src/applications/herald/controller/HeraldRuleController.php
https://github.com/phorgeit/phorge/blob/master/src/applications/herald/controller/HeraldRuleController.php
Apache-2.0
private function renderRepetitionSelector($rule, HeraldAdapter $adapter) { $repetition_policy = $rule->getRepetitionPolicyStringConstant(); $repetition_map = $this->getRepetitionOptionMap($adapter); if (count($repetition_map) < 2) { return head($repetition_map); } else { return AphrontFormSelectControl::renderSelectTag( $repetition_policy, $repetition_map, array( 'name' => 'repetition_policy', )); } }
Render the selector for "Take these actions (every time | only the first time) this rule matches..." element.
renderRepetitionSelector
php
phorgeit/phorge
src/applications/herald/controller/HeraldRuleController.php
https://github.com/phorgeit/phorge/blob/master/src/applications/herald/controller/HeraldRuleController.php
Apache-2.0
private function loadRulesThisRuleMayDependUpon(HeraldRule $rule) { $viewer = $this->getRequest()->getUser(); // Any rule can depend on a global rule. $all_rules = id(new HeraldRuleQuery()) ->setViewer($viewer) ->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_GLOBAL)) ->withContentTypes(array($rule->getContentType())) ->execute(); if ($rule->isObjectRule()) { // Object rules may depend on other rules for the same object. $all_rules += id(new HeraldRuleQuery()) ->setViewer($viewer) ->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_OBJECT)) ->withContentTypes(array($rule->getContentType())) ->withTriggerObjectPHIDs(array($rule->getTriggerObjectPHID())) ->execute(); } if ($rule->isPersonalRule()) { // Personal rules may depend upon your other personal rules. $all_rules += id(new HeraldRuleQuery()) ->setViewer($viewer) ->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL)) ->withContentTypes(array($rule->getContentType())) ->withAuthorPHIDs(array($rule->getAuthorPHID())) ->execute(); } // A rule can not depend upon itself. unset($all_rules[$rule->getID()]); return $all_rules; }
Load rules for the "Another Herald rule..." condition dropdown, which allows one rule to depend upon the success or failure of another rule.
loadRulesThisRuleMayDependUpon
php
phorgeit/phorge
src/applications/herald/controller/HeraldRuleController.php
https://github.com/phorgeit/phorge/blob/master/src/applications/herald/controller/HeraldRuleController.php
Apache-2.0
private function filterSubscribedPHIDs(array $phids) { $phids = $this->expandRecipients($phids); $tags = $this->getMailTags(); if ($tags) { $all_prefs = id(new PhabricatorUserPreferencesQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withUserPHIDs($phids) ->needSyntheticPreferences(true) ->execute(); $all_prefs = mpull($all_prefs, null, 'getUserPHID'); } $pref_default = PhabricatorEmailTagsSetting::VALUE_EMAIL; $pref_ignore = PhabricatorEmailTagsSetting::VALUE_IGNORE; $keep = array(); foreach ($phids as $phid) { if (($phid == $this->storyAuthorPHID) && !$this->getNotifyAuthor()) { continue; } if ($tags && isset($all_prefs[$phid])) { $mailtags = $all_prefs[$phid]->getSettingValue( PhabricatorEmailTagsSetting::SETTINGKEY); $notify = false; foreach ($tags as $tag) { // If this is set to "email" or "notify", notify the user. if ((int)idx($mailtags, $tag, $pref_default) != $pref_ignore) { $notify = true; break; } } if (!$notify) { continue; } } $keep[] = $phid; } return array_values(array_unique($keep)); }
Remove PHIDs who should not receive notifications from a subscriber list. @param list<string> $phids List of PHIDs of potential subscribers. @return list<string> List of PHIDs of actual subscribers.
filterSubscribedPHIDs
php
phorgeit/phorge
src/applications/feed/PhabricatorFeedStoryPublisher.php
https://github.com/phorgeit/phorge/blob/master/src/applications/feed/PhabricatorFeedStoryPublisher.php
Apache-2.0
private function generateChronologicalKey() { // Use the epoch timestamp for the upper 32 bits of the key. Default to // the current time if the story doesn't have an explicit timestamp. $time = nonempty($this->storyTime, time()); // Generate a random number for the lower 32 bits of the key. $rand = head(unpack('L', Filesystem::readRandomBytes(4))); // On 32-bit machines, we have to get creative. if (PHP_INT_SIZE < 8) { // We're on a 32-bit machine. if (function_exists('bcadd')) { // Try to use the 'bc' extension. return bcadd(bcmul($time, bcpow(2, 32)), $rand); } else { // Do the math in MySQL. TODO: If we formalize a bc dependency, get // rid of this. $conn_r = id(new PhabricatorFeedStoryData())->establishConnection('r'); $result = queryfx_one( $conn_r, 'SELECT (%d << 32) + %d as N', $time, $rand); return $result['N']; } } else { // This is a 64 bit machine, so we can just do the math. return ($time << 32) + $rand; } }
We generate a unique chronological key for each story type because we want to be able to page through the stream with a cursor (i.e., select stories after ID = X) so we can efficiently perform filtering after selecting data, and multiple stories with the same ID make this cumbersome without putting a bunch of logic in the client. We could use the primary key, but that would prevent publishing stories which happened in the past. Since it's potentially useful to do that (e.g., if you're importing another data source) build a unique key for each story which has chronological ordering. @return string A unique, time-ordered key which identifies the story.
generateChronologicalKey
php
phorgeit/phorge
src/applications/feed/PhabricatorFeedStoryPublisher.php
https://github.com/phorgeit/phorge/blob/master/src/applications/feed/PhabricatorFeedStoryPublisher.php
Apache-2.0
public function withEpochInRange($range_min, $range_max) { if ($range_min && $range_max && $range_min > $range_max) { throw new PhutilArgumentUsageException( pht('Feed query minimum range must be lower than maximum range.')); } $this->rangeMin = $range_min; $this->rangeMax = $range_max; return $this; }
@param int|null $range_min Minimum epoch value of feed stories @param int|null $range_max Maximum epoch value of feed stories
withEpochInRange
php
phorgeit/phorge
src/applications/feed/query/PhabricatorFeedQuery.php
https://github.com/phorgeit/phorge/blob/master/src/applications/feed/query/PhabricatorFeedQuery.php
Apache-2.0
public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, ); }
@task policy
getCapabilities
php
phorgeit/phorge
src/applications/feed/story/PhabricatorFeedStory.php
https://github.com/phorgeit/phorge/blob/master/src/applications/feed/story/PhabricatorFeedStory.php
Apache-2.0
public function getPolicy($capability) { // NOTE: We enforce that a user can see all the objects a story is about // when loading it, so we don't need to perform a equivalent secondary // policy check later. return PhabricatorPolicies::getMostOpenPolicy(); }
@task policy
getPolicy
php
phorgeit/phorge
src/applications/feed/story/PhabricatorFeedStory.php
https://github.com/phorgeit/phorge/blob/master/src/applications/feed/story/PhabricatorFeedStory.php
Apache-2.0
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; }
@task policy
hasAutomaticCapability
php
phorgeit/phorge
src/applications/feed/story/PhabricatorFeedStory.php
https://github.com/phorgeit/phorge/blob/master/src/applications/feed/story/PhabricatorFeedStory.php
Apache-2.0
public function isBrowsable() { return true; }
Can the user browse through results from this datasource? Browsable datasources allow the user to switch from typeahead mode to a browse mode where they can scroll through all results. By default, datasources are browsable, but some datasources can not generate a meaningful result set or can't filter results on the server. @return bool
isBrowsable
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
public function getDatasourceFunctions() { return array(); }
@task functions
getDatasourceFunctions
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
public function getAllDatasourceFunctions() { return $this->getDatasourceFunctions(); }
@task functions
getAllDatasourceFunctions
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
protected function isFunctionWithLoginRequired($function) { // This is just a default. // Make sure to override this method to require login. return false; }
Check if this datasource requires a logged-in viewer. @task functions @param string $function Function name. @return bool
isFunctionWithLoginRequired
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
protected function canEvaluateFunction($function) { return $this->shouldStripFunction($function); }
@task functions
canEvaluateFunction
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
protected function shouldStripFunction($function) { $functions = $this->getDatasourceFunctions(); return isset($functions[$function]); }
@task functions
shouldStripFunction
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
protected function evaluateFunction($function, array $argv_list) { throw new PhutilMethodNotImplementedException(); }
@task functions
evaluateFunction
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
protected function evaluateValues(array $values) { return $values; }
@task functions
evaluateValues
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
protected function didEvaluateTokens(array $results) { return $results; }
@task functions
didEvaluateTokens
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
public static function isFunctionToken($token) { // We're looking for a "(" so that a string like "members(q" is identified // and parsed as a function call. This allows us to start generating // results immediately, before the user fully types out "members(quack)". if ($token) { return (strpos($token, '(') !== false); } else { return false; } }
@task functions
isFunctionToken
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
public function renderFunctionTokens($function, array $argv_list) { throw new PhutilMethodNotImplementedException(); }
@task functions
renderFunctionTokens
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
public function setFunctionStack(array $function_stack) { $this->functionStack = $function_stack; return $this; }
@task functions
setFunctionStack
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
public function getFunctionStack() { return $this->functionStack; }
@task functions
getFunctionStack
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
protected function getCurrentFunction() { return nonempty(last($this->functionStack), null); }
@task functions
getCurrentFunction
php
phorgeit/phorge
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
https://github.com/phorgeit/phorge/blob/master/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Apache-2.0
public function getUser() { if (!$this->user) { throw new Exception( pht( 'You can not access the user inside the implementation of a Conduit '. 'method which does not require authentication (as per %s).', 'shouldRequireAuthentication()')); } return $this->user; }
Retrieve the authentic identity of the user making the request. If a method requires authentication (the default) the user object will always be available. If a method does not require authentication (i.e., overrides shouldRequireAuthentication() to return false) the user object will NEVER be available. @return PhabricatorUser Authentic user, available ONLY if the method requires authentication.
getUser
php
phorgeit/phorge
src/applications/conduit/protocol/ConduitAPIRequest.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/protocol/ConduitAPIRequest.php
Apache-2.0
final public function setErrorDescription($error_description) { $this->errorDescription = $error_description; return $this; }
Set a detailed error description. If omitted, the generic error description will be used instead. This is useful to provide specific information about an exception (e.g., which values were wrong in an invalid request). @param string $error_description Detailed error description. @return $this
setErrorDescription
php
phorgeit/phorge
src/applications/conduit/protocol/exception/ConduitException.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/protocol/exception/ConduitException.php
Apache-2.0
final public function getErrorDescription() { return $this->errorDescription; }
Get a detailed error description, if available. @return string|null Error description, if one is available.
getErrorDescription
php
phorgeit/phorge
src/applications/conduit/protocol/exception/ConduitException.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/protocol/exception/ConduitException.php
Apache-2.0
public function getMethodSummary() { return $this->getMethodDescription(); }
Get a short, human-readable text summary of the method. @return string Short summary of method. @task info
getMethodSummary
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
public function getID() { return $this->getAPIMethodName(); }
This is mostly for compatibility with @{class:PhabricatorCursorPagedPolicyAwareQuery}.
getID
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
public function getMethodStatus() { return self::METHOD_STATUS_STABLE; }
Get the status for this method (e.g., stable, unstable or deprecated). Should return a METHOD_STATUS_* constant. By default, methods are "stable". @return string METHOD_STATUS_* constant. @task status
getMethodStatus
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
public function getMethodStatusDescription() { return null; }
Optional description to supplement the method status. In particular, if a method is deprecated, you can return a string here describing the reason for deprecation and stable alternatives. @return string|null Description of the method status, if available. @task status
getMethodStatusDescription
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
public function getSortOrder() { $name = $this->getAPIMethodName(); $map = array( self::METHOD_STATUS_STABLE => 0, self::METHOD_STATUS_UNSTABLE => 1, self::METHOD_STATUS_DEPRECATED => 2, ); $ord = idx($map, $this->getMethodStatus(), 0); list($head, $tail) = explode('.', $name, 2); return "{$head}.{$ord}.{$tail}"; }
Return a key which sorts methods by application name, then method status, then method name.
getSortOrder
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
public function getApplication() { return null; }
Optionally, return a @{class:PhabricatorApplication} which this call is part of. The call will be disabled when the application is uninstalled. @return PhabricatorApplication|null Related application.
getApplication
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
protected function getPagerParamTypes() { return array( 'before' => 'optional string', 'after' => 'optional string', 'limit' => 'optional int (default = 100)', ); }
@task pager
getPagerParamTypes
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
protected function newPager(ConduitAPIRequest $request) { $limit = $request->getValue('limit', 100); $limit = min(1000, $limit); $limit = max(1, $limit); $pager = id(new AphrontCursorPagerView()) ->setPageSize($limit); $before_id = $request->getValue('before'); if ($before_id !== null) { $pager->setBeforeID($before_id); } $after_id = $request->getValue('after'); if ($after_id !== null) { $pager->setAfterID($after_id); } return $pager; }
@task pager
newPager
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
protected function addPagerResults( array $results, AphrontCursorPagerView $pager) { $results['cursor'] = array( 'limit' => $pager->getPageSize(), 'after' => $pager->getNextPageID(), 'before' => $pager->getPrevPageID(), ); return $results; }
@task pager
addPagerResults
php
phorgeit/phorge
src/applications/conduit/method/ConduitAPIMethod.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/method/ConduitAPIMethod.php
Apache-2.0
private function authenticateUser( ConduitAPIRequest $api_request, array $metadata, $method) { $request = $this->getRequest(); if ($request->getUser()->getPHID()) { $request->validateCSRF(); return $this->validateAuthenticatedUser( $api_request, $request->getUser()); } $auth_type = idx($metadata, 'auth.type'); if ($auth_type === ConduitClient::AUTH_ASYMMETRIC) { $host = idx($metadata, 'auth.host'); if (!$host) { return array( 'ERR-INVALID-AUTH', pht( 'Request is missing required "%s" parameter.', 'auth.host'), ); } // TODO: Validate that we are the host! $raw_key = idx($metadata, 'auth.key'); $public_key = PhabricatorAuthSSHPublicKey::newFromRawKey($raw_key); $ssl_public_key = $public_key->toPKCS8(); // First, verify the signature. try { $protocol_data = $metadata; ConduitClient::verifySignature( $method, $api_request->getAllParameters(), $protocol_data, $ssl_public_key); } catch (Exception $ex) { return array( 'ERR-INVALID-AUTH', pht( 'Signature verification failure. %s', $ex->getMessage()), ); } // If the signature is valid, find the user or device which is // associated with this public key. $stored_key = id(new PhabricatorAuthSSHKeyQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withKeys(array($public_key)) ->withIsActive(true) ->executeOne(); if (!$stored_key) { $key_summary = id(new PhutilUTF8StringTruncator()) ->setMaximumBytes(64) ->truncateString($raw_key); return array( 'ERR-INVALID-AUTH', pht( 'No user or device is associated with the public key "%s".', $key_summary), ); } $object = $stored_key->getObject(); if ($object instanceof PhabricatorUser) { $user = $object; } else { if ($object->isDisabled()) { return array( 'ERR-INVALID-AUTH', pht( 'The key which signed this request is associated with a '. 'disabled device ("%s").', $object->getName()), ); } if (!$stored_key->getIsTrusted()) { return array( 'ERR-INVALID-AUTH', pht( 'The key which signed this request is not trusted. Only '. 'trusted keys can be used to sign API calls.'), ); } if (!PhabricatorEnv::isClusterRemoteAddress()) { return array( 'ERR-INVALID-AUTH', pht( 'This request originates from outside of the cluster address '. 'range. Requests signed with trusted device keys must '. 'originate from within the cluster.'), ); } $user = PhabricatorUser::getOmnipotentUser(); // Flag this as an intracluster request. $api_request->setIsClusterRequest(true); } return $this->validateAuthenticatedUser( $api_request, $user); } else if ($auth_type === null) { // No specified authentication type, continue with other authentication // methods below. } else { return array( 'ERR-INVALID-AUTH', pht( 'Provided "%s" ("%s") is not recognized.', 'auth.type', $auth_type), ); } $token_string = idx($metadata, 'token', ''); if (strlen($token_string)) { if (strlen($token_string) != 32) { return array( 'ERR-INVALID-AUTH', pht( 'API token "%s" has the wrong length. API tokens should be '. '32 characters long.', $token_string), ); } $type = head(explode('-', $token_string)); $valid_types = PhabricatorConduitToken::getAllTokenTypes(); $valid_types = array_fuse($valid_types); if (empty($valid_types[$type])) { return array( 'ERR-INVALID-AUTH', pht( 'API token "%s" has the wrong format. API tokens should be '. '32 characters long and begin with one of these prefixes: %s.', $token_string, implode(', ', $valid_types)), ); } $token = id(new PhabricatorConduitTokenQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withTokens(array($token_string)) ->withExpired(false) ->executeOne(); if (!$token) { $token = id(new PhabricatorConduitTokenQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withTokens(array($token_string)) ->withExpired(true) ->executeOne(); if ($token) { return array( 'ERR-INVALID-AUTH', pht( 'API token "%s" was previously valid, but has expired.', $token_string), ); } else { return array( 'ERR-INVALID-AUTH', pht( 'API token "%s" is not valid.', $token_string), ); } } // If this is a "cli-" token, it expires shortly after it is generated // by default. Once it is actually used, we extend its lifetime and make // it permanent. This allows stray tokens to get cleaned up automatically // if they aren't being used. if ($token->getTokenType() == PhabricatorConduitToken::TYPE_COMMANDLINE) { if ($token->getExpires()) { $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $token->setExpires(null); $token->save(); unset($unguarded); } } // If this is a "clr-" token, Phabricator must be configured in cluster // mode and the remote address must be a cluster node. if ($token->getTokenType() == PhabricatorConduitToken::TYPE_CLUSTER) { if (!PhabricatorEnv::isClusterRemoteAddress()) { return array( 'ERR-INVALID-AUTH', pht( 'This request originates from outside of the cluster address '. 'range. Requests signed with cluster API tokens must '. 'originate from within the cluster.'), ); } // Flag this as an intracluster request. $api_request->setIsClusterRequest(true); } $user = $token->getObject(); if (!($user instanceof PhabricatorUser)) { return array( 'ERR-INVALID-AUTH', pht('API token is not associated with a valid user.'), ); } return $this->validateAuthenticatedUser( $api_request, $user); } $access_token = idx($metadata, 'access_token'); if ($access_token) { $token = id(new PhabricatorOAuthServerAccessToken()) ->loadOneWhere('token = %s', $access_token); if (!$token) { return array( 'ERR-INVALID-AUTH', pht('Access token does not exist.'), ); } $oauth_server = new PhabricatorOAuthServer(); $authorization = $oauth_server->authorizeToken($token); if (!$authorization) { return array( 'ERR-INVALID-AUTH', pht('Access token is invalid or expired.'), ); } $user = id(new PhabricatorPeopleQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withPHIDs(array($token->getUserPHID())) ->executeOne(); if (!$user) { return array( 'ERR-INVALID-AUTH', pht('Access token is for invalid user.'), ); } $ok = $this->authorizeOAuthMethodAccess($authorization, $method); if (!$ok) { return array( 'ERR-OAUTH-ACCESS', pht('You do not have authorization to call this method.'), ); } $api_request->setOAuthToken($token); return $this->validateAuthenticatedUser( $api_request, $user); } // For intracluster requests, use a public user if no authentication // information is provided. We could do this safely for any request, // but making the API fully public means there's no way to disable badly // behaved clients. if (PhabricatorEnv::isClusterRemoteAddress()) { if (PhabricatorEnv::getEnvConfig('policy.allow-public')) { $api_request->setIsClusterRequest(true); $user = new PhabricatorUser(); return $this->validateAuthenticatedUser( $api_request, $user); } } // Handle sessionless auth. // TODO: This is super messy. // TODO: Remove this in favor of token-based auth. if (isset($metadata['authUser'])) { $user = id(new PhabricatorUser())->loadOneWhere( 'userName = %s', $metadata['authUser']); if (!$user) { return array( 'ERR-INVALID-AUTH', pht('Authentication is invalid.'), ); } $token = idx($metadata, 'authToken'); $signature = idx($metadata, 'authSignature'); $certificate = $user->getConduitCertificate(); $hash = sha1($token.$certificate); if (!phutil_hashes_are_identical($hash, $signature)) { return array( 'ERR-INVALID-AUTH', pht('Authentication is invalid.'), ); } return $this->validateAuthenticatedUser( $api_request, $user); } // Handle session-based auth. // TODO: Remove this in favor of token-based auth. $session_key = idx($metadata, 'sessionKey'); if (!$session_key) { return array( 'ERR-INVALID-SESSION', pht('Session key is not present.'), ); } $user = id(new PhabricatorAuthSessionEngine()) ->loadUserForSession(PhabricatorAuthSession::TYPE_CONDUIT, $session_key); if (!$user) { return array( 'ERR-INVALID-SESSION', pht('Session key is invalid.'), ); } return $this->validateAuthenticatedUser( $api_request, $user); }
Authenticate the client making the request to a Phabricator user account. @param ConduitAPIRequest $api_request Request being executed. @param dict $metadata Request metadata. @param wild $method @return null|pair Null to indicate successful authentication, or an error code and error message pair.
authenticateUser
php
phorgeit/phorge
src/applications/conduit/controller/PhabricatorConduitAPIController.php
https://github.com/phorgeit/phorge/blob/master/src/applications/conduit/controller/PhabricatorConduitAPIController.php
Apache-2.0
protected function shouldGroupTransactions( PhabricatorApplicationTransaction $u, PhabricatorApplicationTransaction $v) { if ($u->getAuthorPHID() != $v->getAuthorPHID()) { // Don't group transactions by different authors. return false; } if (($v->getDateCreated() - $u->getDateCreated()) > 60) { // Don't group if transactions that happened more than 60s apart. return false; } switch ($u->getTransactionType()) { case PhabricatorTransactions::TYPE_COMMENT: case PhabricatorAuditActionConstants::INLINE: break; default: return false; } switch ($v->getTransactionType()) { case PhabricatorAuditActionConstants::INLINE: return true; } return parent::shouldGroupTransactions($u, $v); }
TODO: This shares a lot of code with Differential and Pholio and should probably be merged up.
shouldGroupTransactions
php
phorgeit/phorge
src/applications/audit/view/PhabricatorAuditTransactionView.php
https://github.com/phorgeit/phorge/blob/master/src/applications/audit/view/PhabricatorAuditTransactionView.php
Apache-2.0
public function getPanelURI($path = '') { $app_key = get_class($this->getApplication()); $panel_key = $this->getPanelKey(); $base = "/applications/panel/{$app_key}/{$panel_key}/"; return $base.ltrim($path, '/'); }
Get the URI for this application configuration panel. @param string $path (optional) Path to append. @return string Relative URI for the panel.
getPanelURI
php
phorgeit/phorge
src/applications/meta/panel/PhabricatorApplicationConfigurationPanel.php
https://github.com/phorgeit/phorge/blob/master/src/applications/meta/panel/PhabricatorApplicationConfigurationPanel.php
Apache-2.0
public function getQueryApplicationClass() { return null; }
NOTE: Although this belongs to the "Applications" application, trying to filter its results just leaves us recursing indefinitely. Users always have access to applications regardless of other policy settings anyway.
getQueryApplicationClass
php
phorgeit/phorge
src/applications/meta/query/PhabricatorApplicationApplicationTransactionQuery.php
https://github.com/phorgeit/phorge/blob/master/src/applications/meta/query/PhabricatorApplicationApplicationTransactionQuery.php
Apache-2.0
public function isUserActivated() { if (!$this->isLoggedIn()) { return false; } if ($this->isOmnipotent()) { return true; } if ($this->getIsDisabled()) { return false; } if (!$this->getIsApproved()) { return false; } if (PhabricatorUserEmail::isEmailVerificationRequired()) { if (!$this->getIsEmailVerified()) { return false; } } return true; }
Is this a live account which has passed required approvals? Returns true if this is an enabled, verified (if required), approved (if required) account, and false otherwise. @return bool True if this is a standard, usable account.
isUserActivated
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function isResponsive() { if (!$this->isUserActivated()) { return false; } if (!$this->getIsEmailVerified()) { return false; } return true; }
Is this a user who we can reasonably expect to respond to requests? This is used to provide a grey "disabled/unresponsive" dot cue when rendering handles and tags, so it isn't a surprise if you get ignored when you ask things of users who will not receive notifications or could not respond to them (because they are disabled, unapproved, do not have verified email addresses, etc). @return bool True if this user can receive and respond to requests from other humans.
isResponsive
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function getIsStandardUser() { $type_user = PhabricatorPeopleUserPHIDType::TYPECONST; return $this->getPHID() && (phid_get_type($this->getPHID()) == $type_user); }
Returns `true` if this is a standard user who is logged in. Returns `false` for logged out, anonymous, or external users. @return bool `true` if the user is a standard user who is logged in with a normal session.
getIsStandardUser
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
private function cleanUpProfile() { $this->profile->setBlurb(''); }
This function removes the blurb from a profile. This is an incredibly broad hammer to handle some spam on the upstream, which will be refined later. @return void
cleanUpProfile
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function compareUserSetting($key, $value) { $actual = $this->getUserSetting($key); return ($actual == $value); }
Test if a given setting is set to a particular value. @param string $key Setting key constant. @param wild $value Value to compare. @return bool True if the setting has the specified value. @task settings
compareUserSetting
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function overrideTimezoneIdentifier($identifier) { $timezone_key = PhabricatorTimezoneSetting::SETTINGKEY; $this->settingCacheKeys[$timezone_key] = true; $this->settingCache[$timezone_key] = $identifier; return $this; }
Override the user's timezone identifier. This is primarily useful for unit tests. @param string $identifier New timezone identifier. @return $this @task settings
overrideTimezoneIdentifier
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public static function loadOneWithVerifiedEmailAddress($address) { $email = id(new PhabricatorUserEmail())->loadOneWhere( 'address = %s AND isVerified = 1', $address); if (!$email) { return null; } return id(new self())->loadOneWhere( 'phid = %s', $email->getUserPHID()); }
Load one user from their verified email address. @param string $address @return PhabricatorUser|null
loadOneWithVerifiedEmailAddress
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public static function loadOneWithEmailAddress($address) { $email = id(new PhabricatorUserEmail())->loadOneWhere( 'address = %s', $address); if (!$email) { return null; } return id(new PhabricatorUser())->loadOneWhere( 'phid = %s', $email->getUserPHID()); }
Load one user from their potentially unverified email address. @param string $address @return PhabricatorUser|null
loadOneWithEmailAddress
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function attachAvailability(array $availability) { $this->availability = $availability; return $this; }
@task availability
attachAvailability
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function getAwayUntil() { $availability = $this->availability; $this->assertAttached($availability); if (!$availability) { return null; } return idx($availability, 'until'); }
Get the timestamp the user is away until, if they are currently away. @return int|null Epoch timestamp, or `null` if the user is not away. @task availability
getAwayUntil
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function getAvailabilityCache() { $now = PhabricatorTime::getNow(); if ($this->availabilityCacheTTL <= $now) { return null; } try { return phutil_json_decode($this->availabilityCache); } catch (Exception $ex) { return null; } }
Get cached availability, if present. @return wild|null Cache data, or null if no cache is available. @task availability
getAvailabilityCache
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function writeAvailabilityCache(array $availability, $ttl) { if (PhabricatorEnv::isReadOnly()) { return $this; } $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); queryfx( $this->establishConnection('w'), 'UPDATE %T SET availabilityCache = %s, availabilityCacheTTL = %nd WHERE id = %d', $this->getTableName(), phutil_json_encode($availability), $ttl, $this->getID()); unset($unguarded); return $this; }
Write to the availability cache. @param wild $availability Availability cache data. @param int|null $ttl Cache TTL. @return $this @task availability
writeAvailabilityCache
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function updateMultiFactorEnrollment() { $factors = id(new PhabricatorAuthFactorConfigQuery()) ->setViewer($this) ->withUserPHIDs(array($this->getPHID())) ->withFactorProviderStatuses( array( PhabricatorAuthFactorProviderStatus::STATUS_ACTIVE, PhabricatorAuthFactorProviderStatus::STATUS_DEPRECATED, )) ->execute(); $enrolled = count($factors) ? 1 : 0; if ($enrolled !== $this->isEnrolledInMultiFactor) { $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); queryfx( $this->establishConnection('w'), 'UPDATE %T SET isEnrolledInMultiFactor = %d WHERE id = %d', $this->getTableName(), $enrolled, $this->getID()); unset($unguarded); $this->isEnrolledInMultiFactor = $enrolled; } }
Update the flag storing this user's enrollment in multi-factor auth. With certain settings, we need to check if a user has MFA on every page, so we cache MFA enrollment on the user object for performance. Calling this method synchronizes the cache by examining enrollment records. After updating the cache, use @{method:getIsEnrolledInMultiFactor} to check if the user is enrolled. This method should be called after any changes are made to a given user's multi-factor configuration. @return void @task factors
updateMultiFactorEnrollment
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function getIsEnrolledInMultiFactor() { return $this->isEnrolledInMultiFactor; }
Check if the user is enrolled in multi-factor authentication. Enrolled users have one or more multi-factor authentication sources attached to their account. For performance, this value is cached. You can use @{method:updateMultiFactorEnrollment} to update the cache. @return bool True if the user is enrolled. @task factors
getIsEnrolledInMultiFactor
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function isOmnipotent() { return $this->omnipotent; }
Returns true if this user is omnipotent. Omnipotent users bypass all policy checks. @return bool True if the user bypasses policy checks.
isOmnipotent
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public static function getOmnipotentUser() { static $user = null; if (!$user) { $user = new PhabricatorUser(); $user->omnipotent = true; $user->makeEphemeral(); } return $user; }
Get an omnipotent user object for use in contexts where there is no acting user, notably daemons. @return PhabricatorUser An omnipotent user.
getOmnipotentUser
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function getCacheFragment() { if ($this->isOmnipotent()) { return 'u.omnipotent'; } $phid = $this->getPHID(); if ($phid) { return 'u.'.$phid; } return 'u.public'; }
Get a scalar string identifying this user. This is similar to using the PHID, but distinguishes between omnipotent and public users explicitly. This allows safe construction of cache keys or cache buckets which do not conflate public and omnipotent users. @return string Scalar identifier.
getCacheFragment
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function loadHandles(array $phids) { if ($this->handlePool === null) { $this->handlePool = id(new PhabricatorHandlePool()) ->setViewer($this); } return $this->handlePool->newHandleList($phids); }
Get a @{class:PhabricatorHandleList} which benefits from this viewer's internal handle pool. @param list<string> $phids List of PHIDs to load. @return PhabricatorHandleList Handle list object. @task handle
loadHandles
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function renderHandle($phid) { return $this->loadHandles(array($phid))->renderHandle($phid); }
Get a @{class:PHUIHandleView} for a single handle. This benefits from the viewer's internal handle pool. @param string $phid PHID to render a handle for. @return PHUIHandleView View of the handle. @task handle
renderHandle
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function renderHandleList(array $phids) { return $this->loadHandles($phids)->renderList(); }
Get a @{class:PHUIHandleListView} for a list of handles. This benefits from the viewer's internal handle pool. @param list<string> $phids List of PHIDs to render. @return PHUIHandleListView View of the handles. @task handle
renderHandleList
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function attachRawCacheData(array $data) { $this->rawCacheData = $data + $this->rawCacheData; return $this; }
@task cache
attachRawCacheData
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
protected function requireCacheData($key) { if (isset($this->usableCacheData[$key])) { return $this->usableCacheData[$key]; } $type = PhabricatorUserCacheType::requireCacheTypeForKey($key); if (isset($this->rawCacheData[$key])) { $raw_value = $this->rawCacheData[$key]; $usable_value = $type->getValueFromStorage($raw_value); $this->usableCacheData[$key] = $usable_value; return $usable_value; } // By default, we throw if a cache isn't available. This is consistent // with the standard `needX()` + `attachX()` + `getX()` interaction. if (!$this->allowInlineCacheGeneration) { throw new PhabricatorDataNotAttachedException($this); } $user_phid = $this->getPHID(); // Try to read the actual cache before we generate a new value. We can // end up here via Conduit, which does not use normal sessions and can // not pick up a free cache load during session identification. if ($user_phid) { $raw_data = PhabricatorUserCache::readCaches( $type, $key, array($user_phid)); if (array_key_exists($user_phid, $raw_data)) { $raw_value = $raw_data[$user_phid]; $usable_value = $type->getValueFromStorage($raw_value); $this->rawCacheData[$key] = $raw_value; $this->usableCacheData[$key] = $usable_value; return $usable_value; } } $usable_value = $type->getDefaultValue(); if ($user_phid) { $map = $type->newValueForUsers($key, array($this)); if (array_key_exists($user_phid, $map)) { $raw_value = $map[$user_phid]; $usable_value = $type->getValueFromStorage($raw_value); $this->rawCacheData[$key] = $raw_value; PhabricatorUserCache::writeCache( $type, $key, $user_phid, $raw_value); } } $this->usableCacheData[$key] = $usable_value; return $usable_value; }
@task cache
requireCacheData
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public function clearCacheData($key) { unset($this->rawCacheData[$key]); unset($this->usableCacheData[$key]); return $this; }
@task cache
clearCacheData
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUser.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUser.php
Apache-2.0
public static function isValidAddress($address) { if (strlen($address) > self::MAX_ADDRESS_LENGTH) { return false; } // Very roughly validate that this address isn't so mangled that a // reasonable piece of code might completely misparse it. In particular, // the major risks are: // // - `PhutilEmailAddress` needs to be able to extract the domain portion // from it. // - Reasonable mail adapters should be hard-pressed to interpret one // address as several addresses. // // To this end, we're roughly verifying that there's some normal text, an // "@" symbol, and then some more normal text. $email_regex = '(^[a-z0-9_+.!-]+@[a-z0-9_+:.-]+\z)i'; if (!preg_match($email_regex, $address)) { return false; } return true; }
@task restrictions
isValidAddress
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUserEmail.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUserEmail.php
Apache-2.0
public static function describeValidAddresses() { return pht( 'Email addresses should be in the form "[email protected]". The maximum '. 'length of an email address is %s characters.', new PhutilNumber(self::MAX_ADDRESS_LENGTH)); }
@task restrictions
describeValidAddresses
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUserEmail.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUserEmail.php
Apache-2.0
public static function describeAllowedAddresses() { $domains = PhabricatorEnv::getEnvConfig('auth.email-domains'); if (!$domains) { return null; } if (count($domains) == 1) { return pht('Email address must be @%s', head($domains)); } else { return pht( 'Email address must be at one of: %s', implode(', ', $domains)); } }
@task restrictions
describeAllowedAddresses
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUserEmail.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUserEmail.php
Apache-2.0
public static function isEmailVerificationRequired() { // NOTE: Configuring required email domains implies required verification. return PhabricatorEnv::getEnvConfig('auth.require-email-verification') || PhabricatorEnv::getEnvConfig('auth.email-domains'); }
Check if this install requires email verification. @return bool True if email addresses must be verified. @task restrictions
isEmailVerificationRequired
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUserEmail.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUserEmail.php
Apache-2.0
public function sendVerificationEmail(PhabricatorUser $user) { $username = $user->getUsername(); $address = $this->getAddress(); $link = PhabricatorEnv::getProductionURI($this->getVerificationURI()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $signature = null; if (!$is_serious) { $signature = pht( "Get Well Soon,\n%s", PlatformSymbols::getPlatformServerName()); } $body = sprintf( "%s\n\n%s\n\n %s\n\n%s", pht('Hi %s', $username), pht( 'Please verify that you own this email address (%s) by '. 'clicking this link:', $address), $link, $signature); id(new PhabricatorMetaMTAMail()) ->addRawTos(array($address)) ->setForceDelivery(true) ->setSubject( pht( '[%s] Email Verification', PlatformSymbols::getPlatformServerName())) ->setBody($body) ->setRelatedPHID($user->getPHID()) ->saveAndSend(); return $this; }
Send a verification email from $user to this address. @param PhabricatorUser $user The user sending the verification. @return $this @task email
sendVerificationEmail
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUserEmail.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUserEmail.php
Apache-2.0
public function sendOldPrimaryEmail( PhabricatorUser $user, PhabricatorUserEmail $new) { $username = $user->getUsername(); $old_address = $this->getAddress(); $new_address = $new->getAddress(); $body = sprintf( "%s\n\n%s\n", pht('Hi %s', $username), pht( 'This email address (%s) is no longer your primary email address. '. 'Going forward, all email will be sent to your new primary email '. 'address (%s).', $old_address, $new_address)); id(new PhabricatorMetaMTAMail()) ->addRawTos(array($old_address)) ->setForceDelivery(true) ->setSubject( pht( '[%s] Primary Address Changed', PlatformSymbols::getPlatformServerName())) ->setBody($body) ->setFrom($user->getPHID()) ->setRelatedPHID($user->getPHID()) ->saveAndSend(); }
Send a notification email from $user to this address, informing the recipient that this is no longer their account's primary address. @param PhabricatorUser $user The user sending the notification. @param PhabricatorUserEmail $new New primary email address. @task email
sendOldPrimaryEmail
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUserEmail.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUserEmail.php
Apache-2.0
public function sendNewPrimaryEmail(PhabricatorUser $user) { $username = $user->getUsername(); $new_address = $this->getAddress(); $body = sprintf( "%s\n\n%s\n", pht('Hi %s', $username), pht( 'This is now your primary email address (%s). Going forward, '. 'all email will be sent here.', $new_address)); id(new PhabricatorMetaMTAMail()) ->addRawTos(array($new_address)) ->setForceDelivery(true) ->setSubject( pht( '[%s] Primary Address Changed', PlatformSymbols::getPlatformServerName())) ->setBody($body) ->setFrom($user->getPHID()) ->setRelatedPHID($user->getPHID()) ->saveAndSend(); return $this; }
Send a notification email from $user to this address, informing the recipient that this is now their account's new primary email address. @param PhabricatorUser $user The user sending the verification. @return $this @task email
sendNewPrimaryEmail
php
phorgeit/phorge
src/applications/people/storage/PhabricatorUserEmail.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorUserEmail.php
Apache-2.0
public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); }
TODO: These permissions aren't very good. They should just be the same as the associated ExternalAccount. See T13381.
getCapabilities
php
phorgeit/phorge
src/applications/people/storage/PhabricatorExternalAccountIdentifier.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/storage/PhabricatorExternalAccountIdentifier.php
Apache-2.0
public function buildSideNavView($for_app = false) { // we are on /people/* $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $viewer = $this->getRequest()->getUser(); id(new PhabricatorPeopleSearchEngine()) ->setViewer($viewer) ->addNavigationItems($nav->getMenu()); if ($viewer->getIsAdmin()) { $nav->addLabel(pht('User Administration')); $nav->addFilter('logs', pht('Activity Logs')); $nav->addFilter('invite', pht('Email Invitations')); } return $nav; }
return AphrontSideNavFilterView
buildSideNavView
php
phorgeit/phorge
src/applications/people/controller/PhabricatorPeopleController.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/controller/PhabricatorPeopleController.php
Apache-2.0
public function createNewUser( PhabricatorUser $user, PhabricatorUserEmail $email, $allow_reassign = false) { if ($user->getID()) { throw new Exception(pht('User has already been created!')); } $is_reassign = false; if ($email->getID()) { if ($allow_reassign) { if ($email->getIsPrimary()) { throw new Exception( pht('Primary email addresses can not be reassigned.')); } $is_reassign = true; } else { throw new Exception(pht('Email has already been created!')); } } if (!PhabricatorUser::validateUsername($user->getUsername())) { $valid = PhabricatorUser::describeValidUsername(); throw new Exception(pht('Username is invalid! %s', $valid)); } // Always set a new user's email address to primary. $email->setIsPrimary(1); // If the primary address is already verified, also set the verified flag // on the user themselves. if ($email->getIsVerified()) { $user->setIsEmailVerified(1); } $this->willAddEmail($email); $user->openTransaction(); try { $user->save(); $email->setUserPHID($user->getPHID()); $email->save(); } catch (AphrontDuplicateKeyQueryException $ex) { // We might have written the user but failed to write the email; if // so, erase the IDs we attached. $user->setID(null); $user->setPHID(null); $user->killTransaction(); throw $ex; } if ($is_reassign) { $log = PhabricatorUserLog::initializeNewLog( $this->requireActor(), $user->getPHID(), PhabricatorReassignEmailUserLogType::LOGTYPE); $log->setNewValue($email->getAddress()); $log->save(); } $user->saveTransaction(); if ($email->getIsVerified()) { $this->didVerifyEmail($user, $email); } id(new DiffusionRepositoryIdentityEngine()) ->didUpdateEmailAddress($email->getAddress()); return $this; }
@task edit
createNewUser
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
public function makeSystemAgentUser(PhabricatorUser $user, $system_agent) { $actor = $this->requireActor(); if (!$user->getID()) { throw new Exception(pht('User has not been created yet!')); } $user->openTransaction(); $user->beginWriteLocking(); $user->reload(); if ($user->getIsSystemAgent() == $system_agent) { $user->endWriteLocking(); $user->killTransaction(); return $this; } $user->setIsSystemAgent((int)$system_agent); $user->save(); $user->endWriteLocking(); $user->saveTransaction(); return $this; }
@task role
makeSystemAgentUser
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
public function makeMailingListUser(PhabricatorUser $user, $mailing_list) { $actor = $this->requireActor(); if (!$user->getID()) { throw new Exception(pht('User has not been created yet!')); } $user->openTransaction(); $user->beginWriteLocking(); $user->reload(); if ($user->getIsMailingList() == $mailing_list) { $user->endWriteLocking(); $user->killTransaction(); return $this; } $user->setIsMailingList((int)$mailing_list); $user->save(); $user->endWriteLocking(); $user->saveTransaction(); return $this; }
@task role
makeMailingListUser
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
public function addEmail( PhabricatorUser $user, PhabricatorUserEmail $email) { $actor = $this->requireActor(); if (!$user->getID()) { throw new Exception(pht('User has not been created yet!')); } if ($email->getID()) { throw new Exception(pht('Email has already been created!')); } // Use changePrimaryEmail() to change primary email. $email->setIsPrimary(0); $email->setUserPHID($user->getPHID()); $this->willAddEmail($email); $user->openTransaction(); $user->beginWriteLocking(); $user->reload(); try { $email->save(); } catch (AphrontDuplicateKeyQueryException $ex) { $user->endWriteLocking(); $user->killTransaction(); throw $ex; } $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), PhabricatorAddEmailUserLogType::LOGTYPE); $log->setNewValue($email->getAddress()); $log->save(); $user->endWriteLocking(); $user->saveTransaction(); id(new DiffusionRepositoryIdentityEngine()) ->didUpdateEmailAddress($email->getAddress()); return $this; }
@task email
addEmail
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
public function removeEmail( PhabricatorUser $user, PhabricatorUserEmail $email) { $actor = $this->requireActor(); if (!$user->getID()) { throw new Exception(pht('User has not been created yet!')); } if (!$email->getID()) { throw new Exception(pht('Email has not been created yet!')); } $user->openTransaction(); $user->beginWriteLocking(); $user->reload(); $email->reload(); if ($email->getIsPrimary()) { throw new Exception(pht("Can't remove primary email!")); } if ($email->getUserPHID() != $user->getPHID()) { throw new Exception(pht('Email not owned by user!')); } $destruction_engine = id(new PhabricatorDestructionEngine()) ->setWaitToFinalizeDestruction(true) ->destroyObject($email); $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), PhabricatorRemoveEmailUserLogType::LOGTYPE); $log->setOldValue($email->getAddress()); $log->save(); $user->endWriteLocking(); $user->saveTransaction(); $this->revokePasswordResetLinks($user); $destruction_engine->finalizeDestruction(); return $this; }
@task email
removeEmail
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
public function changePrimaryEmail( PhabricatorUser $user, PhabricatorUserEmail $email) { $actor = $this->requireActor(); if (!$user->getID()) { throw new Exception(pht('User has not been created yet!')); } if (!$email->getID()) { throw new Exception(pht('Email has not been created yet!')); } $user->openTransaction(); $user->beginWriteLocking(); $user->reload(); $email->reload(); if ($email->getUserPHID() != $user->getPHID()) { throw new Exception(pht('User does not own email!')); } if ($email->getIsPrimary()) { throw new Exception(pht('Email is already primary!')); } if (!$email->getIsVerified()) { throw new Exception(pht('Email is not verified!')); } $old_primary = $user->loadPrimaryEmail(); if ($old_primary) { $old_primary->setIsPrimary(0); $old_primary->save(); } $email->setIsPrimary(1); $email->save(); // If the user doesn't have the verified flag set on their account // yet, set it. We've made sure the email is verified above. See // T12635 for discussion. if (!$user->getIsEmailVerified()) { $user->setIsEmailVerified(1); $user->save(); } $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), PhabricatorPrimaryEmailUserLogType::LOGTYPE); $log->setOldValue($old_primary ? $old_primary->getAddress() : null); $log->setNewValue($email->getAddress()); $log->save(); $user->endWriteLocking(); $user->saveTransaction(); if ($old_primary) { $old_primary->sendOldPrimaryEmail($user, $email); } $email->sendNewPrimaryEmail($user); $this->revokePasswordResetLinks($user); return $this; }
@task email
changePrimaryEmail
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
public function verifyEmail( PhabricatorUser $user, PhabricatorUserEmail $email) { $actor = $this->requireActor(); if (!$user->getID()) { throw new Exception(pht('User has not been created yet!')); } if (!$email->getID()) { throw new Exception(pht('Email has not been created yet!')); } $user->openTransaction(); $user->beginWriteLocking(); $user->reload(); $email->reload(); if ($email->getUserPHID() != $user->getPHID()) { throw new Exception(pht('User does not own email!')); } if (!$email->getIsVerified()) { $email->setIsVerified(1); $email->save(); $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), PhabricatorVerifyEmailUserLogType::LOGTYPE); $log->setNewValue($email->getAddress()); $log->save(); } if (!$user->getIsEmailVerified()) { // If the user just verified their primary email address, mark their // account as email verified. $user_primary = $user->loadPrimaryEmail(); if ($user_primary->getID() == $email->getID()) { $user->setIsEmailVerified(1); $user->save(); } } $user->endWriteLocking(); $user->saveTransaction(); $this->didVerifyEmail($user, $email); }
Verify a user's email address. This verifies an individual email address. If the address is the user's primary address and their account was not previously verified, their account is marked as email verified. @task email
verifyEmail
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
public function reassignEmail( PhabricatorUser $user, PhabricatorUserEmail $email) { $actor = $this->requireActor(); if (!$user->getID()) { throw new Exception(pht('User has not been created yet!')); } if (!$email->getID()) { throw new Exception(pht('Email has not been created yet!')); } $user->openTransaction(); $user->beginWriteLocking(); $user->reload(); $email->reload(); $old_user = $email->getUserPHID(); if ($old_user != $user->getPHID()) { if ($email->getIsVerified()) { throw new Exception( pht('Verified email addresses can not be reassigned.')); } if ($email->getIsPrimary()) { throw new Exception( pht('Primary email addresses can not be reassigned.')); } $email->setUserPHID($user->getPHID()); $email->save(); $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), PhabricatorReassignEmailUserLogType::LOGTYPE); $log->setNewValue($email->getAddress()); $log->save(); } $user->endWriteLocking(); $user->saveTransaction(); id(new DiffusionRepositoryIdentityEngine()) ->didUpdateEmailAddress($email->getAddress()); }
Reassign an unverified email address.
reassignEmail
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
private function willAddEmail(PhabricatorUserEmail $email) { // Hard check before write to prevent creation of disallowed email // addresses. Normally, the application does checks and raises more // user friendly errors for us, but we omit the courtesy checks on some // pathways like administrative scripts for simplicity. if (!PhabricatorUserEmail::isValidAddress($email->getAddress())) { throw new Exception(PhabricatorUserEmail::describeValidAddresses()); } if (!PhabricatorUserEmail::isAllowedAddress($email->getAddress())) { throw new Exception(PhabricatorUserEmail::describeAllowedAddresses()); } $application_email = id(new PhabricatorMetaMTAApplicationEmailQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withAddresses(array($email->getAddress())) ->executeOne(); if ($application_email) { throw new Exception($application_email->getInUseMessage()); } }
@task internal
willAddEmail
php
phorgeit/phorge
src/applications/people/editor/PhabricatorUserEditor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/people/editor/PhabricatorUserEditor.php
Apache-2.0
public static function getObjectSpacePHID($object) { if (!$object) { return null; } if (!($object instanceof PhabricatorSpacesInterface)) { return null; } $space_phid = $object->getSpacePHID(); if ($space_phid === null) { $default_space = self::getDefaultSpace(); if ($default_space) { $space_phid = $default_space->getPHID(); } } return $space_phid; }
Get the Space PHID for an object, if one exists. This is intended to simplify performing a bunch of redundant checks; you can intentionally pass any value in (including `null`). @param wild $object @return string|null Space PHID of the object, or null.
getObjectSpacePHID
php
phorgeit/phorge
src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php
https://github.com/phorgeit/phorge/blob/master/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php
Apache-2.0
final protected function isRenderingTargetExternal() { // Right now, this is our best proxy for this: return $this->isTextMode(); // "TARGET_TEXT" means "EMail" and "TARGET_HTML" means "Web". }
When rendering to external targets (Email/Asana/etc), we need to include more information that users can't obtain later.
isRenderingTargetExternal
php
phorgeit/phorge
src/applications/transactions/storage/PhabricatorModularTransactionType.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/storage/PhabricatorModularTransactionType.php
Apache-2.0
public function getRequiredCapabilities( $object, PhabricatorApplicationTransaction $xaction) { return PhabricatorPolicyCapability::CAN_EDIT; }
Get a list of capabilities the actor must have on the object to apply a transaction to it. Usually, you should use this to reduce capability requirements when a transaction (like leaving a Conpherence thread) can be applied without having edit permission on the object. You can override this method to remove the CAN_EDIT requirement, or to replace it with a different requirement. If you are increasing capability requirements and need to add an additional capability or policy requirement above and beyond CAN_EDIT, it is usually better implemented as a validation check. @param object $object Object being edited. @param PhabricatorApplicationTransaction $xaction Transaction being applied. @return null|const|list<const> A capability constant (or list of capability constants) which the actor must have on the object. You can return `null` as a shorthand for "no capabilities are required".
getRequiredCapabilities
php
phorgeit/phorge
src/applications/transactions/storage/PhabricatorModularTransactionType.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/storage/PhabricatorModularTransactionType.php
Apache-2.0
final public function getTitleForTextMail() { return $this->getTitleForMailWithRenderingTarget( PhabricatorApplicationTransaction::TARGET_TEXT); }
NOTE: See T12921. These APIs are somewhat aspirational. For now, all of these use "TARGET_TEXT" (even the HTML methods!) and the body methods actually return Remarkup, not text or HTML.
getTitleForTextMail
php
phorgeit/phorge
src/applications/transactions/storage/PhabricatorModularTransactionType.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/storage/PhabricatorModularTransactionType.php
Apache-2.0
public function getIsRemoved() { return ($this->getIsDeleted() == 2); }
Whether the transaction removes the comment @return bool True if the transaction removes the comment
getIsRemoved
php
phorgeit/phorge
src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php
Apache-2.0
public function setIgnoreOnNoEffect($ignore) { $this->ignoreOnNoEffect = $ignore; return $this; }
Flag this transaction as a pure side-effect which should be ignored when applying transactions if it has no effect, even if transaction application would normally fail. This both provides users with better error messages and allows transactions to perform optional side effects.
setIgnoreOnNoEffect
php
phorgeit/phorge
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Apache-2.0
public function getRemarkupBlocks() { $blocks = array(); switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_CUSTOMFIELD: $field = $this->getTransactionCustomField(); if ($field) { $custom_blocks = $field->getApplicationTransactionRemarkupBlocks( $this); foreach ($custom_blocks as $custom_block) { $blocks[] = $custom_block; } } break; } return $blocks; }
@deprecated
getRemarkupBlocks
php
phorgeit/phorge
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Apache-2.0
public function isCommentTransaction() { if ($this->hasComment()) { return true; } switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_COMMENT: return true; } return false; }
Whether the transaction concerns a comment (e.g. add, edit, remove) @return bool True if the transaction concerns a comment
isCommentTransaction
php
phorgeit/phorge
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Apache-2.0
private function isSelfSubscription() { $type = $this->getTransactionType(); if ($type != PhabricatorTransactions::TYPE_SUBSCRIBERS) { return false; } $old = $this->getOldValue(); $new = $this->getNewValue(); $add = array_diff($old, $new); $rem = array_diff($new, $old); if ((count($add) + count($rem)) != 1) { // More than one user affected. return false; } $affected_phid = head(array_merge($add, $rem)); if ($affected_phid != $this->getAuthorPHID()) { // Affected user is someone else. return false; } return true; }
Test if this transaction is just a user subscribing or unsubscribing themselves.
isSelfSubscription
php
phorgeit/phorge
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Apache-2.0
public static function findOneByType($xactions, $type) { foreach ($xactions as $xaction) { if ($xaction->getTransactionType() === $type) { return $xaction; } } return null; }
Find the first transaction that matches a type. @param array $xactions @param string $type @return PhabricatorTransactions|null
findOneByType
php
phorgeit/phorge
src/applications/transactions/constants/PhabricatorTransactions.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/constants/PhabricatorTransactions.php
Apache-2.0
protected function doWork() { $object = $this->loadObject(); $editor = $this->buildEditor($object); $xactions = $this->loadTransactions($object); $editor->publishTransactions($object, $xactions); }
Publish information about a set of transactions.
doWork
php
phorgeit/phorge
src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
Apache-2.0
private function loadObject() { $viewer = PhabricatorUser::getOmnipotentUser(); $data = $this->getTaskData(); if (!is_array($data)) { throw new PhabricatorWorkerPermanentFailureException( pht('Task has invalid task data.')); } $phid = idx($data, 'objectPHID'); if (!$phid) { throw new PhabricatorWorkerPermanentFailureException( pht('Task has no object PHID!')); } $object = id(new PhabricatorObjectQuery()) ->setViewer($viewer) ->withPHIDs(array($phid)) ->executeOne(); if (!$object) { throw new PhabricatorWorkerPermanentFailureException( pht( 'Unable to load object with PHID "%s"!', $phid)); } return $object; }
Load the object the transactions affect.
loadObject
php
phorgeit/phorge
src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
Apache-2.0
private function buildEditor( PhabricatorApplicationTransactionInterface $object) { $data = $this->getTaskData(); $daemon_source = $this->newContentSource(); $viewer = PhabricatorUser::getOmnipotentUser(); $editor = $object->getApplicationTransactionEditor() ->setActor($viewer) ->setContentSource($daemon_source) ->setActingAsPHID(idx($data, 'actorPHID')) ->loadWorkerState(idx($data, 'state', array())); return $editor; }
Build and configure an Editor to publish these transactions.
buildEditor
php
phorgeit/phorge
src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
Apache-2.0
private function loadTransactions( PhabricatorApplicationTransactionInterface $object) { $data = $this->getTaskData(); $xaction_phids = idx($data, 'xactionPHIDs'); if (!$xaction_phids) { // It's okay if we don't have any transactions. This can happen when // creating objects or performing no-op updates. We will still apply // meaningful side effects like updating search engine indexes. return array(); } $viewer = PhabricatorUser::getOmnipotentUser(); $query = PhabricatorApplicationTransactionQuery::newQueryForObject($object); if (!$query) { throw new PhabricatorWorkerPermanentFailureException( pht( 'Unable to load query for transaction object "%s"!', $object->getPHID())); } $xactions = $query ->setViewer($viewer) ->withPHIDs($xaction_phids) ->needComments(true) ->execute(); $xactions = mpull($xactions, null, 'getPHID'); $missing = array_diff($xaction_phids, array_keys($xactions)); if ($missing) { throw new PhabricatorWorkerPermanentFailureException( pht( 'Unable to load transactions: %s.', implode(', ', $missing))); } return array_select_keys($xactions, $xaction_phids); }
Load the transactions to be published.
loadTransactions
php
phorgeit/phorge
src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
Apache-2.0
public function setConduitDocumentation($conduit_documentation) { $this->conduitDocumentation = $conduit_documentation; return $this; }
Set the Conduit documentation in raw Remarkup. @param string|null $conduit_documentation @return self
setConduitDocumentation
php
phorgeit/phorge
src/applications/transactions/editfield/PhabricatorEditField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editfield/PhabricatorEditField.php
Apache-2.0
public function getConduitDocumentation() { return $this->conduitDocumentation; }
Get the Conduit documentation in raw Remarkup. @return string|null
getConduitDocumentation
php
phorgeit/phorge
src/applications/transactions/editfield/PhabricatorEditField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editfield/PhabricatorEditField.php
Apache-2.0
protected function getInitialValueFromSubmit(AphrontRequest $request, $key) { return null; }
Read and return the value the object had when the user first loaded the form. This is the initial value from the user's point of view when they started the edit process, and used primarily to prevent race conditions for fields like "Projects" and "Subscribers" that use tokenizers and support edge transactions. Most fields do not need to store these values or deal with initial value handling. @param AphrontRequest $request Request to read from. @param string $key Key to read. @return wild|null Value read from request.
getInitialValueFromSubmit
php
phorgeit/phorge
src/applications/transactions/editfield/PhabricatorEditField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editfield/PhabricatorEditField.php
Apache-2.0
public function setObject($object) { $this->object = $object; return $this; }
Set object in which this comment textarea field is displayed
setObject
php
phorgeit/phorge
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
Apache-2.0