#!/bin/bash

ROOT=/home/shquier/easyconf.net/easychair

echo
echo "==========================================================="
echo " EASYCONF ENTERPRISE WORKFLOW AUDIT"
echo "==========================================================="
echo

echo "===== 1. UPDATE submissions ====="
grep -Rni \
"UPDATE[[:space:]]\+submissions" \
"$ROOT/app" \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== 2. status writes ====="
grep -Rni \
"status[[:space:]]*=" \
"$ROOT/app" \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== 3. stage writes ====="
grep -Rni \
"stage[[:space:]]*=" \
"$ROOT/app" \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== 4. workflow_stage writes ====="
grep -Rni \
"workflow_stage" \
"$ROOT/app" \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== 5. review_assignments updates ====="
grep -Rni \
"UPDATE[[:space:]]\+review_assignments" \
"$ROOT/app" \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== 6. submission_activity_log ====="
grep -Rni \
"submission_activity_log" \
"$ROOT/app" \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== 7. SubmissionWorkflowService ====="
grep -Rni \
"SubmissionWorkflowService::" \
"$ROOT/app" \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "==========================================================="
echo " AUDIT COMPLETE"
echo "==========================================================="
