Example #1
0
 /**
  * Create a copy of an debate.
  *
  * @param string $p_title
  * @param string $p_question
  * @param array $p_answers
  * @return Debate
  */
 public function createCopy($p_data, $p_answers)
 {
     // Construct the duplicate debate object.
     $debate_copy = new Debate();
     $debate_copy->m_data['debate_nr'] = Debate::generatePollNumber();
     $debate_copy->m_data['parent_debate_nr'] = $this->m_data['debate_nr'];
     $debate_copy->m_data['fk_language_id'] = $this->m_data['fk_language_id'];
     // Create the record
     $values = array('title' => $p_data['title'], 'question' => $p_data['question'], 'date_begin' => $p_data['date_begin'], 'date_end' => $p_data['date_end'], 'nr_of_answers' => count($p_answers), 'votes_per_user' => $p_data['votes_per_user']);
     $success = $debate_copy->__create($values);
     if (!$success) {
         return false;
     }
     // create an set of answers
     DebateAnswer::CreateCopySet($debate_copy->getNumber(), $this->m_data['fk_language_id'], $this->m_data['debate_nr'], $p_answers);
     $debate_copy->triggerStatistics();
     /*
     if (function_exists("camp_load_translation_strings")) {
         camp_load_translation_strings("api");
     }
     $logtext = getGS('Article #$1 "$2" ($3) translated to "$5" ($4)',
         $this->getArticleNumber(), $this->getTitle(), $this->getLanguageName(),
         $articleCopy->getTitle(), $articleCopy->getLanguageName());
     Log::Message($logtext, null, 31);
     */
     return $debate_copy;
 }