Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93597726
PhabricatorSearchUsersField.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 30, 01:22
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Dec 2, 01:22 (2 d)
Engine
blob
Format
Raw Data
Handle
22673277
Attached To
rPH Phabricator
PhabricatorSearchUsersField.php
View Options
<?php
final
class
PhabricatorSearchUsersField
extends
PhabricatorSearchTokenizerField
{
protected
function
getDefaultValue
()
{
return
array
();
}
protected
function
newDatasource
()
{
// TODO: Make this use PhabricatorPeopleUserFunctionDatasource once field
// support is a little more powerful.
return
new
PhabricatorPeopleDatasource
();
}
protected
function
getValueFromRequest
(
AphrontRequest
$request
,
$key
)
{
$list
=
$this
->
getListFromRequest
(
$request
,
$key
);
$allow_types
=
array
();
$phids
=
array
();
$names
=
array
();
$allow_types
=
array_fuse
(
$allow_types
);
$user_type
=
PhabricatorPeopleUserPHIDType
::
TYPECONST
;
foreach
(
$list
as
$item
)
{
$type
=
phid_get_type
(
$item
);
if
(
$type
==
$user_type
)
{
$phids
[]
=
$item
;
}
else
if
(
isset
(
$allow_types
[
$type
]))
{
$phids
[]
=
$item
;
}
else
{
if
(
PhabricatorTypeaheadDatasource
::
isFunctionToken
(
$item
))
{
// If this is a function, pass it through unchanged; we'll evaluate
// it later.
$phids
[]
=
$item
;
}
else
{
$names
[]
=
$item
;
}
}
}
if
(
$names
)
{
$users
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withUsernames
(
$names
)
->
execute
();
foreach
(
$users
as
$user
)
{
$phids
[]
=
$user
->
getPHID
();
}
$phids
=
array_unique
(
$phids
);
}
return
$phids
;
}
}
Event Timeline
Log In to Comment