10 // Load Elgg framework
11 @require_once
("../../includes.php");
13 // We need to be logged on for this!
18 define("context","dashboard");
20 // Load global variables
21 global $CFG, $PAGE, $db, $page_owner, $messages;
24 $ident = optional_param('wid',0,PARAM_INT
);
25 $widget = get_record('widgets','ident',$ident);
27 // Page owner = where the widget resides
28 $page_owner = $widget->owner
;
30 // Do we have permission to touch this?
32 if (run("permissions:check","profile")) {
34 widget_destroy($widget->ident
);
35 widget_reorder($page_owner,$widget->location
,$widget->location_id
);
39 // Get the username of the widget owner
40 $username = user_info("username",$widget->owner
);
43 $messages[] = __gettext("Widget deleted.");
44 $_SESSION['messages'] = $messages;
46 // Redirect back to the relevant location
47 switch( $widget->location
) {
50 $redirect_url = $CFG->wwwroot
. $username . "/profile/";
53 // get module from the widget type
55 $mod_pos = strpos($widget->type
,"::");
57 $module = substr($widget->type
,0,$mod_pos);
59 $redirect_url = widget_get_display_url($module).'?'.widget_get_display_query();
62 header("Location: " . $redirect_url);