optionDel() public method

returns field options (array), or false (bool)
public optionDel ( &$field, &$value )
Beispiel #1
0
 case 'delOption':
     // validate field ID
     $field = current(Pommo_Fields::get(array('id' => $_REQUEST['field_id'])));
     if ($field['id'] != $_REQUEST['field_id']) {
         die('bad field ID');
     }
     $affected = Pommo_Fields::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 {
         require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
         $options = Pommo_Fields::optionDel($field, $_REQUEST['options']);
         if (!options) {
             $json->fail(Pommo::_T('Error with deletion.'));
         }
         // flag subscribers for update
         if (count($affected) > 0) {
             Pommo_Subscribers::flagByID($affected);
         }
         $json->add('callbackFunction', 'updateOptions');
         $json->add('callbackParams', $options);
         $json->serve();
     }
     break;
 default:
     die('invalid request passed to ' . __FILE__);
     break;