function participateAction()
 {
     $this->view->activeTab = 'Polls';
     $this->view->title = $this->view->title = $this->view->translate("Wildfire") . " - " . $this->view->translate("Participate_title");
     $consumer = $this->_currentUser;
     $surveyId = (int) $this->_request->getParam('id', 0);
     //precampaignsurvey的css使用的是layout_survey
     $this->_helper->layout->setLayout("layout_survey");
     //check history to prevent multiple participation
     $db = Zend_Registry::get('db');
     $select1 = $db->select();
     $select1->from("poll_participation", "count(*)");
     $select1->where("poll_participation.poll_id = ?", $surveyId);
     $select1->where("poll_participation.consumer_id = ?", $consumer->id);
     $participationCount = $db->fetchOne($select1);
     if ($participationCount > 0) {
         $this->_helper->redirector('index', 'home');
     }
     $profileSurveyModel = new ProfileSurvey();
     $profile = $profileSurveyModel->fetchRow("id=" . $surveyId);
     if ($profile->public == 0) {
         $profileSurveyInvitation = new ProfileSurveyInvitation();
         $profileInvitation = $profileSurveyInvitation->fetchRow('consumer_id =' . $consumer->id . ' and profile_id =' . $surveyId);
         if (!count($profileInvitation)) {
             $this->_helper->redirector('index', 'home');
         }
     }
     $langNamespace = new Zend_Session_Namespace('Lang');
     $lang = $langNamespace->lang;
     if ($lang == 'en') {
         $id = $profile->i2_survey_id_en;
     } else {
         $id = $profile->i2_survey_id;
     }
     //check static file
     $testEnv = Zend_Registry::get('testEnv');
     $file = "./surveys/" . $id . ".phtml";
     // if static file not exist, go to the normal flow
     if ($testEnv != 0 || file_exists($file) == false) {
         // connect to webservice, get the page
         $indicate2Connect = new Indicate2_Connect();
         $accesscode = $indicate2Connect->createParticipation($consumer->email, $id);
         $config = Zend_Registry::get('config');
         $this->view->filloutPage = $config->indicate2->home . "/c/" . $accesscode . "/theme/wildfire";
         if ($testEnv == 0) {
             //save the page to static file
             if ($data = @file_get_contents($this->view->filloutPage)) {
                 set_time_limit(10);
                 ignore_user_abort(true);
                 Zend_Debug::dump(file_put_contents($file, $data));
             } else {
                 Zend_Debug::dump('Get remote page error!');
             }
         }
     } else {
         $this->view->file = $file;
         $this->view->surveyId = $id;
     }
     $this->view->includeCrystalCss = true;
     $this->view->user = $this->_currentUser;
     //		Zend_Debug::dump($consumer->email);
     //		Zend_Debug::dump($result);
 }
 function adminprofilesurveyAction()
 {
     $profileSurvey = $this->_request->getParam('profileSurvey');
     $consumerId = $this->_request->getParam('id');
     $consumerArray = explode(',', $consumerId);
     $profileSurveyInvitation = new ProfileSurveyInvitation();
     $notificationModel = new Notification();
     foreach ($consumerArray as $consumer) {
         if ($consumer != '') {
             $invitation = $profileSurveyInvitation->fetchRow('consumer_id = ' . $consumer . ' and profile_id = ' . $profileSurvey);
             if (!count($invitation)) {
                 $currentTime = date("Y-m-d H:i:s");
                 $row = $profileSurveyInvitation->createRow();
                 $row->consumer_id = $consumer;
                 $row->profile_id = $profileSurvey;
                 $row->date = $currentTime;
                 $row->save();
                 // add notification
                 $notificationModel->createRecord("PROFILE_SURVEY", $consumer, $profileSurvey);
             }
         }
     }
     $this->_helper->json('Success');
 }