本文整理汇总了PHP中Poll::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Poll::exists方法的具体用法?PHP Poll::exists怎么用?PHP Poll::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poll
的用法示例。
在下文中一共展示了Poll::exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Poll
camp_html_display_error(getGS('You do not have the right to manage polls.'));
exit;
}
$f_poll_nr = Input::Get('f_poll_nr', 'int');
$f_fk_language_id = Input::Get('f_fk_language_id', 'int');
$f_title = Input::Get('f_title', 'string');
$f_question = Input::Get('f_question', 'string');
$f_date_begin = Input::Get('f_date_begin', 'string');
$f_date_end = Input::Get('f_date_end', 'string');
$f_votes_per_user = Input::Get('f_votes_per_user', 'int');
$f_is_extended = Input::Get('f_is_extended', 'boolean');
$f_nr_of_answers = Input::Get('f_nr_of_answers', 'int');
$f_answers = Input::Get('f_answer', 'array');
$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 {
示例2: Poll
// Check permissions
if (!$g_user->hasPermission('plugin_poll')) {
camp_html_display_error(getGS('You do not have the right to manage polls.'));
exit;
}
$allLanguages = Language::GetLanguages();
$f_poll_nr = Input::Get('f_poll_nr', 'int');
$f_fk_language_id = Input::Get('f_fk_language_id', 'int');
$f_from = Input::Get('f_from', 'string', false);
$poll = new Poll($f_fk_language_id, $f_poll_nr);
if ($poll->exists()) {
// edit existing poll
$parent_poll_nr = $poll->getProperty('parent_poll_nr');
$is_extended = $poll->isExtended();
$title = $poll->getProperty('title');
$question = $poll->getProperty('question');
$date_begin = $poll->getProperty('date_begin');
$date_end = $poll->getProperty('date_end');
$nr_of_answers = $poll->getProperty('nr_of_answers');
$fk_language_id = $poll->getProperty('fk_language_id');
$votes_per_user = $poll->getProperty('votes_per_user');
$poll_answers = $poll->getAnswers();
foreach ($poll_answers as $poll_answer) {
$answers[$poll_answer->getProperty('nr_answer')] = $poll_answer->getProperty('answer');
示例3: GetList
//.........这里部分代码省略.........
$selectClauseObj->addWhere($whereCondition);
$whereCondition = "date_end >= NOW()";
$selectClauseObj->addWhere($whereCondition);
} elseif (strpos($comparisonOperation['left'], 'language_id') !== false) {
$language_id = $comparisonOperation['right'];
$whereCondition = $g_ado_db->escapeOperation($comparisonOperation);
$selectClauseObj->addWhere($whereCondition);
} else {
$whereCondition = $g_ado_db->escapeOperation($comparisonOperation);
$selectClauseObj->addWhere($whereCondition);
}
}
// sets the columns to be fetched
$tmpPoll = new Poll();
$columnNames = $tmpPoll->getColumnNames(true);
foreach ($columnNames as $columnName) {
$selectClauseObj->addColumn($columnName);
}
// sets the main table for the query
$mainTblName = $tmpPoll->getDbTableName();
$selectClauseObj->setTable($mainTblName);
unset($tmpPoll);
switch ($p_item) {
case 'publication':
if (empty($assign_publication_id)) {
return;
}
$tmpAssignObj = new PollPublication();
$assignTblName = $tmpAssignObj->getDbTableName();
$join = "LEFT JOIN `{$assignTblName}` AS j\n ON\n j.fk_poll_nr = `{$mainTblName}`.poll_nr\n AND j.fk_publication_id = '{$assign_publication_id}'";
$selectClauseObj->addJoin($join);
$selectClauseObj->addWhere('j.fk_poll_nr IS NOT NULL');
$selectClauseObj->setDistinct('plugin_poll.poll_nr');
break;
case 'issue':
if (empty($assign_publication_id) || empty($assign_issue_nr)) {
return;
}
$tmpAssignObj = new PollIssue();
$assignTblName = $tmpAssignObj->getDbTableName();
$join = "LEFT JOIN {$assignTblName} AS j\n ON\n j.fk_poll_nr = `{$mainTblName}`.poll_nr\n AND j.fk_issue_nr = '{$assign_issue_nr}'\n AND j.fk_publication_id = '{$assign_publication_id}'";
if (isset($language_id)) {
$join .= " AND j.fk_issue_language_id = '{$language_id}'";
}
$selectClauseObj->addJoin($join);
$selectClauseObj->addWhere('j.fk_poll_nr IS NOT NULL');
$selectClauseObj->setDistinct('plugin_poll.poll_nr');
break;
case 'section':
if (empty($assign_publication_id) || empty($assign_issue_nr) || empty($assign_section_nr)) {
return;
}
$tmpAssignObj = new PollSection();
$assignTblName = $tmpAssignObj->getDbTableName();
$join = "LEFT JOIN `{$assignTblName}` AS j\n ON\n j.fk_poll_nr = `{$mainTblName}`.poll_nr\n AND j.fk_section_nr = '{$assign_section_nr}'\n AND j.fk_issue_nr = '{$assign_issue_nr}'\n AND j.fk_publication_id = '{$assign_publication_id}'";
if (isset($language_id)) {
$join .= " AND j.fk_section_language_id = '{$language_id}'";
}
$selectClauseObj->addJoin($join);
$selectClauseObj->addWhere('j.fk_poll_nr IS NOT NULL');
$selectClauseObj->setDistinct('plugin_poll.poll_nr');
break;
case 'article':
if (empty($assign_article_nr)) {
return;
}
$tmpAssignObj = new PollArticle();
$assignTblName = $tmpAssignObj->getDbTableName();
$join = "LEFT JOIN `{$assignTblName}` AS j\n ON\n j.fk_poll_nr = `{$mainTblName}`.poll_nr\n AND j.fk_article_nr = '{$assign_article_nr}'";
if (isset($language_id)) {
$join .= " AND j.fk_article_language_id = '{$language_id}'";
}
$selectClauseObj->addJoin($join);
$selectClauseObj->addWhere('j.fk_poll_nr IS NOT NULL');
$selectClauseObj->setDistinct('plugin_poll.poll_nr');
break;
}
if (is_array($p_order)) {
$order = Poll::ProcessListOrder($p_order);
// sets the order condition if any
foreach ($order as $orderField => $orderDirection) {
$selectClauseObj->addOrderBy($orderField . ' ' . $orderDirection);
}
}
$sqlQuery = $selectClauseObj->buildQuery();
// count all available results
$countRes = $g_ado_db->Execute($sqlQuery);
$p_count = $countRes->recordCount();
//get the wanted rows
$pollRes = $g_ado_db->SelectLimit($sqlQuery, $p_limit, $p_start);
// builds the array of poll objects
$pollsList = array();
while ($poll = $pollRes->FetchRow()) {
$pollObj = new Poll($poll['fk_language_id'], $poll['poll_nr']);
if ($pollObj->exists()) {
$pollsList[] = $pollObj;
}
}
return $pollsList;
}
示例4: __construct
/**
* Reads the input parameters and vote the poll
*
* @param array $p_input
*/
public function __construct(array $p_input)
{
$this->m_defined = true;
$this->m_name = 'poll';
if (!isset($p_input['f_poll_nr']) || empty($p_input['f_poll_nr'])) {
$this->m_error = new PEAR_Error('The poll number is missing.', ACTION_POLL_ERR_NO_POLL_NUMBER);
return false;
}
$this->m_properties['poll_nr'] = $p_input['f_poll_nr'];
if (!isset($p_input['f_poll_language_id']) || empty($p_input['f_poll_language_id'])) {
$this->m_error = new PEAR_Error('The poll language is missing.', ACTION_POLL_ERR_NO_LANGUAGE_ID);
return false;
}
$this->m_properties['poll_language_id'] = $p_input['f_poll_language_id'];
if ($p_input['f_poll_mode'] !== 'standard' && $p_input['f_poll_mode'] !== 'ajax') {
$this->m_error = new PEAR_Error('The poll mode parameter is invalid.', ACTION_POLL_ERR_INVLID_MODE);
return false;
}
$this->m_properties['poll_mode'] = $p_input['f_poll_mode'];
$Poll = new Poll($this->m_properties['poll_language_id'], $this->m_properties['poll_nr']);
if (!$Poll->exists()) {
$this->m_error = new PEAR_Error('Poll does not exists.', ACTION_POLL_ERR_NOT_EXISTS);
return false;
}
if (!$Poll->isVotable()) {
$this->m_error = new PEAR_Error('Poll is not votable.', ACTION_POLL_ERR_NOT_VOTABLE);
return false;
} else {
switch($p_input['f_poll_mode']) {
case 'ajax':
$allowed_values = $_SESSION['camp_poll_maxvote'][$this->m_properties['poll_nr']][$this->m_properties['poll_language_id']];
if (!is_array($allowed_values)) {
$this->m_error = new PEAR_Error('Invalid poll voting value.', ACTION_POLL_ERR_INVALID_VALUE);
return false;
}
foreach ($Poll->getAnswers() as $PollAnswer) {
$nr = $PollAnswer->getNumber();
if (isset($p_input['f_pollanswer_'.$nr]) && !empty($p_input['f_pollanswer_'.$nr])) {
// check if value is valid
if (!array_key_exists($p_input['f_pollanswer_'.$nr], $allowed_values[$nr])) {
$this->m_error = new PEAR_Error('Invalid poll voting value.', ACTION_POLL_ERR_INVALID_VALUE);
return false;
}
$this->m_properties['pollanswer_nr'] = $nr;
$this->m_properties['value'] = $p_input['f_pollanswer_'.$nr];
break;
}
}
if (!$this->m_properties['value']) {
$this->m_error = new PEAR_Error('No answer value was given.', ACTION_POLL_ERR_NOANSWER_VALUE);
return false;
}
break;
case 'standard':
if (!isset($p_input['f_pollanswer_nr']) || empty($p_input['f_pollanswer_nr'])) {
$this->m_error = new PEAR_Error('Invalid poll voting value.', ACTION_POLL_ERR_INVALID_VALUE);
return false;
}
$this->m_properties['pollanswer_nr'] = $p_input['f_pollanswer_nr'];
$this->m_properties['value'] = 1;
break;
}
}
$this->m_poll = $Poll;
}
示例5: Poll
camp_load_translation_strings("plugin_poll");
// Check permissions
if (!$g_user->hasPermission('plugin_poll')) {
camp_html_display_error(getGS('You do not have the right to manage polls.'));
exit;
}
$allLanguages = Language::GetLanguages();
$f_poll_nr = Input::Get('f_poll_nr', 'int');
$f_fk_language_id = Input::Get('f_fk_language_id', 'int');
$f_from = Input::Get('f_from', 'string', false);
if (empty($f_from)) {
$f_from = $Campsite['WEBSITE_URL'] . '/admin/poll/index.php';
}
$poll = new Poll($f_fk_language_id, $f_poll_nr);
if ($poll->exists()) {
// edit existing poll
$parent_poll_nr = $poll->getProperty('parent_poll_nr');
$is_extended = $poll->isExtended();
$title = $poll->getProperty('title');
$question = $poll->getProperty('question');
$date_begin = $poll->getProperty('date_begin');
$date_end = $poll->getProperty('date_end');
$nr_of_answers = $poll->getProperty('nr_of_answers');
$fk_language_id = $poll->getProperty('fk_language_id');
$votes_per_user = $poll->getProperty('votes_per_user');
$poll_answers = $poll->getAnswers();
foreach ($poll_answers as $poll_answer) {
$answers[$poll_answer->getProperty('nr_answer')] = $poll_answer->getProperty('answer');
}
} else {
示例6: Poll
camp_load_translation_strings("plugin_poll");
// Check permissions
if (!$g_user->hasPermission('plugin_poll')) {
camp_html_display_error(getGS('You do not have the right to manage polls.'));
exit;
}
$allLanguages = Language::GetLanguages();
$f_poll_nr = Input::Get('f_poll_nr', 'int');
$f_fk_language_id = Input::Get('f_fk_language_id', 'int');
$poll = new Poll($f_fk_language_id, $f_poll_nr);
if (!$poll->exists()) {
camp_html_display_error(getGS('Poll does not exists.'));
exit;
}
$title = $poll->getProperty('title');
$question = $poll->getProperty('question');
$date_begin = $poll->getProperty('date_begin');
$date_end = $poll->getProperty('date_end');
$fk_language_id = $poll->getProperty('fk_language_id');
$votes_per_user = $poll->getProperty('votes_per_user');
/*
$topArray = array('Pub' => $publicationObj, 'Issue' => $issueObj,
'Section' => $sectionObj);
camp_html_content_top(getGS('Add new article'), $topArray, true, false, array(getGS("Articles") => "/$ADMIN/articles/?f_publication_id=$f_publication_id&f_issue_number=$f_issue_number&f_section_number=$f_section_number&f_language_id=$f_language_id"));