/**
 * Check Poll form
 */
function cot_poll_check()
{
    global $cfg, $L, $poll_id, $poll_text, $poll_multiple, $poll_state, $poll_options;
    $poll_id = cot_import('poll_id', 'P', 'INT');
    $poll_delete = cot_import('poll_delete', 'P', 'BOL');
    $poll_reset = cot_import('poll_reset', 'P', 'BOL');
    $poll_text = trim(cot_import('poll_text', 'P', 'HTM'));
    $poll_multiple = cot_import('poll_multiple', 'P', 'BOL');
    $poll_state = cot_import('poll_state', 'P', 'BOL');
    $poll_options = cot_import('poll_option', 'P', 'ARR');
    if ($poll_delete && (int) $poll_id > 0) {
        cot_poll_delete($poll_id);
        $poll_id = '';
    }
    if (isset($_POST['poll_id'])) {
        if ($poll_reset && (int) $poll_id > 0) {
            cot_poll_reset($poll_id);
        }
        $poll_options_temp = array();
        foreach ($poll_options as $key => $val) {
            $val = trim(cot_import($val, 'D', 'TXT'));
            if (!empty($val)) {
                $poll_options_temp[$key] = $val;
            }
        }
        $poll_options = $poll_options_temp;
        if (is_int($poll_id) || $cfg['polls']['del_dup_options']) {
            $poll_options = array_unique($poll_options);
        }
        if (mb_strlen($poll_text) < 4) {
            cot_error('polls_error_title', 'poll_text');
        }
        if (count($poll_options) < 2) {
            cot_error('polls_error_count', 'poll_option');
        }
    }
}
Example #2
0
$variants[0] = array($L['All'], "");
$variants['index'] = array($L['Main'], "index");
$variants['forum'] = array($L['Forums'], "forum");
$id = cot_import('id', 'G', 'INT');
/* === Hook === */
foreach (cot_getextplugins('polls.admin.first') as $pl) {
    include $pl;
}
/* ===== */
if ($a == 'delete' && $id > 0) {
    cot_check_xg();
    cot_poll_delete($id);
    cot_message('adm_polls_msg916_deleted');
} elseif ($a == 'reset' && $id > 0) {
    cot_check_xg();
    cot_poll_reset($id);
    cot_message('adm_polls_msg916_reset');
} elseif ($a == 'lock' && $id > 0) {
    cot_check_xg();
    cot_poll_lock($id, 3);
    cot_message('Locked');
} elseif ($a == 'bump' && $id > 0) {
    cot_check_xg();
    $sql_polls = $db->update($db_polls, array('poll_creationdate' => $sys['now']), "poll_id={$id}");
    cot_message('adm_polls_msg916_bump');
}
cot_poll_check();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !cot_error_found()) {
    $number = cot_poll_save();
    if ($poll_id == 0) {
        cot_message('polls_created');