Exemplo n.º 1
0
 function GetCurrentSurvey()
 {
     // Look for an existing survey
     if ($CurrentUserID = Member::currentUserID()) {
         // look for a deployment survey for this user
         $DeploymentSurvey = DeploymentSurvey::get()->filter(array('MemberID' => $CurrentUserID, 'Created:GreaterThanOrEqual' => SURVEY_START_DATE))->first();
         if (!$DeploymentSurvey) {
             // Create a new deployment survey
             $DeploymentSurvey = new DeploymentSurvey();
             $DeploymentSurvey->MemberID = $CurrentUserID;
             //check if we have an older survey and pre-populate
             $oldSurvey = DeploymentSurvey::get()->filter(array('MemberID' => $CurrentUserID))->first();
             if ($oldSurvey) {
                 $DeploymentSurvey->copyFrom($oldSurvey);
             }
             $DeploymentSurvey->CurrentStep = 'AboutYou';
             $DeploymentSurvey->HighestStepAllowed = 'AboutYou';
             $DeploymentSurvey->UpdateDate = SS_Datetime::now()->Rfc2822();
             //old business drivers does not match with current answers
             $DeploymentSurvey->BusinessDrivers = '';
             $DeploymentSurvey->Write();
         }
         return $DeploymentSurvey;
     }
 }