Esempio n. 1
0
 /**
  * Creates a search restriction
  *
  * @param ContentParameter $cpo
  * @return array
  */
 private function getSearchRestriction($cpo)
 {
     $searchText = $cpo->GetSearchFreeText();
     $searchGreater = strtotime($cpo->GetSearchValueGreater());
     $searchLess = strtotime($cpo->GetSearchValueLess());
     // split the search on whitespache and look for every word
     $searchText = preg_split("/\\W+/", $searchText);
     $searchProps = array(PR_BODY, PR_SUBJECT, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SENDER_NAME, PR_SENDER_EMAIL_ADDRESS, PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS);
     $resAnd = array();
     foreach ($searchText as $term) {
         $resOr = array();
         foreach ($searchProps as $property) {
             array_push($resOr, array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => $property, VALUE => u2w($term))));
         }
         array_push($resAnd, array(RES_OR, $resOr));
     }
     // add time range restrictions
     if ($searchGreater) {
         array_push($resAnd, array(RES_PROPERTY, array(RELOP => RELOP_GE, ULPROPTAG => PR_MESSAGE_DELIVERY_TIME, VALUE => array(PR_MESSAGE_DELIVERY_TIME => $searchGreater))));
         // RES_AND;
     }
     if ($searchLess) {
         array_push($resAnd, array(RES_PROPERTY, array(RELOP => RELOP_LE, ULPROPTAG => PR_MESSAGE_DELIVERY_TIME, VALUE => array(PR_MESSAGE_DELIVERY_TIME => $searchLess))));
     }
     $mapiquery = array(RES_AND, $resAnd);
     return $mapiquery;
 }
Esempio n. 2
0
 /**
  * Searches for the emails on the server
  *
  * @param ContentParameter $cpo
  *
  * @return array
  */
 public function GetMailboxSearchResults($cpo)
 {
     ZLog::Write(LOGLEVEL_DEBUG, "Combined->GetMailboxSearchResults()");
     $i = $this->getSearchBackend(ISearchProvider::SEARCH_MAILBOX);
     $result = false;
     if ($i !== false) {
         //Convert $cpo GetSearchFolderid
         $cpo->SetSearchFolderid($this->GetBackendFolder($cpo->GetSearchFolderid()));
         $result = $this->backends[$i]->GetMailboxSearchResults($cpo, $i . $this->config['delimiter']);
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * Creates a search restriction
  *
  * @param ContentParameter $cpo
  * @return string
  */
 private function getSearchRestriction($cpo)
 {
     $searchText = $cpo->GetSearchFreeText();
     $searchGreater = $cpo->GetSearchValueGreater();
     $searchLess = $cpo->GetSearchValueLess();
     $filter = '';
     if ($searchGreater != '') {
         $filter .= ' SINCE "' . $searchGreater . '"';
     } else {
         // Only search in sync messages
         $limitdate = new DateTime();
         switch (SYNC_FILTERTIME_MAX) {
             case SYNC_FILTERTYPE_1DAY:
                 $limitdate = $limitdate->sub(new DateInterval("P1D"));
                 break;
             case SYNC_FILTERTYPE_3DAYS:
                 $limitdate = $limitdate->sub(new DateInterval("P3D"));
                 break;
             case SYNC_FILTERTYPE_1WEEK:
                 $limitdate = $limitdate->sub(new DateInterval("P1W"));
                 break;
             case SYNC_FILTERTYPE_2WEEKS:
                 $limitdate = $limitdate->sub(new DateInterval("P2W"));
                 break;
             case SYNC_FILTERTYPE_1MONTH:
                 $limitdate = $limitdate->sub(new DateInterval("P1M"));
                 break;
             case SYNC_FILTERTYPE_3MONTHS:
                 $limitdate = $limitdate->sub(new DateInterval("P3M"));
                 break;
             case SYNC_FILTERTYPE_6MONTHS:
                 $limitdate = $limitdate->sub(new DateInterval("P6M"));
                 break;
             default:
                 $limitdate = false;
                 break;
         }
         if ($limitdate !== false) {
             // date format : 7 Jan 2012
             $filter .= ' SINCE "' . $limitdate->format("d M Y") . '"';
         }
     }
     if ($searchLess != '') {
         $filter .= ' BEFORE "' . $searchLess . '"';
     }
     $filter .= ' TEXT "' . $searchText . '"';
     return $filter;
 }
Esempio n. 4
0
 /**
  * Creates a search restriction
  *
  * @param ContentParameter $cpo
  * @return array
  */
 private function getSearchRestriction($cpo)
 {
     $searchText = $cpo->GetSearchFreeText();
     $searchGreater = strtotime($cpo->GetSearchValueGreater());
     $searchLess = strtotime($cpo->GetSearchValueLess());
     if (version_compare(phpversion(), '5.3.4') < 0) {
         ZLog::Write(LOGLEVEL_WARN, sprintf("Your system's PHP version (%s) might not correctly process unicode strings. Search containing such characters might not return correct results. It is recommended to update to at least PHP 5.3.4. See ZP-541 for more information.", phpversion()));
     }
     // split the search on whitespache and look for every word
     $searchText = preg_split("/\\W+/u", $searchText);
     $searchProps = array(PR_BODY, PR_SUBJECT, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SENDER_NAME, PR_SENDER_EMAIL_ADDRESS, PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS);
     $resAnd = array();
     foreach ($searchText as $term) {
         $resOr = array();
         foreach ($searchProps as $property) {
             array_push($resOr, array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => $property, VALUE => u2w($term))));
         }
         array_push($resAnd, array(RES_OR, $resOr));
     }
     // add time range restrictions
     if ($searchGreater) {
         array_push($resAnd, array(RES_PROPERTY, array(RELOP => RELOP_GE, ULPROPTAG => PR_MESSAGE_DELIVERY_TIME, VALUE => array(PR_MESSAGE_DELIVERY_TIME => $searchGreater))));
         // RES_AND;
     }
     if ($searchLess) {
         array_push($resAnd, array(RES_PROPERTY, array(RELOP => RELOP_LE, ULPROPTAG => PR_MESSAGE_DELIVERY_TIME, VALUE => array(PR_MESSAGE_DELIVERY_TIME => $searchLess))));
     }
     $mapiquery = array(RES_AND, $resAnd);
     return $mapiquery;
 }