/** * Test storing attachments. * * @return NULL */ public function testCacheAttachmentAsContent() { $data = new Horde_Kolab_Storage_Data('contact'); $data->setFolder($this->folder); $object = array('uid' => '1', 'full-name' => 'User Name', 'email' => '*****@*****.**', 'inline-attachment' => array('test.txt'), '_attachments' => array('test.txt' => array('type' => 'text/plain', 'content' => 'test', 'name' => 'test.txt'))); $result = $data->save($object); $this->assertNoError($result); $result = $data->getObject(1); $this->assertNoError($result); $this->assertTrue(isset($result['_attachments']['test.txt'])); $this->assertEquals("test\r", $data->getAttachment($result['_attachments']['test.txt']['key'])); }
/** * Retrieve a handler for the data in this folder. * * @param Kolab_List $list The handler for the list of folders. * * @return Horde_Kolab_Storage_Data The data handler. */ public function getData($object_type = null, $data_version = 1) { if (empty($object_type)) { $object_type = $this->getType(); if (is_a($object_type, 'PEAR_Error')) { return $object_type; } } if ($this->tainted) { foreach ($this->_data as $data) { $data->synchronize(); } $this->tainted = false; } $key = $object_type . '|' . $data_version; if (!isset($this->_data[$key])) { if ($object_type != 'annotation') { $type = $this->getType(); } else { $type = 'annotation'; } $data = new Horde_Kolab_Storage_Data($type, $object_type, $data_version); $data->setFolder($this); $data->setCache($this->_storage->getDataCache()); $data->synchronize(); $this->_data[$key] =& $data; } return $this->_data[$key]; }