本文整理汇总了PHP中User::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getAll方法的具体用法?PHP User::getAll怎么用?PHP User::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hello
public function hello()
{
$users = User::getAll();
foreach ($users as $user) {
print_r($user->UserEmail);
}
}
示例2: testRebuildDatabaseWithNonSuperAdminUser
public function testRebuildDatabaseWithNonSuperAdminUser()
{
$steven = UserTestHelper::createBasicUser('Steven');
Yii::app()->user->userModel = $steven;
$item = NamedSecurableItem::getByName('AccountsModule');
$this->assertEquals(Permission::NONE, $item->getEffectivePermissions($steven));
$accounts = Account::getAll();
$users = User::getAll();
$this->assertEquals(0, count($accounts));
$this->assertEquals(2, count($users));
$adapter = new ModelAttributesAdapter(new Account());
$adapter->resolveDatabaseSchemaForModel('Account');
//Confirm the counts of data are still correct
$accounts = Account::getAll();
$users = User::getAll();
$this->assertEquals(0, count($accounts));
$this->assertEquals(2, count($users));
//Explicitly deny read, write, and deny
Yii::app()->user->userModel = User::getByUsername('super');
$item->addPermissions($steven, Permission::READ_WRITE_DELETE, Permission::DENY);
$this->assertTrue($item->save());
//Make sure steven has explicit deny
$item = NamedSecurableItem::getByName('AccountsModule');
$this->assertEquals(Permission::NONE, $item->getEffectivePermissions($steven));
Yii::app()->user->userModel = $steven;
$adapter = new ModelAttributesAdapter(new Account());
$adapter->resolveDatabaseSchemaForModel('Account');
//Confirm the counts of data are still correct
$accounts = Account::getAll();
$users = User::getAll();
$this->assertEquals(0, count($accounts));
$this->assertEquals(2, count($users));
}
示例3: loadUsers
/**
* Any user who has access to the scheduler module is added to receive a
* notification.
*/
protected function loadUsers()
{
foreach (User::getAll() as $user) {
if ($user->getEffectiveRight('JobsManagerModule', JobsManagerModule::RIGHT_ACCESS_JOBSMANAGER) == Right::ALLOW) {
$this->addUser($user);
}
}
}
示例4: loadUsers
/**
* Any user who has access to the workflows module is added to receive a
* notification.
*/
protected function loadUsers()
{
foreach (User::getAll() as $user) {
if ($user->getEffectiveRight('WorkflowsModule', WorkflowsModule::RIGHT_ACCESS_WORKFLOWS) == Right::ALLOW) {
$this->addUser($user);
}
}
}
示例5: test_save
function test_save()
{
//Arrange
$name = "Bob";
$email = "test@email.com";
$test_user = new User($name, $email);
$test_user->save();
//Act
$result = User::getAll();
//Assert
$this->assertEquals([$test_user], $result);
}
示例6: testUpdateUser
function testUpdateUser()
{
$name = "John Doe";
$password = "password";
$email = "johndoe@osa.biz";
$signed_in = 0;
$test_user = new User($name, $password, $email, $signed_in);
$test_user->save();
$name2 = "Jane Boe";
$password2 = "wordpass";
$email2 = "janeboe@osa.biz";
$test_user->updateUser($name2, $password2, $email2);
$result = User::getAll();
$this->assertEquals($test_user, $result[0]);
}
示例7: getRanges
/**
* Get from the database a list of the ranges of online users
* @return array
*/
public static function getRanges()
{
if (OnlineRange::$ranges_cache) {
return OnlineRange::$ranges_cache;
}
$startTime = microtime(true);
$rows = OnlineRange::fetchAllRows();
OnlineRange::$users_cache = User::getAll();
$result = OnlineRange::$ranges_cache = OnlineRange::buildRanges($rows);
$endTime = microtime(true);
Logger::log(" OnlineRange::getRanges() -> ", $endTime - $startTime);
$startTime = microtime(true);
OnlineRange::saveRanges($result);
$endTime = microtime(true);
Logger::log(" OnlineRange::saveRanges() -> ", $endTime - $startTime);
return $result;
}
示例8: makeAll
public function makeAll(&$demoDataHelper)
{
assert('$demoDataHelper instanceof DemoDataHelper');
assert('$demoDataHelper->isSetRange("User")');
foreach (User::getAll() as $user) {
$gameScore = GameScore::resolveToGetByTypeAndPerson('LoginUser', $user);
$gameScore->value = 10;
$saved = $gameScore->save();
assert('$saved');
$gamePoint = GamePoint::resolveToGetByTypeAndPerson(GamePoint::TYPE_USER_ADOPTION, $user);
$gamePoint->value = mt_rand(100, 300);
$saved = $gamePoint->save();
assert('$saved');
$gameScore = GameScore::resolveToGetByTypeAndPerson('CreateAccount', $user);
$gameScore->value = 10;
$saved = $gameScore->save();
assert('$saved');
$gamePoint = GamePoint::resolveToGetByTypeAndPerson(GamePoint::TYPE_NEW_BUSINESS, $user);
$gamePoint->value = 100;
$saved = $gamePoint->save();
assert('$saved');
//Badges
$gameBadge = new GameBadge();
$gameBadge->type = 'LoginUser';
$gameBadge->grade = 2;
$gameBadge->person = $user;
$saved = $gameBadge->save();
assert('$saved');
$gameBadge = new GameBadge();
$gameBadge->type = 'CreateAccount';
$gameBadge->grade = 3;
$gameBadge->person = $user;
$saved = $gameBadge->save();
assert('$saved');
//Levels
$gameLevel = GameLevel::resolveByTypeAndPerson(GameLevel::TYPE_GENERAL, $user);
$gameLevel->value = 1;
$saved = $gameLevel->save();
assert('$saved');
$gameLevel = GameLevel::resolveByTypeAndPerson(GameLevel::TYPE_NEW_BUSINESS, $user);
$gameLevel->value = 1;
$saved = $gameLevel->save();
assert('$saved');
}
}
示例9: listUser
function listUser()
{
global $lang;
$page_lang = scandir('inc/lang/' . $_SESSION['language']);
foreach ($page_lang as $file) {
if ($file != '.' && $file != '..') {
$parts = explode(".", $file);
$page = $parts[0];
if ($page == 'user') {
$page_file = $file;
}
}
}
include_once 'inc/lang/' . $_SESSION['language'] . '/' . $page_file;
if ($_SESSION['access']->users > 0) {
$results = array();
$gResults = array();
$data = User::getAll();
$gData = Group::getAll();
$results['users'] = $data['results'];
$results['totalRows'] = $data['totalRows'];
$results['pageTitle'] = "Admin User Management";
$gResults['groups'] = $gData['results'];
$gResults['totalRows'] = $gData['totalRows'];
if (isset($_GET['success'])) {
if ($_GET['success'] == "userCreated") {
$results['successMessage'] = "Your new admin user profile has been created successully.";
}
if ($_GET['success'] == "groupCreated") {
$results['successMessage'] = "Your new admin group has been created successully.";
}
if ($_GET['success'] == "changesSaved") {
$results['successMessage'] = "Your user profile changes have been saved successully.";
}
if ($_GET['success'] == "groupChangesSaved") {
$results['successMessage'] = "Your group changes have been saved successully.";
}
}
require "inc/layout/listUser.php";
} else {
require "inc/layout/noAccess.php";
}
}
示例10: testDownloadDefaultControllerActions
/**
* Walkthrough test for synchronous download
*/
public function testDownloadDefaultControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$nobody = User::getByUsername('nobody');
$users = User::getAll();
if (count($users)) {
foreach ($users as $user) {
if ($user->id !== $super->id && $user->id !== $nobody->id) {
$user->delete();
}
}
}
$users = array();
for ($i = 0; $i <= ExportModule::$asynchronousThreshold - 3; $i++) {
$users[] = UserTestHelper::createBasicUser('aUser' . $i);
}
// Check if access is denied if user doesn't have access privileges at all to export actions
Yii::app()->user->userModel = User::getByUsername('nobody');
$nobody = $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody');
$this->runControllerShouldResultInAccessFailureAndGetContent('users/default/list');
// Check if user have access to module action, but not to export action
// Now test peon with elevated rights to accounts
$nobody->setRight('UsersModule', UsersModule::RIGHT_ACCESS_USERS);
$nobody->setRight('ExportModule', ExportModule::RIGHT_ACCESS_EXPORT);
$this->assertTrue($nobody->save());
// Check if access is denied if user doesn't have access privileges at all to export actions
$nobody = $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody');
Yii::app()->user->userModel = User::getByUsername('nobody');
$this->runControllerWithNoExceptionsAndGetContent('users/default/list');
$this->setGetArray(array('User_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => ''));
$response = $this->runControllerWithRedirectExceptionAndGetUrl('users/default/export');
$this->assertTrue(strstr($response, 'users/default/index') !== false);
$this->setGetArray(array('UsersSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => ''), 'User_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
$response = $this->runControllerWithExitExceptionAndGetContent('users/default/export');
$this->assertEquals('Testing download.', $response);
$this->setGetArray(array('UsersSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => ''), 'User_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$users[0]->id}, {$users[1]->id}"));
$response = $this->runControllerWithExitExceptionAndGetContent('users/default/export');
$this->assertEquals('Testing download.', $response);
// No mathces
$this->setGetArray(array('UsersSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => 'missingOne'), 'User_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
$response = $this->runControllerWithRedirectExceptionAndGetUrl('users/default/export');
$this->assertTrue(strstr($response, 'users/default/index') !== false);
}
示例11: testSimpleUserImportWhereAllRowsSucceed
public function testSimpleUserImportWhereAllRowsSucceed()
{
Yii::app()->user->userModel = User::getByUsername('super');
$users = User::getAll();
$this->assertEquals(1, count($users));
$import = new Import();
$serializedData['importRulesType'] = 'User';
$serializedData['firstRowIsHeaderRow'] = true;
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.users.tests.unit.files'));
$this->assertEquals(11, ImportDatabaseUtil::getCount($import->getTempTableName()));
// includes header rows.
$mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'username', 'type' => 'importColumn', 'mappingRulesData' => array()), 'column_1' => array('attributeIndexOrDerivedType' => 'Password', 'type' => 'importColumn', 'mappingRulesData' => array('PasswordDefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_2' => array('attributeIndexOrDerivedType' => 'UserStatus', 'type' => 'importColumn', 'mappingRulesData' => array('UserStatusDefaultValueMappingRuleForm' => array('defaultValue' => UserStatusUtil::ACTIVE))), 'column_3' => ImportMappingUtil::makeStringColumnMappingData('firstName'), 'column_4' => ImportMappingUtil::makeStringColumnMappingData('lastName'));
$importRules = ImportRulesUtil::makeImportRulesByType('Users');
$page = 0;
$config = array('pagination' => array('pageSize' => 50));
//This way all rows are processed.
$dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
$dataProvider->getPagination()->setCurrentPage($page);
$importResultsUtil = new ImportResultsUtil($import);
$messageLogger = new ImportMessageLogger();
ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
$importResultsUtil->processStatusAndMessagesForEachRow();
//Confirm that 10 models where created.
$users = User::getAll();
$this->assertEquals(11, count($users));
$activeUser = User::getByUsername('myusername7');
$userStatus = UserStatusUtil::makeByUser($activeUser);
$this->assertTrue($userStatus->isActive());
$inactiveUser = User::getByUsername('myusername8');
$userStatus = UserStatusUtil::makeByUser($inactiveUser);
$this->assertFalse($userStatus->isActive());
//Confirm 10 rows were processed as 'created'.
$this->assertEquals(10, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
//Confirm that 0 rows were processed as 'updated'.
$this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
//Confirm 2 rows were processed as 'errors'.
$this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
$beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
$this->assertEquals(0, count($beansWithErrors));
}
示例12: function
//path to userhome for viewing current users and adding new
$app->get("/userhome", function () use($app) {
return $app['twig']->render('userhome.html.twig', array('users' => User::getAll()));
});
//path to specific users account info and activity info
$app->get("/updateuser/{id}", function () use($app) {
return $app['twig']->render('updateuser.html.twig', array('user' => $user));
});
//Update user info
$app->post("/userhome", function () use($app) {
$user_name = $_POST['user_name'];
$user_phone = $_POST['user_phone'];
$user_email = $_POST['user_email'];
$user = new User($user_name, $user_buy_quantity = null, $user_phone, $user_email, $activity_id = null, $id = null);
$user->save();
return $app['twig']->render('userhome.html.twig', array('users' => User::getAll()));
});
//Path to update and activity
$app->get("/updateactivity/{id}", function () use($app) {
return $app['twig']->render('updateactivity.html.twig', array('activity' => $activity));
});
//Update activity info
$app->post("/updateactivity/{id}", function () use($app) {
$activity_name = $_POST['activity_name'];
$activity_date = $_POST['activity_date'];
$activity_location = $_POST['activity_location'];
$activity_description = $_POST['activity_description'];
$activity_price = $_POST['activity_price'];
$activity_quantity = $_POST['activity_quantity'];
$activity = new Activity($activity_name, $activity_date, $activity_location, $activity_description, $activity_price, $activity_quantity, $business_id = null, $activity_category_id = null, $id = null);
$activity->save();
示例13: getUsers
public function getUsers()
{
$userController = new User($this->user, $this->token);
$users = $userController->getAll();
return $users;
}
示例14: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// We need to unfreeze here as we are working with custom field values
self::$freeze = false;
if (RedBeanDatabase::isFrozen()) {
RedBeanDatabase::unfreeze();
self::$freeze = true;
}
SecurityTestHelper::createSuperAdmin();
SecurityTestHelper::createUsers();
self::$super = User::getByUsername('super');
Yii::app()->user->userModel = self::$super;
$currencies = Currency::getAll();
$currencyValue1 = new CurrencyValue();
$currencyValue1->value = 100;
$currencyValue1->currency = $currencies[0];
$multiDropDownCustomFieldData1 = new CustomFieldData();
$multiDropDownCustomFieldData1->name = 'multiDropDown1';
$multiDropDownCustomFieldData1->serializedData = serialize(array('Ten', 11, 'XII'));
$saved = $multiDropDownCustomFieldData1->save();
assert('$saved');
// Not Coding Standard
$multiDropDownCustomFieldValue1 = new CustomFieldValue();
$multiDropDownCustomFieldValue1->value = 'Ten';
$multiDropDownCustomFieldValue2 = new CustomFieldValue();
$multiDropDownCustomFieldValue2->value = 11;
$multiDropDownCustomFieldValue3 = new CustomFieldValue();
$multiDropDownCustomFieldValue3->value = 'XII';
$tagCustomFieldData1 = new CustomFieldData();
$tagCustomFieldData1->name = 'tagCloud1';
$tagCustomFieldData1->serializedData = serialize(array('Apache', 'PHP'));
$saved = $tagCustomFieldData1->save();
assert('$saved');
// Not Coding Standard
$tagCustomFieldValue1 = new CustomFieldValue();
$tagCustomFieldValue1->value = 'PHP';
$tagCustomFieldValue2 = new CustomFieldValue();
$tagCustomFieldValue2->value = 'Apache';
$primaryEmail1 = new Email();
$primaryEmail1->emailAddress = "info@zurmo.com";
$primaryEmail1->isInvalid = true;
$primaryEmail1->optOut = false;
$secondaryEmail1 = new Email();
$secondaryEmail1->emailAddress = "jake@zurmo.com";
$secondaryEmail1->isInvalid = false;
$secondaryEmail1->optOut = true;
$address1 = new Address();
$address1->street1 = "SomeStreet1";
$address1->street2 = "SomeStreet2";
$address1->city = "SomeCity";
$address1->state = "SomeState";
$address1->postalCode = 1111;
$address1->country = "SomeCountry";
$likeContactState1 = new ContactState();
$likeContactState1->name = 'Customer';
$likeContactState1->order = 0;
$users = User::getAll();
$user1 = new User();
$user1->lastName = 'Kevin';
$user1->hash = 'rieWoy3aijohP6chaigaokohs1oovohf';
$user1->language = 'es';
$user1->timeZone = 'America/Chicago';
$user1->username = 'dave';
$user1->currency = $currencies[0];
$user1->manager = $users[0];
//Custom attribute
$attributeForm = new TextAttributeForm();
$attributeForm->attributeName = 'custom';
$attributeForm->attributeLabels = array('en' => 'test label en');
$modelAttributesAdapterClassName = $attributeForm::getModelAttributeAdapterNameForSavingAttributeFormData();
$adapter = new $modelAttributesAdapterClassName(new EmailTemplateModelTestItem());
$adapter->setAttributeMetadataFromForm($attributeForm);
$model = new EmailTemplateModelTestItem();
$model->string = 'abc';
$model->firstName = 'James';
$model->lastName = 'Jackson';
$model->phone = 1122334455;
$model->boolean = true;
$model->date = '2008-12-31';
$model->dateTime = '2008-12-31 07:48:04';
$model->textArea = 'Multiple Lines\\nOf Text';
$model->url = 'http://www.zurmo.com/';
$model->integer = 999;
$model->float = 999.999;
$model->currencyValue = $currencyValue1;
$model->dropDown->value = "DropdownSelectedValue";
$model->radioDropDown->value = "RadioDropdownSelectedValue";
$model->primaryEmail = $primaryEmail1;
$model->secondaryEmail = $secondaryEmail1;
$model->primaryAddress = $address1;
$model->likeContactState = $likeContactState1;
$model->user = $user1;
$model->multiDropDown->data = $multiDropDownCustomFieldData1;
$model->tagCloud->data = $tagCustomFieldData1;
$model->multiDropDown->values->add($multiDropDownCustomFieldValue1);
$model->multiDropDown->values->add($multiDropDownCustomFieldValue2);
$model->multiDropDown->values->add($multiDropDownCustomFieldValue3);
$model->tagCloud->values->add($tagCustomFieldValue1);
$model->tagCloud->values->add($tagCustomFieldValue2);
//.........这里部分代码省略.........
示例15: testGetUsersListUsingNonSystemUsersStateMetadataAdapter
/**
* Test users count using NonSystemUsersStateMetadataAdapter
*/
public function testGetUsersListUsingNonSystemUsersStateMetadataAdapter()
{
$users = User::getAll();
$this->assertEquals(5, count($users));
$user = UserTestHelper::createBasicUser('mysysuser');
$user->setIsSystemUser();
$this->assertTrue($user->save());
$nonSystemUsersStateMetadataAdapter = new NonSystemUsersStateMetadataAdapter(array('clauses' => array(), 'structure' => ''));
$metadata = $nonSystemUsersStateMetadataAdapter->getAdaptedDataProviderMetadata();
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('User');
$where = RedBeanModelDataProvider::makeWhere('User', $metadata, $joinTablesAdapter);
$models = User::getSubset($joinTablesAdapter, null, null, $where, null);
$this->assertEquals(5, count($models));
$actualUsers = User::getAll();
$this->assertEquals(6, count($actualUsers));
unset($user);
$user = User::getByUsername('mysysuser');
$this->assertTrue((bool) $user->isSystemUser);
$user->setIsNotSystemUser();
$this->assertTrue($user->save());
unset($user);
$user = User::getByUsername('mysysuser');
$this->assertEquals(0, $user->isSystemUser);
$where = RedBeanModelDataProvider::makeWhere('User', $metadata, $joinTablesAdapter);
$models = User::getSubset($joinTablesAdapter, null, null, $where, null);
$this->assertEquals(6, count($models));
}