Example #1
0
 /**
  * Create a form to access a paper
  *
  */
 function form(&$user, &$view)
 {
     $view->setFile("form_submit", "form_submit.xml");
     $view->setBlock("form_submit", "ABSTRACT", "ABSTRACTS");
     $view->setBlock("form_submit", "FILE_UPLOAD");
     $view->setBlock("form_submit", "AUTHOR", "AUTHORS");
     $view->setBlock("form_submit", "QUESTION", "QUESTIONS");
     $registry = Zend_registry::getInstance();
     $config = $registry->get("Config");
     // If in two phases submission: hide the upload
     if ($config->two_phases_submission == "Y") {
         $view->FILE_UPLOAD = "";
     }
     // Put the connected user in the form
     $view->me_last_name = $user->last_name;
     $view->me_first_name = $user->first_name;
     $view->me_affiliation = $user->affiliation;
     $view->me_email = $user->email;
     $view->me_country = $user->country_code;
     $db = Zend_Db_Table::getDefaultAdapter();
     $user = new User();
     // Get the lists of choices
     $countryList = $db->fetchPairs("SELECT * FROM Country");
     // Sort the countries in alphabetical order
     asort($countryList, SORT_STRING);
     $topicList = $db->fetchPairs("SELECT * FROM ResearchTopic");
     // Produce the list of abstracts sections ordered by their position
     $abstract = new AbstractSection();
     $abstract->select()->order('position ASC');
     $abstractRows = $abstract->fetchAll();
     $view->list_abstract_ids = $separator = "";
     foreach ($abstractRows as $abstractRow) {
         $abstractRow->putInView($view, false);
         // Set the default value
         if (isset($this->_abstract[$abstractRow->id])) {
             $view->abstract_content = $this->_abstract[$abstractRow->id]->content;
         } else {
             $view->abstract_content = "";
         }
         if ($abstractRow->mandatory == 'Y') {
             $view->abstract_mandatory = "*";
         } else {
             $view->abstract_mandatory = "";
         }
         $view->list_abstract_ids .= $separator . $abstractRow->id;
         $separator = "; ";
         $view->append("ABSTRACTS", "ABSTRACT");
     }
     $view->topic_list = Zmax_View_Phplib::selectField("topic", $topicList, $this->topic);
     // Produce the list of fields for authors.
     for ($i = 0; $i < $this->nb_authors_in_form; $i++) {
         if ($i % 2 == 0) {
             $view->css_class = 'odd';
         } else {
             $view->css_class = 'even';
         }
         $view->ith = $i;
         $view->iplus = $i + 1;
         $view->checked = "";
         // Take the existing author for default values
         if ($i < $this->nbAuthors()) {
             $author = $this->getAuthor($i);
             if ($this->_contactAuthor == $i) {
                 $view->checked = "checked='1'";
             }
         } else {
             // Create an empty author
             $author = $user->createRow();
         }
         $author->putInView($view);
         // Propose the list of countries
         $view->country_list = Zmax_View_Phplib::selectField("country_code[{$i}]", $countryList, $author->country_code, 1, "author_country_{$i}");
         $view->append("AUTHORS", "AUTHOR");
     }
     // Produce the list of questions
     $paperQuestion = new PaperQuestion();
     $questions = $paperQuestion->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->findPQChoice($paperQuestion->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", "answers[{$question->id}]", $choicesList, $defaultChoice, array("length" => 5));
         $view->append("QUESTIONS", "QUESTION");
     }
     // Put the values in the view
     $this->putInView($view, false);
     // Note: make a double assignment, to translate text code which are
     // dynamically generated
     $view->assign("form_result1", "form_submit");
     $view->assign("form_result2", "form_result1");
     return $view->form_result2;
 }
 /**
  *  List of papers with their reviews
  */
 private function papersReviews($view, $templateName, $html = true, $anonymized = false)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $paperTbl = new Paper();
     $paperStatusTbl = new PaperStatus();
     $criteriaTbl = new Criteria();
     $reviewTbl = new Review();
     $reviewMarkTbl = new ReviewMark();
     $registry = Zend_registry::getInstance();
     $config = $registry->get("Config");
     $config->putInView($view);
     // Set the mail types
     $view->someUser = Mail::SOME_USER;
     // Extract the block for each paper
     $view->setBlock($templateName, "PAPER_DETAIL", "PAPERS");
     $view->setBlock($templateName, "REVIEW_CRITERIA", "REVIEW_CRITERIAS");
     $view->setBlock("PAPER_DETAIL", "PAPER_INFO", "PAPER_DATA");
     $view->setBlock("PAPER_DETAIL", "REVIEW_MARK", "REVIEW_MARKS");
     $view->setBlock("PAPER_DETAIL", "REVIEWER", "REVIEWER_INFO");
     // Header of the  table, taken from table Criteria
     $criterias = $criteriaTbl->fetchAll();
     $listCriterias = array();
     foreach ($criterias as $criteria) {
         $criteria->putInView($view);
         $listCriterias[] = $criteria;
         $view->append("REVIEW_CRITERIAS", "REVIEW_CRITERIA");
     }
     // Sort the papers on the average 'overall' field
     $query = "SELECT p.*, round(AVG(overall),4) AS overall " . "FROM Paper p LEFT JOIN Review r ON p.id=r.idPaper " . " WHERE inCurrentSelection='Y' GROUP BY p.id";
     $result = $db->query($query);
     $arrPaper = $rankPaper = array();
     while ($paper = $result->fetch(Zend_Db::FETCH_OBJ)) {
         $arrPaper[$paper->id] = $paper;
         $rankPaper[$paper->id] = $paper->overall;
     }
     // Get the status list
     $statusList = $db->fetchPairs("SELECT * FROM PaperStatus WHERE final_status='Y'");
     // Sort in descending order
     arsort($rankPaper);
     reset($rankPaper);
     // List the papers in order
     $iPaper = 0;
     foreach ($rankPaper as $idPaper => $overall) {
         $paper = $arrPaper[$idPaper];
         // Choose the CSS class
         $view->css_class = Config::CssCLass($iPaper++);
         $view->paper_id = $paper->id;
         $view->paper_title = $paper->title;
         if (!$anonymized) {
             $view->paper_authors = PaperRow::getPaperAuthors($db, $paper);
         } else {
             $view->paper_authors = "[anonymized]";
         }
         $view->paper_email_contact = $paper->emailContact;
         $view->paper_rank = $iPaper;
         $view->paper_overall = $overall;
         $view->form_status = Zmax_View_Phplib::checkboxField("radio", "status[{$paper->id}]", $statusList, $paper->status, array("length" => 2));
         // Now, loop on reviews
         $qRev = "SELECT * FROM Review r, User u " . " WHERE idPaper='{$paper->id}' AND u.id=r.id_user";
         $resRev = $db->query($qRev);
         $countReviews = 0;
         $mail_reviewers = $comma = "";
         while ($review = $resRev->fetch(Zend_Db::FETCH_OBJ)) {
             $countReviews++;
             $mail_reviewers .= $comma . $review->email;
             $comma = ", ";
         }
         $view->paper_nb_reviewers = Max(1, $countReviews);
         //echo "Mail reviewers = $mail_reviewers<br/>";
         $view->paper_email_reviewers = $mail_reviewers;
         $view->append("PAPER_DATA", "PAPER_INFO");
         $resRev = $db->query($qRev);
         $iReview = 0;
         while ($review = $resRev->fetch(Zend_Db::FETCH_OBJ)) {
             $iReview++;
             $view->reviewer_id = $review->id;
             if ($anonymized == false) {
                 $view->reviewer_fname = $review->first_name;
                 $view->reviewer_lname = $review->last_name;
                 $view->external_reviewer_fname = $review->fname_ext_reviewer;
                 $view->external_reviewer_lname = $review->lname_ext_reviewer;
                 $view->review_comments = $review->comments;
             } else {
                 $view->reviewer_fname = $iReview;
                 $view->reviewer_lname = "";
                 $view->external_reviewer_fname = "";
                 $view->external_reviewer_lname = "";
                 $view->review_comments = "";
             }
             $view->reviewer_email = $review->email;
             $view->review_overall = $review->overall;
             $view->review_summary = $review->summary;
             $view->review_details = $review->details;
             if ($review->reviewerExpertise >= 1 and $review->reviewerExpertise <= 3) {
                 $view->reviewer_expertise = Config::$Expertise[$review->reviewerExpertise];
             }
             // Avoid to introduce Latex commands  in Latex files ....
             if (!$html) {
                 $view->review_summary = str_replace("\\", "", $view->review_summary);
                 $view->review_details = str_replace("\\", "", $view->review_details);
                 $view->review_comments = str_replace("\\", "", $view->review_comments);
             }
             $view->assign("REVIEWER_INFO", "REVIEWER");
             reset($listCriterias);
             $view->set_var("REVIEW_MARKS", "");
             foreach ($listCriterias as $criteria) {
                 $reviewMark = $reviewMarkTbl->find($review->idPaper, $review->id_user, $criteria->id)->current();
                 if (!is_object($reviewMark)) {
                     $reviewMark = $reviewMarkTbl->createRow();
                     // for default values
                 }
                 $reviewMark->putInView($view);
                 $view->criteria_label = $criteria->label;
                 $view->append("REVIEW_MARKS", "REVIEW_MARK");
             }
             $view->append("PAPERS", "PAPER_DETAIL");
             // The paper data is shown only once for all the reviews
             $view->set_var("PAPER_DATA", " ");
         }
         // Show the paper even without reviewer
         if ($countReviews == 0) {
             $review = $reviewTbl->createRow();
             $review->putInView($view);
             $view->set_var("REVIEW_MARKS", "");
             foreach ($listCriterias as $id => $label) {
                 $reviewMark = $reviewMarkTbl->createRow();
                 $reviewMark->putInView($view);
                 $view->append("REVIEW_MARKS", "REVIEW_MARK");
             }
             $view->set_var("REVIEWER_INFO", "");
             $view->append("PAPERS", "PAPER_DETAIL");
             $view->set_var("PAPER_DATA", "");
         }
         // Summary for the paper
         if ($html) {
             $statPaper = Paper::getStats($paper->id, $listCriterias);
             $markFieldName = "ReviewMark" . "->mark";
             $overallFieldName = "review_overall";
             $view->set_var("NB_REVIEWERS", 1);
             if ($html) {
                 $view->set_var("PAPER_DATA", "<td>&nbsp;</td><th>Summary</th>");
             }
             $view->set_var("REVIEWER_INFO", " ");
             $view->set_var($overallFieldName, $paper->overall);
             reset($listCriterias);
             $view->set_var("REVIEW_MARKS", "");
             foreach ($listCriterias as $c) {
                 $view->setVar($markFieldName, $statPaper[$c->id]);
                 $view->append("REVIEW_MARKS", "REVIEW_MARK");
             }
             $view->append("PAPERS", "PAPER_DETAIL");
             $view->set_var("PAPER_DATA", "");
         }
     }
 }
 /**
  * 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");
 }
 function exporttextsAction()
 {
     $this->view->setFile("content", "export_texts.xml");
     $defaultLang = "fr";
     $langs = $this->zmax_context->db->fetchPairs("SELECT * FROM zmax_lang where lang !='en'");
     $this->view->list_langs = Zmax_View_Phplib::checkboxField("radio", "lang", $langs, $defaultLang, array("length" => 5));
     $namespaces = $this->zmax_context->db->fetchPairs("SELECT namespace, namespace FROM zmax_namespace");
     $namespaces[' all'] = "All";
     ksort($namespaces);
     $this->view->list_namespaces = Zmax_View_Phplib::checkboxField("radio", "namespace", $namespaces, ' all', array("length" => 10));
     echo $this->view->render("layout");
 }
Example #5
0
 public function showReview($view, $html = false, $revName = "review")
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     // Initialize the review content
     $view->review_marks = "";
     $view->review_answers = "";
     // Put the data in the view
     $this->putInView($view, $html);
     // Default selection of the reviewer expertise
     $selectedName = "selected" . $this->reviewerExpertise;
     $view->setVar($selectedName, "selected");
     // Get the reviewer
     $reviewer = $this->findParentUser();
     $reviewer->putInView($view, $html);
     // Get the paper
     $paper = $this->findParentPaper();
     $paper->putInView($view, $html);
     // Show the marks
     $j = 0;
     foreach ($this->_marks as $mark) {
         // Choose the CSS class
         $view->css_class = Config::CssCLass($j++);
         $mark->putInView($view);
         $criteria = $mark->findParentCriteria();
         $criteria->putInView($view, $html);
         // Create the list of marks (for forms)
         $view->list_marks = Zmax_View_Phplib::selectField("marks[{$criteria->id}]", Config::$Scale, $mark->mark);
         $view->append($revName . "_marks", $revName . "_mark");
     }
     // Put the answers to questions
     foreach ($this->_answers as $answer) {
         // Choose the CSS class
         $view->css_class = Config::CssCLass($j++);
         // Instantiate the answer
         $answer->putInView($view, $html);
         // Get and instantiate the question
         $question = $answer->findParentReviewQuestion();
         $question->putInView($view);
         // get and instantiate the choice
         $choiceList = $db->fetchPairs("SELECT * FROM RQChoice WHERE id_question={$answer->id_question}");
         $choice = $answer->findParentRQChoice();
         if (is_object($choice)) {
             $choice->putInView($view);
         }
         $view->list_choices = Zmax_View_Phplib::checkboxField("radio", "answers[{$answer->id_question}]", $choiceList, $answer->id_answer, array());
         $view->append($revName . "_answers", $revName . "_answer");
     }
     // Instantiate twice to resolve translations
     $view->assign("result1", $revName);
     $view->assign("result2", "result1");
     return $view->result2;
 }
Example #6
0
 /**
  * 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;
 }