summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-01-24 20:14:01 -0800
committerTim Almdal <tnalmdal@shaw.ca>2010-01-24 20:14:01 -0800
commit865995305cbd709db4f8587d73e7178a277a8d8b (patch)
tree1e607d0184f29bee7665df42df99b3a32cf2c2ff /modules
parent26eb000637fb83c04919e1e18c67b1441db76da6 (diff)
Add the active notifications and rest api key to user profile page.
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/controllers/user_profile.php3
-rw-r--r--modules/notification/helpers/notification_event.php21
-rw-r--r--modules/notification/views/user_profile_notification.html.php12
-rw-r--r--modules/rest/helpers/rest_event.php17
-rw-r--r--modules/rest/views/user_profile_rest.html.php8
5 files changed, 58 insertions, 3 deletions
diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php
index 3a7e0200..53c76a48 100644
--- a/modules/gallery/controllers/user_profile.php
+++ b/modules/gallery/controllers/user_profile.php
@@ -30,8 +30,6 @@ class User_Profile_Controller extends Controller {
$v->content = new View("user_profile.html");
// @todo modify user_home to supply a link to their album,
- // @todo add list of watches
- // @todo add rest api key
$v->content->user = $user;
$v->content->not_current = !$is_current_active;
$v->content->editable = identity::is_writable() && $display_all;
@@ -39,7 +37,6 @@ class User_Profile_Controller extends Controller {
$event_data = (object)array("user" => $user, "display_all" => $display_all, "content" => array());
module::event("show_user_profile", $event_data);
- Kohana_Log::add("error", Kohana::debug($event_data));
$v->content->info_parts = $event_data->content;
print $v;
diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php
index edbf6e39..c8628ae4 100644
--- a/modules/notification/helpers/notification_event.php
+++ b/modules/notification/helpers/notification_event.php
@@ -126,4 +126,25 @@ class notification_event_Core {
}
}
}
+
+ static function show_user_profile($data) {
+ if ($data->display_all) {
+ $view = new View("user_profile_notification.html");
+ $view->subscriptions = array();
+ foreach(ORM::factory("subscription")
+ ->where("user_id", "=", $data->user->id)
+ ->find_all() as $subscription) {
+ $item = ORM::factory("item")
+ ->where("id", "=", $subscription->item_id)
+ ->find();
+ if ($item->loaded()) {
+ $view->subscriptions[] = (object)array("id" => $subscription->id, "title" => $item->title,
+ "url" => $item->url());
+ }
+ }
+ if (count($view->subscriptions) > 0) {
+ $data->content[] = (object)array("title" => t("Watching"), "view" => $view);
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/modules/notification/views/user_profile_notification.html.php b/modules/notification/views/user_profile_notification.html.php
new file mode 100644
index 00000000..8864f0c7
--- /dev/null
+++ b/modules/notification/views/user_profile_notification.html.php
@@ -0,0 +1,12 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<div id="g-notification-detail">
+<ul>
+ <? foreach ($subscriptions as $subscription): ?>
+ <li id="g-watch-<?= $subscription->id ?>">
+ <a href="<?= $subscription->url ?>">
+ <?= html::purify($subscription->title) ?>
+ </a>
+ </li>
+ <? endforeach ?>
+</ul>
+</div>
diff --git a/modules/rest/helpers/rest_event.php b/modules/rest/helpers/rest_event.php
index 860c8e41..f9aa34e3 100644
--- a/modules/rest/helpers/rest_event.php
+++ b/modules/rest/helpers/rest_event.php
@@ -74,4 +74,21 @@ class rest_event {
->class("g-form-static")
->label(t("Remote access key"));
}
+
+ static function show_user_profile($data) {
+ if ($data->display_all) {
+ $view = new View("user_profile_rest.html");
+ $key = ORM::factory("user_access_token")
+ ->where("user_id", "=", $data->user->id)
+ ->find();
+
+ if (!$key->loaded()) {
+ $key->user_id = $data->user->id;
+ $key->access_key = md5($data->user->name . rand());
+ $key->save();
+ }
+ $view->rest_key = $key->access_key;
+ $data->content[] = (object)array("title" => t("Rest api"), "view" => $view);
+ }
+ }
}
diff --git a/modules/rest/views/user_profile_rest.html.php b/modules/rest/views/user_profile_rest.html.php
new file mode 100644
index 00000000..3807817e
--- /dev/null
+++ b/modules/rest/views/user_profile_rest.html.php
@@ -0,0 +1,8 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<div id="g-rest-detail">
+<ul>
+ <li id="g-rest-key">
+ <p><b><?= t("Key") ?></b>:<?= $rest_key ?></p>
+ </li>
+</ul>
+</div>