Esempio n. 1
0
 /**
  * Gets one entry (by property)
  *
  * @param  mixed  $_value
  * @param  string $_property
  * @param  bool   $_getDeleted
  * @return Tinebase_Record_Interface
  * @throws Tinebase_Exception_NotFound
  */
 public function getByProperty($_value, $_property = 'name', $_getDeleted = FALSE)
 {
     //$pagination = new Tinebase_Model_Pagination(array('limit' => 1));
     $filters = new Calendar_Model_EventFilter();
     $filter = new Tinebase_Model_Filter_Text($_property, 'equals', $_value);
     $filters->addFilter($filter);
     // for get operations we need to take all attendee into account
     $filters->addFilter($filters->createFilter('attender', 'specialNode', 'all'));
     $resultSet = $this->search($filters, NULL, FALSE, $_getDeleted);
     switch (count($resultSet)) {
         case 0:
             throw new Tinebase_Exception_NotFound($this->_modelName . " record with {$_property} " . $_value . ' not found!');
             break;
         case 1:
             $result = $resultSet->getFirstRecord();
             break;
         default:
             throw new Tinebase_Exception_UnexpectedValue(' in total ' . count($resultSet) . ' where found. But only one should!');
     }
     return $result;
 }