/** * get by id * - results are cached * * @param string $_id the id of the peer * @return Voipmanager_Model_Snom_Location */ public function get($_id) { $id = Tinebase_Record_Abstract::convertId($_id, $this->_modelName); if ($this->_cacheIdPrefix && $this->_cache) { $cacheId = $this->_cacheIdPrefix . $id; if ($this->_cache->test($id)) { $result = $this->_cache->load($id); } else { $result = $this->_backend->get($id); $this->_cache->save($result, $cacheId, array($this->_cacheIdPrefix), 5); } } else { $result = $this->_backend->get($id); } return $result; }
/** * get updates of human interest * * @param Calendar_Model_Event $_event * @param Calendar_Model_Event $_oldEvent * @return array */ protected function _getUpdates($_event, $_oldEvent) { // check event details $diff = $_event->diff($_oldEvent)->diff; $orderedUpdateFieldOfInterest = array('dtstart', 'dtend', 'rrule', 'summary', 'location', 'description', 'transp', 'priority', 'status', 'class', 'url', 'is_all_day_event', 'originator_tz'); $updates = array(); foreach ($orderedUpdateFieldOfInterest as $field) { if (isset($diff[$field]) || array_key_exists($field, $diff)) { $updates[$field] = $diff[$field]; } } // rrule legacy if (isset($updates['rrule']) || array_key_exists('rrule', $updates)) { $updates['rrule'] = $_oldEvent->rrule; } // check for organizer update if (Tinebase_Record_Abstract::convertId($_event['organizer'], 'Addressbook_Model_Contact') != Tinebase_Record_Abstract::convertId($_oldEvent['organizer'], 'Addressbook_Model_Contact')) { $updates['organizer'] = $_event->resolveOrganizer(); } // check attendee updates $attendeeMigration = Calendar_Model_Attender::getMigration($_oldEvent->attendee, $_event->attendee); foreach ($attendeeMigration['toUpdate'] as $attendee) { $oldAttendee = Calendar_Model_Attender::getAttendee($_oldEvent->attendee, $attendee); if ($attendee->status == $oldAttendee->status) { $attendeeMigration['toUpdate']->removeRecord($attendee); } } foreach ($attendeeMigration as $action => $migration) { Calendar_Model_Attender::resolveAttendee($migration, FALSE); if (!count($migration)) { unset($attendeeMigration[$action]); } } if (!empty($attendeeMigration)) { $updates['attendee'] = $attendeeMigration; } return $updates; }
/** * get group memberships of contact id * * @param mixed $contactId * @return array */ public function getMemberships($contactId) { $contactId = Tinebase_Record_Abstract::convertId($contactId, 'Addressbook_Model_Contact'); $select = $this->_db->select()->from($this->_tablePrefix . $this->_foreignTables['members']['table'], 'list_id')->where($this->_db->quoteIdentifier('contact_id') . ' = ?', $contactId); $stmt = $this->_db->query($select); $rows = (array) $stmt->fetchAll(Zend_Db::FETCH_ASSOC); $result = array(); foreach ($rows as $membership) { $result[] = $membership['list_id']; } return $result; }
/** * Deletes entries * * @param string|integer|Tinebase_Record_Interface|array $_id * @return int The number of affected rows. */ public function delete($_id) { if (empty($_id)) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' No records deleted.'); } return 0; } $idArray = !is_array($_id) ? array(Tinebase_Record_Abstract::convertId($_id, $this->_modelName)) : $_id; $identifier = $this->_getRecordIdentifier(); $where = array($this->_db->quoteInto($this->_db->quoteIdentifier($identifier) . ' IN (?)', $idArray)); return $this->_db->delete($this->_tablePrefix . $this->_tableName, $where); }
/** * get redirects by sippeer_id * * @param string|Voipmanager_Model_Asterisk_SipPeer $_sipPeer the sippeer id|object * @return Voipmanager_Model_Asterisk_Redirect * * @throws Voipmanager_Exception_NotFound */ protected function _getRedirect($_sipPeer) { $sipPeerId = Tinebase_Record_Abstract::convertId($_sipPeer, 'Voipmanager_Model_Asterisk_SipPeer'); $filter = new Voipmanager_Model_Asterisk_RedirectFilter(array(array('field' => 'sippeer_id', 'operator' => 'equals', 'value' => $sipPeerId))); $redirects = Voipmanager_Controller_Asterisk_Redirect::getInstance()->search($filter); if (count($redirects) === 0) { throw new Voipmanager_Exception_NotFound(); } return $redirects[0]; }