protected function getMockProperties($timId = TimEnum::ILE, $sexId = SexEnum::MALE) { $properties = $this->getMock(PropertiesDAO::class, ['getTim', 'getSex'], [], '', false); $properties->expects($this->any())->method('getTim')->willReturn(TimEnum::create($timId)); $properties->expects($this->any())->method('getSex')->willReturn(SexEnum::create($sexId)); return $properties; }
/** * @param Lang $lang * @param Logger $logger * @param User $newUserWrapper * @param Request $socketRequest * @return UserDAO */ private function createNewUser(Lang $lang, Logger $logger, User $newUserWrapper, Request $socketRequest) { $user = UserDAO::create()->setChatId(1)->setDateRegister(DbQueryHelper::timestamp2date())->setRole(UserRoleEnum::USER)->setBanned(false)->setImprint(null); try { $user->save(); } catch (\PDOException $e) { $logger->error("PDO Exception: " . $e->getMessage() . ': ' . $e->getTraceAsString(), [__METHOD__]); } $id = $user->getId(); $guestName = $lang->getPhrase('Guest') . $id; if (PropertiesDAO::create()->getByUserName($guestName)->getName()) { $guestName = $lang->getPhrase('Guest') . ' ' . $id; } $properties = $user->getPropeties(); $properties->setUserId($user->getId())->setName($guestName)->setSex(SexEnum::create(SexEnum::ANONYM))->setTim(TimEnum::create(TimEnum::ANY))->setBirthday(Rules::LOWEST_YEAR)->setOptions([PropertiesDAO::CENSOR => true])->setOnlineCount(0)->setMusicCount(0)->setWordsCount(0)->setRudeCount(0)->setKarma(0)->setMessagesCount(0)->setSubscription(true); try { $properties->save(); } catch (\PDOException $e) { $logger->error("PDO Exception: " . $e->getTraceAsString(), [__CLASS__]); } if ($refUserId = $socketRequest->getCookie('refUserId')) { $ref = ReferralDAO::create()->getByUserId($user->getId(), $refUserId); if (!$ref) { $ref = ReferralDAO::create()->setUserId($user->getId())->setRefUserId($refUserId)->setDateRegister(DbQueryHelper::timestamp2date()); $ref->save(); $logger->info('Found referral userId ' . $refUserId . ' for guest userId ' . $user->getId()); } } $logger->info("Created new user with id = {$id} for connectionId = {$newUserWrapper->getConnectionId()}", [__CLASS__]); return $user; }
echo $tim->getName(); ?> </option> <?php } ?> </select> </div> <div class="col-md-2 btn-vert-block"> <select class="form-control" id="profile-sex"> <option selected disabled><?php echo $lang->getPhrase('profile.Sex'); ?> </option> <?php foreach (SexEnum::getList() as $sex) { ?> <option value="<?php echo $sex->getId(); ?> "><?php echo $sex->getName(); ?> </option> <?php } ?> </select> </div> <div class="col-md-2 btn-vert-block"> <select class="form-control" id="profile-year">
public function setSex(SexEnum $sex) { $this[self::SEX] = $sex->getId(); return $this; }
private function importProperties(User $user, $request) { $this->handleNameChange($user, $request); $properties = $user->getProperties(); $properties->setUserId($user->getId())->setName($request[PropertiesDAO::NAME])->setAbout(strip_tags(trim($request[PropertiesDAO::ABOUT])))->setTim(TimEnum::create($request[PropertiesDAO::TIM]))->setSex(SexEnum::create($request[PropertiesDAO::SEX]))->setCity($request[PropertiesDAO::CITY])->setBirthday($request[PropertiesDAO::BIRTH])->setSubscription($request[PropertiesDAO::IS_SUBSCRIBED])->setOptions([PropertiesDAO::CENSOR => $request[PropertiesDAO::CENSOR], PropertiesDAO::LINE_BREAK_TYPE => $request[PropertiesDAO::LINE_BREAK_TYPE], PropertiesDAO::NOTIFY_VISUAL => $request[PropertiesDAO::NOTIFY_VISUAL], PropertiesDAO::NOTIFY_SOUND => $request[PropertiesDAO::NOTIFY_SOUND], PropertiesDAO::ONLINE_NOTIFICATION => $request[PropertiesDAO::ONLINE_NOTIFICATION], PropertiesDAO::ONLINE_NOTIFICATION_LAST => $properties->getOnlineNotificationLast(), PropertiesDAO::MESSAGE_ANIMATION_TYPE => $request[PropertiesDAO::MESSAGE_ANIMATION_TYPE]]); $properties->save(false); $online = OnlineDAO::create(); $online->setOnlineList($user->getChannelId()); }