当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorUser::getUsername方法代码示例

本文整理汇总了PHP中PhabricatorUser::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorUser::getUsername方法的具体用法?PHP PhabricatorUser::getUsername怎么用?PHP PhabricatorUser::getUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorUser的用法示例。


在下文中一共展示了PhabricatorUser::getUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:12,代码来源:PhabricatorPeopleApplication.php

示例2: buildUserInformationDictionary

 protected function buildUserInformationDictionary(PhabricatorUser $user, PhabricatorUserStatus $current_status = null)
 {
     $roles = array();
     if ($user->getIsDisabled()) {
         $roles[] = 'disabled';
     }
     if ($user->getIsSystemAgent()) {
         $roles[] = 'agent';
     }
     if ($user->getIsAdmin()) {
         $roles[] = 'admin';
     }
     $primary = $user->loadPrimaryEmail();
     if ($primary && $primary->getIsVerified()) {
         $roles[] = 'verified';
     } else {
         $roles[] = 'unverified';
     }
     $return = array('phid' => $user->getPHID(), 'userName' => $user->getUserName(), 'realName' => $user->getRealName(), 'image' => $user->loadProfileImageURI(), 'uri' => PhabricatorEnv::getURI('/p/' . $user->getUsername() . '/'), 'roles' => $roles);
     if ($current_status) {
         $return['currentStatus'] = $current_status->getTextStatus();
         $return['currentStatusUntil'] = $current_status->getDateTo();
     }
     return $return;
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:25,代码来源:ConduitAPI_user_Method.php

示例3: buildIconNavView

 public function buildIconNavView(PhabricatorUser $user)
 {
     $viewer = $this->getViewer();
     $picture = $user->getProfileImageURI();
     $name = $user->getUsername();
     $nav = new AphrontSideNavFilterView();
     $nav->setIconNav(true);
     $nav->setBaseURI(new PhutilURI('/p/'));
     $nav->addIcon("{$name}/", $name, null, $picture);
     $class = 'PhabricatorCalendarApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $nav->addIcon("{$name}/calendar/", pht('Calendar'), 'fa-calendar');
     }
     $class = 'PhabricatorManiphestApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $phid = $user->getPHID();
         $view_uri = sprintf('/maniphest/?statuses=open()&assigned=%s#R', $phid);
         $nav->addIcon('maniphest', pht('Open Tasks'), 'fa-anchor', null, $view_uri);
     }
     $class = 'PhabricatorDifferentialApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $username = phutil_escape_uri($name);
         $view_uri = '/differential/?authors=' . $username;
         $nav->addIcon('differential', pht('Revisions'), 'fa-cog', null, $view_uri);
     }
     $class = 'PhabricatorAuditApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $username = phutil_escape_uri($name);
         $view_uri = '/audit/?authors=' . $username;
         $nav->addIcon('audit', pht('Commits'), 'fa-code', null, $view_uri);
     }
     return $nav;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:33,代码来源:PhabricatorPeopleController.php

