public function setUser(User $user) { $this[self::USER_ID] = $user->getId(); $this[self::OLD_NAME] = $user->getProperties()->getName(); $this[self::DATE_CHANGE] = DbQueryHelper::timestamp2date(); return $this; }
public static function welcome(User $user, UserCollection $userCollection) { if ($user->getLastMsgId() == 0) { $channelId = $user->getChannelId(); $response = (new MessageResponse())->setTime(null)->setChannelId($channelId)->setMsg(MsgToken::create('WelcomeUser', $user->getProperties()->getName())); $userCollection->setResponse($response)->notify(); } self::notifyOnPendingDuals($user); }
/** * @param User $user * @param UserCollection $users */ private static function moveUsersToPublic(User $user, UserCollection $users) { $partners = $users->getUsersByChatId($user->getChannelId()); $response = (new MessageResponse())->setTime(null)->setMsg(MsgToken::create('UserLeftPrivate', $user->getProperties()->getName()))->setDualChat('exit')->setChannelId($user->getChannelId()); $users->setResponse($response)->notify(); foreach ($partners as $pUser) { $pUser->setChannelId(1); $pUser->save(); } }
private function notifyOnClose(User $user, UserCollection $clients) { $response = new MessageResponse(); if ($user->isAsyncDetach()) { $response->setMsg(MsgToken::create('LeavesUs', $user->getProperties()->getName())); } $response->setTime(null)->setGuests($clients->getUsersByChatId($user->getChannelId()))->setChannelId($user->getChannelId()); $clients->setResponse($response)->notify(); ChannelNotifier::updateChannelInfo($clients, ChannelsCollection::get()); }
private static function dualGuestsList(User $user) { $dualUsers = DI::get()->getUsers()->getUsersByChatId($user->getChannelId()); $dual = TimEnum::create(PendingDuals::get()->getDualTim($user->getProperties()->getTim())); foreach ($dualUsers as $n => $partner) { $props = $partner->getProperties(); if ($props->getTim()->getId() != $dual->getId() && $props->getTim()->getId() != TimEnum::ANY) { unset($dualUsers[$n]); } if ($props->getSex()->getId() == $user->getProperties()->getSex()->getId()) { unset($dualUsers[$n]); } } if (empty($dualUsers)) { return; } $collection = new UserCollection(); foreach ($dualUsers as $partner) { $collection->attach($partner); } $response = (new MessageResponse())->setTime(null)->setChannelId($user->getChannelId())->setMsg(MsgToken::create('DualIsWanted', $dual->getShortName())); $collection->setResponse($response)->notify(false); }
private function sendPublic(UserCollection $clients, User $user, $msg, $isSelf) { $props = $user->getProperties(); $filteredMsg = RudeFilter::parse($msg); if (mb_strlen($filteredMsg) != mb_strlen($msg)) { $props->setRudeCount($props->getRudeCount() + 1); } $props->setWordsCount($props->getWordsCount() + mb_substr_count($msg, ' ') + 1); $response = (new MessageResponse())->setMsg(Msg::create($msg))->setFilteredMsg(Msg::create($filteredMsg))->setTime(null)->setChannelId($user->getChannelId()); if (!$isSelf) { $response->setFrom($user); } $clients->setResponse($response)->notify(); }
public function setUserProps(User $user) { $properties = $user->getProperties(); $dir = DI::get()->getConfig()->uploads->avatars->wwwfolder . DIRECTORY_SEPARATOR; $this->setId($user->getId())->setEmail($user->getUserDAO()->getEmail())->setSex($properties->getSex()->getId())->setTim($properties->getTim()->getId())->setName($properties->getName())->setAbout($properties->getAbout())->setAvatarImg($properties->getAvatarImg() ? $dir . $properties->getAvatarImg() : null)->setAvatarThumb($properties->getAvatarThumb() ? $dir . $properties->getAvatarThumb() : null)->setYear($properties->getBirthday())->setCity($properties->getCity())->setCensor($properties->hasCensor())->setNotifyVisual($properties->hasNotifyVisual())->setNotifySound($properties->hasNotifySound())->setLineBreakType($properties->getLineBreakType())->setOnlineNotifyLimit($properties->getOnlineNotificationLimit())->setSubscription($properties->hasSubscription())->setMsgAnimationType($properties->getMessageAnimationType()); return $this; }
public function setUser(User $user) { $this[self::NAME] = $user->getProperties()->getName(); return $this; }
private function isCorrectUser(User $user) { return $user->getProperties()->getTim()->getId() != TimEnum::ANY && $user->getProperties()->getSex()->getId() != SexEnum::ANONYM; }
public function setFrom(User $user) { $this->from = $user; $this->fromName = $user->getProperties()->getName(); return $this; }
private function guestsUpdateResponse(User $user, $oldName) { $response = (new MessageResponse())->setGuests(DI::get()->getUsers()->getUsersByChatId($user->getChannelId()))->setChannelId($user->getChannelId())->setTime(null); $props = $user->getProperties(); if ($props->getName() != $oldName) { $response->setMsg(MsgToken::create('UserChangedName', $oldName, $props->getName())); } DI::get()->getUsers()->setResponse($response)->notify(); }
public function run(User $user, $args) { return ['<b><i>' . $user->getProperties()->getName() . ' ' . $args . '</i></b>', false]; }