Exemplo n.º 1
0
 /**
  * this function creates a Addressbook_Model_Contact and stores it in the database
  * 
  * @todo the header handling does not belong here. It should be moved to the DAV_Server class when supported
  * 
  * @param  Tinebase_Model_Container  $container
  * @param  stream|string           $vcardData
  */
 public static function create(Tinebase_Model_Container $container, $name, $vcardData)
 {
     list($backend, $version) = Addressbook_Convert_Contact_VCard_Factory::parseUserAgent($_SERVER['HTTP_USER_AGENT']);
     $converter = Addressbook_Convert_Contact_VCard_Factory::factory($backend, $version);
     $contact = $converter->toTine20Model($vcardData);
     $contact->container_id = $container->getId();
     $id = ($pos = strpos($name, '.')) === false ? $name : substr($name, 0, $pos);
     $contact->setId($id);
     $contact = Addressbook_Controller_Contact::getInstance()->create($contact, false);
     $card = new self($container, $contact);
     return $card;
 }
 /**
  * this function creates a Addressbook_Model_Contact and stores it in the database
  * 
  * @todo the header handling does not belong here. It should be moved to the DAV_Server class when supported
  * 
  * @param  Tinebase_Model_Container  $container
  * @param  stream|string           $vcardData
  */
 public static function create(Tinebase_Model_Container $container, $name, $vcardData)
 {
     list($backend, $version) = Addressbook_Convert_Contact_VCard_Factory::parseUserAgent($_SERVER['HTTP_USER_AGENT']);
     $converter = Addressbook_Convert_Contact_VCard_Factory::factory($backend, $version);
     $contact = $converter->toTine20Model($vcardData);
     $contact->container_id = $container->getId();
     $id = ($pos = strpos($name, '.')) === false ? $name : substr($name, 0, $pos);
     $id = strlen($id) > 40 ? sha1($id) : $id;
     $contact->setId($id);
     try {
         $contact = Addressbook_Controller_Contact::getInstance()->create($contact, false);
     } catch (Tinebase_Exception_AccessDenied $tead) {
         Tinebase_Exception::log($tead);
         throw new DAV\Exception\Forbidden('Access denied');
     }
     $card = new self($container, $contact);
     return $card;
 }
Exemplo n.º 3
0
 /**
  * test factory with useragent string from kde 
  */
 public function testUserAgentKDE()
 {
     list($backend, $version) = Addressbook_Convert_Contact_VCard_Factory::parseUserAgent('Mozilla/5.0 (X11; Linux i686) KHTML/4.7.3 (like Gecko) Konqueror/4.7');
     $this->assertEquals(Addressbook_Convert_Contact_VCard_Factory::CLIENT_KDE, $backend);
     $this->assertEquals('4.7', $version);
 }