setData() public method

Set the object data.
public setData ( array $data )
$data array The object data.
Beispiel #1
0
    public function testStore()
    {
        $driver = new Horde_Kolab_Storage_Stub_Driver('user');
        $driver->setMessage('INBOX', 1, file_get_contents(__DIR__ . '/../../../../fixtures/note.eml'));
        $factory = new Horde_Kolab_Format_Factory();
        $writer = new Horde_Kolab_Storage_Object_Writer_Format($factory);
        $object = new Horde_Kolab_Storage_Object();
        $object->setDriver($driver);
        $folder = $this->getMock('Horde_Kolab_Storage_Folder');
        $folder->expects($this->once())->method('getPath')->will($this->returnValue('INBOX'));
        $folder->expects($this->once())->method('getType')->will($this->returnValue('note'));
        $structure = $driver->fetchComplete('INBOX', 1);
        $object->load(1, $folder, $writer, $structure[1]);
        $object->setData(array('summary' => 'NEW', 'description' => 'test', 'uid' => 'ABC1234'));
        $object->save($writer);
        $result = $driver->messages['INBOX'][2];
        $result = preg_replace(array('/=20/', '/Date: .*/', '/boundary=".*"/', '/--=_.*/', '/<creation-date>[^<]*/', '/<last-modification-date>[^<]*/', '/\\r\\n/', '/=\\n/'), array(' ', 'Date: ', 'boundary=""', '--=_', '<creation-date>', '<last-modification-date>', "\n", ''), $result);
        $this->assertEquals('From: user
To: user
Date: 
Subject: ABC1234
User-Agent: Horde::Kolab::Storage v@version@
MIME-Version: 1.0
X-Kolab-Type: application/x-vnd.kolab.note
Content-Type: multipart/mixed; boundary="";
 name="Kolab Groupware Data"
Content-Disposition: attachment; filename="Kolab Groupware Data"

This message is in MIME format.

--=_
Content-Type: text/plain; charset=utf-8; name="Kolab Groupware Information"
Content-Disposition: inline; filename="Kolab Groupware Information"

This is a Kolab Groupware object. To view this object you will need an email
client that understands the Kolab Groupware format. For a list of such email
clients please visit http://www.kolab.org/content/kolab-clients
--=_
Content-Type: application/x-vnd.kolab.note; name=kolab.xml
Content-Disposition: inline; x-kolab-type=xml; filename=kolab.xml

<?xml version="1.0" encoding="UTF-8"?>
<note version="1.0">
  <uid>ABC1234</uid>
  <body/>
  <categories/>
  <creation-date></creation-date>
  <last-modification-date></last-modification-date>
  <sensitivity>public</sensitivity>
  <product-id>Horde_Kolab_Format_Xml-@version@ (api version: 2)</product-id>
  <summary>NEW</summary>
  <x-test>other client</x-test>
  <background-color>#000000</background-color>
  <foreground-color>#ffff00</foreground-color>
</note>

--=_
', $result);
    }
Beispiel #2
0
    public function testStore()
    {
        if (version_compare(PHP_VERSION, '5.5.0', '>=') && version_compare(PHP_VERSION, '5.5.3', '<=')) {
            $this->markTestSkipped('PHP version with broken quoted-printable-encode');
        }
        setlocale(LC_MESSAGES, 'C');
        $factory = new Horde_Kolab_Format_Factory();
        $writer = new Horde_Kolab_Storage_Object_Writer_Format($factory);
        $folder = $this->getMock('Horde_Kolab_Storage_Folder');
        $folder->expects($this->once())->method('getPath')->will($this->returnValue('INBOX'));
        $driver = new Horde_Kolab_Storage_Stub_Driver('user');
        $object = new Horde_Kolab_Storage_Object();
        $object->setDriver($driver);
        $object->setData(array('summary' => 'TEST', 'description' => 'test', 'uid' => 'ABC1234'));
        $object->create($folder, $writer, 'note');
        $result = $driver->messages['INBOX'][0];
        $result = preg_replace(array('/=20/', '/Date: .*/', '/boundary=".*"/', '/--=_.*/', '/<creation-date>[^<]*/', '/<last-modification-date>[^<]*/', '/\\r\\n/', '/=\\n/'), array(' ', 'Date: ', 'boundary=""', '--=_', '<creation-date>', '<last-modification-date>', "\n", ''), $result);
        $this->assertEquals('From: user
To: user
Date: 
Subject: ABC1234
User-Agent: Horde_Kolab_Storage @version@
MIME-Version: 1.0
X-Kolab-Type: application/x-vnd.kolab.note
Content-Type: multipart/mixed; name="Kolab Groupware Data";
 boundary=""
Content-Disposition: attachment; filename="Kolab Groupware Data"

This message is in MIME format.

--=_
Content-Type: text/plain; name="Kolab Groupware Information"; charset=utf-8
Content-Disposition: inline; filename="Kolab Groupware Information"

This is a Kolab Groupware object. To view this object you will need an email client that understands the Kolab Groupware format. For a list of such email clients please visit http://www.kolab.org/content/kolab-clients
--=_
Content-Type: application/x-vnd.kolab.note; name=kolab.xml
Content-Disposition: inline; x-kolab-type=xml; filename=kolab.xml
Content-Transfer-Encoding: quoted-printable

<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<note version=3D"1.0">
  <uid>ABC1234</uid>
  <body></body>
  <categories></categories>
  <creation-date></creation-date>
  <last-modification-date></last-modification-date>
  <sensitivity>public</sensitivity>
  <product-id>Horde_Kolab_Format_Xml-@version@ (api version: 2)</product-id>
  <summary>TEST</summary>
  <background-color>#000000</background-color>
  <foreground-color>#ffff00</foreground-color>
</note>

--=_
', $result);
    }
Beispiel #3
0
 /**
  * Convert the object content into a data structure and update the object
  * accordingly.
  *
  * @param resource $content The raw content from the object.
  * @param Horde_Kolab_Storage_Object $object The object that should receive the parsed data.
  */
 public function load($content, Horde_Kolab_Storage_Object $object)
 {
     try {
         $object->setData($this->_getParser($object->getType())->load($content));
         return true;
     } catch (Horde_Kolab_Format_Exception $e) {
         $object->setContent($content);
         return $e;
     }
 }
Beispiel #4
0
 public function testAutomaticUid()
 {
     $object = new Horde_Kolab_Storage_Object();
     $object->setData(array());
     $this->assertEquals(array('uid'), array_keys($object->getData()));
 }
Beispiel #5
0
 /**
  * Create a new object.
  *
  * @param array   &$object The array that holds the object data.
  * @param boolean $raw     True if the data to be stored has been provided in
  *                         raw format.
  *
  * @return string The ID of the new object or true in case the backend does
  *                not support this return value.
  *
  * @throws Horde_Kolab_Storage_Exception In case an error occured while
  *                                       saving the data.
  */
 public function create(&$object, $raw = false)
 {
     if ($raw === false) {
         $writer = new Horde_Kolab_Storage_Object_Writer_Format(new Horde_Kolab_Format_Factory(), array('version' => $this->_version));
     } else {
         $writer = new Horde_Kolab_Storage_Object_Writer_Raw();
     }
     $storage_object = new Horde_Kolab_Storage_Object();
     $storage_object->setDriver($this->_driver);
     $storage_object->setData($object);
     if (empty($object['uid'])) {
         $object['uid'] = $storage_object->getUid();
     }
     $result = $storage_object->create($this->_folder, $writer, $this->getType());
     if ($result === true) {
         $params = array();
     } else {
         $params = array('changes' => array(Horde_Kolab_Storage_Folder_Stamp::ADDED => array($result => $storage_object), Horde_Kolab_Storage_Folder_Stamp::DELETED => array()));
     }
     $this->synchronize($params);
     return $result;
 }