$f_onhitlist = Input::Get('f_onhitlist', 'array'); $poll = new Poll($f_fk_language_id, $f_poll_nr); if ($poll->exists()) { // update existing poll $poll = new Poll($f_fk_language_id, $f_poll_nr); $poll->setProperty('title', $f_title); $poll->setProperty('question', $f_question); $poll->setProperty('date_begin', $f_date_begin); $poll->setProperty('date_end', $f_date_end); $poll->setProperty('votes_per_user', $f_votes_per_user); $poll->setProperty('nr_of_answers', $f_nr_of_answers); $poll->setProperty('is_extended', $f_is_extended); foreach ($f_answers as $nr_answer => $text) { if ($text !== '__undefined__') { $answer = new PollAnswer($f_fk_language_id, $f_poll_nr, $nr_answer); if ($answer->exists()) { $answer->setProperty('answer', $text); } else { $answer->create($text); } } } PollAnswer::SyncNrOfAnswers($f_fk_language_id, $f_poll_nr); } else { // create new poll $poll = new Poll($f_fk_language_id); $success = $poll->create($f_title, $f_question, $f_date_begin, $f_date_end, $f_nr_of_answers, $f_votes_per_user); if ($success) { $poll->setProperty('is_extended', $f_is_extended); foreach ($f_answers as $nr_answer => $text) { if ($text !== '__undefined__') {
break; case 4: // 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 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); } $PollAnswer = new PollAnswer($f_fk_language_id, $f_poll_nr, $f_pollanswer_nr); if (!$PollAnswer->exists()) { camp_html_display_error(getGS("Poll Answer $1 does not exist.", $f_pollanswer_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";
/** * Create a copy of an answer set. * * @param int $p_fk_poll_nr * @param int $p_parent_nr * @param array $p_answers * @return Article */ function CreateCopySet($p_poll_nr, $p_language_id, $p_parent_nr) { $ParentPoll = new Poll($p_language_id, $p_parent_nr); $parentAnswers = $ParentPoll->getAnswers(); foreach ($parentAnswers as $ParentPollAnswer) { $TargetPollAnswer = new PollAnswer($p_language_id, $p_poll_nr, $ParentPollAnswer->getNumber()); if ($TargetPollAnswer->exists()) { $parentPollAnswerAttachments = $ParentPollAnswer->getPollAnswerAttachments(); foreach ($parentPollAnswerAttachments as $ParentPollAnswerAttachment) { $TargetPollAnswerAttachment = new PollAnswerAttachment($p_poll_nr, $ParentPollAnswerAttachment->getProperty('fk_pollanswer_nr'), $ParentPollAnswerAttachment->getProperty('fk_attachment_id')); $TargetPollAnswerAttachment->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; $hasPollNr = 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'], 'poll_nr') !== false) { $hasPollNr = true; } if (strpos($comparisonOperation['left'], 'language_id') !== false) { $hasLanguageId = true; } $whereCondition = $comparisonOperation['left'] . ' ' . $comparisonOperation['symbol'] . " '" . $g_ado_db->escape($comparisonOperation['right']) . "' "; $selectClauseObj->addWhere($whereCondition); } // validates whether publication identifier was given if ($hasPollNr == false) { CampTemplate::singleton()->trigger_error('missed parameter Poll Number in statement list_pollanswers'); return; } // validates whether language identifier was given if ($hasLanguageId == false) { CampTemplate::singleton()->trigger_error('missed parameter Language Identifier in statement list_pollanswers'); return; } // sets the columns to be fetched $tmpPollAnswer = new PollAnswer(); $columnNames = $tmpPollAnswer->getColumnNames(true); foreach ($columnNames as $columnName) { $selectClauseObj->addColumn($columnName); } // sets the main table for the query $mainTblName = $tmpPollAnswer->getDbTableName(); $selectClauseObj->setTable($mainTblName); unset($tmpPollAnswer); if (!is_array($p_order)) { $p_order = array(); } // sets the ORDER BY condition $p_order = count($p_order) > 0 ? $p_order : PollAnswer::$s_defaultOrder; $order = PollAnswer::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 $pollAnswerRes = $g_ado_db->Execute($sqlQuery); // builds the array of poll objects $pollAnswersList = array(); while ($pollAnswer = $pollAnswerRes->FetchRow()) { $pollAnswerObj = new PollAnswer($pollAnswer['fk_language_id'], $pollAnswer['fk_poll_nr'], $pollAnswer['nr_answer']); if ($pollAnswerObj->exists()) { $pollAnswersList[] = $pollAnswerObj; } } return $pollAnswersList; } // fn GetList