示例4: handleLoggedInInvite

 private function handleLoggedInInvite(PhabricatorAuthInvite $invite, PhabricatorUser $viewer, PhabricatorUserEmail $email = null)
 {
     if ($email && $email->getUserPHID() !== $viewer->getPHID()) {
         $other_user = $this->loadUserForEmail($email);
         if ($email->getIsVerified()) {
             throw id(new PhabricatorAuthInviteAccountException(pht('Wrong Account'), pht('You are logged in as %s, but the email address you just ' . 'clicked a link from is already verified and associated ' . 'with another account (%s). Switch accounts, then try again.', phutil_tag('strong', array(), $viewer->getUsername()), phutil_tag('strong', array(), $other_user->getName()))))->setSubmitButtonText(pht('Log Out'))->setSubmitButtonURI($this->getLogoutURI())->setCancelButtonURI('/');
         } else {
             if ($email->getIsPrimary()) {
                 // NOTE: We never steal primary addresses from other accounts, even
                 // if they are unverified. This would leave the other account with
                 // no address. Users can use password recovery to access the other
                 // account if they really control the address.
                 throw id(new PhabricatorAuthInviteAccountException(pht('Wrong Acount'), pht('You are logged in as %s, but the email address you just ' . 'clicked a link from is already the primary email address ' . 'for another account (%s). Switch accounts, then try again.', phutil_tag('strong', array(), $viewer->getUsername()), phutil_tag('strong', array(), $other_user->getName()))))->setSubmitButtonText(pht('Log Out'))->setSubmitButtonURI($this->getLogoutURI())->setCancelButtonURI('/');
             } else {
                 if (!$this->shouldVerify()) {
                     throw id(new PhabricatorAuthInviteVerifyException(pht('Verify Email'), pht('You are logged in as %s, but the email address (%s) you just ' . 'clicked a link from is already associated with another ' . 'account (%s). You can log out to switch accounts, or verify ' . 'the address and attach it to your current account. Attach ' . 'email address %s to user account %s?', phutil_tag('strong', array(), $viewer->getUsername()), phutil_tag('strong', array(), $invite->getEmailAddress()), phutil_tag('strong', array(), $other_user->getName()), phutil_tag('strong', array(), $invite->getEmailAddress()), phutil_tag('strong', array(), $viewer->getUsername()))))->setSubmitButtonText(pht('Verify %s', $invite->getEmailAddress()))->setCancelButtonText(pht('Log Out'))->setCancelButtonURI($this->getLogoutURI());
                 }
             }
         }
     }
     if (!$email) {
         $email = id(new PhabricatorUserEmail())->setAddress($invite->getEmailAddress())->setIsVerified(0)->setIsPrimary(0);
     }
     if (!$email->getIsVerified()) {
         // We're doing this check here so that we can verify the address if
         // it's already attached to the viewer's account, just not verified.
         if (!$this->shouldVerify()) {
             throw id(new PhabricatorAuthInviteVerifyException(pht('Verify Email'), pht('Verify this email address (%s) and attach it to your ' . 'account (%s)?', phutil_tag('strong', array(), $invite->getEmailAddress()), phutil_tag('strong', array(), $viewer->getUsername()))))->setSubmitButtonText(pht('Verify %s', $invite->getEmailAddress()))->setCancelButtonURI('/');
         }
         $editor = id(new PhabricatorUserEditor())->setActor($viewer);
         // If this is a new email, add it to the user's account.
         if (!$email->getUserPHID()) {
             $editor->addEmail($viewer, $email);
         }
         // If another user added this email (but has not verified it),
         // take it from them.
         $editor->reassignEmail($viewer, $email);
         $editor->verifyEmail($viewer, $email);
     }
     $invite->setAcceptedByPHID($viewer->getPHID());
     $invite->save();
     // If we make it here, the user was already logged in with the email
     // address attached to their account and verified, or we attached it to
     // their account (if it was not already attached) and verified it.
     throw new PhabricatorAuthInviteRegisteredException();
 }
开发者ID:truSense,项目名称:phabricator,代码行数:46,代码来源:PhabricatorAuthInviteEngine.php

示例5: validateSender

 public function validateSender(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender)
 {
     $failure_reason = null;
     if ($sender->getIsDisabled()) {
         $failure_reason = pht('Your account (%s) is disabled, so you can not interact with ' . 'Phabricator over email.', $sender->getUsername());
     } else {
         if ($sender->getIsStandardUser()) {
             if (!$sender->getIsApproved()) {
                 $failure_reason = pht('Your account (%s) has not been approved yet. You can not interact ' . 'with Phabricator over email until your account is approved.', $sender->getUsername());
             } else {
                 if (PhabricatorUserEmail::isEmailVerificationRequired() && !$sender->getIsEmailVerified()) {
                     $failure_reason = pht('You have not verified the email address for your account (%s). ' . 'You must verify your email address before you can interact ' . 'with Phabricator over email.', $sender->getUsername());
                 }
             }
         }
     }
     if ($failure_reason) {
         throw new PhabricatorMetaMTAReceivedMailProcessingException(MetaMTAReceivedMailStatus::STATUS_DISABLED_SENDER, $failure_reason);
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:20,代码来源:PhabricatorMailReceiver.php

示例6: 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;
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:20,代码来源:PhabricatorApplicationPeople.php

示例7: buildUserInformationDictionary

 protected function buildUserInformationDictionary(PhabricatorUser $user)
 {
     $src_phid = $user->getProfileImagePHID();
     $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid);
     if ($file) {
         $picture = $file->getBestURI();
     } else {
         $picture = null;
     }
     return array('phid' => $user->getPHID(), 'userName' => $user->getUserName(), 'realName' => $user->getRealName(), 'email' => $user->getEmail(), 'image' => $picture, 'uri' => PhabricatorEnv::getURI('/p/' . $user->getUsername() . '/'));
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:11,代码来源:ConduitAPI_user_Method.php

示例8: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorPeopleQuery())->needPrimaryEmail(true)->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = 'Verified';
         } else {
             $email = 'Unverified';
         }
         $status = array();
         if ($user->getIsDisabled()) {
             $status[] = 'Disabled';
         }
         if ($user->getIsAdmin()) {
             $status[] = 'Admin';
         }
         if ($user->getIsSystemAgent()) {
             $status[] = 'System Agent';
         }
         $status = implode(', ', $status);
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, $email, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Roles', 'Email', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
         if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) {
             $panel->addButton(phutil_render_tag('a', array('href' => '/people/ldap/', 'class' => 'button green'), 'Import from LDAP'));
         }
     }
     $nav = $this->buildSideNavView();
     $nav->selectFilter('people');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'People'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:53,代码来源:PhabricatorPeopleListController.php

