Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7292106 authored by AVINASH GUSAIN's avatar AVINASH GUSAIN
Browse files

changes for email template modification on update

parent 13a1acc2
Loading
Loading
Loading
Loading
Loading
+141 −64
Original line number Diff line number Diff line
--- apps/dav/lib/CalDAV/Schedule/IMipPlugin.php	2022-04-27 09:57:34.955523100 +0530
+++ apps/dav/lib/CalDAV/Schedule/IMipPlugin_Modifiednew.php	2022-04-27 09:57:09.345523100 +0530
@@ -659,7 +659,7 @@
 										Message $iTipMessage, $lastOccurrence) {
 		$token = $this->createInvitationToken($iTipMessage, $lastOccurrence);

-		$template->addBodyButtonGroup(
+		$template->addBodyButtonGroupTentative(
 			$l10n->t('Accept'),
 			$this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.accept', [
 				'token' => $token,
@@ -667,18 +667,11 @@
 			$l10n->t('Decline'),
 			$this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.decline', [
 				'token' => $token,
-			])
+			]),
+			$l10n->t('Maybe'),
+			$this->urlGenerator->getAbsoluteUrl('apps/calendar/invitation/tentative/'.$token)
 		);
--- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php	2022-07-07 09:40:41.675627600 +0530
+++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php	2022-07-07 09:45:48.035627600 +0530
@@ -151,15 +151,6 @@
 	 */
 	public function schedule(Message $iTipMessage) {

-		$moreOptionsURL = $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.options', [
-			'token' => $token,
-		]);
-		$html = vsprintf('<small><a href="%s">%s</a></small>', [
-			$moreOptionsURL, $l10n->t('More options …')
-		]);
-		$text = $l10n->t('More options at %s', [$moreOptionsURL]);
-		// Not sending any emails if the system considers the update
-		// insignificant.
-		if (!$iTipMessage->significantChange) {
-			if (!$iTipMessage->scheduleStatus) {
-				$iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email';
-			}
-			return;
-		}
-
-		$template->addBodyText($html, $text);
 	}
 		$summary = $iTipMessage->message->VEVENT->SUMMARY;

 	/**
 		if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') {
@@ -414,7 +405,7 @@
 		return false;
 	}

--- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php	2022-07-04 12:41:03.228533600 +0530
+++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php	2022-07-04 14:42:56.208533600 +0530
@@ -419,23 +419,33 @@
-	/**
+		/**
 	 * @param IL10N $l10n
 	 * @param VEvent $vevent
 	 */
 	private function generateWhenString(IL10N $l10n, VEvent $vevent) {
-		$dtstart = $vevent->DTSTART;
-		if (isset($vevent->DTEND)) {
-			$dtend = $vevent->DTEND;
-		} elseif (isset($vevent->DURATION)) {
-			$isFloating = $vevent->DTSTART->isFloating();
-			$dtend = clone $vevent->DTSTART;
@@ -542,21 +533,57 @@
 	 * @param VEVENT $vevent
 	 */
 	private function addBulletList(IEMailTemplate $template, IL10N $l10n, $vevent) {
-		if ($vevent->SUMMARY) {
-			$template->addBodyListItem($vevent->SUMMARY, $l10n->t('Title:'),
-				$this->getAbsoluteImagePath('caldav/title.png'),'','',self::IMIP_INDENT);
+		$lastmodified=0;
+		$selectedEvent = $vevent;
+		$selectedEvent = $parentevent = $vevent;
+		foreach( $vevent as $currentevent){
+			$dtstamp= $currentevent->{'LAST-MODIFIED'};
+			$dtstampTime = strtotime($dtstamp);
@@ -53,31 +41,120 @@
+				$lastmodified=$dtstampTime;
+				$selectedEvent = $currentevent;
+			}
 		}
-		$meetingWhen = $this->generateWhenString($l10n, $vevent);
+
+		if ($selectedEvent->SUMMARY) {
+
+			if(trim($selectedEvent->SUMMARY)==trim($parentevent->SUMMARY)){
+				$template->addBodyListItem($selectedEvent->SUMMARY, $l10n->t('Title:'),
+					$this->getAbsoluteImagePath('caldav/title.png'),'','',self::IMIP_INDENT);
+			}else{
+				$template->addBodyListItemModified($selectedEvent->SUMMARY, $l10n->t('Updated Title:'),
+					$this->getAbsoluteImagePath('caldav/title.png'),'','',self::IMIP_INDENT);
+			}
+		}
+		$meetingWhen = $this->generateWhenString($l10n, $selectedEvent);
 		if ($meetingWhen) {
-			$template->addBodyListItem($meetingWhen, $l10n->t('Time:'),
-				$this->getAbsoluteImagePath('caldav/time.png'),'','',self::IMIP_INDENT);
+				$selectedtimestart= substr(($selectedEvent->DTSTART), strpos(($selectedEvent->DTSTART), "T") + 1);
+				$parenttimestart= substr(($parentevent->DTSTART), strpos(($parentevent->DTSTART), "T") + 1);
+				$selectedtimeend= substr(($selectedEvent->DTEND), strpos(($selectedEvent->DTEND), "T") + 1);
+				$parenttimeend= substr(($parentevent->DTEND), strpos(($parentevent->DTEND), "T") + 1);
+
+			if(trim($selectedtimestart)==trim($parenttimestart) && trim($selectedtimeend)==trim($parenttimeend)){
+				$template->addBodyListItem($meetingWhen, $l10n->t('Time:'),
+					$this->getAbsoluteImagePath('caldav/time.png'),'','',self::IMIP_INDENT);
+			}else{
+				$template->addBodyListItemModified($meetingWhen, $l10n->t('Updated Time:'),
+					$this->getAbsoluteImagePath('caldav/time.png'),'','',self::IMIP_INDENT);
+			}
+
+
 		}
-		if ($vevent->LOCATION) {
-			$template->addBodyListItem($vevent->LOCATION, $l10n->t('Location:'),
-				$this->getAbsoluteImagePath('caldav/location.png'),'','',self::IMIP_INDENT);
+		if ($selectedEvent->LOCATION) {
+			if(trim($selectedEvent->LOCATION)==trim($parentevent->LOCATION)){
+				$template->addBodyListItem($selectedEvent->LOCATION, $l10n->t('Location:'),
+					$this->getAbsoluteImagePath('caldav/location.png'),'','',self::IMIP_INDENT);
+			}else{
+				$template->addBodyListItemModified($selectedEvent->LOCATION, $l10n->t('Updated Location:'),
+					$this->getAbsoluteImagePath('caldav/location.png'),'','',self::IMIP_INDENT);
+			}
+
+
 		}
-		if ($vevent->URL) {
-			$url = $vevent->URL->getValue();
+		if ($selectedEvent->URL) {
+			$url = $selectedEvent->URL->getValue();
 			$template->addBodyListItem(sprintf('<a href="%s">%s</a>',
 					htmlspecialchars($url),
 					htmlspecialchars($url)),
@@ -565,12 +592,18 @@
 				$url,'',self::IMIP_INDENT);
 		}

-		$this->addAttendees($template, $l10n, $vevent);
+		$this->addAttendees($template, $l10n, $selectedEvent);

 		/* Put description last, like an email body, since it can be arbitrarily long */
-		if ($vevent->DESCRIPTION) {
-			$template->addBodyListItem($vevent->DESCRIPTION->getValue(), $l10n->t('Description:'),
-				$this->getAbsoluteImagePath('caldav/description.png'),'','',self::IMIP_INDENT);
+		if ($selectedEvent->DESCRIPTION) {
+			if(trim($selectedEvent->DESCRIPTION)==trim($parentevent->DESCRIPTION)){
+				$template->addBodyListItem($selectedEvent->DESCRIPTION->getValue(), $l10n->t('Description:'),
+					$this->getAbsoluteImagePath('caldav/description.png'),'','',self::IMIP_INDENT);
+			}else{
+				$template->addBodyListItemModified($selectedEvent->DESCRIPTION, $l10n->t('Updated Description:'),
+					$this->getAbsoluteImagePath('caldav/description.png'),'','',self::IMIP_INDENT);
+			}
+		$dtstart = $selectedEvent->DTSTART;
+		if (isset($selectedEvent->DTEND)) {
+			$dtend = $selectedEvent->DTEND;
+		} elseif (isset($selectedEvent->DURATION)) {
+			$isFloating = $selectedEvent->DTSTART->isFloating();
+			$dtend = clone $selectedEvent->DTSTART;
 			$endDateTime = $dtend->getDateTime();
-			$endDateTime = $endDateTime->add(DateTimeParser::parse($vevent->DURATION->getValue()));
+			$endDateTime = $endDateTime->add(DateTimeParser::parse($selectedEvent->DURATION->getValue()));
 			$dtend->setDateTime($endDateTime, $isFloating);
-		} elseif (!$vevent->DTSTART->hasTime()) {
-			$isFloating = $vevent->DTSTART->isFloating();
-			$dtend = clone $vevent->DTSTART;
+		} elseif (!$selectedEvent->DTSTART->hasTime()) {
+			$isFloating = $selectedEvent->DTSTART->isFloating();
+			$dtend = clone $selectedEvent->DTSTART;
 			$endDateTime = $dtend->getDateTime();
 			$endDateTime = $endDateTime->modify('+1 day');
 			$dtend->setDateTime($endDateTime, $isFloating);
 		} else {
-			$dtend = clone $vevent->DTSTART;
+			$dtend = clone $selectedEvent->DTSTART;
+
 		}
 	}

@@ -659,7 +692,7 @@
 										Message $iTipMessage, $lastOccurrence) {
 		$token = $this->createInvitationToken($iTipMessage, $lastOccurrence);

-		$template->addBodyButtonGroupTentative(
+		$template->addBodyButtonGroup(
 			$l10n->t('Accept'),
 			$this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.accept', [
 				'token' => $token,
@@ -667,11 +700,18 @@
 			$l10n->t('Decline'),
 			$this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.decline', [
 				'token' => $token,
-			]),
-			$l10n->t('Maybe'),
-			$this->urlGenerator->getAbsoluteUrl('apps/calendar/invitation/tentative/'.$token)
+			])
 		);

+		$moreOptionsURL = $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.options', [
+			'token' => $token,
+		]);
+		$html = vsprintf('<small><a href="%s">%s</a></small>', [
+			$moreOptionsURL, $l10n->t('More options …')
+		]);
+		$text = $l10n->t('More options at %s', [$moreOptionsURL]);
+
+		$template->addBodyText($html, $text);
 	}

 		$isAllDay = $dtstart instanceof Property\ICalendar\Date;
 	/**
@@ -716,4 +756,4 @@

 		return $token;
 	}
-}
+}
\ No newline at end of file