$title = __gettext("Edit widget"); templates_page_setup(); // If action is specified if (!empty($action) && ($action == "widget:save" || $action == "widget:save:ajax")) { // Get the username of the widget owner // KJ - why? $username = user_info("username", $widget->owner); // Get any data $js_override = optional_param('widget_allcontent'); if ($js_override == "yes" && in_array($widget->type, $CFG->widgets->allcontent)) { $widget_data = optional_param('widget_data', '', null); } else { $widget_data = optional_param('widget_data', '', PARAM_CLEAN); } if (!empty($widget_data)) { widget_remove_data($widget->ident); if (is_array($widget_data)) { foreach ($widget_data as $key => $value) { widget_set_data($key, $widget->ident, $value); } } } // Save access $widget->access = optional_param('_widget_access', $CFG->default_access); update_record('widgets', $widget); if ($action == "widget:save") { // Add a message $messages[] = __gettext("Widget edited."); $_SESSION['messages'] = $messages; // Redirect back to the relevant location switch ($widget->location) {
function widget_destroy($ident) { if ($widget = get_record('widgets', 'ident', $ident)) { if ($widget = plugin_hook("widget", "delete", $widget)) { delete_records('widgets', 'ident', $ident); widget_remove_data($ident); } } }