Created
October 17, 2017 14:27
-
-
Save axon-obriend/bda6038597a7062013e77ce28d95fb96 to your computer and use it in GitHub Desktop.
Compare any modified CiviCRM workflow templates to the originals
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
#!/usr/bin/env bash | |
set -x | |
test -d ./default && rm -rf ./default | |
mkdir ./default | |
test -d ./modified && rm -rf ./modified | |
mkdir ./modified | |
TID=`mysql --skip-column-names --database=civicrm -e " | |
SELECT workflow_id | |
FROM civicrm_msg_template | |
WHERE workflow_id IS NOT NULL | |
GROUP BY workflow_id | |
HAVING COUNT(*)>1"` | |
for ID in $TID; do | |
for X in text html; do | |
TNAME=`mysql --skip-column-names --database=civicrm -e " | |
SELECT msg_title | |
FROM civicrm_msg_template | |
WHERE workflow_id=$ID AND is_default=1"` | |
cat <<EOF > "./default/$TNAME.$X" | |
`mysql --skip-column-names --database=civicrm -e " | |
SELECT msg_$X | |
FROM civicrm_msg_template | |
WHERE workflow_id=$ID AND is_default=1"` | |
EOF | |
sed -i -e 's/\\n/\n/g' "./default/$TNAME.$X" | |
cat <<EOF > "./modified/$TNAME.$X" | |
`mysql --skip-column-names --database=civicrm -e " | |
SELECT msg_$X | |
FROM civicrm_msg_template | |
WHERE workflow_id=$ID AND is_default=0"` | |
EOF | |
sed -i -e 's/\\n/\n/g' "./modified/$TNAME.$X" | |
diff -bB "./default/$TNAME.$X" "./modified/$TNAME.$X" > "./modified/$TNAME.$X.diff" && rm "./modified/$TNAME.$X" "./modified/$TNAME.$X.diff" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/ginkgomzd/0ae45009afda8b6d85aca9e03a57df2b
I changed some things to suite my preferences but some things are objectively better. See comment on my gist for other changes.
Note, that thanks to CiviCRM being Civi... is_default does not mean what you think it means... so the diffs were actually backwards. See comment in my version.