/** * Register to the conference * @author philipperigaux * */ function registerAction() { // No way to change a registrationb once the payment is made if ($this->user->payment_received == "Y") { $this->view->content = $this->zmax_context->texts->attendee->payment_already_made; echo $this->view->render("layout"); return; } $this->view->setFile("content", "register.xml"); $this->view->setFile("form_register", "form_register.xml"); $this->view->setBlock("form_register", "REGISTRATION_QUESTION"); $db = Zend_Db_Table::getDefaultAdapter(); // Put the values in the view (don't use HTML formating) $this->user->putInView($this->view, false); // If this is a registered user: show the attendee information, else hide them $regQuestion = new RegQuestion(); // Registration? Produce the list of questions $this->view->setBlock("REGISTRATION_QUESTION", "QUESTION", "QUESTIONS"); $questions = $regQuestion->fetchAll(); foreach ($questions as $question) { $this->view->id_question = $question->id; $this->view->question = $question->question_code; // Get the list of choices, ordered by the position $this->view->CHOICES = ""; $choices = $question->findRegChoice($regQuestion->select()->order('position ASC')); $choicesList = array(); $defaultChoice = ""; foreach ($choices as $choice) { $choicesList[$choice->id_choice] = $choice->choice . "<br/>({$choice->cost} " . $this->config_v1["currency"] . ")"; if (empty($defaultChoice)) { $defaultChoice = $choice->id_choice; } // Check whether this is the default choice $answers = $this->user->getAnswers(); if (isset($answers[$question->id])) { if ($answers[$question->id]->id_answer == $choice->id_choice) { $defaultChoice = $choice->id_choice; } } } $this->view->CHOICES = Zmax_View_Phplib::checkboxField("radio", "reg_answers[{$question->id}]", $choicesList, $defaultChoice, array("length" => 5)); $this->view->append("QUESTIONS", "QUESTION"); } // Instantiate the template $this->view->assign("form_result1", "form_register"); $this->view->assign("form_result2", "form_result1"); $this->view->form_mode = "insert"; echo $this->view->render("layout"); }
/** * Create a form to access a User * */ function form(&$view, $formTemplate = "form_user.xml", $changePassword = true, $register = false) { $view->setFile("form_user", $formTemplate); $view->setBlock("form_user", "TOPICS"); $view->setBlock("form_user", "PASSWORD"); $view->setBlock("form_user", "ATTENDEE"); $view->setBlock("form_user", "NO_ATTENDEE"); $view->setBlock("form_user", "REGISTRATION_QUESTION"); if ($register) { $this->addRole(User::PARTICIPANT_ROLE); } $db = Zend_Db_Table::getDefaultAdapter(); // Put the values in the view (don't use HTML formating) $this->putInView($view, false); if (!$changePassword) { // Do not show the password $view->PASSWORD = ""; } $view->change_password = $changePassword; $view->register = $register; $countryList = $db->fetchPairs("SELECT * FROM Country"); // Sort the countries in alphabetical order asort($countryList, SORT_STRING); $view->country_list = Zmax_View_Phplib::selectField("country_code", $countryList, $this->country_code); // Do not allow empty roles if (empty($this->roles)) { $this->addRole(User::REVIEWER_ROLE); } $existingRoles = array_flip(explode(",", $this->roles)); $view->roles_list = Zmax_View_Phplib::checkboxField("checkbox", "roles[]", Config::$Roles, $existingRoles, $this->country_code); if ($this->isReviewer()) { // We show a form that allows the user to choose his/her topics $topicList = $db->fetchPairs("SELECT * FROM ResearchTopic"); $existingTopics = array(); foreach ($this->_topics as $topic) { $existingTopics[$topic->id_topic] = 1; } $view->topic_list = Zmax_View_Phplib::checkboxField("checkbox", "topics[]", $topicList, $existingTopics, array("length" => 5)); $view->assign("TOPICS", "TOPICS"); } else { $view->TOPICS = ""; } // If this is a registered user: show the attendee information, else hide them if ($this->isParticipant()) { $view->NO_ATTENDEE = ""; $regQuestion = new RegQuestion(); // Registration? Produce the list of questions $view->setBlock("REGISTRATION_QUESTION", "QUESTION", "QUESTIONS"); $questions = $regQuestion->fetchAll(); foreach ($questions as $question) { $view->id_question = $question->id; $view->question = $question->question_code; // Get the list of choices, ordered by the position $view->CHOICES = ""; $choices = $question->findRegChoice($regQuestion->select()->order('position ASC')); $choicesList = array(); $defaultChoice = ""; foreach ($choices as $choice) { $choicesList[$choice->id_choice] = $choice->choice; if (empty($defaultChoice)) { $defaultChoice = $choice->id_choice; } // Check whether this is the default choice if (isset($this->_answers[$question->id])) { if ($this->_answers[$question->id]->id_answer == $choice->id_choice) { $defaultChoice = $choice->id_choice; } } } $view->CHOICES = Zmax_View_Phplib::checkboxField("radio", "reg_answers[{$question->id}]", $choicesList, $defaultChoice, array("length" => 5)); $view->append("QUESTIONS", "QUESTION"); } } else { $view->ATTENDEE = ""; $view->REGISTRATION_QUESTION = ""; } // Instantiate the template $view->assign("form_result1", "form_user"); $view->assign("form_result2", "form_result1"); return $view->form_result2; }