} $safe[] = $optid; } delete_records_select('block_poll_option', "pollid = {$pid} AND id NOT IN (" . implode($safe, ',') . ")"); } for ($i = count($options); $i < $optioncount; $i++) { $pollopt = new Object(); $pollopt->id = 0; $pollopt->pollid = $pid; $pollopt->optiontext = ''; insert_record('block_poll_option', $pollopt); } $url .= "&instanceid={$instanceid}&sesskey={$sesskey}&blockaction=config&action=editpoll&pid={$pid}"; break; case 'delete': test_allowed_to_update(); $step = optional_param('step', 'first', PARAM_TEXT); $urlno = $url . "&instanceid={$instanceid}&sesskey={$sesskey}&blockaction=config&action=managepolls"; if ($step == 'confirm') { delete_records('block_poll', 'id', $pid); delete_records('block_poll_option', 'pollid', $pid); delete_records('block_poll_response', 'pollid', $pid); $url = $urlno; } else { $poll = get_record('block_poll', 'id', $pid); $urlyes = "{$CFG->wwwroot}/blocks/poll/poll_action.php?id={$cid}&instanceid={$instanceid}&action=delete&step=confirm&pid={$pid}"; notice_yesno(get_string('pollconfirmdelete', 'block_poll', $poll->name), $urlyes, $urlno); die; } break; case 'respond':
list($insql, $params) = $DB->get_in_or_equal($safe, SQL_PARAMS_NAMED); $insql = count($params) > 1 ? "NOT {$insql}" : "!{$insql}"; $params['pid'] = $pid; $DB->delete_records_select('block_poll_option', "pollid = :pid AND id {$insql}", $params); } for ($i = count($options); $i < $optioncount; $i++) { $pollopt = new stdClass(); $pollopt->id = 0; $pollopt->pollid = $pid; $pollopt->optiontext = ''; $DB->insert_record('block_poll_option', $pollopt); } $url->params(array('instanceid' => $instanceid, 'sesskey' => $sesskey, 'blockaction' => 'config', 'action' => 'editpoll', 'pid' => $pid)); break; case 'delete': test_allowed_to_update($cid); $step = optional_param('step', 'first', PARAM_TEXT); $urlno = clone $url; $urlno->params(array('instanceid' => $instanceid, 'sesskey' => $sesskey, 'blockaction' => 'config', 'action' => 'managepolls')); if ($step == 'confirm') { $DB->delete_records('block_poll', array('id' => $pid)); $DB->delete_records('block_poll_option', array('pollid' => $pid)); $DB->delete_records('block_poll_response', array('pollid' => $pid)); $url = $urlno; } else { $poll = $DB->get_record('block_poll', array('id' => $pid)); $yesparams = array('id' => $cid, 'instanceid' => $instanceid, 'action' => 'delete', 'step' => 'confirm', 'pid' => $pid); $urlyes = new moodle_url('/blocks/poll/poll_action.php', array('id' => $cid, 'instanceid' => $instanceid, 'action' => 'delete', 'step' => 'confirm', 'pid' => $pid)); if ($srcpage != '') { $urlyes->param('page', $srcpage); }