Esempio n. 1
0
 protected function _rooms()
 {
     $roomHandler = new Dura_Model_RoomHandler();
     $roomModels = $roomHandler->loadAll();
     $rooms = array();
     $lang = Dura::user()->getLanguage();
     $rooms[$lang] = array();
     $roomExpire = time() - DURA_CHAT_ROOM_EXPIRE;
     $activeUser = 0;
     foreach ($roomModels as $id => $roomModel) {
         $room = $roomModel->asArray();
         if ($room['update'] < $roomExpire) {
             $roomHandler->delete($id);
             continue;
         }
         $room['creater'] = '';
         foreach ($room['users'] as $user) {
             if ($user['id'] == $room['host']) {
                 $room['creater'] = $user['name'];
             }
         }
         $room['id'] = $id;
         $room['total'] = count($room['users']);
         $room['url'] = Dura::url('room');
         $lang = $room['language'];
         $rooms[$lang][] = $room;
         $activeUser += $room['total'];
     }
     unset($roomHandler, $roomModels, $roomModel, $room);
     $this->output['rooms'] = $rooms;
     $this->output['active_user'] = $activeUser;
 }
Esempio n. 2
0
 protected function _roomLimit()
 {
     $roomHandler = new Dura_Model_RoomHandler();
     $roomModels = $roomHandler->loadAll();
     $roomExpire = time() - DURA_CHAT_ROOM_EXPIRE;
     $usedCapacity = 0;
     foreach ($roomModels as $id => $roomModel) {
         if (intval($roomModel->update) < $roomExpire) {
             $roomHandler->delete($id);
             continue;
         }
         $usedCapacity += (int) $roomModel->limit;
     }
     unset($roomHandler, $roomModels, $roomModel);
     if ($usedCapacity >= DURA_SITE_USER_CAPACITY) {
         Dura::trans(t("Cannot create new room any more."), 'lounge');
     }
     $this->userMax = DURA_SITE_USER_CAPACITY - $usedCapacity;
     if ($this->userMax > DURA_USER_MAX) {
         $this->userMax = DURA_USER_MAX;
     }
     if ($this->userMax < DURA_USER_MIN) {
         Dura::trans(t("Cannot create new room any more."), 'lounge');
     }
 }