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


PHP PhabricatorUser类代码示例

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


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

示例1: testParseLocalTime

 public function testParseLocalTime()
 {
     $u = new PhabricatorUser();
     $u->setTimezoneIdentifier('UTC');
     $v = new PhabricatorUser();
     $v->setTimezoneIdentifier('America/Los_Angeles');
     $t = 1370202281;
     // 2013-06-02 12:44:41 -0700
     $time = PhabricatorTime::pushTime($t, 'America/Los_Angeles');
     $this->assertEqual($t, PhabricatorTime::parseLocalTime('now', $u));
     $this->assertEqual($t, PhabricatorTime::parseLocalTime('now', $v));
     $this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 -0700', $u));
     $this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 -0700', $v));
     $this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 PDT', $u));
     $this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 PDT', $v));
     $this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 19:44:41', $u));
     $this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41', $v));
     $this->assertEqual($t + 3600, PhabricatorTime::parseLocalTime('+1 hour', $u));
     $this->assertEqual($t + 3600, PhabricatorTime::parseLocalTime('+1 hour', $v));
     unset($time);
     $t = 1370239200;
     // 2013-06-02 23:00:00 -0700
     $time = PhabricatorTime::pushTime($t, 'America/Los_Angeles');
     // For the UTC user, midnight was 6 hours ago because it's early in the
     // morning for htem. For the PDT user, midnight was 23 hours ago.
     $this->assertEqual($t + -6 * 3600 + 60, PhabricatorTime::parseLocalTime('12:01:00 AM', $u));
     $this->assertEqual($t + -23 * 3600 + 60, PhabricatorTime::parseLocalTime('12:01:00 AM', $v));
     unset($time);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:29,代码来源:PhabricatorTimeTestCase.php

示例2: applyLeaveProject

 public static function applyLeaveProject(PhabricatorProject $project, PhabricatorUser $user)
 {
     $members = array_fill_keys($project->getMemberPHIDs(), true);
     unset($members[$user->getPHID()]);
     $members = array_keys($members);
     self::applyOneTransaction($project, $user, PhabricatorProjectTransactionType::TYPE_MEMBERS, $members);
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:7,代码来源:PhabricatorProjectEditor.php

示例3: didMarkupText

 public function didMarkupText()
 {
     $engine = $this->getEngine();
     $metadata_key = self::KEY_RULE_MENTION;
     $metadata = $engine->getTextMetadata($metadata_key, array());
     if (empty($metadata)) {
         // No mentions, or we already processed them.
         return;
     }
     $usernames = array_keys($metadata);
     $user_table = new PhabricatorUser();
     $real_user_names = queryfx_all($user_table->establishConnection('r'), 'SELECT username, phid, realName FROM %T WHERE username IN (%Ls)', $user_table->getTableName(), $usernames);
     $actual_users = array();
     $mentioned_key = self::KEY_MENTIONED;
     $mentioned = $engine->getTextMetadata($mentioned_key, array());
     foreach ($real_user_names as $row) {
         $actual_users[strtolower($row['username'])] = $row;
         $mentioned[$row['phid']] = $row['phid'];
     }
     $engine->setTextMetadata($mentioned_key, $mentioned);
     foreach ($metadata as $username => $tokens) {
         $exists = isset($actual_users[$username]);
         $class = $exists ? 'phabricator-remarkup-mention-exists' : 'phabricator-remarkup-mention-unknown';
         if ($exists) {
             $tag = phutil_render_tag('a', array('class' => $class, 'href' => '/p/' . $username . '/', 'target' => '_blank', 'title' => $actual_users[$username]['realName']), phutil_escape_html('@' . $username));
         } else {
             $tag = phutil_render_tag('span', array('class' => $class), phutil_escape_html('@' . $username));
         }
         foreach ($tokens as $token) {
             $engine->overwriteStoredText($token, $tag);
         }
     }
     // Don't re-process these mentions.
     $engine->setTextMetadata($metadata_key, array());
 }
开发者ID:hwang36,项目名称:phabricator,代码行数:35,代码来源:PhabricatorRemarkupRuleMention.php

示例4: 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;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:26,代码来源:PhabricatorDifferentialApplication.php

示例5: 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

示例6: processImportRequest

 private function processImportRequest($request)
 {
     $admin = $request->getUser();
     $usernames = $request->getArr('usernames');
     $emails = $request->getArr('email');
     $names = $request->getArr('name');
     $panel = new AphrontErrorView();
     $panel->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
     $panel->setTitle("Import Successful");
     $errors = array("Successfully imported users from LDAP");
     foreach ($usernames as $username) {
         $user = new PhabricatorUser();
         $user->setUsername($username);
         $user->setRealname($names[$username]);
         $email_obj = id(new PhabricatorUserEmail())->setAddress($emails[$username])->setIsVerified(1);
         try {
             id(new PhabricatorUserEditor())->setActor($admin)->createNewUser($user, $email_obj);
             $ldap_info = new PhabricatorUserLDAPInfo();
             $ldap_info->setLDAPUsername($username);
             $ldap_info->setUserID($user->getID());
             $ldap_info->save();
             $errors[] = 'Successfully added ' . $username;
         } catch (Exception $ex) {
             $errors[] = 'Failed to add ' . $username . ' ' . $ex->getMessage();
         }
     }
     $panel->setErrors($errors);
     return $panel;
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:29,代码来源:PhabricatorPeopleLdapController.php

示例7: phabricator_form

function phabricator_form(PhabricatorUser $user, $attributes, $content)
{
    $body = array();
    $http_method = idx($attributes, 'method');
    $is_post = strcasecmp($http_method, 'POST') === 0;
    $http_action = idx($attributes, 'action');
    $is_absolute_uri = preg_match('#^(https?:|//)#', $http_action);
    if ($is_post) {
        // NOTE: We only include CSRF tokens if a URI is a local URI on the same
        // domain. This is an important security feature and prevents forms which
        // submit to foreign sites from leaking CSRF tokens.
        // In some cases, we may construct a fully-qualified local URI. For example,
        // we can construct these for download links, depending on configuration.
        // These forms do not receive CSRF tokens, even though they safely could.
        // This can be confusing, if you're developing for Phabricator and
        // manage to construct a local form with a fully-qualified URI, since it
        // won't get CSRF tokens and you'll get an exception at the other end of
        // the request which is a bit disconnected from the actual root cause.
        // However, this is rare, and there are reasonable cases where this
        // construction occurs legitimately, and the simplest fix is to omit CSRF
        // tokens for these URIs in all cases. The error message you receive also
        // gives you some hints as to this potential source of error.
        if (!$is_absolute_uri) {
            $body[] = phutil_tag('input', array('type' => 'hidden', 'name' => AphrontRequest::getCSRFTokenName(), 'value' => $user->getCSRFToken()));
            $body[] = phutil_tag('input', array('type' => 'hidden', 'name' => '__form__', 'value' => true));
        }
    }
    if (is_array($content)) {
        $body = array_merge($body, $content);
    } else {
        $body[] = $content;
    }
    return javelin_tag('form', $attributes, $body);
}
开发者ID:pugong,项目名称:phabricator,代码行数:34,代码来源:markup.php

示例8: willBeginExecution

 public final function willBeginExecution()
 {
     $request = $this->getRequest();
     $user = new PhabricatorUser();
     $phusr = $request->getCookie('phusr');
     $phsid = $request->getCookie('phsid');
     if ($phusr && $phsid) {
         $info = queryfx_one($user->establishConnection('r'), 'SELECT u.* FROM %T u JOIN %T s ON u.phid = s.userPHID
       AND s.type LIKE %> AND s.sessionKey = %s', $user->getTableName(), 'phabricator_session', 'web-', $phsid);
         if ($info) {
             $user->loadFromArray($info);
         }
     }
     $request->setUser($user);
     if ($user->getIsDisabled() && $this->shouldRequireEnabledUser()) {
         $disabled_user_controller = newv('PhabricatorDisabledUserController', array($request));
         return $this->delegateToController($disabled_user_controller);
     }
     if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
         if ($user->getConsoleEnabled() || PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {
             $console = new DarkConsoleCore();
             $request->getApplicationConfiguration()->setConsole($console);
         }
     }
     if ($this->shouldRequireLogin() && !$user->getPHID()) {
         $login_controller = newv('PhabricatorLoginController', array($request));
         return $this->delegateToController($login_controller);
     }
     if ($this->shouldRequireAdmin() && !$user->getIsAdmin()) {
         return new Aphront403Response();
     }
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:32,代码来源:PhabricatorController.php

示例9: 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

示例10: hasAutomaticCapability

 public function hasAutomaticCapability($capability, PhabricatorUser $viewer)
 {
     if ($viewer->getPHID() == $this->userPHID) {
         return true;
     }
     return false;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:7,代码来源:PhabricatorNamedQuery.php

示例11: apply

 public function apply($text)
 {
     // NOTE: Negative lookahead for period prevents us from picking up email
     // addresses, while allowing constructs like "@tomo, lol". The negative
     // lookbehind for a word character prevents us from matching "mail@lists"
     // while allowing "@tomo/@mroch". The negative lookahead prevents us from
     // matching "@joe.com" while allowing us to match "hey, @joe.".
     $regexp = '/(?<!\\w)@([a-zA-Z0-9]+)\\b(?![.]\\w)/';
     $matches = null;
     $ok = preg_match_all($regexp, $text, $matches);
     if (!$ok) {
         // No mentions in this text.
         return $text;
     }
     $usernames = $matches[1];
     // TODO: This is a little sketchy perf-wise. Once APC comes up, it is an
     // ideal candidate to back with an APC cache.
     $user_table = new PhabricatorUser();
     $real_user_names = queryfx_all($user_table->establishConnection('r'), 'SELECT username, phid, realName FROM %T WHERE username IN (%Ls)', $user_table->getTableName(), $usernames);
     $engine = $this->getEngine();
     $metadata_key = 'phabricator.mentioned-user-phids';
     $mentioned = $engine->getTextMetadata($metadata_key, array());
     foreach ($real_user_names as $row) {
         $this->actualUsers[strtolower($row['username'])] = $row;
         $mentioned[$row['phid']] = $row['phid'];
     }
     $engine->setTextMetadata($metadata_key, $mentioned);
     return preg_replace_callback($regexp, array($this, 'markupMention'), $text);
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:29,代码来源:PhabricatorRemarkupRuleMention.php

示例12: hasAutomaticCapability

 public function hasAutomaticCapability($capability, PhabricatorUser $viewer)
 {
     $can_edit = PhabricatorPolicyCapability::CAN_EDIT;
     switch ($capability) {
         case PhabricatorPolicyCapability::CAN_VIEW:
             if ($this->isUserMember($viewer->getPHID())) {
                 // Project members can always view a project.
                 return true;
             }
             break;
         case PhabricatorPolicyCapability::CAN_EDIT:
             $parent = $this->getParentProject();
             if ($parent) {
                 $can_edit_parent = PhabricatorPolicyFilter::hasCapability($viewer, $parent, $can_edit);
                 if ($can_edit_parent) {
                     return true;
                 }
             }
             break;
         case PhabricatorPolicyCapability::CAN_JOIN:
             if (PhabricatorPolicyFilter::hasCapability($viewer, $this, $can_edit)) {
                 // Project editors can always join a project.
                 return true;
             }
             break;
     }
     return false;
 }
开发者ID:phpengineer,项目名称:phabricator,代码行数:28,代码来源:PhabricatorProject.php

示例13: processImportRequest

 private function processImportRequest($request)
 {
     $admin = $request->getUser();
     $usernames = $request->getArr('usernames');
     $emails = $request->getArr('email');
     $names = $request->getArr('name');
     $notice_view = new PHUIInfoView();
     $notice_view->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
     $notice_view->setTitle(pht('Import Successful'));
     $notice_view->setErrors(array(pht('Successfully imported users from LDAP')));
     $list = new PHUIObjectItemListView();
     $list->setNoDataString(pht('No users imported?'));
     foreach ($usernames as $username) {
         $user = new PhabricatorUser();
         $user->setUsername($username);
         $user->setRealname($names[$username]);
         $email_obj = id(new PhabricatorUserEmail())->setAddress($emails[$username])->setIsVerified(1);
         try {
             id(new PhabricatorUserEditor())->setActor($admin)->createNewUser($user, $email_obj);
             id(new PhabricatorExternalAccount())->setUserPHID($user->getPHID())->setAccountType('ldap')->setAccountDomain('self')->setAccountID($username)->save();
             $header = pht('Successfully added %s', $username);
             $attribute = null;
             $color = 'fa-check green';
         } catch (Exception $ex) {
             $header = pht('Failed to add %s', $username);
             $attribute = $ex->getMessage();
             $color = 'fa-times red';
         }
         $item = id(new PHUIObjectItemView())->setHeader($header)->addAttribute($attribute)->setStatusIcon($color);
         $list->addItem($item);
     }
     return array($notice_view, $list);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:PhabricatorPeopleLdapController.php

示例14: createConpherence

 public static function createConpherence(PhabricatorUser $creator, array $participant_phids, $title, $message, PhabricatorContentSource $source)
 {
     $conpherence = id(new ConpherenceThread())->attachParticipants(array())->attachFilePHIDs(array())->setMessageCount(0);
     $files = array();
     $errors = array();
     if (empty($participant_phids)) {
         $errors[] = self::ERROR_EMPTY_PARTICIPANTS;
     } else {
         $participant_phids[] = $creator->getPHID();
         $participant_phids = array_unique($participant_phids);
         $conpherence->setRecentParticipantPHIDs(array_slice($participant_phids, 0, 10));
     }
     if (empty($message)) {
         $errors[] = self::ERROR_EMPTY_MESSAGE;
     }
     $file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles($creator, array($message));
     if ($file_phids) {
         $files = id(new PhabricatorFileQuery())->setViewer($creator)->withPHIDs($file_phids)->execute();
     }
     if (!$errors) {
         $xactions = array();
         $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS)->setNewValue(array('+' => $participant_phids));
         if ($files) {
             $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransactionType::TYPE_FILES)->setNewValue(array('+' => mpull($files, 'getPHID')));
         }
         if ($title) {
             $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransactionType::TYPE_TITLE)->setNewValue($title);
         }
         $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new ConpherenceTransactionComment())->setContent($message)->setConpherencePHID($conpherence->getPHID()));
         id(new ConpherenceEditor())->setContentSource($source)->setContinueOnNoEffect(true)->setActor($creator)->applyTransactions($conpherence, $xactions);
     }
     return array($errors, $conpherence);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:33,代码来源:ConpherenceEditor.php

示例15: phabricator_render_form

function phabricator_render_form(PhabricatorUser $user, $attributes, $content)
{
    if (strcasecmp(idx($attributes, 'method'), 'POST') == 0 && !preg_match('#^(https?:|//)#', idx($attributes, 'action'))) {
        $content = phutil_render_tag('input', array('type' => 'hidden', 'name' => AphrontRequest::getCSRFTokenName(), 'value' => $user->getCSRFToken())) . phutil_render_tag('input', array('type' => 'hidden', 'name' => '__form__', 'value' => true)) . $content;
    }
    return javelin_render_tag('form', $attributes, $content);
}
开发者ID:nexeck,项目名称:phabricator,代码行数:7,代码来源:markup.php


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