Merge branch '2013.03' into 2013.10
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 8 Apr 2014 08:30:22 +0000 (10:30 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 8 Apr 2014 08:30:22 +0000 (10:30 +0200)
Conflicts:
tine20/Tinebase/Record/RecordSet.php

1  2 
tests/tine20/Calendar/Controller/EventNotificationsTests.php
tine20/Calendar/Controller/Event.php
tine20/Calendar/Model/Rrule.php
tine20/Tinebase/Record/RecordSet.php

Simple merge
Simple merge
@@@ -570,30 -564,34 +570,35 @@@ class Tinebase_Record_RecordSet impleme
      /**
       * filter recordset and return matching records
       *
--     * @param string $_field
++     * @param string|function $_field
       * @param string $_value
++     * @param boolean $_valueIsRegExp
       * @return array
       * 
       * @todo reactivate indices (@see 0007558: reactivate indices in Tinebase_Record_RecordSet)
       */
      protected function _getMatchingRecords($_field, $_value, $_valueIsRegExp = FALSE)
      {
-         // NOTE: indices may lead to wrong results if a record is changed after build of indices
-         if (FALSE && (isset($this->_indices[$_field]) || array_key_exists($_field, $this->_indices))) {
-             if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Filtering with indices, expecting fast results ;-)');
-             $valueMap = $this->_indices[$_field];
-         } else {
-             if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " Filtering field '$_field' of '{$this->_recordClass}' without indices, expecting slow results");
-             $valueMap = $this->$_field;
-         }
-         
-         if ($_valueIsRegExp) {
-             $matchingMap = preg_grep($_value,  $valueMap);
+         if (is_callable($_field)) {
+             $matchingRecords = array_filter($this->_listOfRecords, $_field);
          } else {
-             $matchingMap = array_flip((array)array_keys($valueMap, $_value));
+             // NOTE: indices may lead to wrong results if a record is changed after build of indices
 -            if (FALSE && array_key_exists($_field, $this->_indices)) {
++            if (FALSE && (isset($this->_indices[$_field]) || array_key_exists($_field, $this->_indices))) {
+                 if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Filtering with indices, expecting fast results ;-)');
+                 $valueMap = $this->_indices[$_field];
+             } else {
+                 if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " Filtering field '$_field' of '{$this->_recordClass}' without indices, expecting slow results");
+                 $valueMap = $this->$_field;
+             }
+             
+             if ($_valueIsRegExp) {
+                 $matchingMap = preg_grep($_value,  $valueMap);
+             } else {
+                 $matchingMap = array_flip((array)array_keys($valueMap, $_value));
+             }
+             
+             $matchingRecords = array_intersect_key($this->_listOfRecords, $matchingMap);
          }
-         
-         $matchingRecords = array_intersect_key($this->_listOfRecords, $matchingMap);
          return $matchingRecords;
      }