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


PHP User::getById方法代码示例

本文整理汇总了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);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:27,代码来源:GroupUserMembershipFormUtilTest.php

示例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);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:39,代码来源:DataToReportUtil.php

示例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;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:28,代码来源:LeaderboardView.php

示例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");
    }
开发者ID:Austin503,项目名称:waca,代码行数:60,代码来源:StatsUsers.php

示例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);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:29,代码来源:UserGroupMembershipToViewAdapterTest.php

示例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;
 }
开发者ID:rasismeiro,项目名称:cintient,代码行数:31,代码来源:Auth.php

示例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'));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:11,代码来源:LeaderboardUserListViewColumnAdapter.php

示例8: load

 public function load($params = null)
 {
     if (empty($params[0])) {
         return 'no id';
     }
     $user = User::getById($params[0]);
     unset($user->password);
     return $user;
 }
开发者ID:lenlyle1,项目名称:lightupdating,代码行数:9,代码来源:User.class.php

示例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));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:12,代码来源:OutboundEmailConfigurationFormAdapter.php

示例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;
 }
开发者ID:rdaitan,项目名称:dc-board,代码行数:9,代码来源:comment.php

示例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;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:14,代码来源:Resource.php

示例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);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:11,代码来源:DefaultController.php

示例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);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:14,代码来源:InstallUtilMiscTest.php

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

示例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");
         }
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:19,代码来源:User.php


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