You are here

function ftools_unlink_form_submit in Features Tools 7

Same name and namespace in other branches
  1. 7.2 ftools.module \ftools_unlink_form_submit()

@todo Please document this function.

See also

http://drupal.org/node/1354

File

./ftools.module, line 349
ftools module

Code

function ftools_unlink_form_submit($form, &$form_state) {
  $hooks = _ftools_get_hooks();
  $files = drupal_system_listing('/\\.unlink.inc$/', 'modules', 'name', 0);
  foreach ($form_state['values']['unlink_options'] as $key => $value) {
    if ($value) {
      include_once DRUPAL_ROOT . "/" . $files[$key]->uri;
      views_include('view');
      foreach ($hooks as $hook) {
        $function_name = str_replace('.unlink', '', $key) . "_{$hook}";
        $function_name = str_replace('.', '_', $function_name);
        if (function_exists($function_name)) {

          //TODO add info file so we can check if the element is in the db before trying to insert it.

          //i add a try catch block meanwhile to hide the error message.
          try {
            include_once DRUPAL_ROOT . "/" . $files[$key]->uri;
            call_user_func_array($function_name, array());
          } catch (Exception $e) {
            watchdog('ftools', "error in unlink function:" . $e
              ->getMessage());
          }
          drupal_set_message("{$hook} {$function_name}");
        }
      }
    }
  }
}