diff options
-rw-r--r-- | modules/comment/helpers/comment_event.php | 12 | ||||
-rw-r--r-- | modules/comment/views/user_profile_comments.html.php | 20 | ||||
-rw-r--r-- | modules/gallery/controllers/user_profile.php | 20 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 18 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/user_profile.php | 3 | ||||
-rw-r--r-- | modules/gallery/views/user_profile.html.php | 41 | ||||
-rw-r--r-- | modules/gallery/views/user_profile_info.html.php | 9 | ||||
-rw-r--r-- | modules/notification/helpers/notification_event.php | 21 | ||||
-rw-r--r-- | modules/notification/views/user_profile_notification.html.php | 12 | ||||
-rw-r--r-- | modules/rest/helpers/rest_event.php | 17 | ||||
-rw-r--r-- | modules/rest/views/user_profile_rest.html.php | 8 |
12 files changed, 143 insertions, 40 deletions
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 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<div id="g-comment-detail"> +<ul> + <? foreach ($comments as $comment): ?> + <li id="g-comment-<?= $comment->id ?>"> + <p class="g-author"> + <?= t('on %date for %title ', + array("date" => date("Y-M-d H:i:s", $comment->created), + "title" => $comment->item()->title)); ?> + <a href="<?= $comment->item()->url() ?>"> + <?= $comment->item()->thumb_img(array(), 50) ?> + </a> + </p> + <div> + <?= nl2br(html::purify($comment->text)) ?> + </div> + </li> + <? endforeach ?> +</ul> +</div> diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php index 808531da..a0e6619e 100644 --- a/modules/gallery/controllers/user_profile.php +++ b/modules/gallery/controllers/user_profile.php @@ -30,26 +30,13 @@ 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 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); + $v->content->info_parts = $event_data->content; print $v; } @@ -60,6 +47,7 @@ class User_Profile_Controller extends Controller { } public function send($id) { + access::verify_csrf(); $user = identity::lookup_user($id); $form = user_profile::get_contact_form($user); if ($form->validate()) { diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 255176c4..1df3a507 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -395,4 +395,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/helpers/module.php b/modules/gallery/helpers/module.php index f680ff6a..95e426c4 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -98,7 +98,7 @@ class module_Core { $m->active = self::is_active($module_name); $m->code_version = $m->version; $m->version = self::get_version($module_name); - $m->locked = !empty($m->no_module_admin); + $m->locked = false; } // Lock certain modules diff --git a/modules/gallery/helpers/user_profile.php b/modules/gallery/helpers/user_profile.php index 018e1bd1..95a994bc 100644 --- a/modules/gallery/helpers/user_profile.php +++ b/modules/gallery/helpers/user_profile.php @@ -24,8 +24,7 @@ class user_profile_Core { * @return url for the profile display */ static function url($user_id) { - $return_url = urlencode(url::abs_current()); - return url::site("user_profile/show/{$user_id}?return=$return_url"); + return url::site("user_profile/show/{$user_id}"); } static function get_contact_form($user) { diff --git a/modules/gallery/views/user_profile.html.php b/modules/gallery/views/user_profile.html.php index e7ce56b3..708b1613 100644 --- a/modules/gallery/views/user_profile.html.php +++ b/modules/gallery/views/user_profile.html.php @@ -1,9 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <style> - #g-user-profile #g-profile-buttons { - bottom: 0; - position: absolute; - right: 0; + #g-user-profile div { + margin-top: 1em; } #g-user-profile fieldset { @@ -23,32 +21,33 @@ border: none; padding: 0; } - </style> <script> - $("#g-user-profile").ready(function() { - //$("#g-profile-return").click(function(event) { - // window.location = <?= $return->for_js() ?>; - //}); + $(document).ready(function() { + $("#g-profile-return").click(function(event) { + history.go(-1); + }) }); </script> -<div id="g-user-profile" style="height: <?= $height ?>px"> - <h1 style="display: none"><?= t("%name Profile", array("name" => $user->display_name())) ?></h1> +<div id="g-user-profile"> + <h1> + <a href="#"> + <img src="<?= $user->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>" + alt="<?= html::clean_attribute($user->display_name()) ?>" + class="g-avatar" width="40" height="40" /> + </a> + <?= t("%name Profile", array("name" => $user->display_name())) ?> + </h1> + <? foreach ($info_parts as $info): ?> <div> <fieldset> - <label><?= t("User information") ?></label> + <label><?= $info->title ?></label> <div> - <table> - <? foreach ($fields as $field => $value): ?> - <tr> - <td><?= $field ?></td> - <td><?= $value ?></td> - </tr> - <? endforeach ?> - </table> + <?= $info->view ?> </div> </fieldset> </div> + <? endforeach ?> <div id="g-profile-buttons" class="ui-helper-clearfix g-right"> <? if (!$user->guest && $not_current && !empty($user->email)): ?> <a class="g-button ui-icon-right ui-state-default ui-corner-all g-dialog-link" @@ -62,7 +61,7 @@ </a> <? endif ?> - <a class="g-button ui-icon-right ui-state-default ui-corner-all" href="<?= $return->for_html_attr() ?>"> + <a id="g-profile-return" class="g-button ui-icon-right ui-state-default ui-corner-all" href="#"> <?= t("Return") ?> </a> </div> diff --git a/modules/gallery/views/user_profile_info.html.php b/modules/gallery/views/user_profile_info.html.php new file mode 100644 index 00000000..2a2549c8 --- /dev/null +++ b/modules/gallery/views/user_profile_info.html.php @@ -0,0 +1,9 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<table> + <? foreach ($fields as $field => $value): ?> + <tr> + <td><?= $field ?></td> + <td><?= $value ?></td> + </tr> + <? endforeach ?> +</table> 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> |