You are here

function webform_invitation_disable in Webform Invitation 7.2

File

./webform_invitation.install, line 87

Code

function webform_invitation_disable() {
  $db_settings = db_select('webform_invitation', 'i')
    ->fields('i')
    ->condition('invitation', 1, '=')
    ->execute();
  while ($result = $db_settings
    ->fetchAssoc()) {
    $node = node_load($result['nid']);

    /*
     * The actual component ID is in $result['cid']
     * but we better check for the form_key
     */
    foreach ($node->webform['components'] as $id => $com) {
      if ($com['form_key'] == 'webform_invitation_code') {
        unset($node->webform['components'][$id]);
        node_save($node);
        break;
      }
    }
  }
}