Example #1
0
/**
 * Called on installation and upgrades.
 */
function ft_file_reset_hooks()
{
    ft_unregister_module_hooks("field_type_file");
    ft_register_hook("code", "field_type_file", "manage_files", "ft_update_submission", "ft_file_update_submission_hook", 50, true);
    ft_register_hook("code", "field_type_file", "manage_files", "ft_process_form", "ft_file_process_form_hook", 50, true);
    ft_register_hook("code", "field_type_file", "manage_files", "ft_api_process_form", "ft_file_api_process_form_hook", 50, true);
    ft_register_hook("code", "field_type_file", "start", "ft_delete_submission_files", "ft_file_delete_submissions_hook", 50, true);
    ft_register_hook("code", "field_type_file", "start", "ft_get_uploaded_files", "ft_file_get_uploaded_files_hook", 50, true);
    ft_register_hook("template", "field_type_file", "head_bottom", "", "ft_file_include_js");
    ft_register_hook("template", "field_type_file", "standalone_form_fields_head_bottom", "", "ft_file_include_standalone_js");
}
Example #2
0
function field_type_tinymce_reset_hooks()
{
    ft_unregister_module_hooks("field_type_tinymce");
    ft_register_hook("template", "field_type_tinymce", "head_bottom", "", "tinymce_include_files");
    ft_register_hook("template", "field_type_tinymce", "standalone_form_fields_head_bottom", "", "tinymce_include_standalone_files");
}
Example #3
0
/**
 * Uninstalls a module from the database.
 *
 * @param integer $module_id
 */
function ft_uninstall_module($module_id)
{
    global $g_table_prefix, $LANG, $g_root_dir, $g_delete_module_folder_on_uninstallation;
    $module_info = ft_get_module($module_id);
    $module_folder = $module_info["module_folder"];
    if (empty($module_info)) {
        return false;
    }
    $success = true;
    $has_custom_uninstall_script = false;
    if (is_file("{$g_root_dir}/modules/{$module_folder}/library.php")) {
        @(include_once "{$g_root_dir}/modules/{$module_folder}/library.php");
        $uninstall_function_name = "{$module_folder}__uninstall";
        if (function_exists($uninstall_function_name)) {
            $has_custom_uninstall_script = true;
            // get the module language file contents and store the info in the $LANG global for
            // so it can be accessed by the uninstallation script
            $LANG[$module_folder] = ft_get_module_lang_file_contents($module_folder);
            list($success, $custom_message) = $uninstall_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;
            }
        }
    }
    // finally, if there wasn't a custom uninstallation script, or there WAS and it was successfully
    // run, remove the module record and any old database references
    if (!$has_custom_uninstall_script || $has_custom_uninstall_script && $success) {
        // delete the module tables
        mysql_query("DELETE FROM {$g_table_prefix}modules WHERE module_id = {$module_id}");
        mysql_query("DELETE FROM {$g_table_prefix}module_menu_items WHERE module_id = {$module_id}");
        // if this module was used in any menus, update them
        $query = mysql_query("\n      SELECT DISTINCT menu_id\n      FROM   {$g_table_prefix}menu_items\n      WHERE  page_identifier = 'module_{$module_id}'\n    ");
        $affected_menu_ids = array();
        while ($row = mysql_fetch_assoc($query)) {
            $affected_menu_ids[] = $row["menu_id"];
        }
        if (!empty($affected_menu_ids)) {
            mysql_query("\n        DELETE FROM {$g_table_prefix}menu_items\n        WHERE page_identifier = 'module_{$module_id}'\n          ");
            // now update the orders of all affected menus
            foreach ($affected_menu_ids as $menu_id) {
                ft_update_menu_order($menu_id);
            }
            // if rows were deleted, re-cache the admin menu and update the ordering of the admin account.
            // ASSUMPTION: only administrator accounts can have modules as items (will need to update at some
            // point soon, no doubt).
            ft_cache_account_menu($_SESSION["ft"]["account"]["account_id"]);
            ft_update_menu_order($_SESSION["ft"]["account"]["menu_id"]);
        }
        // delete any hooks registered by this module
        ft_unregister_module_hooks($module_folder);
    }
    // now delete the entire module folder
    $deleted = false;
    if ($g_delete_module_folder_on_uninstallation) {
        $deleted = ft_delete_folder("{$g_root_dir}/modules/{$module_folder}");
    }
    if ($deleted) {
        $message = $LANG["notify_module_uninstalled"];
    } else {
        $message = $LANG["notify_module_uninstalled_files_not_deleted"];
    }
    extract(ft_process_hook_calls("end", compact("module_id", "success", "message"), array("success", "message")), EXTR_OVERWRITE);
    return array($success, $message);
}