/** * parse options * * @param string $_value * @return array|string */ public static function parseConfigValue($_value) { if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_value, TRUE)); } // check value is json encoded if (Tinebase_Helper::is_json($_value)) { return Zend_Json::decode($_value); } $result = array('active' => 1); // keep spaces, \: and \, $_value = preg_replace(array('/ /', '/\\\\:/', '/\\\\,/', '/\\s*/'), array('§', '@', ';', ''), $_value); $parts = explode(',', $_value); foreach ($parts as $part) { $part = str_replace(';', ',', $part); $part = str_replace('§', ' ', $part); $part = str_replace('@', ':', $part); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $part); } if (strpos($part, '_') !== FALSE) { list($key, $sub) = preg_split('/_/', $part, 2); if (preg_match('/:/', $sub)) { list($subKey, $value) = explode(':', $sub); $result[$key][$subKey] = $value; } else { // might be a '_' in the value if (preg_match('/:/', $part)) { $exploded = explode(':', $part); $key = array_shift($exploded); $result[$key] = implode(':', $exploded); } else { throw new Timetracker_Exception_UnexpectedValue('You have an error in the config syntax (":" expected): ' . $part); } } } else { if (strpos($part, ':') !== FALSE) { list($key, $value) = preg_split('/:/', $part, 2); $result[$key] = $value; } else { $result = $part; } } } return $result; }
/** * converts raw data from adapter into a set of records * * @param array $_rawData of arrays * @return Tinebase_Record_RecordSet */ protected function _rawDataToRecordSet(array $_rawData) { $events = new Tinebase_Record_RecordSet($this->_modelName); $events->addIndices(array('rrule', 'recurid')); foreach ($_rawData as $rawEvent) { $rawEvent['rrule_constraints'] = Tinebase_Helper::is_json($rawEvent['rrule_constraints']) ? json_decode($rawEvent['rrule_constraints'], true) : NULL; $events->addRecord(new Calendar_Model_Event($rawEvent, true)); } $this->appendForeignRecordSetToRecordSet($events, 'attendee', 'id', Calendar_Backend_Sql_Attendee::FOREIGNKEY_EVENT, $this->_attendeeBackend); return $events; }
/** * get system note change text * * @param Tinebase_Model_ModificationLog $modification * @return string */ protected function _getSystemNoteChangeText(Tinebase_Model_ModificationLog $modification) { // check if $modification->new_value is json string and record set diff // @see 0008546: When edit event, history show "code" ... if (Tinebase_Helper::is_json($modification->new_value)) { $newValueArray = Zend_Json::decode($modification->new_value); if ((isset($newValueArray['model']) || array_key_exists('model', $newValueArray)) && (isset($newValueArray['added']) || array_key_exists('added', $newValueArray))) { $diff = new Tinebase_Record_RecordSetDiff($newValueArray); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' fetching translated text for diff: ' . print_r($diff->toArray(), true)); } return $diff->getTranslatedDiffText(); } } return $modification->old_value . ' -> ' . $modification->new_value; }