public function updateOperatorOnlineStats()
 {
     $operator = $this->GetLoggedOperator();
     $this->updateOperatorOnlineTime($operator['operatorid']);
     //MapperFactory::getMapper("OperatorOnline")->updateOperatorOnlineTime($operator['operatorid']);
     if (is_has_threads(HAS_THREADS_FILE) && MapperFactory::getMapper('Thread')->operatorHasActiveThreads($operator['operatorid'])) {
         //MapperFactory::getMapper("OperatorOnline")->updateOperatorOnlineTime($operator['operatorid'],  -2);
         $this->updateOperatorOnlineTime($operator['operatorid'], -2);
     }
 }
Exemple #2
0
 public function buildPendingThreadsXml($since, $operator)
 {
     $xml = array();
     $params = array('revision' => $since, 'time' => getCurrentTime() . '000', 'product' => strtolower(Settings::GetProduct()), 'version' => WEBIM_VERSION);
     $prio = array_fill(0, 10, array());
     $queue = array_fill(0, 10, array());
     $info = array_fill(0, 10, array());
     $closed = array_fill(0, 10, array());
     $res = array();
     $departmentsExist = MapperFactory::getMapper("Department")->departmentsExist();
     $operator_data = MapperFactory::getMapper("OperatorLastAccess")->getById($operator['operatorid']);
     $locales = empty($operator_data['locales']) ? null : split(',', $operator_data['locales']);
     $threads = array();
     if (is_has_threads(HAS_THREADS_FILE)) {
         $threads = MapperFactory::getMapper("Thread")->getPendingThreads($since, $includeClosed = $since != 0, $operator['operatorid'], $departmentsExist, $locales);
         foreach ($threads as $thread) {
             $state = $thread['state'];
             $isForMe = $thread['nextoperatorid'] == $operator['operatorid'] || empty($thread['nextoperatorid']);
             $isMine = $thread['operatorid'] == $operator['operatorid'];
             switch ($state) {
                 case STATE_CHATTING_OPERATOR_BROWSER_CLOSED_REFRESHED:
                     if ($isForMe || $isMine) {
                         $prio[0][] = $thread;
                     } else {
                         $info[1][] = $thread;
                     }
                     break;
                 case STATE_REDIRECTED:
                     if ($isForMe) {
                         $prio[1][] = $thread;
                     } else {
                         $info[2][] = $thread;
                     }
                     break;
                 case STATE_QUEUE_EXACT_OPERATOR:
                 case STATE_LOADING_FOR_EXACT_OPERATOR:
                     if ($isForMe) {
                         $prio[3][] = $thread;
                     } else {
                         $info[1][] = $thread;
                     }
                     break;
                 case STATE_LOADING:
                 case STATE_QUEUE:
                     $queue[0][] = $thread;
                     break;
                 case STATE_CHATTING:
                     $info[0][] = $thread;
                     break;
                 case STATE_CLOSED:
                     $closed[0][] = $thread;
                     break;
                 default:
                     $info[2][] = $thread;
                     break;
             }
             if ($thread['revision'] > $params['revision']) {
                 $params['revision'] = $thread['revision'];
             }
             if (MapperFactory::getMapper("Thread")->countActiveThreads() < 1 && count($threads) < 1) {
                 unset_has_threads(HAS_THREADS_FILE);
             }
         }
     }
     $res = array();
     self::appendThreads($res, $prio, $operator, 'prio');
     self::appendThreads($res, $queue, $operator, 'wait');
     self::appendThreads($res, $info, $operator, 'chat');
     self::appendThreads($res, $closed, $operator, 'closed');
     $xml[] = '<threads ' . self::xmlParamsToProperties($params) . '>';
     $xml[] = join("\n", $res);
     $xml[] = '</threads>';
     return join("\n", $xml);
 }