/** * @covers CentralAuthUser::newFromId */ public function testNewFromId() { $ca = CentralAuthUser::newFromId(1001); $this->assertEquals('GlobalUser', $ca->getName()); $caBad = CentralAuthUser::newFromId(-1001); $this->assertFalse($caBad); }
/** * Get a GlobalUser object from a user's global id * * @param int $id * @return GlobalUser */ public static function newFromId($id) { // Use CentralAuth if available. Use local user to ease testing. if (class_exists('\\CentralAuthUser')) { $user = \CentralAuthUser::newFromId($id); } else { $user = \User::newFromId($id); } if ($user === null) { throw new \MWException("Unable to find global user for"); } return new GlobalUser($user); }
/** * @param string $name The database field name * @param string $value The value retrieved from the database * @return string HTML to place inside table cell */ public function formatValue($name, $value) { $formatted = htmlspecialchars($value); switch ($name) { case 'rq_requested_ts': case 'rq_completed_ts': $formatted = $this->formatDateTime($value); break; case 'rq_name': case 'rq_newname': $title = SpecialPage::getTitleFor('CentralAuth', $value); $formatted = Linker::link($title, htmlspecialchars($value)); break; case 'rq_performer': $steward = CentralAuthUser::newFromId($value); $formatted = '<span class="plainlinks">' . WikiMap::foreignUserLink($steward->getHomeWiki(), $steward->getName(), $steward->getName()) . '</span>'; break; case 'row_actions': $formatted = $this->formatActionValue($this->mCurrentRow); break; } return $formatted; }
/** * @param $id * @return CentralAuthGroupMembershipProxy|null */ public static function newFromId($id) { $globalUser = CentralAuthUser::newFromId($id); return $globalUser ? new CentralAuthGroupMembershipProxy($globalUser) : null; }