示例9: buildUserInformationDictionary

 protected function buildUserInformationDictionary(PhabricatorUser $user, $with_email = false, $with_availability = false)
 {
     $roles = array();
     if ($user->getIsDisabled()) {
         $roles[] = 'disabled';
     }
     if ($user->getIsSystemAgent()) {
         $roles[] = 'agent';
     }
     if ($user->getIsMailingList()) {
         $roles[] = 'list';
     }
     if ($user->getIsAdmin()) {
         $roles[] = 'admin';
     }
     $primary = $user->loadPrimaryEmail();
     if ($primary && $primary->getIsVerified()) {
         $email = $primary->getAddress();
         $roles[] = 'verified';
     } else {
         $email = null;
         $roles[] = 'unverified';
     }
     if ($user->getIsApproved()) {
         $roles[] = 'approved';
     }
     if ($user->isUserActivated()) {
         $roles[] = 'activated';
     }
     $return = array('phid' => $user->getPHID(), 'userName' => $user->getUserName(), 'realName' => $user->getRealName(), 'image' => $user->getProfileImageURI(), 'uri' => PhabricatorEnv::getURI('/p/' . $user->getUsername() . '/'), 'roles' => $roles);
     if ($with_email) {
         $return['primaryEmail'] = $email;
     }
     if ($with_availability) {
         // TODO: Modernize this once we have a more long-term view of what the
         // data looks like.
         $until = $user->getAwayUntil();
         if ($until) {
             $return['currentStatus'] = 'away';
             $return['currentStatusUntil'] = $until;
         }
     }
     return $return;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:44,代码来源:UserConduitAPIMethod.php

示例10: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorUser())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
     $rows = array();
     foreach ($users as $user) {
         $status = '';
         if ($user->getIsDisabled()) {
             $status = 'Disabled';
         } else {
             if ($user->getIsAdmin()) {
                 $status = 'Admin';
             } else {
                 $status = '-';
             }
         }
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Status', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
     }
     return $this->buildStandardPageResponse($panel, array('title' => 'People', 'tab' => 'directory'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:40,代码来源:PhabricatorPeopleListController.php

示例11: getCommonEnvironment

 private function getCommonEnvironment(PhabricatorUser $viewer)
 {
     $remote_address = $this->getRequest()->getRemoteAddress();
     return array(DiffusionCommitHookEngine::ENV_USER => $viewer->getUsername(), DiffusionCommitHookEngine::ENV_REMOTE_ADDRESS => $remote_address, DiffusionCommitHookEngine::ENV_REMOTE_PROTOCOL => 'http');
 }
开发者ID:bigboi900,项目名称:phabricator,代码行数:5,代码来源:DiffusionServeController.php

示例12: processBasicRequest

    private function processBasicRequest(PhabricatorUser $user)
    {
        $request = $this->getRequest();
        $admin = $request->getUser();
        $e_username = true;
        $e_realname = true;
        $e_email = true;
        $errors = array();
        $welcome_checked = true;
        $request = $this->getRequest();
        if ($request->isFormPost()) {
            $welcome_checked = $request->getInt('welcome');
            if (!$user->getID()) {
                $user->setUsername($request->getStr('username'));
                $user->setEmail($request->getStr('email'));
                if ($request->getStr('role') == 'agent') {
                    $user->setIsSystemAgent(true);
                }
            }
            $user->setRealName($request->getStr('realname'));
            if (!strlen($user->getUsername())) {
                $errors[] = "Username is required.";
                $e_username = 'Required';
            } else {
                if (!preg_match('/^[a-z0-9]+$/', $user->getUsername())) {
                    $errors[] = "Username must consist of only numbers and letters.";
                    $e_username = 'Invalid';
                } else {
                    $e_username = null;
                }
            }
            if (!strlen($user->getRealName())) {
                $errors[] = 'Real name is required.';
                $e_realname = 'Required';
            } else {
                $e_realname = null;
            }
            if (!strlen($user->getEmail())) {
                $errors[] = 'Email is required.';
                $e_email = 'Required';
            } else {
                $e_email = null;
            }
            if (!$errors) {
                try {
                    $is_new = !$user->getID();
                    $user->save();
                    if ($is_new) {
                        $log = PhabricatorUserLog::newLog($admin, $user, PhabricatorUserLog::ACTION_CREATE);
                        $log->save();
                        if ($welcome_checked) {
                            $admin_username = $admin->getUserName();
                            $admin_realname = $admin->getRealName();
                            $user_username = $user->getUserName();
                            $base_uri = PhabricatorEnv::getProductionURI('/');
                            $uri = $user->getEmailLoginURI();
                            $body = <<<EOBODY
Welcome to Phabricator!

{$admin_username} ({$admin_realname}) has created an account for you.

  Username: {$user_username}

To login to Phabricator, follow this link and set a password:

  {$uri}

After you have set a password, you can login in the future by going here:

  {$base_uri}

Love,
Phabricator

EOBODY;
                            $mail = id(new PhabricatorMetaMTAMail())->addTos(array($user->getPHID()))->setSubject('[Phabricator] Welcome to Phabricator')->setBody($body)->setFrom($admin->getPHID())->saveAndSend();
                        }
                    }
                    $response = id(new AphrontRedirectResponse())->setURI('/people/edit/' . $user->getID() . '/?saved=true');
                    return $response;
                } catch (AphrontQueryDuplicateKeyException $ex) {
                    $errors[] = 'Username and email must be unique.';
                    $same_username = id(new PhabricatorUser())->loadOneWhere('username = %s', $user->getUsername());
                    $same_email = id(new PhabricatorUser())->loadOneWhere('email = %s', $user->getEmail());
                    if ($same_username) {
                        $e_username = 'Duplicate';
                    }
                    if ($same_email) {
                        $e_email = 'Duplicate';
                    }
                }
            }
        }
        $error_view = null;
        if ($errors) {
            $error_view = id(new AphrontErrorView())->setTitle('Form Errors')->setErrors($errors);
        }
        $form = new AphrontFormView();
        $form->setUser($admin);
        if ($user->getID()) {
//.........这里部分代码省略.........
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:101,代码来源:PhabricatorPeopleEditController.php

示例13: processRequest

 public function processRequest()
 {
     $provider = $this->getLDAProvider();
     $ldap_info = $this->getLDAPInfo();
     $request = $this->getRequest();
     $errors = array();
     $e_username = true;
     $e_email = true;
     $e_realname = true;
     $user = new PhabricatorUser();
     $user->setUsername();
     $user->setRealname($provider->retrieveUserRealName());
     $new_email = $provider->retrieveUserEmail();
     if ($new_email) {
         // If the user's LDAP provider account has an email address but the
         // email address domain is not allowed by the Phabricator configuration,
         // we just pretend the provider did not supply an address.
         //
         // For instance, if the user uses LDAP Auth and their email address
         // is "joe@personal.com" but Phabricator is configured to require users
         // use "@company.com" addresses, we show a prompt below and tell the user
         // to provide their "@company.com" address. They can still use the LDAP
         // account to login, they just need to associate their account with an
         // allowed address.
         //
         // If the email address is fine, we just use it and don't prompt the user.
         if (!PhabricatorUserEmail::isAllowedAddress($new_email)) {
             $new_email = null;
         }
     }
     $show_email_input = $new_email === null;
     if ($request->isFormPost()) {
         $user->setUsername($request->getStr('username'));
         $username = $user->getUsername();
         if (!strlen($user->getUsername())) {
             $e_username = 'Required';
             $errors[] = 'Username is required.';
         } else {
             if (!PhabricatorUser::validateUsername($username)) {
                 $e_username = 'Invalid';
                 $errors[] = PhabricatorUser::describeValidUsername();
             } else {
                 $e_username = null;
             }
         }
         if (!$new_email) {
             $new_email = trim($request->getStr('email'));
             if (!$new_email) {
                 $e_email = 'Required';
                 $errors[] = 'Email is required.';
             } else {
                 $e_email = null;
             }
         }
         if ($new_email) {
             if (!PhabricatorUserEmail::isAllowedAddress($new_email)) {
                 $e_email = 'Invalid';
                 $errors[] = PhabricatorUserEmail::describeAllowedAddresses();
             }
         }
         if (!strlen($user->getRealName())) {
             $user->setRealName($request->getStr('realname'));
             if (!strlen($user->getRealName())) {
                 $e_realname = 'Required';
                 $errors[] = 'Real name is required.';
             } else {
                 $e_realname = null;
             }
         }
         if (!$errors) {
             try {
                 // NOTE: We don't verify LDAP email addresses by default because
                 // LDAP providers might associate email addresses with accounts that
                 // haven't actually verified they own them. We could selectively
                 // auto-verify some providers that we trust here, but the stakes for
                 // verifying an email address are high because having a corporate
                 // address at a company is sometimes the key to the castle.
                 $email_obj = id(new PhabricatorUserEmail())->setAddress($new_email)->setIsVerified(0);
                 id(new PhabricatorUserEditor())->setActor($user)->createNewUser($user, $email_obj);
                 $ldap_info->setUserID($user->getID());
                 $ldap_info->save();
                 $session_key = $user->establishSession('web');
                 $request->setCookie('phusr', $user->getUsername());
                 $request->setCookie('phsid', $session_key);
                 $email_obj->sendVerificationEmail($user);
                 return id(new AphrontRedirectResponse())->setURI('/');
             } catch (AphrontQueryDuplicateKeyException $exception) {
                 $same_username = id(new PhabricatorUser())->loadOneWhere('userName = %s', $user->getUserName());
                 $same_email = id(new PhabricatorUserEmail())->loadOneWhere('address = %s', $new_email);
                 if ($same_username) {
                     $e_username = 'Duplicate';
                     $errors[] = 'That username or email is not unique.';
                 } else {
                     if ($same_email) {
                         $e_email = 'Duplicate';
                         $errors[] = 'That email is not unique.';
                     } else {
                         throw $exception;
                     }
                 }
//.........这里部分代码省略.........
开发者ID:nexeck,项目名称:phabricator,代码行数:101,代码来源:PhabricatorLDAPRegistrationController.php

示例14: sendWaitingForApprovalEmail

 private function sendWaitingForApprovalEmail(PhabricatorUser $user)
 {
     $title = '[Phabricator] ' . pht('New User "%s" Awaiting Approval', $user->getUsername());
     $body = new PhabricatorMetaMTAMailBody();
     $body->addRawSection(pht('Newly registered user "%s" is awaiting account approval by an ' . 'administrator.', $user->getUsername()));
     $body->addLinkSection(pht('APPROVAL QUEUE'), PhabricatorEnv::getProductionURI('/people/query/approval/'));
     $body->addLinkSection(pht('DISABLE APPROVAL QUEUE'), PhabricatorEnv::getProductionURI('/config/edit/auth.require-approval/'));
     $admins = id(new PhabricatorPeopleQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIsAdmin(true)->execute();
     if (!$admins) {
         return;
     }
     $mail = id(new PhabricatorMetaMTAMail())->addTos(mpull($admins, 'getPHID'))->setSubject($title)->setBody($body->render())->saveAndSend();
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:13,代码来源:PhabricatorAuthRegisterController.php

示例15: changeUsername

 /**
  * @task edit
  */
 public function changeUsername(PhabricatorUser $user, $username)
 {
     $actor = $this->requireActor();
     if (!$user->getID()) {
         throw new Exception("User has not been created yet!");
     }
     if (!PhabricatorUser::validateUsername($username)) {
         $valid = PhabricatorUser::describeValidUsername();
         throw new Exception("Username is invalid! {$valid}");
     }
     $old_username = $user->getUsername();
     $user->openTransaction();
     $user->reload();
     $user->setUsername($username);
     try {
         $user->save();
     } catch (AphrontQueryDuplicateKeyException $ex) {
         $user->setUsername($old_username);
         $user->killTransaction();
         throw $ex;
     }
     $log = PhabricatorUserLog::newLog($this->actor, $user, PhabricatorUserLog::ACTION_CHANGE_USERNAME);
     $log->setOldValue($old_username);
     $log->setNewValue($username);
     $log->save();
     $user->saveTransaction();
     $user->sendUsernameChangeEmail($actor, $old_username);
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:31,代码来源:PhabricatorUserEditor.php


注:本文中的PhabricatorUser::getUsername方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。