function findReportsByReporteeId($id)
{
    global $me, $db;
    $reports_found = array();
    // Search for reports about this person.
    $result = pg_query_params($db->getHandle(), 'SELECT * FROM incidents WHERE reportee_id=$1', array($id));
    if (pg_num_rows($result)) {
        while ($row = pg_fetch_assoc($result)) {
            $r = new PATIncident($row);
            $r->setReader($me);
            if ($r->isVisible()) {
                $reports_found[] = $r;
            }
        }
    }
    return $reports_found;
}
<?php

// We're ready to save?
if (isset($_REQUEST['submit']) && !empty($_REQUEST['reportee_id'])) {
    $report = new PATIncident(array('reporter_id' => $user_id, 'reportee_id' => $_REQUEST['reportee_id'], 'report_title' => $_REQUEST['report_title'], 'report_text' => $_REQUEST['report_text'], 'report_visibility' => $_REQUEST['report_visibility'], 'contactable' => $_REQUEST['communication_preference']));
    if ($report->fieldsValidate()) {
        if ($rid = $report->save()) {
            // get list of other people who have reported this reportee.
            $result = pg_query_params($db->getHandle(), 'SELECT DISTINCT reporter_id FROM incidents WHERE reportee_id = $1 AND reporter_id <> $2', array($report->reportee_id, $report->reporter_id));
            // Check those other people's notification preference.
            while ($row = pg_fetch_assoc($result)) {
                $usr = new PATFacebookUser($FB, $row['reporter_id']);
                $prefs = $usr->getPreferences();
                // If their notification preference is on,
                if ($prefs['notify_on_same_reportee']) {
                    $report->setReader($usr);
                    if ($report->isVisible()) {
                        // send each of them a notification.
                        $FB->setAccessToken(getFacebookAppToken());
                        $FB->api("/{$usr->getId()}/notifications", 'post', array('template' => 'More information was shared about someone you previously shared about; click here to read the statement.', 'href' => "reports.php?action=lookup&id={$rid}"));
                    }
                }
            }
            header('Location: ' . AppInfo::getUrl($_SERVER['PHP_SELF'] . "?action=lookup&id={$rid}"));
            exit;
        }
    }
}
?>
<section id="MainContent">
    <h1>Share</h1>
                        $reports_about_friends[] = $r;
                    }
                }
            }
        }
    }
}
// Search for any reports filed by other people about people I've reported.
$sql_vals = array();
$sql = 'SELECT * FROM incidents WHERE reportee_id IN (';
$sql .= 'SELECT reportee_id FROM incidents WHERE reporter_id=$1';
$sql .= ') AND reporter_id <> $1 ORDER BY report_date DESC';
$result = pg_query_params($db->getHandle(), $sql, array($user_id));
if (pg_num_rows($result)) {
    while ($row = pg_fetch_assoc($result)) {
        $r = new PATIncident($row);
        $r->setReader($me);
        if ($r->isVisible()) {
            $reports_about_reported[] = $r;
        }
    }
}
?>
<section id="MainContent">
    <h1>Take action</h1>
    <ul>
<!--
        <li>
            <a href="https://www.heroku.com/?utm_source=facebook&utm_medium=app&utm_campaign=fb_integration" target="_top" class="icon heroku">Heroku</a>
            <p>Learn more about <a href="https://www.heroku.com/?utm_source=facebook&utm_medium=app&utm_campaign=fb_integration" target="_top">Heroku</a>, or read developer docs in the Heroku <a href="https://devcenter.heroku.com/" target="_top">Dev Center</a>.</p>
        </li>