Last active
November 19, 2015 14:36
-
-
Save mariolopjr/395375aad33759f6ce32 to your computer and use it in GitHub Desktop.
Discard JEvents iCal Import Events from Showing on Front End
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // This PHP opening tag can be discarded, only exists for syntax coloring :) | |
/* | |
* | |
* Author: Mario Lopez (iibits.com) | |
* License: MIT | |
* | |
* Instructions to implement will follow | |
* | |
*/ | |
// Determines whether to log discarded JEvents messages | |
$logErrors = false; | |
// Iterates through all Joomla! messages, checks for those related to iCal | |
// importing, and then discards them. This is to improve UX | |
foreach ($msgList as $type => $msgs) { | |
// Loops through all msgLists of different error levels to select the one | |
// that contains the JEvents alerts | |
foreach ($msgs as $key => $msg) { | |
// Checks to see if the current iteration matches the following alert | |
if ($msg == "The iCal file was successfully imported.") { | |
// If error logging is turned on, log the discarded message | |
if ($logErrors) | |
error_log("Discarded Message: " . $msg); | |
// Removes the message from the list of messages | |
unset($msgs[$key]); | |
} | |
else { | |
// Removes the amount of events processed from the string | |
$msgArray = explode(' ', $msg, 2); | |
// Checks to see if the current iteration matches the following | |
// alert | |
if ($msgArray[1] == "iCal events processed") { | |
// If error logging is turned on, log the discarded message | |
if ($logErrors) | |
error_log("Discarded Message: " . $msg); | |
// Removes the message from the list of messages | |
unset($msgs[$key]); | |
} | |
} | |
} | |
// If there are no more messages of type information (that's the message | |
// that) JEvents spawns, then dump the entire info msgList | |
if (count($msgs) == 0) { | |
// If error logging is turned on, log the discarded message | |
if ($logErrors) | |
error_log("Discarded MessageList"); | |
// Removes the messagelist from the list of messagelists | |
unset($msgList[$type]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment