本文整理汇总了PHP中User::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getById方法的具体用法?PHP User::getById怎么用?PHP User::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::getById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMakeFormFromGroup
public function testMakeFormFromGroup()
{
$user = UserTestHelper::createBasicUser('Billy');
$billId = $user->id;
unset($user);
$user = User::getById($billId);
$this->assertEquals('billy', $user->username);
$user = UserTestHelper::createBasicUser('Jimmy');
$jimId = $user->id;
unset($user);
$user = User::getById($jimId);
$this->assertEquals('jimmy', $user->username);
$users = User::GetAll();
$allUsers = array();
foreach ($users as $user) {
$allUsers[$user->id] = strval($user);
}
$this->assertEquals(3, count($allUsers));
$a = new Group();
$a->name = 'JJJ';
$this->assertTrue($a->save());
$this->assertEquals(0, $a->users->count());
$this->assertEquals(0, $a->groups->count());
$form = GroupUserMembershipFormUtil::makeFormFromGroup($a);
$this->assertEquals(array(), $form->userMembershipData);
$this->assertEquals($allUsers, $form->userNonMembershipData);
}
示例2: resolveReportByWizardPostData
/**
* @param Report $report
* @param array $postData
* @param string $wizardFormClassName
*/
public static function resolveReportByWizardPostData(Report $report, $postData, $wizardFormClassName)
{
assert('is_array($postData)');
assert('is_string($wizardFormClassName)');
$data = ArrayUtil::getArrayValue($postData, $wizardFormClassName);
if (isset($data['description'])) {
$report->setDescription($data['description']);
}
if (isset($data['moduleClassName'])) {
$report->setModuleClassName($data['moduleClassName']);
}
if (isset($data['name'])) {
$report->setName($data['name']);
}
self::resolveFiltersStructure($data, $report);
if (null != ArrayUtil::getArrayValue($data, 'ownerId')) {
$owner = User::getById((int) $data['ownerId']);
$report->setOwner($owner);
} else {
$report->setOwner(new User());
}
if (isset($data['currencyConversionType'])) {
$report->setCurrencyConversionType((int) $data['currencyConversionType']);
}
if (isset($data['spotConversionCurrencyCode'])) {
$report->setSpotConversionCurrencyCode($data['spotConversionCurrencyCode']);
}
self::resolveFilters($data, $report);
self::resolveOrderBys($data, $report);
self::resolveDisplayAttributes($data, $report);
self::resolveDrillDownDisplayAttributes($data, $report);
self::resolveGroupBys($data, $report);
self::resolveChart($data, $report);
}
示例3: renderLeaderboardContent
protected function renderLeaderboardContent()
{
$content = '<table class="items">';
$content .= '<colgroup>';
$content .= '<col style="width:10%" /><col style="width:80%" /><col style="width:10%" />';
$content .= '</colgroup>';
$content .= '<tbody>';
$content .= '<tr><th>' . Zurmo::t('GamificationModule', 'Rank') . '</th>';
$content .= '<th>' . Zurmo::t('GamificationModule', 'User') . '</th>';
$content .= '<th>' . Zurmo::t('GamificationModule', 'Points') . '</th>';
$content .= '</tr>';
foreach ($this->leaderboardData as $userId => $leaderboardData) {
assert('is_string($leaderboardData["rank"])');
assert('is_string($leaderboardData["userLabel"])');
assert('is_int($leaderboardData["points"])');
$userUrl = Yii::app()->createUrl('/users/default/details', array('id' => $userId));
$user = User::getById($userId);
$avatarImage = $user->getAvatarImage(24);
$content .= '<tr>';
$content .= '<td><span class="ranking">' . $leaderboardData['rank'] . '</span></td>';
$content .= '<td class="user-label">' . ZurmoHtml::link($avatarImage . '<span>' . $leaderboardData['userLabel'] . '</span>', $userUrl) . '</td>';
$content .= '<td><span class="points">' . $leaderboardData['points'] . '</span></td>';
$content .= '</tr>';
}
$content .= '</tbody>';
$content .= '</table>';
return $content;
}
示例4: getUserDetail
private function getUserDetail($userId)
{
$database = gGetDb();
$user = User::getById($userId, $database);
if ($user == false) {
return BootstrapSkin::displayAlertBox("User not found", "alert-error", "Error", true, false, true);
}
global $smarty;
$activitySummary = $database->prepare(<<<SQL
SELECT COALESCE(c.mail_desc, l.log_action) AS action, COUNT(*) AS count
FROM acc_log l
LEFT JOIN closes c ON l.log_action = c.closes
WHERE l.log_user = :username
GROUP BY action;
SQL
);
$activitySummary->execute(array(":username" => $user->getUsername()));
$activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC);
$smarty->assign("user", $user);
$smarty->assign("activity", $activitySummaryData);
$usersCreatedQuery = $database->prepare(<<<SQL
SELECT l.log_time time, r.name name, r.id id
FROM acc_log l
JOIN request r ON r.id = l.log_pend
LEFT JOIN emailtemplate e ON concat('Closed ', e.id) = l.log_action
WHERE l.log_user = :username
AND l.log_action LIKE 'Closed %'
AND (e.oncreated = '1' OR l.log_action = 'Closed custom-y')
ORDER BY l.log_time;
SQL
);
$usersCreatedQuery->execute(array(":username" => $user->getUsername()));
$usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
$smarty->assign("created", $usersCreated);
$usersNotCreatedQuery = $database->prepare(<<<SQL
SELECT l.log_time time, r.name name, r.id id
FROM acc_log l
JOIN request r ON r.id = l.log_pend
LEFT JOIN emailtemplate e ON concat('Closed ', e.id) = l.log_action
WHERE l.log_user = :username
AND l.log_action LIKE 'Closed %'
AND (e.oncreated = '0' OR l.log_action = 'Closed custom-n' OR l.log_action='Closed 0')
ORDER BY l.log_time;
SQL
);
$usersNotCreatedQuery->execute(array(":username" => $user->getUsername()));
$usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
$smarty->assign("notcreated", $usersNotCreated);
$accountLogQuery = $database->prepare(<<<SQL
SELECT *
FROM acc_log l
WHERE l.log_pend = :userid
\t AND log_action IN ('Approved','Suspended','Declined','Promoted','Demoted','Renamed','Prefchange');
SQL
);
$accountLogQuery->execute(array(":userid" => $user->getId()));
$accountLog = $accountLogQuery->fetchAll(PDO::FETCH_ASSOC);
$smarty->assign("accountlog", $accountLog);
return $smarty->fetch("statistics/userdetail.tpl");
}
示例5: testPasswordExpiresPolicyRules
public function testPasswordExpiresPolicyRules()
{
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
$everyoneGroup->save();
$user = UserTestHelper::createBasicUser('Bobby');
$id = $user->id;
unset($user);
$user = User::getById($id);
$adapter = new UserGroupMembershipToViewAdapter($user);
$viewData = $adapter->getViewData();
$compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false));
$this->assertEquals($compareData, $viewData);
$a = new Group();
$a->name = 'AAA';
$this->assertTrue($a->save());
$a->users->add($user);
$this->assertTrue($a->save());
$user->forget();
$groupId = $a->id;
$a->forget();
unset($a);
$user = User::getById($id);
$adapter = new UserGroupMembershipToViewAdapter($user);
$viewData = $adapter->getViewData();
$compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false), $groupId => array('displayName' => 'AAA', 'canRemoveFrom' => true));
$this->assertEquals($compareData, $viewData);
$user->forget();
unset($user);
}
示例6: authenticate
/**
* On success populates $GLOBALS['user'] with the authenticated user.
*
* @return bool
*/
public static function authenticate()
{
$authClass = 'Auth_' . ucfirst(AUTH_METHOD);
if (!class_exists($authClass)) {
SystemEvent::raise(SystemEvent::ERROR, 'Authentication module not found, reverting to default local. [MODULE=' . AUTH_METHOD . '] [PATH="src/core/Auth/' . $authClass . '.php"]', __METHOD__);
return false;
}
$userId = $authClass::authenticate();
if (null === $userId) {
// No actual authentication attempt was tried, so no point in logging anything
SystemEvent::raise(SystemEvent::DEBUG, "No authentication attempted.", __METHOD__);
return null;
} elseif (false === $userId) {
SystemEvent::raise(SystemEvent::DEBUG, "Failed authentication attempt.", __METHOD__);
return false;
}
$user = User::getById($userId);
if (!$user instanceof User) {
SystemEvent::raise(SystemEvent::INFO, "Unknown user from user ID. [ID={$userId}]", __METHOD__);
return false;
}
$_SESSION['userId'] = $userId;
$GLOBALS['user'] = $user;
SystemEvent::raise(SystemEvent::DEBUG, "User authenticated. [USR={$user->getUsername()}]", __METHOD__);
return true;
}
示例7: resolveValue
/**
* @param array $data
*/
public static function resolveValue($data)
{
$userUrl = Yii::app()->createUrl('/users/default/details', array('id' => $data['userId']));
$user = User::getById($data['userId']);
$avatarImage = $user->getAvatarImage(24);
$userLabel = ZurmoHtml::tag('span', array(), $data['userLabel']);
return ZurmoHtml::link($avatarImage . $userLabel, $userUrl, array('class' => 'user-label'));
}
示例8: load
public function load($params = null)
{
if (empty($params[0])) {
return 'no id';
}
$user = User::getById($params[0]);
unset($user->password);
return $user;
}
示例9: setConfigurationFromForm
/**
* Given a OutboundEmailConfigurationForm, save the configuration global values.
*/
public static function setConfigurationFromForm(OutboundEmailConfigurationForm $form)
{
Yii::app()->emailHelper->outboundHost = $form->host;
Yii::app()->emailHelper->outboundPort = $form->port;
Yii::app()->emailHelper->outboundUsername = $form->username;
Yii::app()->emailHelper->outboundPassword = $form->password;
Yii::app()->emailHelper->setOutboundSettings();
Yii::app()->emailHelper->setUserToSendNotificationsAs(User::getById((int) $form->userIdOfUserToSendNotificationsAs));
}
示例10: __construct
public function __construct(array $data = array())
{
parent::__construct($data);
if (!isset($this->user_id)) {
return;
}
$user = User::getById($this->user_id);
$this->user = $user;
}
示例11: load
/**
* Loads a list of users for the specicifies parameters, returns an array of User elements
*
* @return array
*/
public function load()
{
$usersData = $this->db->fetchAll("SELECT id FROM users" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
foreach ($usersData as $userData) {
$users[] = User::getById($userData["id"]);
}
$this->model->setUsers($users);
return $users;
}
示例12: getZurmoControllerUtil
protected static function getZurmoControllerUtil()
{
$getData = GetUtil::getData();
$relatedUserId = ArrayUtil::getArrayValue($getData, 'relatedUserId');
if ($relatedUserId == null) {
$relatedUser = null;
} else {
$relatedUser = User::getById((int) $relatedUserId);
}
return new SocialItemZurmoControllerUtil($relatedUser);
}
示例13: testCreateSystemUser
/**
* test create system user
*/
public function testCreateSystemUser()
{
$user = InstallUtil::createSystemUser('testsystemuser', 'test');
$id = $user->id;
$user->forget();
unset($user);
$user = User::getById($id);
$this->assertTrue((bool) $user->isSystemUser);
$this->assertTrue((bool) $user->hideFromSelecting);
$this->assertTrue((bool) $user->hideFromLeaderboard);
}
示例14: getSoapClient
public static function getSoapClient()
{
ini_set("soap.wsdl_cache_enabled", "0");
$conf = Zend_Registry::get("pimcore_config_test");
$user = User::getById($conf->user);
if (!$user instanceof User) {
throw new Exception("invalid user id");
}
$client = new Zend_Soap_Client($conf->webservice->wsdl . "&username=" . $user->getUsername() . "&apikey=" . $user->getPassword(), array("cache_wsdl" => false, "soap_version" => SOAP_1_2, "classmap" => Webservice_Tool::createClassMappings()));
$client->setLocation($conf->webservice->serviceEndpoint . "?username=" . $user->getUsername() . "&apikey=" . $user->getPassword());
return $client;
}
示例15: checkValidity
/**
* Checks if data is valid for current data field
*
* @param mixed $data
* @param boolean $omitMandatoryCheck
* @throws Exception
*/
public function checkValidity($data, $omitMandatoryCheck = false)
{
if (!$omitMandatoryCheck and $this->getMandatory() and empty($data)) {
throw new Exception("Empty mandatory field [ " . $this->getName() . " ]");
}
if (!empty($data)) {
$user = User::getById($data);
if (!$user instanceof User) {
throw new Exception("invalid user reference");
}
}
}