Exemple #1
0
 /**
  * @dataProvider providerCriteriaTree
  */
 public function testCriteriaTree($testData, $expect)
 {
     $tree = new CriteriaTree($testData);
     $gate = $tree->build();
     #fwrite(STDOUT, 'gate'."\n"); ve($gate);
     $this->assertEquals($expect, $gate);
 }
Exemple #2
0
 private function sendSearchRaw($criteriaStr, $isUid = false)
 {
     $criteria = array();
     $criteria = $this->msgGetParenthesizedlist($criteriaStr);
     $criteria = $this->parseSearchKeys($criteria);
     $tree = new CriteriaTree($criteria);
     $tree->build();
     #\Doctrine\Common\Util\Debug::dump($tree);
     if (!$tree->getRootGate()) {
         return '';
     }
     $ids = array();
     $msgSeqNums = $this->createSequenceSet('*');
     foreach ($msgSeqNums as $msgSeqNum) {
         $uid = $this->getServer()->getMsgIdBySeq($msgSeqNum, $this->selectedFolder);
         $this->log('debug', 'client ' . $this->id . ' check msg: ' . $msgSeqNum . ', ' . $uid);
         $message = $this->getServer()->getMailBySeq($msgSeqNum, $this->selectedFolder);
         $add = false;
         if ($message) {
             $rootGate = clone $tree->getRootGate();
             #\Doctrine\Common\Util\Debug::dump($rootGate, 5);
             #print_r($rootGate);
             $add = $this->parseSearchMessage($message, $msgSeqNum, $uid, $isUid, $rootGate);
         }
         if ($add) {
             if ($isUid) {
                 $ids[] = $uid;
             } else {
                 // NOT_IMPLEMENTED
                 $ids[] = $msgSeqNum;
             }
         }
     }
     sort($ids);
     $rv = '';
     while ($ids) {
         $this->log('debug', 'client ' . $this->id . ' msg: ' . $msgSeqNum);
         $sendIds = array_slice($ids, 0, 30);
         $ids = array_slice($ids, 30);
         $rv .= $this->dataSend('* SEARCH ' . join(' ', $sendIds) . '');
     }
     return $rv;
 }