Example #1
0
/**
 * Called whenever a submission or submissions are deleted. It's the hook for the ft_delete_submission_files
 * Core function.
 *
 * @param array $params this contains all the details passed by the hook.
 */
function ft_file_delete_submissions_hook($params)
{
    $L = ft_get_module_lang_file_contents("field_type_file");
    $form_id = $params["form_id"];
    $file_field_info = $params["file_field_info"];
    $module_field_type_id = ft_get_field_type_id_by_identifier("file");
    $problem_files = array();
    foreach ($file_field_info as $info) {
        if ($info["field_type_id"] != $module_field_type_id) {
            continue;
        }
        $field_id = $info["field_id"];
        $submission_id = $info["submission_id"];
        $filename = $info["filename"];
        $field_settings = ft_get_field_settings($field_id);
        $folder = $field_settings["folder_path"];
        if (!@unlink("{$folder}/{$filename}")) {
            if (!is_file("{$folder}/{$filename}")) {
                $problems[] = array("filename" => $filename, "error" => ft_eval_smarty_string($L["notify_file_not_deleted_no_exist"], array("folder" => $folder)));
            } else {
                if (is_file("{$folder}/{$file}") && (!is_readable("{$folder}/{$file}") || !is_writable("{$folder}/{$file}"))) {
                    $problems[] = array("filename" => $filename, "error" => ft_eval_smarty_string($L["notify_file_not_deleted_permissions"], array("folder" => $folder)));
                } else {
                    $problems[] = array("filename" => $filename, "error" => ft_eval_smarty_string($L["notify_file_not_deleted_unknown_error"], array("folder" => $folder)));
                }
            }
        }
    }
    if (empty($problems)) {
        return array(true, "");
    } else {
        return array(false, $problems);
    }
}
Example #2
0
/**
 * This hook function is what actually outputs the Export options at the bottom of the Submission Listing page.
 *
 * @param string $template_name
 * @param array $params
 */
function exp_display_export_options($template_name, $params)
{
    global $g_smarty, $g_root_url, $g_root_dir;
    $account_id = $params["SESSION"]["account"]["account_id"];
    $form_id = $params["form_id"];
    $view_id = $params["view_id"];
    $export_groups = array();
    $is_admin = false;
    if ($template_name == "admin_submission_listings_bottom") {
        $is_admin = true;
    }
    if ($is_admin) {
        $account_id = "admin";
    }
    // this does all the hard work of figuring out what groups & types should appear
    $export_groups = exp_get_assigned_export_types($account_id, $form_id, $view_id);
    // now for the fun stuff! We loop through all export groups and log all the settings for
    // each of the fields, based on incoming POST values
    $page_vars = array();
    foreach ($export_groups as $export_group) {
        $export_group_id = $export_group["export_group_id"];
        $page_vars["export_group_{$export_group_id}_results"] = ft_load_module_field("export_manager", "export_group_{$export_group_id}_results", "export_group_{$export_group_id}_results");
        $page_vars["export_group_{$export_group_id}_export_type"] = ft_load_module_field("export_manager", "export_group_{$export_group_id}_export_type", "export_group_{$export_group_id}_export_type");
    }
    $params["LANG"]["export_manager"] = ft_get_module_lang_file_contents("export_manager");
    // now pass the information to the Smarty template to display
    $g_smarty->assign("export_groups", $export_groups);
    $g_smarty->assign("is_admin", $is_admin);
    $g_smarty->assign("page_vars", $page_vars);
    $g_smarty->assign("LANG", $params["LANG"]);
    $g_smarty->assign("export_icon_folder", "{$g_root_url}/modules/export_manager/images/icons");
    echo $g_smarty->fetch("../../modules/export_manager/templates/export_options_html.tpl");
}
Example #3
0
/**
 * Called automatically on installation, or when the administrator clicks on the "Install" link for a module
 * This function runs the module's installation script (if it exists) and returns the appropriate success
 * or error message.
 *
 * @param integer $module_id
 * @return array [0] T/F, [1] error / success message.
 */
function ft_install_module($info)
{
    global $LANG, $g_root_dir, $g_root_url, $g_table_prefix;
    $module_id = $info["install"];
    $module_info = ft_get_module($module_id);
    $module_folder = $module_info["module_folder"];
    $success = true;
    $message = ft_eval_smarty_string($LANG["notify_module_installed"], array("link" => "{$g_root_url}/modules/{$module_folder}"));
    $has_custom_install_script = false;
    if (is_file("{$g_root_dir}/modules/{$module_folder}/library.php")) {
        @(include_once "{$g_root_dir}/modules/{$module_folder}/library.php");
        $install_function_name = "{$module_folder}__install";
        if (function_exists($install_function_name)) {
            $has_custom_install_script = true;
            // get the module language file contents and store the info in the $LANG global for
            // so it can be accessed by the installation script
            $LANG[$module_folder] = ft_get_module_lang_file_contents($module_folder);
            list($success, $custom_message) = $install_function_name($module_id);
            // if there was a custom message returned (error or notification), overwrite the default
            // message
            if (!empty($custom_message)) {
                $message = $custom_message;
            }
        }
    }
    // if there wasn't a custom installation script, or there was and it was successfully run,
    // update the record in the module table to mark it as both is_installed and is_enabled.
    if (!$has_custom_install_script || $has_custom_install_script && $success) {
        $module_key_clause = "";
        if (isset($info["k"])) {
            $module_key_clause = ", module_key = '{$info["k"]}'";
        }
        mysql_query("\n      UPDATE {$g_table_prefix}modules\n      SET    is_installed = 'yes',\n             is_enabled = 'yes'\n             {$module_key_clause}\n      WHERE  module_id = {$module_id}\n        ");
    }
    return array($success, $message);
}