Put overflow hidden and a fixed width on profile widgets to stop large img coming...
[elgg.git] / mod / widget / edit.php
blob53059122ab44b77d05e10e7fb911376e8a0e86c6
1 <?php
3 /*
5 Elgg Widgets
6 http://elgg.org/
8 */
10 // Load Elgg framework
11 @require_once("../../includes.php");
13 // We need to be logged on for this!
15 if (isloggedin()) {
17 // Define context
18 define("context","widget");
20 // Load global variables
21 global $CFG, $PAGE, $db, $page_owner, $messages;
23 // Load external variables
24 $action = trim(optional_param('_widget_action'));
25 // Get widget details
26 $ident = optional_param('wid',0,PARAM_INT);
27 $widget = get_record("widgets", "ident", $ident);
28 // Page owner = where the widget resides
29 $page_owner = $widget->owner;
31 // Initialise page
32 $body = "";
33 $title = __gettext("Edit widget");
34 templates_page_setup();
36 // If action is specified
38 if (!empty($action) && ($action == "widget:save" || $action == "widget:save:ajax")) {
40 // Get the username of the widget owner
41 // KJ - why?
42 $username = user_info("username",$widget->owner);
44 // Get any data
45 $widget_data = optional_param('widget_data');
47 if (!empty($widget_data)) {
49 widget_remove_data($widget->ident);
51 if (is_array($widget_data)) {
52 foreach($widget_data as $key => $value) {
53 widget_set_data($key, $widget->ident, $value);
58 // Save access
59 $widget->access = optional_param('_widget_access',"user".$_SESSION['userid']);
60 update_record('widgets',$widget);
62 if ($action == "widget:save") {
64 // Add a message
65 $messages[] = __gettext("Widget edited.");
66 $_SESSION['messages'] = $messages;
68 // Redirect back to the relevant location
69 switch( $widget->location ) {
70 case 'profile':
71 case '':
72 $redirect_url = $CFG->wwwroot . $username . "/profile/";
73 break;
74 default:
75 // get module from the widget type
76 $module = '';
77 $mod_pos = strpos($widget->type,"::");
78 if ($mod_pos) {
79 $module = substr($widget->type,0,$mod_pos);
81 $redirect_url = widget_get_display_url($module).'?'.widget_get_display_query();
82 break;
85 header("Location: " . $redirect_url);
86 exit;
88 } else {
90 $result = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
91 $result .= '<answer>';
92 $result .= '<result>'.$widget->ident.'</result>';
93 $result .= '</answer>';
94 header('Content-Type: application/xml');
95 print $result;
99 } else {
101 // Do we have permission to touch this?
102 // If so, display edit screen
103 if (run("permissions:check","profile")) {
105 $body = widget_edit($widget);
107 } else {
109 $body = "<p>" . __gettext("You do not have permission to edit this widget.") . "</p>";
114 // Output to the screen
115 $body = templates_draw(array(
116 'context' => 'contentholder',
117 'title' => $title,
118 'body' => $body
122 echo templates_page_draw( array(
123 $title, $body