Beispiel #1
0
 /**
  * testInvitationExternalReply
  */
 public function testInvitationExternalReply()
 {
     $testConfig = Zend_Registry::get('testConfig');
     $email = $testConfig->email ? $testConfig->email : '*****@*****.**';
     $ics = file_get_contents(dirname(__FILE__) . '/files/invitation_reply_external_accepted.ics');
     $ics = preg_replace('/unittest@tine20\\.org/', $email, $ics);
     $iMIP = new Calendar_Model_iMIP(array('id' => Tinebase_Record_Abstract::generateUID(), 'ics' => $ics, 'method' => 'REPLY', 'originator' => '*****@*****.**'));
     $this->assertEquals(1, $iMIP->getEvent()->seq);
     $this->assertTrue(!empty($iMIP->getEvent()->last_modified_time));
     // force creation of external attendee
     $externalAttendee = new Calendar_Model_Attender(array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => $iMIP->getEvent()->attendee->getFirstRecord()->user_id, 'status' => Calendar_Model_Attender::STATUS_NEEDSACTION));
     // create matching event
     $event = new Calendar_Model_Event(array('summary' => 'TEST7', 'dtstart' => '2011-11-30 14:00:00', 'dtend' => '2011-11-30 15:00:00', 'description' => 'Early to bed and early to rise, makes a men healthy, wealthy and wise ...', 'attendee' => $this->_getAttendee(), 'organizer' => Tinebase_Core::getUser()->contact_id, 'uid' => 'a8d10369e051094ae9322bd65e8afecac010bfc8'));
     $event->attendee->addRecord($externalAttendee);
     $event = Calendar_Controller_Event::getInstance()->create($event);
     $this->_eventIdsToDelete[] = $event->getId();
     // TEST NORMAL REPLY
     try {
         $this->_iMIPFrontend->autoProcess($iMIP);
     } catch (Exception $e) {
         $this->fail('TEST NORMAL REPLY autoProcess throws Exception: ' . $e);
     }
     unset($iMIP->existing_event);
     $updatedEvent = Calendar_Controller_Event::getInstance()->get($event->getId());
     $updatedExternalAttendee = Calendar_Model_Attender::getAttendee($updatedEvent->attendee, $externalAttendee);
     $this->assertEquals(3, count($updatedEvent->attendee));
     $this->assertEquals(Calendar_Model_Attender::STATUS_ACCEPTED, $updatedExternalAttendee->status, 'status not updated');
     // TEST ACCEPTABLE NON RECENT REPLY
     $updatedExternalAttendee->status = Calendar_Model_Attender::STATUS_NEEDSACTION;
     Calendar_Controller_Event::getInstance()->attenderStatusUpdate($updatedEvent, $updatedExternalAttendee, $updatedExternalAttendee->status_authkey);
     try {
         $iMIP->preconditionsChecked = false;
         $this->_iMIPFrontend->autoProcess($iMIP);
     } catch (Exception $e) {
         $this->fail('TEST ACCEPTABLE NON RECENT REPLY autoProcess throws Exception: ' . $e);
     }
     unset($iMIP->existing_event);
     $updatedEvent = Calendar_Controller_Event::getInstance()->get($event->getId());
     $updatedExternalAttendee = Calendar_Model_Attender::getAttendee($updatedEvent->attendee, $externalAttendee);
     $this->assertEquals(3, count($updatedEvent->attendee));
     $this->assertEquals(Calendar_Model_Attender::STATUS_ACCEPTED, $updatedExternalAttendee->status, 'status not updated');
     // TEST NON ACCEPTABLE NON RECENT REPLY
     $this->setExpectedException('Calendar_Exception_iMIP', 'iMIP preconditions failed: RECENT');
     $iMIP->preconditionsChecked = false;
     $this->_iMIPFrontend->autoProcess($iMIP);
 }
 /**
  * testExternalInvitationCancelProcessAttendee
  *
  */
 public function testExternalInvitationCancelProcessAttendee()
 {
     $iMIP = $this->testExternalInvitationRequestAutoProcess();
     $this->_iMIPFrontendMock->process($iMIP, Calendar_Model_Attender::STATUS_ACCEPTED);
     $this->_eventIdsToDelete[] = $eventId = $iMIP->event->getId();
     $ics = file_get_contents(dirname(__FILE__) . '/files/invitation_cancel.ics');
     // set status to not cancelled, so that only attendees are removed from the event
     $ics = preg_replace('#STATUS:CANCELLED#', 'STATUS:CONFIRMED', $ics);
     $iMIP = new Calendar_Model_iMIP(array('id' => Tinebase_Record_Abstract::generateUID(), 'ics' => $ics, 'method' => 'CANCEL', 'originator' => '*****@*****.**'));
     // TEST CANCEL
     try {
         $this->_iMIPFrontend->autoProcess($iMIP);
     } catch (Exception $e) {
         $this->fail('TEST NORMAL CANCEL autoProcess throws Exception: ' . $e);
     }
     unset($iMIP->existing_event);
     $updatedEvent = Calendar_Controller_Event::getInstance()->get($eventId);
     $this->assertEquals(3, count($updatedEvent->attendee), 'attendee count must be 3');
 }
 /**
  * process an iMIP (RFC 6047) Message
  * 
  * @param array  $iMIP
  * @param string $status
  * @return array prepared iMIP part
  */
 public function iMIPProcess($iMIP, $status = null)
 {
     $iMIPMessage = new Calendar_Model_iMIP($iMIP);
     $iMIPFrontend = new Calendar_Frontend_iMIP();
     $iMIPFrontend->process($iMIPMessage, $status);
     return $this->iMIPPrepare($iMIPMessage);
 }
 /**
  * returns message prepared for json transport
  * - overwriten to convert recipients to array
  *
  * @param Tinebase_Record_Interface $_record
  * @return array record data
  */
 protected function _recordToJson($_record)
 {
     if ($_record instanceof Felamimail_Model_Message) {
         foreach (array('to', 'cc', 'bcc') as $type) {
             if (!is_array($_record->{$type})) {
                 if (!empty($_record->{$type})) {
                     $exploded = explode(',', $_record->{$type});
                     $_record->{$type} = $exploded;
                 } else {
                     $_record->{$type} = array();
                 }
             }
         }
         if ($_record->preparedParts instanceof Tinebase_Record_RecordSet) {
             foreach ($_record->preparedParts as $preparedPart) {
                 if ($preparedPart->preparedData instanceof Calendar_Model_iMIP) {
                     try {
                         $iMIPFrontend = new Calendar_Frontend_iMIP();
                         $iMIPFrontend->prepareComponent($preparedPart->preparedData, true);
                     } catch (Exception $e) {
                         Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not prepare calendar iMIP component: ' . $e->getMessage());
                         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $e->getTraceAsString());
                         }
                         $_record->preparedParts->removeRecord($preparedPart);
                     }
                 }
             }
         }
     } else {
         if ($_record instanceof Felamimail_Model_Account) {
             // add usernames
             $_record->resolveCredentials();
             // imap
             $_record->resolveCredentials(TRUE, FALSE, TRUE);
             // smtp
         } else {
             if ($_record instanceof Felamimail_Model_Sieve_Vacation) {
                 if (!$_record->mime) {
                     $_record->reason = Tinebase_Mail::convertFromTextToHTML($_record->reason, 'felamimail-body-blockquote');
                 }
             }
         }
     }
     return parent::_recordToJson($_record);
 }