Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 81... Línea 81...
81
 
81
 
82
        return $haschanged;
82
        return $haschanged;
Línea 83... Línea 83...
83
    }
83
    }
-
 
84
 
-
 
85
    /**
-
 
86
     * Update the display mode for a specific plugin based on `$displaymode` parameter.
-
 
87
     *
-
 
88
     * @param string $pluginname The plugin name.
-
 
89
     * @param bool $displaymode whether the eye icon of display mode is enabled or disabled.
-
 
90
     * @return bool Returns true if the configuration has been changed, false otherwise.
-
 
91
     */
-
 
92
    public static function update_display_mode(string $pluginname, bool $displaymode): bool {
-
 
93
        $haschanged = false;
-
 
94
 
-
 
95
        $plugin = 'availability_' . $pluginname;
-
 
96
        $oldvalue = get_config($plugin, 'defaultdisplaymode');
-
 
97
        $disabled = !$displaymode;
-
 
98
        // Only set value if there is no config setting or if the value is different from the previous one.
-
 
99
        if ($oldvalue == false && $disabled) {
-
 
100
            set_config('defaultdisplaymode', $disabled, $plugin);
-
 
101
            $haschanged = true;
-
 
102
        } else if ($oldvalue != false && !$disabled) {
-
 
103
            unset_config('defaultdisplaymode', $plugin);
-
 
104
            $haschanged = true;
-
 
105
        }
-
 
106
 
-
 
107
        if ($haschanged) {
-
 
108
            add_to_config_log('defaultdisplaymode', $oldvalue, $disabled, $plugin);
-
 
109
            \core_plugin_manager::reset_caches();
-
 
110
        }
-
 
111
 
-
 
112
        return $haschanged;
-
 
113
    }
84
 
114
 
85
    /**
115
    /**
86
     * Defines if there should be a way to uninstall the plugin via the administration UI.
116
     * Defines if there should be a way to uninstall the plugin via the administration UI.
87
     *
117
     *
88
     * @return bool
118
     * @return bool