/** * Create a copy of an answer set. * * @param int $p_fk_debate_nr * @param int $p_parent_nr * @param array $p_answers * @return Article */ function CreateCopySet($p_debate_nr, $p_language_id, $p_parent_nr) { $ParentDebate = new Debate($p_language_id, $p_parent_nr); $parentAnswers = $ParentDebate->getAnswers(); foreach ($parentAnswers as $ParentDebateAnswer) { $TargetDebateAnswer = new DebateAnswer($p_language_id, $p_debate_nr, $ParentDebateAnswer->getNumber()); if ($TargetDebateAnswer->exists()) { $parentDebateAnswerAttachments = $ParentDebateAnswer->getDebateAnswerAttachments(); foreach ($parentDebateAnswerAttachments as $ParentDebateAnswerAttachment) { $TargetDebateAnswerAttachment = new DebateAnswerAttachment($p_debate_nr, $ParentDebateAnswerAttachment->getProperty('fk_debateanswer_nr'), $ParentDebateAnswerAttachment->getProperty('fk_attachment_id')); $TargetDebateAnswerAttachment->create(); } } } }
/** * Gets an issue list based on the given parameters. * * @param array $p_parameters * An array of ComparisonOperation objects * @param string $p_order * An array of columns and directions to order by * @param integer $p_count * The count of answers. * * @return array $issuesList * An array of Issue objects */ public static function GetList(array $p_parameters, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count) { global $g_ado_db; $hasDebateNr = false; $hasLanguageId = fase; $selectClauseObj = new SQLSelectClause(); if (!is_array($p_parameters)) { return null; } // adodb::selectLimit() interpretes -1 as unlimited if ($p_limit == 0) { $p_limit = -1; } // sets the where conditions foreach ($p_parameters as $param) { $comparisonOperation = self::ProcessListParameters($param); if (empty($comparisonOperation)) { continue; } if (strpos($comparisonOperation['left'], 'debate_nr') !== false) { $hasDebateNr = true; } if (strpos($comparisonOperation['left'], 'language_id') !== false) { $hasLanguageId = true; } $whereCondition = $g_ado_db->escapeOperation($comparisonOperation); $selectClauseObj->addWhere($whereCondition); } // validates whether publication identifier was given if ($hasDebateNr == false) { CampTemplate::singleton()->trigger_error('missed parameter Debate Number in statement list_debateanswers'); return; } // validates whether language identifier was given if ($hasLanguageId == false) { CampTemplate::singleton()->trigger_error('missed parameter Language Identifier in statement list_debateanswers'); return; } // sets the columns to be fetched $tmpDebateAnswer = new DebateAnswer(); $columnNames = $tmpDebateAnswer->getColumnNames(true); foreach ($columnNames as $columnName) { $selectClauseObj->addColumn($columnName); } // sets the main table for the query $mainTblName = $tmpDebateAnswer->getDbTableName(); $selectClauseObj->setTable($mainTblName); unset($tmpDebateAnswer); if (!is_array($p_order)) { $p_order = array(); } // sets the ORDER BY condition $p_order = count($p_order) > 0 ? $p_order : DebateAnswer::$s_defaultOrder; $order = DebateAnswer::ProcessListOrder($p_order); foreach ($order as $orderColumn => $orderDirection) { $selectClauseObj->addOrderBy($orderColumn . ' ' . $orderDirection); } $sqlQuery = $selectClauseObj->buildQuery(); // count all available results $countRes = $g_ado_db->Execute($sqlQuery); $p_count = $countRes->recordCount(); //get the wanted rows $debateAnswerRes = $g_ado_db->Execute($sqlQuery); // builds the array of debate objects $debateAnswersList = array(); while ($debateAnswer = $debateAnswerRes->FetchRow()) { $debateAnswerObj = new DebateAnswer($debateAnswer['fk_language_id'], $debateAnswer['fk_debate_nr'], $debateAnswer['nr_answer']); if ($debateAnswerObj->exists()) { $debateAnswersList[] = $debateAnswerObj; } } return $debateAnswersList; }
// UPLOAD_ERR_NO_FILE camp_html_display_error(getGS("You must select a file to upload."), null, true); break; case 6: // UPLOAD_ERR_NO_TMP_DIR // UPLOAD_ERR_NO_TMP_DIR case 7: // UPLOAD_ERR_CANT_WRITE camp_html_display_error(getGS("There was a problem uploading the file."), null, true); break; } } else { camp_html_display_error(getGS("The file exceeds the allowed max file size."), null, true); } $DebateAnswer = new DebateAnswer($f_fk_language_id, $f_debate_nr, $f_debateanswer_nr); if (!$DebateAnswer->exists()) { camp_html_display_error(getGS("Debate Answer \$1 does not exist.", $f_debateanswer_nr), null, true); exit; } $description = new Translation(@$f_language_id); $description->create($f_description); $attributes = array(); $attributes['fk_description_id'] = $description->getPhraseId(); $attributes['fk_user_id'] = $g_user->getUserId(); if ($f_language_specific == "yes") { $attributes['fk_language_id'] = @$f_language_id; } if ($f_content_disposition == "attachment") { $attributes['content_disposition'] = "attachment"; } if (!empty($_FILES['f_file'])) {
$debate = new Debate($f_fk_language_id, $f_debate_nr); if ($debate->exists()) { // update existing debate $debate = new Debate($f_fk_language_id, $f_debate_nr); $debate->setProperty('title', $f_title); $debate->setProperty('question', $f_question); $debate->setProperty('date_begin', strftime("%F %H:%M:%S", strtotime($f_date_begin . " " . $f_time_begin))); $debate->setProperty('date_end', strftime("%F %H:%M:%S", strtotime($f_date_end . " " . $f_time_end))); $debate->setProperty('votes_per_user', $f_votes_per_user); $debate->setProperty('nr_of_answers', $f_nr_of_answers); $debate->setProperty('is_extended', $f_is_extended); $debate->setProperty('allow_not_logged_in', $f_allow_not_logged_in); foreach ($f_answers as $nr_answer => $text) { if (trim($text) != '') { $answer = new DebateAnswer($f_fk_language_id, $f_debate_nr, $nr_answer); if ($answer->exists()) { $answer->setProperty('answer', $text); } else { $answer->create($text); } } } DebateAnswer::SyncNrOfAnswers($f_fk_language_id, $f_debate_nr); } else { // create new debate $debate = new Debate($f_fk_language_id); $f_date_begin = strftime("%F %H:%M:%S", strtotime($f_date_begin . " " . $f_time_begin)); $f_date_end = strftime("%F %H:%M:%S", strtotime($f_date_end . " " . $f_time_end)); $success = $debate->create($f_title, $f_question, $f_date_begin, $f_date_end, $f_nr_of_answers, $f_votes_per_user); if ($success) { $debate->setProperty('is_extended', $f_is_extended);