10 // Load Elgg framework
11 @require_once
("../../includes.php");
13 // We need to be logged on for this!
18 define("context","widget");
20 // Load global variables
21 global $CFG, $PAGE, $db, $page_owner, $messages;
25 $ident = optional_param('wid',0,PARAM_INT
);
26 $widget = get_record("widgets", "ident", $ident);
28 // Get moving instructions
29 $move = optional_param('_widget_move');
31 // Page owner = where the widget resides
32 $page_owner = $widget->owner
;
34 // Do we have permission to touch this?
36 if (run("permissions:check","profile")) {
39 widget_moveup($widget);
40 } else if ($move == "down") {
41 widget_movedown($widget);
42 } else if ($move == "1") {
43 widget_move_before($widget,$widget->display_order
,0);
44 } else if ($move == "2") {
45 widget_move_before($widget,$widget->display_order
,1);
49 // Get the username of the widget owner
50 $username = user_info("username",$widget->owner
);
53 $messages[] = __gettext("Widget moved.");
54 $_SESSION['messages'] = $messages;
56 // Redirect back to the relevant location
57 switch( $widget->location
) {
60 $redirect_url = $CFG->wwwroot
. $username . "/profile/";
63 // get module from the widget type
65 $mod_pos = strpos($widget->type
,"::");
67 $module = substr($widget->type
,0,$mod_pos);
69 $redirect_url = widget_get_display_url($module).'?'.widget_get_display_query();
73 header("Location: " . $redirect_url);