Skip to content

Commit

Permalink
Fix parsing task organizer and owner.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Feb 20, 2015
1 parent bf0ebf2 commit f96f075
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
3 changes: 3 additions & 0 deletions framework/Compress/lib/Horde/Compress/Tnef.php
Expand Up @@ -109,6 +109,9 @@ class Horde_Compress_Tnef extends Horde_Compress_Base
// pidTagSentRepresentingEmail
const MAPI_SENT_REP_EMAIL_ADDR = 0x0065;

// pidTagDisplayTo
const MAPI_DISPLAY_TO = 0x0e04;

// pidTagSentRepresentingSMTPAddress
const MAPI_SENT_REP_SMTP_ADDR = 0x5d02;

Expand Down
42 changes: 26 additions & 16 deletions framework/Compress/lib/Horde/Compress/Tnef/VTodo.php
Expand Up @@ -55,7 +55,6 @@ class Horde_Compress_Tnef_VTodo extends Horde_Compress_Tnef_Object
const MAPI_TASK_LASTUSER = 0x8122;
const MAPI_TASK_OWNERSHIP = 0x8129;


/**
* MAPI_TASK_STATUS constants
*/
Expand Down Expand Up @@ -290,6 +289,10 @@ public function setMapiAttribute($type, $name, $value, $ns = null)
switch ($name) {
case self::MAPI_TASK_OWNER:
// This is the OWNER, not to be confused with the ORGANIZER.
// I.e., this is the person the task has been assigned to.
// The ORGANIZER is the person who created the task and has
// assigned it. I.e., the person that any task updates are
// sent back to by the owner.
$this->_owner = str_replace(array('(', ')'), array('<', '>'), $value);
break;
case self::MAPI_TASK_DUEDATE:
Expand Down Expand Up @@ -341,21 +344,27 @@ public function setMapiAttribute($type, $name, $value, $ns = null)
case Horde_Compress_Tnef::MAPI_LAST_MODIFIER_NAME:
$this->_lastUser = $value;
break;
case self::MAPI_TASK_ASSIGNER:
// *sigh* This isn't set by Outlook/Exchange until AFTER the
// assignee receives the request. I.e., this is blank on the initial
// REQUEST so not a valid way to obtain the task creator.
//$this->_organizer = $value;
break;
case self::MAPI_TASK_LASTUSER:
// From MS-OXOTASK 2.2.2.2.25:
// Before client sends a REQUEST, it is set to the assigner.
// Before client sends an ACCEPT, it is set to the assignee.
// Before client sneds REJECT, it is set to the assigner, not assignee.
// Unfortunately, it is only the display name, not the email!
//$this->_lastUser = $value;
// case self::MAPI_TASK_ASSIGNER:
// // *sigh* This isn't set by Outlook/Exchange until AFTER the
// // assignee receives the request. I.e., this is blank on the initial
// // REQUEST so not a valid way to obtain the task creator.
// //$this->_organizer = $value;
// break;
// case self::MAPI_TASK_LASTUSER:
// // From MS-OXOTASK 2.2.2.2.25:
// // Before client sends a REQUEST, it is set to the assigner.
// // Before client sends an ACCEPT, it is set to the assignee.
// // Before client sneds REJECT, it is set to the assigner, not assignee.
// // Unfortunately, it is only the display name, not the email!
// //$this->_lastUser = $value;
break;
}
} else {
// pidTag?
switch ($name) {
case Horde_Compress_Tnef::MAPI_SENT_REP_EMAIL_ADDR:
$this->_organizer = $value;
}
}
}

Expand All @@ -380,10 +389,11 @@ protected function _tovTodo()
$vtodo = Horde_Icalendar::newComponent('vtodo', $iCal);

$vtodo->setAttribute('UID', $this->_guid);

// For REQUESTS, we MUST have the ORGANIZER and an ATTENDEE.
if ($this->_state == self::STATE_ASSIGNERS_COPY || $this->_ownership == self::OWNERSHIP_ASSIGNERS_COPY) {
$vtodo->setAttribute('ORGANIZER', 'mailto: ' . $this->_owner);
$list = new Horde_Mail_Rfc822_List($this->_lastUser);
$vtodo->setAttribute('ORGANIZER', 'mailto: ' . $this->_organizer);
$list = new Horde_Mail_Rfc822_List($this->_owner);
foreach ($list as $email) {
$vtodo->setAttribute('ATTENDEE', $email, array('ROLE' => 'REQ-PARTICIPANT'));
}
Expand Down

0 comments on commit f96f075

Please sign in to comment.