From ed5b07b335d8bd1520f3b54bf28272f853bbfbfb Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Jan 2010 21:38:01 -0800 Subject: Create a user profile page that is used as a landing page when referencing a user in messages or pages. Partial fix for ticket #889 and a fix for #931. --- modules/comment/views/admin_block_recent_comments.html.php | 3 ++- modules/comment/views/comment.html.php | 3 ++- modules/comment/views/comments.html.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'modules/comment') diff --git a/modules/comment/views/admin_block_recent_comments.html.php b/modules/comment/views/admin_block_recent_comments.html.php index d9776def..99f72a30 100644 --- a/modules/comment/views/admin_block_recent_comments.html.php +++ b/modules/comment/views/admin_block_recent_comments.html.php @@ -8,8 +8,9 @@ width="32" height="32" /> created) ?> - %author_name said %comment_text', + %author_name said %comment_text', array("author_name" => html::clean($comment->author_name()), + "url" => user_profile::url($comment->author_id), "comment_text" => text::limit_words(nl2br(html::purify($comment->text)), 50))); ?> diff --git a/modules/comment/views/comment.html.php b/modules/comment/views/comment.html.php index 2c485b53..c4cf1ce0 100644 --- a/modules/comment/views/comment.html.php +++ b/modules/comment/views/comment.html.php @@ -8,8 +8,9 @@ width="40" height="40" /> - %name said", + %name said", array("date_time" => gallery::date_time($comment->created), + "url" => user_profile::url($comment->author_id), "name" => html::clean($comment->author_name()))) ?>

diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php index fc54e3d2..c8236997 100644 --- a/modules/comment/views/comments.html.php +++ b/modules/comment/views/comments.html.php @@ -22,8 +22,9 @@ width="40" height="40" /> - %name said', + %name said', array("date" => date("Y-M-d H:i:s", $comment->created), + "url" => user_profile::url($comment->author_id), "name" => html::clean($comment->author_name()))); ?>

-- cgit v1.2.3 From 7c06e21ec443a46bd78bc9e99d8284283ff85c59 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 24 Jan 2010 15:27:33 -0800 Subject: Refactor creating the user profile page content into the the event module. The show_user_profile is used to provide content to the user profile page. Add the list of the users comments to the profile page. --- modules/comment/helpers/comment_event.php | 12 +++++++ .../comment/views/user_profile_comments.html.php | 20 ++++++++++++ modules/gallery/controllers/user_profile.php | 17 +++------- modules/gallery/helpers/gallery_event.php | 18 +++++++++++ modules/gallery/views/user_profile.html.php | 37 +++++++++------------- modules/gallery/views/user_profile_info.html.php | 9 ++++++ 6 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 modules/comment/views/user_profile_comments.html.php create mode 100644 modules/gallery/views/user_profile_info.html.php (limited to 'modules/comment') diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index bd336cda..12e8d73f 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -76,4 +76,16 @@ class comment_event_Core { $data[] = $row->text; } } + + static function show_user_profile($data) { + $view = new View("user_profile_comments.html"); + $view->comments = ORM::factory("comment") + ->order_by("created", "DESC") + ->where("state", "=", "published") + ->where("author_id", "=", $data->user->id) + ->find_all(); + if ($view->comments->count()) { + $data->content[] = (object)array("title" => t("Comments"), "view" => $view); + } + } } diff --git a/modules/comment/views/user_profile_comments.html.php b/modules/comment/views/user_profile_comments.html.php new file mode 100644 index 00000000..a2a641ba --- /dev/null +++ b/modules/comment/views/user_profile_comments.html.php @@ -0,0 +1,20 @@ + +
+ +
diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php index 808531da..6159894d 100644 --- a/modules/gallery/controllers/user_profile.php +++ b/modules/gallery/controllers/user_profile.php @@ -31,25 +31,16 @@ class User_Profile_Controller extends Controller { // @todo modify user_home to supply a link to their album, // @todo add list of watches - // @todo add all comments // @todo add rest api key $v->content->user = $user; - $v->content->height = 250; $v->content->not_current = !$is_current_active; $v->content->editable = identity::is_writable() && $display_all; $v->content->return = SafeString::of(Input::instance()->get("return")); - $fields = array("name" => t("Name"), "locale" => t("Locale"), "email" => t("Email"), - "full_name" => t("Full name"), "url" => "Web site"); - if (!$display_all) { - $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => "Web site"); - } - $v->content->fields = array(); - foreach ($fields as $field => $label) { - if (!empty($user->$field)) { - $v->content->fields[(string)$label->for_html()] = $user->$field; - } - } + $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/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 29940ac6..6b70513a 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -377,4 +377,22 @@ class gallery_event_Core { } } } + + static function show_user_profile($data) { + $v = new View("user_profile_info.html"); + + $fields = array("name" => t("Name"), "locale" => t("Locale"), "email" => t("Email"), + "full_name" => t("Full name"), "url" => "Web site"); + if (!$data->display_all) { + $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => "Web site"); + } + $v->fields = array(); + foreach ($fields as $field => $label) { + if (!empty($data->user->$field)) { + $v->fields[(string)$label->for_html()] = $data->user->$field; + } + } + $data->content[] = (object)array("title" => t("User information"), "view" => $v); + + } } diff --git a/modules/gallery/views/user_profile.html.php b/modules/gallery/views/user_profile.html.php index e7ce56b3..bcfa5346 100644 --- a/modules/gallery/views/user_profile.html.php +++ b/modules/gallery/views/user_profile.html.php @@ -1,9 +1,7 @@ - -
-

$user->display_name())) ?>

+
+

+ + " + alt="display_name()) ?>" + class="g-avatar" width="40" height="40" /> + + $user->display_name())) ?> +

+
- +
- - $value): ?> - - - - - -
+ view ?>
+
guest && $not_current && !empty($user->email)): ?> + + $value): ?> + + + + + +
-- cgit v1.2.3