$field = current(PommoField::get(array('id' => $_REQUEST['field_id']))); if ($field['id'] != $_REQUEST['field_id']) { die('bad field ID'); } $affected = PommoField::subscribersAffected($field['id'], $_REQUEST['options']); if (count($affected) > 0 && empty($_REQUEST['confirmed'])) { $msg = sprintf(Pommo::_T('Deleting option %1$s will affect %2$s subscribers who have selected this choice. They will be flagged as needing to update their records.'), '<b>' . $_REQUEST['options'] . '</b>', '<em>' . count($affected) . '</em>'); $msg .= "\n " . Pommo::_T('Are you sure?'); $json->add('callbackFunction', 'confirm'); $json->add('callbackParams', $msg); $json->serve(); } else { Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/subscribers.php'); $options = PommoField::optionDel($field, $_REQUEST['options']); if (!options) { $json->fail(Pommo::_T('Error with deletion.')); } // flag subscribers for update if (count($affected) > 0) { PommoSubscriber::flagByID($affected); } $json->add('callbackFunction', 'updateOptions'); $json->add('callbackParams', $options); $json->serve(); } break; default: die('invalid request passed to ' . __FILE__); break; } die;