示例#1
0
     }
     $view_id = ft_create_new_view($form_id, $group_id, $view_name, $duplicate_view_id);
     // always set the default Edit View tab to the first one
     $_SESSION["ft"]["edit_view_tab"] = 1;
     echo "{ \"success\": \"1\", \"view_id\": \"{$view_id}\" }";
     break;
 case "create_new_view_group":
     $form_id = $_SESSION["ft"]["form_id"];
     $group_type = "form_{$form_id}_view_group";
     $group_name = $request["group_name"];
     $info = ft_add_list_group($group_type, $group_name);
     echo ft_convert_to_json($info);
     break;
 case "delete_view":
     $view_id = $request["view_id"];
     ft_delete_view($view_id);
     echo "{ \"success\": \"1\", \"view_id\": \"{$view_id}\" }";
     break;
     // this is called when the user clicks on the "Save Changes" button on the Edit Field dialog on the
     // Fields tab
 // this is called when the user clicks on the "Save Changes" button on the Edit Field dialog on the
 // Fields tab
 case "update_form_fields":
     $form_id = $request["form_id"];
     $changed_field_ids = $request["data"]["changed_field_ids"];
     // update whatever information has been included in the request
     $problems = array();
     $count = 1;
     $new_field_map = array();
     foreach ($changed_field_ids as $field_id) {
         if (!isset($request["data"]["field_{$field_id}"])) {
示例#2
0
/**
 * Completely removes a form from the database. This includes deleting all form fields, emails, Views,
 * View fields, View tabs, View filters, client-form, client-view and public omit list (form & View),
 * and anything else !
 *
 * It also includes an optional parameter to remove all files that were uploaded through file fields in the
 * form; defaulted to FALSE.
 *
 * @param integer $form_id the unique form ID
 * @param boolean $remove_associated_files A boolean indicating whether or not all files that were
 *              uploaded via file fields in this form should be removed as well.
 */
function ft_delete_form($form_id, $remove_associated_files = false)
{
    global $g_table_prefix;
    extract(ft_process_hook_calls("start", compact("form_id"), array()), EXTR_OVERWRITE);
    $form_fields = ft_get_form_fields($form_id, array("include_field_type_info" => true));
    $success = true;
    $message = "";
    $file_delete_problems = array();
    if ($remove_associated_files) {
        $submission_id_query = mysql_query("SELECT submission_id FROM {$g_table_prefix}form_{$form_id}");
        $file_fields_to_delete = array();
        while ($row = mysql_fetch_assoc($submission_id_query)) {
            $submission_id = $row["submission_id"];
            foreach ($form_fields as $form_field_info) {
                if ($form_field_info["is_file_field"] == "no") {
                    continue;
                }
                // I really don't like this... what should be done is do a SINGLE query after this loop is complete
                // to return a map of field_id to values. That would then update $file_fields_to_delete
                // with a fraction of the cost
                $submission_info = ft_get_submission_info($form_id, $submission_id);
                $filename = $submission_info[$form_field_info["col_name"]];
                // if no filename was stored, it was empty - just continue
                if (empty($filename)) {
                    continue;
                }
                $file_fields_to_delete[] = array("submission_id" => $submission_id, "field_id" => $form_field_info["field_id"], "field_type_id" => $field_type_id, "filename" => $filename);
            }
        }
        if (!empty($file_fields_to_delete)) {
            list($success, $file_delete_problems) = ft_delete_submission_files($form_id, $file_fields_to_delete, "ft_delete_form");
        }
    }
    // remove the table
    $query = "DROP TABLE IF EXISTS {$g_table_prefix}form_{$form_id}";
    mysql_query($query) or ft_handle_error("Failed query in <b>" . __FUNCTION__ . "</b>, line " . __LINE__ . ": <i>{$query}</i>", mysql_error());
    // remove any reference to the form in form_fields
    mysql_query("DELETE FROM {$g_table_prefix}form_fields WHERE form_id = {$form_id}") or ft_handle_error("Failed query in <b>" . __FUNCTION__ . "</b>, line " . __LINE__ . ": <i>{$query}</i>", mysql_error());
    // remove any reference to the form in forms table
    mysql_query("DELETE FROM {$g_table_prefix}forms WHERE form_id = {$form_id}");
    mysql_query("DELETE FROM {$g_table_prefix}client_forms WHERE form_id = {$form_id}");
    mysql_query("DELETE FROM {$g_table_prefix}form_export_templates WHERE form_id = {$form_id}");
    mysql_query("DELETE FROM {$g_table_prefix}form_email_fields WHERE form_id = {$form_id}");
    mysql_query("DELETE FROM {$g_table_prefix}public_form_omit_list WHERE form_id = {$form_id}");
    mysql_query("DELETE FROM {$g_table_prefix}multi_page_form_urls WHERE form_id = {$form_id}");
    mysql_query("DELETE FROM {$g_table_prefix}list_groups WHERE group_type = 'form_{$form_id}_view_group'");
    // delete all email templates for the form
    $email_templates = ft_get_email_template_list($form_id);
    foreach ($email_templates as $email_template_info) {
        ft_delete_email_template($email_template_info["email_id"]);
    }
    // delete all form Views
    $views_result = mysql_query("SELECT view_id FROM {$g_table_prefix}views WHERE form_id = {$form_id}");
    while ($info = mysql_fetch_assoc($views_result)) {
        ft_delete_view($info["view_id"]);
    }
    // remove any field settings
    foreach ($form_fields as $field_info) {
        $field_id = $field_info["field_id"];
        mysql_query("DELETE FROM {$g_table_prefix}field_settings WHERE field_id = {$field_id}");
    }
    // as with many things in the script, potentially we need to return a vast range of information from this last function. But
    // we'l limit
    if (!$success) {
        $message = $file_delete_problems;
    }
    return array($success, $message);
}
示例#3
0
文件: views.php 项目: jdearaujo/core
/**
 * This is called by the administrator on the main Views tab. It lets them delete an entire group of Views
 * in one go.
 *
 * @param integer $group_id
 */
function ft_delete_view_group($group_id)
{
    global $g_table_prefix, $LANG;
    $query = mysql_query("\r\n    SELECT view_id\r\n    FROM   {$g_table_prefix}views\r\n    WHERE  group_id = {$group_id}\r\n  ");
    // first, delete all the Views
    while ($view_info = mysql_fetch_assoc($query)) {
        $view_id = $view_info["view_id"];
        ft_delete_view($view_id);
    }
    // next, delete the group
    mysql_query("DELETE FROM {$g_table_prefix}list_groups WHERE group_id = {$group_id}");
    // TODO: should update order of other View groups
    return array(true, $LANG["notify_view_group_deleted"]);
}