**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**    GNU General Public License for more details.
**
**    You should have received a copy of the GNU General Public License
**    along with Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
include "code/includes.php";
$project_id = $_REQUEST['project_id'];
$active_project = new Project();
$active_project->populateFromId($project_id);
$active_project->id = "";
$active_project->title .= " (Copy)";
//DEFAULT TITLE FOR DUPLICATED PROJECTS IS "[ORIGINAL PROJECT NAME] (Copy)"
$active_project->user_id = $active_user->id;
$active_project->insertNew();
$new_project_id = $active_project->id;
$old_evidence = array();
$old_hypotheses = array();
$new_evidence = array();
$new_hypotheses = array();
//GET ALL OF THE EVIDENCE FROM THIS MATRIX AND DUPLICATE IT
$result = mysql_do("SELECT id, deleted FROM evidence WHERE project_id='{$project_id}'");
while ($query_data = mysql_fetch_array($result)) {
    if ($query_data['deleted'] != "y") {
        $this_evidence = new Evidence();
        $this_evidence->populateFromId($query_data['id']);
        $this_evidence->project_id = $active_project->id;
        $this_evidence->user_id = $active_user->id;
        //this makes the duplicating user the creator of the new evidence, regardless of who originally created it
        $this_evidence->insertNew();
 }
 if (strtolower($achz->CLASSIFICATION) == "t") {
     $this_project->classification = "TS";
 }
 if (strtolower($achz->CLASSIFICATION) == "ts") {
     $this_project->classification = "TS";
 }
 if (strtolower($achz->CLASSIFICATION) == "top secret") {
     $this_project->classification = "TS";
 }
 if (strtolower($achz->CLASSIFICATION) == "top-secret") {
     $this_project->classification = "TS";
 }
 $this_project->open = "n";
 $this_project->user_id = $active_user->id;
 $this_project->insertNew();
 $this_hypothesis = array();
 for ($i = 0; $i < count($achz->MATRIX->HYPOTHESIS); $i++) {
     $this_hypothesis[$i] = new Hypothesis();
     $this_hypothesis[$i]->label = $achz->MATRIX->HYPOTHESIS[$i]->NAME;
     $this_hypothesis[$i]->user_id = $active_user->id;
     $this_hypothesis[$i]->project_id = $this_project->id;
     $this_hypothesis[$i]->insertNew();
 }
 for ($i = 0; $i < count($achz->MATRIX->EVIDENCE); $i++) {
     $this_evidence = new Evidence();
     $this_evidence->name = $achz->MATRIX->EVIDENCE[$i]->NAME[0];
     $this_evidence->details = $achz->MATRIX->EVIDENCE[$i]->NOTES[0];
     if ($achz->MATRIX->EVIDENCE[$i]->LINK[0] != "") {
         if ($this_evidence->details != "") {
             $this_evidence->details .= " ";