<?php
   define('USER', 'jesse.turner@gatewaybaltic.com');
   define('TOKEN', 'reNaj8P1B4r3y9=fD8RaM0a4Lf30sdBda1d210we'); 
   require 'Solve360Service.php';
   
   $solve360Service = new Solve360Service(USER, TOKEN);

   $blogId=$_GET["p"];
   $blog = $solve360Service->getProjectblog($blogId);
   $comps[]="$blogId";
   
   $loadedFiles=array('NO','NO','NO');
   $noteText='';
   foreach ($blog->activities->children() as $ch) {
      if ($ch->typeid==23) {
         $f=$ch->fields->filename;
         $file=$ch->fields->file;
         if (stripos($f,'info_profile')!==false) {
            //info profile uploaded
            $loadedFiles[0]='YES';
         } else {
            if (stripos($f,'meeting_plan')!==false) {
               // meeting plan uploaded
               $loadedFiles[1]='YES';
            } else {
               if (stripos($f,'final_report')!==false) {
                  // final report uploaded!
                  $loadedFiles[2]='YES';
               }
            }
         }
      } else {
         // look for program-created note with info about profiler, selector & HELPERS (add. select, calling)
         // [*] info profile:NAME / selection:? // HELP WITH additional selection:NAME / calling:NAME / calling:NAME
         if ($ch->typeid==3) {
            $noteString=$ch->name;
            if (substr($noteString,0,3)=='[*]') $noteText=$noteString;
         }  
      }
   }
     
   $comps[]=$loadedFiles;
   $comps[]="$noteText";
   
   foreach ($blog->relateditems->children() as $comp) {
      if ($comp->typeid==40) {
         $compId=$comp->id;
         $comps[]="$compId";
      }
   }
   
   echo json_encode($comps);
?>