/** * Function which checks whether received meeting request is either conflicting with other appointments or not. *@return mixed(boolean/integer) true if normal meeting is conflicting or an integer which specifies no of instances * conflict of recurring meeting and false if meeting is not conflicting. */ function isMeetingConflicting($message = false, $userStore = false, $calFolder = false, $msgprops = false) { $returnValue = false; $conflicting = false; $noOfInstances = 0; if (!$message) { $message = $this->message; } if (!$userStore) { $userStore = $this->store; } if (!$calFolder) { $root = mapi_msgstore_openentry($userStore); $rootprops = mapi_getprops($root, array(PR_STORE_ENTRYID, PR_IPM_APPOINTMENT_ENTRYID, PR_FREEBUSY_ENTRYIDS)); if (!isset($rootprops[PR_IPM_APPOINTMENT_ENTRYID])) { return; } $calFolder = mapi_msgstore_openentry($userStore, $rootprops[PR_IPM_APPOINTMENT_ENTRYID]); } if (!$msgprops) { $msgprops = mapi_getprops($message, array($this->proptags['goid'], $this->proptags['goid2'], $this->proptags['startdate'], $this->proptags['duedate'], $this->proptags['recurring'], $this->proptags['clipstart'], $this->proptags['clipend'])); } if ($calFolder) { // Meeting request is recurring, so get all occurrence and check for each occurrence whether it conflicts with other appointments in Calendar. if (isset($msgprops[$this->proptags['recurring']]) && $msgprops[$this->proptags['recurring']]) { // Apply recurrence class and retrieve all occurrences(max: 30 occurrence because recurrence can also be set as 'no end date') $recurr = new Recurrence($userStore, $message); $items = $recurr->getItems($msgprops[$this->proptags['clipstart']], $msgprops[$this->proptags['clipend']] * (24 * 24 * 60), 30); foreach ($items as $item) { // Get all items in the timeframe that we want to book, and get the goid and busystatus for each item $calendarItems = $recurr->getCalendarItems($userStore, $calFolder, $item[$this->proptags['startdate']], $item[$this->proptags['duedate']], array($this->proptags['goid'], $this->proptags['busystatus'], PR_OWNER_APPT_ID)); foreach ($calendarItems as $calendarItem) { if ($calendarItem[$this->proptags['busystatus']] != fbFree) { /** * Only meeting requests have globalID, normal appointments do not have globalID * so if any normal appointment if found then it is assumed to be conflict. */ if (isset($calendarItem[$this->proptags['goid']])) { if ($calendarItem[$this->proptags['goid']] !== $msgprops[$this->proptags['goid']]) { $noOfInstances++; break; } } else { $noOfInstances++; break; } } } } $returnValue = $noOfInstances; } else { // Get all items in the timeframe that we want to book, and get the goid and busystatus for each item $items = getCalendarItems($userStore, $calFolder, $msgprops[$this->proptags['startdate']], $msgprops[$this->proptags['duedate']], array($this->proptags['goid'], $this->proptags['busystatus'], PR_OWNER_APPT_ID)); foreach ($items as $item) { if ($item[$this->proptags['busystatus']] != fbFree) { if (isset($item[$this->proptags['goid']])) { if ($item[$this->proptags['goid']] !== $msgprops[$this->proptags['goid']] && $item[$this->proptags['goid']] !== $msgprops[$this->proptags['goid2']]) { $conflicting = true; break; } } else { $conflicting = true; break; } } } if ($conflicting) { $returnValue = true; } } } return $returnValue; }
/** * Function which checks whether received meeting request is either conflicting with other appointments or not. * @return mixed(boolean/integer) true if normal meeting is conflicting or an integer which specifies no of instances * conflict of recurring meeting and false if meeting is not conflicting. * @param MAPIMessage $message meeting request item that should be checked for conflicts in calendar * @param MAPIStore $userStore store containing calendar folder that will be used for confilict checking * @param MAPIFolder $calFolder calendar folder for conflict checking * @return Mixed if boolean then true/false for indicating confict, if number then items that are conflicting with the message. */ function isMeetingConflicting($message = false, $userStore = false, $calFolder = false) { $returnValue = false; $noOfInstances = 0; if ($message === false) { $message = $this->message; } $messageProps = mapi_getprops($message, array(PR_MESSAGE_CLASS, $this->proptags['goid'], $this->proptags['goid2'], $this->proptags['startdate'], $this->proptags['duedate'], $this->proptags['recurring'], $this->proptags['clipstart'], $this->proptags['clipend'], PR_RCVD_REPRESENTING_NAME)); if ($userStore === false) { $userStore = $this->store; // check if delegate is processing the response if (isset($messageProps[PR_RCVD_REPRESENTING_NAME])) { $delegatorStore = $this->getDelegatorStore($messageProps[PR_RCVD_REPRESENTING_NAME], array(PR_IPM_APPOINTMENT_ENTRYID)); $userStore = $delegatorStore['store']; $calFolder = $delegatorStore[PR_IPM_APPOINTMENT_ENTRYID]; } } if ($calFolder === false) { $calFolder = $this->openDefaultCalendar($userStore); } if ($calFolder) { // Meeting request is recurring, so get all occurrence and check for each occurrence whether it conflicts with other appointments in Calendar. if (isset($messageProps[$this->proptags['recurring']]) && $messageProps[$this->proptags['recurring']] === true) { // Apply recurrence class and retrieve all occurrences(max: 30 occurrence because recurrence can also be set as 'no end date') $recurr = new Recurrence($userStore, $message); $items = $recurr->getItems($messageProps[$this->proptags['clipstart']], $messageProps[$this->proptags['clipend']] * (24 * 24 * 60), 30); foreach ($items as $item) { // Get all items in the timeframe that we want to book, and get the goid and busystatus for each item $calendarItems = $recurr->getCalendarItems($userStore, $calFolder, $item[$this->proptags['startdate']], $item[$this->proptags['duedate']], array($this->proptags['goid'], $this->proptags['busystatus'])); foreach ($calendarItems as $calendarItem) { if ($calendarItem[$this->proptags['busystatus']] !== fbFree) { /** * Only meeting requests have globalID, normal appointments do not have globalID * so if any normal appointment if found then it is assumed to be conflict. */ if (isset($calendarItem[$this->proptags['goid']])) { if ($calendarItem[$this->proptags['goid']] !== $messageProps[$this->proptags['goid']]) { $noOfInstances++; break; } } else { $noOfInstances++; break; } } } } if ($noOfInstances > 0) { $returnValue = $noOfInstances; } } else { // Get all items in the timeframe that we want to book, and get the goid and busystatus for each item $items = getCalendarItems($userStore, $calFolder, $messageProps[$this->proptags['startdate']], $messageProps[$this->proptags['duedate']], array($this->proptags['goid'], $this->proptags['busystatus'])); foreach ($items as $item) { if ($item[$this->proptags['busystatus']] !== fbFree) { if (isset($item[$this->proptags['goid']])) { if ($item[$this->proptags['goid']] !== $messageProps[$this->proptags['goid']] && $item[$this->proptags['goid']] !== $messageProps[$this->proptags['goid2']]) { $returnValue = true; break; } } else { $returnValue = true; break; } } } } } return $returnValue; }