public static function run($userId, $mode = 'test') { $testMode = $mode != 'run'; $message = ''; $userlist = new UserListModel(); $userlist->read(); $badAvatarLinks = 0; foreach ($userlist->entries as $userParams) { // foreach existing user $userId = $userParams['id']; $user = new UserProfileModel($userId); if (strpos($user->avatar_ref, '/') !== FALSE or strpos($user->avatar_ref, '\\') !== FALSE) { if ($user->avatar_color != '' && $user->avatar_shape != '') { $newRef = $user->avatar_color . '-' . $user->avatar_shape . '-128x128.png'; } else { $newRef = 'anonymoose.png'; } $message .= "Changed user {$userId} 's avatar from " . $user->avatar_ref . " to {$newRef}\n"; $user->avatar_ref = $newRef; $badAvatarLinks++; if (!$testMode) { $user->write(); } } } if ($badAvatarLinks > 0) { $message .= "\n\nFixed {$badAvatarLinks} bad avatar URLs\n\n"; } else { $message .= "\n\nNo bad avatar URLs were found\n\n"; } return $message; }
public function testEncode_userProjectHasNoUserProfileProperties_noProjectSettings() { $environ = new MongoTestEnvironment(); $environ->clean(); $userId = $environ->createUser("User", "Name", "*****@*****.**"); $user = new UserProfileModel($userId); $user->role = SiteRoles::USER; $project = $environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $projectId = $project->id->asString(); $project->addUser($userId, ProjectRoles::CONTRIBUTOR); $user->addProject($projectId); // user profile has data; but the encode method ignores it because the project has not enabled the 'city' property $projectUserProfile = new SfchecksUserProfile(); $projectUserProfile->city = 'myCity'; $user->projectUserProfiles[$projectId] = $projectUserProfile; $user->write(); $project->write(); $dto = UserProfileDto::encode($userId, $environ->website); $this->assertInternalType('array', $dto['userProfile']); $this->assertEquals($userId, $dto['userProfile']['id']); $this->assertEquals('Name', $dto['userProfile']['name']); $this->assertEquals(SiteRoles::USER, $dto['userProfile']['role']); $this->assertArrayHasKey('avatar_shape', $dto['userProfile']); $this->assertArrayHasKey('avatar_color', $dto['userProfile']); $this->assertFalse(isset($dto['userProfile']['projects'])); $this->assertInternalType('array', $dto['projectsSettings']); $this->assertEquals(0, count($dto['projectsSettings'])); }
public function testEncode_Project_DtoCorrect() { $environ = new LexiconMongoTestEnvironment(); $environ->clean(); $userId = $environ->createUser('User', 'Name', '*****@*****.**'); $user = new UserProfileModel($userId); $user->role = SystemRoles::USER; $project = $environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $projectId = $project->id->asString(); $project->addUser($userId, ProjectRoles::CONTRIBUTOR); $user->addProject($projectId); $user->interfaceLanguageCode = 'th'; $user->write(); $project->write(); $dto = LexBaseViewDto::encode($projectId, $userId); // test for a few default values $this->assertEquals('en', $dto['config']['inputSystems']['en']['tag']); $this->assertTrue($dto['config']['tasks']['dbe']['visible']); $this->assertEquals('fields', $dto['config']['entry']['type'], 'dto config is not valid'); $this->assertEquals('Word', $dto['config']['entry']['fields']['lexeme']['label']); $this->assertEquals('Word', $dto['config']['entry']['fields']['lexeme']['label']); $this->assertEquals('Part of Speech', $dto['config']['entry']['fields']['senses']['fields']['partOfSpeech']['label']); $this->assertTrue($dto['config']['roleViews']['contributor']['fields']['lexeme']['show']); $this->assertTrue($dto['config']['roleViews']['contributor']['showTasks']['dbe']); // todo re-enable this after userLanguageCode feature is mature //$this->assertEquals('th', $dto['interfaceConfig']['userLanguageCode']); $this->assertEquals('English', $dto['interfaceConfig']['selectLanguages']['options']['en']); }