Fixing a stupid mistake
[elgg.git] / _activity / index.php
blobcd9601e6da770875ce24efb1ed88bf07fd65cf41
1 <?php
2 global $CFG;
3 // ELGG recent activity page
5 // Run includes
6 require_once(dirname(dirname(__FILE__))."/includes.php");
8 // Initialise functions for user details, icon management and profile management
9 run("profile:init");
11 // Whose friends are we looking at?
12 global $page_owner;
14 // Weblog context
15 define("context", "weblog");
17 // You must be logged on to view this!
18 protect(1);
20 templates_page_setup();
22 cleanup_messages(time() - (86400 * 30));
24 $title = run("profile:display:name") . " :: " . __gettext("Recent activity");
26 // If we haven't specified a start time, start time = 1 day ago
27 $starttime = optional_param('starttime',time()-86400,PARAM_INT);
29 $body = "<p>" . __gettext("Currently viewing recent activity since ") . gmstrftime("%B %d, %Y", $starttime) . ".</p>";
31 $body .= "<p>" . __gettext("You may view recent activity during the following time-frames:") . "</p>";
33 $body .= "<ul><li><a href=\"index.php?starttime=" . (time() - 86400) . "\">" . __gettext("The last 24 hours") . "</a></li>";
34 $body .= "<li><a href=\"index.php?starttime=" . (time() - (86400 * 2)) . "\">" . __gettext("The last 48 hours") . "</a></li>";
35 $body .= "<li><a href=\"index.php?starttime=" . (time() - (86400 * 7)) . "\">" . __gettext("The last week") . "</a></li>";
36 $body .= "<li><a href=\"index.php?starttime=" . (time() - (86400 * 30)) . "\">" . __gettext("The last month") . "</a></li></ul>";
38 $body .= "<h2>" . __gettext("Your recent messages") . "</h2>";
40 $user_messages = get_messages($page_owner,null,(time() - $starttime));
42 if (is_array($user_messages) && !empty($user_messages)) {
43 foreach($user_messages as $user_message) {
44 $body .= "<div class=\"user_message\">" . display_message($user_message) . "</div>";
49 $body .= "<h2>" . __gettext("Activity on weblog posts you have marked as interesting") . "</h2>";
51 if ($activities = get_records_sql('SELECT wc.*, u.username, u.name as weblogname, wp.weblog, wp.ident AS weblogpost, wp.title AS weblogtitle, wp.weblog AS weblog
52 FROM '.$CFG->prefix.'weblog_comments wc
53 LEFT JOIN '.$CFG->prefix.'weblog_watchlist wl ON wl.weblog_post = wc.post_id
54 LEFT JOIN '.$CFG->prefix.'weblog_posts wp ON wp.ident = wc.post_id
55 LEFT JOIN '.$CFG->prefix.'users u ON u.ident = wp.weblog
56 WHERE wc.posted > ? AND wl.owner = ?
57 ORDER BY wc.posted DESC',array($starttime, $page_owner))) {
58 foreach($activities as $activity) {
59 $commentbody = stripslashes($activity->body);
60 $commentbody .= "<br /><br /><a href=\"" . url . $activity->username . "/weblog/" . $activity->weblogpost . ".html\">" . __gettext("Read more") . "</a>";
61 $activity->postedname = stripslashes($activity->postedname);
62 $activity->weblogname = stripslashes($activity->weblogname);
63 if ($activity->weblog == $USER->ident) {
64 $activity->weblogname = __gettext("your blog");
66 if ($activity->owner == $USER->ident) {
67 $commentposter = sprintf(__gettext("<b>You</b> commented on weblog post '%s' in %s:"), stripslashes($activity->weblogtitle), $activity->weblogname);
68 } else {
69 $commentposter = sprintf(__gettext("<b>%s</b> commented on weblog post '%s' in %s:"), $activity->postedname, stripslashes($activity->weblogtitle), $activity->weblogname);
71 $body .= templates_draw(array(
72 'context' => 'databox1',
73 'name' => $commentposter,
74 'column1' => $commentbody
78 } else {
79 $body .= "<p>" . __gettext("No activity during this time period.") . "</p>";
82 $body = templates_draw(array(
83 'context' => 'contentholder',
84 'title' => $title,
85 'body' => $body
89 echo templates_page_draw( array(
90 $title, $body