| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
Elgg Dashboard |
|---|
| 6 |
http://elgg.org/ |
|---|
| 7 |
|
|---|
| 8 |
*/ |
|---|
| 9 |
|
|---|
| 10 |
// Load Elgg framework |
|---|
| 11 |
@require_once("../../includes.php"); |
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
define("context","widgets"); |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
global $CFG, $PAGE, $page_owner; |
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
$user_id = optional_param('owner',$_SESSION['userid'],PARAM_INT); |
|---|
| 21 |
$page_owner = $user_id; |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
$body = ""; |
|---|
| 25 |
$title = __gettext("Add widgets"); |
|---|
| 26 |
|
|---|
| 27 |
templates_page_setup(); |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
if (run("permissions:check","profile")) { |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
$action = trim(optional_param('action')); |
|---|
| 34 |
$widget_type = trim(optional_param('widget_type')); |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
if (!empty($action) && $action == "widgets:add" && !empty($widget_type)) { |
|---|
| 38 |
|
|---|
| 39 |
$widget = new stdClass; |
|---|
| 40 |
$widget->owner = $page_owner; |
|---|
| 41 |
$widget->type = $widget_type; |
|---|
| 42 |
$widget->access = "user" . $_SESSION['userid']; |
|---|
| 43 |
$widget->location = "profile"; |
|---|
| 44 |
$widget->location_id = 0; |
|---|
| 45 |
$widget_id = insert_record('widgets',$widget); |
|---|
| 46 |
|
|---|
| 47 |
$messages[] = __gettext("Widget added."); |
|---|
| 48 |
$_SESSION['messages'] = $messages; |
|---|
| 49 |
|
|---|
| 50 |
widget_reorder($page_owner,'profile',0); |
|---|
| 51 |
|
|---|
| 52 |
$username = user_info("username",$page_owner); |
|---|
| 53 |
header("Location: " .$CFG->wwwroot."mod/widget/edit.php?widget=" . $widget_id); |
|---|
| 54 |
exit; |
|---|
| 55 |
|
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
if (is_array($CFG->widgets->list) && !empty($CFG->widgets->list)) { |
|---|
| 60 |
|
|---|
| 61 |
$body = "<p>" . __gettext("Select a widget type from the list below:") . "</p>"; |
|---|
| 62 |
|
|---|
| 63 |
foreach($CFG->widgets->list as $widget) { |
|---|
| 64 |
$body .= "<form action=\"" . $CFG->wwwroot . "mod/widget/add.php\" method=\"post\" >"; |
|---|
| 65 |
$body .= "<div class=\"widget\">\n"; |
|---|
| 66 |
$body .= "<h2>" . $widget['name'] . "</h2>"; |
|---|
| 67 |
$body .= "<p>" . $widget['description'] . "</p>"; |
|---|
| 68 |
$body .= "<p><input type=\"hidden\" name=\"action\" value=\"widgets:add\" />"; |
|---|
| 69 |
$body .= "<input type=\"hidden\" name=\"owner\" value=\"$page_owner\" />"; |
|---|
| 70 |
$body .= "<input type=\"hidden\" name=\"widget_type\" value=\"" . $widget['type'] . "\" />"; |
|---|
| 71 |
$body .= "<input type=\"submit\" value=\"" . __gettext("Add") . "\" /></p>"; |
|---|
| 72 |
$body .= "</div>"; |
|---|
| 73 |
$body .= "</form>"; |
|---|
| 74 |
|
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
} else { |
|---|
| 80 |
$body = "<p>" . __gettext("You do not have permission to add widgets to this profile.") . "</p>"; |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
templates_page_output($title, $body); |
|---|
| 85 |
|
|---|
| 86 |
?> |
|---|