root/releases/0.9rc2/mod/profile/add.php

Revision 1369, 3.3 kB (checked in by rho, 1 year ago)

cleanup

  • use to templates_page_output function to display page

Signed-off: Rolando Espinoza La fuente <rho@prosoftpeople.com>

Line 
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     // Define context
14         define("context","profile");
15             
16     // Load global variables
17         global $CFG, $PAGE, $page_owner;
18     
19     // Get the current user
20         $user_id = optional_param('owner',$_SESSION['userid'],PARAM_INT);
21         $page_owner = $user_id;
22         
23     // Initialise page body and title
24         $body = "";
25         $title = __gettext("Add widgets");
26         
27         templates_page_setup();
28         
29     // Are we eligible to edit this?
30         if (run("permissions:check","profile")) {
31             
32         // Load external data
33             $action = trim(optional_param('action'));
34             $widget_type = trim(optional_param('widget_type'));
35             
36         // If we've been asked to add an item, do that
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 = $CFG->default_access;
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?wid=" . $widget_id);
54                 exit;
55                 
56             }
57             
58         // Iterate through the types of widgets we can add
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                     if (!$widget['type']) {
65                         $widget['type'] = $widget['id'];
66                     }
67                     $body .= "<form action=\"" . $CFG->wwwroot . "mod/profile/add.php\" method=\"post\" >";
68                     $body .= "<div class=\"widget\">\n";
69                     $body .= "<h2>" . $widget['name'] . "</h2>";
70                     $body .= "<p>" . $widget['description'] . "</p>";
71                     $body .= "<p><input type=\"hidden\" name=\"action\" value=\"widgets:add\" />";
72                     $body .= "<input type=\"hidden\" name=\"owner\" value=\"$page_owner\" />";
73                     $body .= "<input type=\"hidden\" name=\"widget_type\" value=\"" . $widget['type'] . "\" />";
74                     $body .= "<input type=\"submit\" value=\"" . __gettext("Add") . "\" /></p>";
75                     $body .= "</div>";
76                     $body .= "</form>";
77                     
78                 }
79                 
80             }               
81
82         } else {
83             $body = "<p>" . __gettext("You do not have permission to add widgets to this profile.") . "</p>";
84         }
85         
86         templates_page_output($title, $body);
87
88 ?>
Note: See TracBrowser for help on using the browser.