Esempio n. 1
0
 protected function createForUser(\Symbb\Core\UserBundle\Entity\UserInterface $object = null, $breadcrumb)
 {
     if ($object) {
         $uri = $this->router->generate('symbb_user_profile', array('id' => $object->getId(), 'name' => $object->getUsername()));
         $breadcrumb[] = array('name' => $object->getUsername(), 'link' => $uri);
     }
     $uri = $this->router->generate('symbb_user_userlist', array());
     $breadcrumb[] = array('name' => $this->translator->trans('Members', array(), 'symbb_frontend'), 'link' => $uri);
     return $breadcrumb;
 }
Esempio n. 2
0
 public function addUser(UserInterface $user, $ip)
 {
     $userlist = $this->getUserlist();
     $now = time();
     $currUserFound = false;
     foreach ($userlist as $key => $onlineUserData) {
         if ($onlineUserData['id'] !== $user->getId()) {
             $diff = $now - $onlineUserData['added'];
             // if ip in array but id is not the same than the user has logged in!
             if ($diff > 300 || in_array($ip, $onlineUserData['ips'])) {
                 unset($userlist[$key]);
             }
         } else {
             $currUserFound = true;
             $userlist[$key]['added'] = $now;
             $ips = $onlineUserData['ips'];
             $ips[] = $ip;
             $ips = array_unique($ips);
             $userlist[$key]['ips'] = $ips;
             $userlist[$key]['count'] = count($ips);
         }
     }
     if (!$currUserFound) {
         $count = 1;
         $ips = array($ip);
         $userlist[] = array('id' => (int) $user->getId(), 'added' => $now, 'username' => $user->getUsername(), 'type' => $user->getSymbbType(), 'count' => $count, 'ips' => $ips);
     }
     $this->memcache->set(self::CACHE_KEY, $userlist, self::LIFETIME);
 }