本文整理汇总了PHP中PhabricatorUser::isLoggedIn方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorUser::isLoggedIn方法的具体用法?PHP PhabricatorUser::isLoggedIn怎么用?PHP PhabricatorUser::isLoggedIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorUser
的用法示例。
在下文中一共展示了PhabricatorUser::isLoggedIn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadNeedAttentionRevisions
public static function loadNeedAttentionRevisions(PhabricatorUser $viewer)
{
if (!$viewer->isLoggedIn()) {
return array();
}
$viewer_phid = $viewer->getPHID();
$responsible_phids = id(new DifferentialResponsibleDatasource())->setViewer($viewer)->evaluateTokens(array($viewer_phid));
$revision_query = id(new DifferentialRevisionQuery())->setViewer($viewer)->withStatus(DifferentialRevisionQuery::STATUS_OPEN)->withResponsibleUsers($responsible_phids)->needReviewerStatus(true)->needRelationships(true)->needFlags(true)->needDrafts(true)->setLimit(self::MAX_STATUS_ITEMS);
$revisions = $revision_query->execute();
$query = id(new PhabricatorSavedQuery())->attachParameterMap(array('responsiblePHIDs' => $responsible_phids));
$groups = id(new DifferentialRevisionRequiredActionResultBucket())->setViewer($viewer)->newResultGroups($query, $revisions);
$include = array();
foreach ($groups as $group) {
switch ($group->getKey()) {
case DifferentialRevisionRequiredActionResultBucket::KEY_MUSTREVIEW:
case DifferentialRevisionRequiredActionResultBucket::KEY_SHOULDREVIEW:
foreach ($group->getObjects() as $object) {
$include[] = $object;
}
break;
default:
break;
}
}
return $include;
}
示例2: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$items = array();
if ($user->isLoggedIn() && $user->isUserActivated()) {
$selected = $controller instanceof PhabricatorSettingsMainController;
$item = id(new PHUIListItemView())->setName(pht('Settings'))->setIcon('settings-sm')->addClass('core-menu-item')->setSelected($selected)->setHref('/settings/')->setAural(pht('Settings'))->setOrder(400);
$items[] = $item;
}
return $items;
}
示例3: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$items = array();
if ($user->isLoggedIn() && $user->isUserActivated()) {
$create_id = celerity_generate_unique_node_id();
Javelin::initBehavior('aphlict-dropdown', array('bubbleID' => $create_id, 'dropdownID' => 'phabricator-quick-create-menu', 'local' => true, 'desktop' => true, 'right' => true));
$item = id(new PHUIListItemView())->setName(pht('Create New...'))->setIcon('new-sm')->addClass('core-menu-item')->setHref('/home/create/')->addSigil('quick-create-menu')->setID($create_id)->setAural(pht('Quick Create'))->setOrder(300);
$items[] = $item;
}
return $items;
}
示例4: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$items = array();
if ($user->isLoggedIn() && $user->isUserActivated()) {
$image = $user->loadProfileImageURI();
$item = id(new PHUIListItemView())->setName($user->getUsername())->setHref('/p/' . $user->getUsername() . '/')->addClass('core-menu-item')->setAural(pht('Profile'))->setOrder(100);
$classes = array('phabricator-core-menu-icon', 'phabricator-core-menu-profile-image');
$item->appendChild(phutil_tag('span', array('class' => implode(' ', $classes), 'style' => 'background-image: url(' . $image . ')'), ''));
$items[] = $item;
}
return $items;
}
示例5: loadStatus
public function loadStatus(PhabricatorUser $user)
{
$status = array();
if (!$user->isLoggedIn()) {
return $status;
}
$query = id(new ManiphestTaskQuery())->setViewer($user)->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())->withOwners(array($user->getPHID()))->setLimit(self::MAX_STATUS_ITEMS);
$count = count($query->execute());
$count_str = self::formatStatusCount($count, '%s Assigned Tasks', '%d Assigned Task(s)');
$type = PhabricatorApplicationStatusView::TYPE_WARNING;
$status[] = id(new PhabricatorApplicationStatusView())->setType($type)->setText($count_str)->setCount($count);
return $status;
}
示例6: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$items = array();
if ($user->isLoggedIn()) {
$item = id(new PHUIListItemView())->addClass('core-menu-item')->setName(pht('Log Out'))->setIcon('logout-sm')->setWorkflow(true)->setHref('/logout/')->setSelected($controller instanceof PhabricatorLogoutController)->setAural(pht('Log Out'))->setOrder(900);
$items[] = $item;
} else {
if ($controller instanceof PhabricatorAuthController) {
// Don't show the "Login" item on auth controllers, since they're
// generally all related to logging in anyway.
} else {
$item = id(new PHUIListItemView())->addClass('core-menu-item')->setName(pht('Log In'))->setIcon('power')->setHref('/auth/start/')->setAural(pht('Log In'))->setOrder(900);
$items[] = $item;
}
}
return $items;
}
示例7: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$items = array();
if ($controller instanceof PhabricatorSettingsMainController) {
$class = 'main-menu-item-icon-settings-selected';
} else {
$class = 'main-menu-item-icon-settings';
}
if ($user->isLoggedIn()) {
$item = new PhabricatorMainMenuIconView();
$item->setName(pht('Settings'));
$item->addClass('autosprite main-menu-item-icon ' . $class);
$item->setHref('/settings/');
$item->setSortOrder(0.9);
$items[] = $item;
}
return $items;
}
示例8: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$items = array();
if ($controller instanceof PhabricatorLogoutController) {
$class = 'main-menu-item-icon-logout-selected';
} else {
$class = 'main-menu-item-icon-logout';
}
if ($user->isLoggedIn()) {
$item = new PhabricatorMainMenuIconView();
$item->setName(pht('Log Out'));
$item->addClass('autosprite main-menu-item-icon ' . $class);
$item->setWorkflow(true);
$item->setHref('/logout/');
$item->setSortOrder(1.0);
$items[] = $item;
}
return $items;
}
示例9: isExtensionEnabledForViewer
public function isExtensionEnabledForViewer(PhabricatorUser $viewer)
{
if (!$viewer->isLoggedIn()) {
return false;
}
if (!$viewer->isUserActivated()) {
return false;
}
// Don't show menus for users with partial sessions. This usually means
// they have logged in but have not made it through MFA, so we don't want
// to show notification counts, saved queries, etc.
if (!$viewer->hasSession()) {
return false;
}
if ($viewer->getSession()->getIsPartial()) {
return false;
}
return true;
}
示例10: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$items = array();
if ($controller instanceof PhabricatorPeopleProfileController && $controller->getProfileUser() && $controller->getProfileUser()->getPHID() == $user->getPHID()) {
$class = 'main-menu-item-icon-profile-selected';
} else {
$class = 'main-menu-item-icon-profile-not-selected';
}
if ($user->isLoggedIn()) {
$image = $user->loadProfileImageURI();
$item = new PhabricatorMainMenuIconView();
$item->setName($user->getUsername());
$item->addClass('main-menu-item-icon-profile ' . $class);
$item->addStyle('background-image: url(' . $image . ')');
$item->setHref('/p/' . $user->getUsername() . '/');
$item->setSortOrder(0.0);
$items[] = $item;
}
return $items;
}
示例11: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$items = array();
if ($user->isLoggedIn()) {
$item = id(new PHUIListItemView())->addClass('core-menu-item')->setName(pht('Log Out'))->setIcon('fa-sign-out')->setWorkflow(true)->setHref('/logout/')->setSelected($controller instanceof PhabricatorLogoutController)->setAural(pht('Log Out'))->setOrder(900);
$items[] = $item;
} else {
if ($controller instanceof PhabricatorAuthController) {
// Don't show the "Login" item on auth controllers, since they're
// generally all related to logging in anyway.
} else {
$uri = new PhutilURI('/auth/start/');
if ($controller) {
$path = $controller->getRequest()->getPath();
$uri->setQueryParam('next', $path);
}
$item = id(new PHUIListItemView())->addClass('core-menu-item')->setName(pht('Log In'))->setIcon('fa-sign-in')->setHref($uri)->setAural(pht('Log In'))->setOrder(900);
$items[] = $item;
}
}
return $items;
}
示例12: loadClusterTokenForUser
public static function loadClusterTokenForUser(PhabricatorUser $user)
{
if (!$user->isLoggedIn()) {
return null;
}
$tokens = id(new PhabricatorConduitTokenQuery())->setViewer($user)->withObjectPHIDs(array($user->getPHID()))->withTokenTypes(array(self::TYPE_CLUSTER))->withExpired(false)->execute();
// Only return a token if it has at least 5 minutes left before
// expiration. Cluster tokens cycle regularly, so we don't want to use
// one that's going to expire momentarily.
$now = PhabricatorTime::getNow();
$must_expire_after = $now + phutil_units('5 minutes in seconds');
foreach ($tokens as $token) {
if ($token->getExpires() > $must_expire_after) {
return $token;
}
}
// We didn't find any existing tokens (or the existing tokens are all about
// to expire) so generate a new token.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$token = self::initializeNewToken($user->getPHID(), self::TYPE_CLUSTER);
$token->save();
unset($unguarded);
return $token;
}
示例13: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$callsign = self::getCallsign($request);
// If authentication credentials have been provided, try to find a user
// that actually matches those credentials.
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
$username = $_SERVER['PHP_AUTH_USER'];
$password = new PhutilOpaqueEnvelope($_SERVER['PHP_AUTH_PW']);
$viewer = $this->authenticateHTTPRepositoryUser($username, $password);
if (!$viewer) {
return new PhabricatorVCSResponse(403, pht('Invalid credentials.'));
}
} else {
// User hasn't provided credentials, which means we count them as
// being "not logged in".
$viewer = new PhabricatorUser();
}
$allow_public = PhabricatorEnv::getEnvConfig('policy.allow-public');
$allow_auth = PhabricatorEnv::getEnvConfig('diffusion.allow-http-auth');
if (!$allow_public) {
if (!$viewer->isLoggedIn()) {
if ($allow_auth) {
return new PhabricatorVCSResponse(401, pht('You must log in to access repositories.'));
} else {
return new PhabricatorVCSResponse(403, pht('Public and authenticated HTTP access are both forbidden.'));
}
}
}
try {
$repository = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withCallsigns(array($callsign))->executeOne();
if (!$repository) {
return new PhabricatorVCSResponse(404, pht('No such repository exists.'));
}
} catch (PhabricatorPolicyException $ex) {
if ($viewer->isLoggedIn()) {
return new PhabricatorVCSResponse(403, pht('You do not have permission to access this repository.'));
} else {
if ($allow_auth) {
return new PhabricatorVCSResponse(401, pht('You must log in to access this repository.'));
} else {
return new PhabricatorVCSResponse(403, pht('This repository requires authentication, which is forbidden ' . 'over HTTP.'));
}
}
}
if (!$repository->isTracked()) {
return new PhabricatorVCSResponse(403, pht('This repository is inactive.'));
}
$is_push = !$this->isReadOnlyRequest($repository);
switch ($repository->getServeOverHTTP()) {
case PhabricatorRepository::SERVE_READONLY:
if ($is_push) {
return new PhabricatorVCSResponse(403, pht('This repository is read-only over HTTP.'));
}
break;
case PhabricatorRepository::SERVE_READWRITE:
if ($is_push) {
$can_push = PhabricatorPolicyFilter::hasCapability($viewer, $repository, DiffusionPushCapability::CAPABILITY);
if (!$can_push) {
if ($viewer->isLoggedIn()) {
return new PhabricatorVCSResponse(403, pht('You do not have permission to push to this repository.'));
} else {
if ($allow_auth) {
return new PhabricatorVCSResponse(401, pht('You must log in to push to this repository.'));
} else {
return new PhabricatorVCSResponse(403, pht('Pushing to this repository requires authentication, ' . 'which is forbidden over HTTP.'));
}
}
}
}
break;
case PhabricatorRepository::SERVE_OFF:
default:
return new PhabricatorVCSResponse(403, pht('This repository is not available over HTTP.'));
}
$vcs_type = $repository->getVersionControlSystem();
$req_type = $this->isVCSRequest($request);
if ($vcs_type != $req_type) {
switch ($req_type) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$result = new PhabricatorVCSResponse(500, pht('This is not a Git repository.'));
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$result = new PhabricatorVCSResponse(500, pht('This is not a Mercurial repository.'));
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$result = new PhabricatorVCSResponse(500, pht('This is not a Subversion repository.'));
break;
default:
$result = new PhabricatorVCSResponse(500, pht('Unknown request type.'));
break;
}
} else {
switch ($vcs_type) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$result = $this->serveVCSRequest($repository, $viewer);
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$result = new PhabricatorVCSResponse(500, pht('Phabricator does not support HTTP access to Subversion ' . 'repositories.'));
break;
//.........这里部分代码省略.........
示例14: shouldJoinForViewer
private function shouldJoinForViewer(PhabricatorUser $viewer)
{
if ($viewer->isLoggedIn() && $this->ids === null && $this->phids === null) {
return true;
}
return false;
}
示例15: getDisplayIconLabel
public function getDisplayIconLabel(PhabricatorUser $viewer)
{
if ($this->getIsCancelled()) {
return pht('Cancelled');
}
if ($viewer->isLoggedIn()) {
$status = $this->getUserInviteStatus($viewer->getPHID());
switch ($status) {
case PhabricatorCalendarEventInvitee::STATUS_ATTENDING:
return pht('Attending');
case PhabricatorCalendarEventInvitee::STATUS_INVITED:
return pht('Invited');
case PhabricatorCalendarEventInvitee::STATUS_DECLINED:
return pht('Declined');
}
}
return null;
}