コード例 #1
0
 public function index()
 {
     $user_id = mysql_real_escape_string(Site::CurrentUser()->id);
     $all_surveys = Survey::find_all("surveys.active = true");
     $all_responses = SurveyResponse::find_all("users.id = '{$user_id}'");
     $responses = array();
     $surveys = array();
     foreach ($all_responses as $response) {
         $responses[] = $response->survey_id;
     }
     foreach ($all_surveys as $survey) {
         if (!in_array($survey->id, $responses)) {
             if ($survey->event_id > 0) {
                 $event_id = mysql_real_escape_string($survey->event_id);
                 $user_id = mysql_real_escape_string(Site::CurrentUser()->id);
                 $result = EventSignup::find("events.id = '{$event_id}' AND users.id = '{$user_id}' AND event_signups.paid");
                 if ($result) {
                     $surveys[] = $survey;
                 }
             } else {
                 $surveys[] = $survey;
             }
         }
     }
     $this->assign("surveys", $surveys);
     $this->title = "Surveys";
     $this->render("survey/index.tpl");
 }
コード例 #2
0
 public function responses($reload = false)
 {
     if ($reload or !$this->responses_cache) {
         $id = mysql_real_escape_string($this->id);
         $this->responses_cache = SurveyResponse::find_all("surveys.id = '{$id}'");
     }
     return $this->responses_cache;
 }