diff options
author | Andy Staudacher <andy.st@gmail.com> | 2010-02-21 13:08:06 -0800 |
---|---|---|
committer | Andy Staudacher <andy.st@gmail.com> | 2010-02-21 13:08:06 -0800 |
commit | be20309259de9310da3be703c93c4e42def2541b (patch) | |
tree | 38ecbb4fe4183e65af79cd9fbdfae3d99b8cd4d3 | |
parent | cb57c3912aef6bed394a4693f94e9c97001aff34 (diff) | |
parent | 1377b2c7b3110a132d4b2d748be72a6aafa537e6 (diff) |
Merge commit 'upstream/master'
-rw-r--r-- | lib/gallery.common.css | 5 | ||||
-rw-r--r-- | modules/comment/views/comments.html.php | 2 | ||||
-rw-r--r-- | modules/gallery/controllers/user_profile.php | 16 | ||||
-rw-r--r-- | modules/gallery/css/gallery.css | 34 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 5 | ||||
-rw-r--r-- | modules/gallery/libraries/Gallery_I18n.php | 3 | ||||
-rw-r--r-- | modules/gallery/models/item.php | 6 | ||||
-rw-r--r-- | modules/gallery/views/permissions_form.html.php | 2 | ||||
-rw-r--r-- | modules/gallery/views/upgrader.html.php | 2 | ||||
-rw-r--r-- | modules/gallery/views/user_profile.html.php | 82 | ||||
-rw-r--r-- | modules/gallery/views/user_profile_info.html.php | 2 | ||||
-rw-r--r-- | modules/notification/helpers/notification_event.php | 36 | ||||
-rw-r--r-- | modules/rest/helpers/rest.php | 10 | ||||
-rw-r--r-- | modules/rest/helpers/rest_event.php | 28 | ||||
-rw-r--r-- | modules/user/helpers/user_installer.php | 8 | ||||
-rw-r--r-- | modules/user/models/user.php | 2 | ||||
-rw-r--r-- | modules/user/views/admin_users.html.php | 2 | ||||
-rw-r--r-- | modules/user/views/admin_users_group.html.php | 8 |
18 files changed, 139 insertions, 114 deletions
diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 553eb496..98b4ee40 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -743,6 +743,11 @@ div#g-action-status { margin-right: .4em; } +.rtl #g-admin-comment-button { + right: inherit; + left: 0; +} + /* RTL Superfish ~~~~~~~~~~~~~~~~~~~~~~~~~ */ .rtl .sf-menu a { diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php index 58ff1765..8e2a9e51 100644 --- a/modules/comment/views/comments.html.php +++ b/modules/comment/views/comments.html.php @@ -1,6 +1,6 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <a href="<?= url::site("form/add/comments/{$item->id}") ?>" id="g-admin-comment-button" - class="g-button ui-corner-all ui-icon-left ui-state-default right"> + class="g-button ui-corner-all ui-icon-left ui-state-default"> <span class="ui-icon ui-icon-comment"></span> <?= t("Add a comment") ?> </a> diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php index 05373466..b89bc358 100644 --- a/modules/gallery/controllers/user_profile.php +++ b/modules/gallery/controllers/user_profile.php @@ -21,21 +21,21 @@ class User_Profile_Controller extends Controller { public function show($id) { // If we get here, then we should have a user id other than guest. $user = identity::lookup_user($id); - $active_user = identity::active_user(); - $is_current_active = $active_user->id == $id; - $can_edit = $is_current_active && !$active_user->guest; - $display_all = $active_user->admin || $can_edit; + if (!$user) { + throw new Kohana_404_Exception(); + } $v = new Theme_View("page.html", "other", "profile"); $v->page_title = t("%name Profile", array("name" => $user->display_name())); $v->content = new View("user_profile.html"); - // @todo modify user_home to supply a link to their album, $v->content->user = $user; - $v->content->not_current = !$is_current_active; - $v->content->editable = identity::is_writable() && $can_edit; + $v->content->contactable = + !$user->guest && $user->id != identity::active_user()->id && $user->email; + $v->content->editable = + identity::is_writable() && !$user->guest && $user->id == identity::active_user()->id; - $event_data = (object)array("user" => $user, "display_all" => $display_all, "content" => array()); + $event_data = (object)array("user" => $user, "content" => array()); module::event("show_user_profile", $event_data); $v->content->info_parts = $event_data->content; diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index e06c4dd9..f3e5ec6d 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -55,6 +55,34 @@ margin: 0; } +/* User profile ~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#g-user-profile h1 { + margin: 1em 0; +} + +#g-user-profile .g-avatar { + margin-right: .6em; +} + +#g-user-profile .g-block { + margin-top: 0; +} + +#g-user-profile .g-block-content { + margin-top: 0; +} + +#g-user-profile th, +#g-user-profile td { + border: none; +} + +#g-user-profile th { + white-space: nowrap; + width: 1%; +} + /** ******************************************************************* * 2) Admin **********************************************************************/ @@ -96,4 +124,8 @@ .rtl #g-block-admin .g-left { margin-left: 1em; margin-right: 0; -}
\ No newline at end of file +} + +.rtl #g-user-profile .g-avatar { + margin-left: .6em; +} diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 3f77bc42..36f91142 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -413,7 +413,7 @@ class gallery_event_Core { $fields = array("name" => t("Name"), "locale" => t("Language Preference"), "email" => t("Email"), "full_name" => t("Full name"), "url" => "Web site"); - if (!$data->display_all) { + if (!$data->user->guest) { $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => "Web site"); } $v->user_profile_data = array(); @@ -423,9 +423,6 @@ class gallery_event_Core { if ($field == "locale") { $value = locales::display_name($value); } - if ($field == "full_name") { - $value = t($value); - } $v->user_profile_data[(string) $label] = $value; } } diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index 26d1de2c..ac0588e3 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -131,9 +131,6 @@ class Gallery_I18n_Core { $count = isset($options['count']) ? $options['count'] : null; $values = $options; unset($values['locale']); - if ($message instanceof SafeString) { - $message = (string) $message; - } $this->log($message, $options); $entry = $this->lookup($locale, $message); diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index a64bcb49..d747b84d 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -930,11 +930,11 @@ class Item_Model extends ORM_MPTT { } unset($data["album_cover_item_id"]); - if (access::can("view_fillsize", $this) && $this->is_photo()) { - $data["fullsize_url"] = $this->abs_url(true); + if (access::can("view_full", $this) && $this->is_photo()) { + $data["file_url"] = $this->file_url(true); } - if ($tmp = $this->resize_url(true) && $this->is_photo()) { + if (($tmp = $this->resize_url(true)) && $this->is_photo()) { $data["resize_url"] = $tmp; } $data["thumb_url"] = $this->thumb_url(true); diff --git a/modules/gallery/views/permissions_form.html.php b/modules/gallery/views/permissions_form.html.php index b486acb7..f1714119 100644 --- a/modules/gallery/views/permissions_form.html.php +++ b/modules/gallery/views/permissions_form.html.php @@ -5,7 +5,7 @@ <tr> <th> </th> <? foreach ($groups as $group): ?> - <th> <?= html::clean(t($group->name)) ?> </th> + <th> <?= html::clean($group->name) ?> </th> <? endforeach ?> </tr> diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index 55731440..c7a96cb5 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -112,7 +112,7 @@ <? else: // can_upgrade ?> <h1> <?= t("Who are you?") ?> </h1> <p> - <?= t("You're not logged in as an administrator, so we have to verify you to make sure it's ok for you to do an upgrade. To prove you can run an upgrade, create a file called <b>%name</b> in your <b>%tmp_dir_path</b> directory.", + <?= t("You're not logged in as an administrator, so we have to verify you to make sure it's ok for you to do an upgrade. To prove you can run an upgrade, create a file called <b> %name </b> in your <b>%tmp_dir_path</b> directory.", array("name" => "$upgrade_token", "tmp_dir_path" => "gallery3/var/tmp")) ?> </p> diff --git a/modules/gallery/views/user_profile.html.php b/modules/gallery/views/user_profile.html.php index 1c346c26..257bd7ca 100644 --- a/modules/gallery/views/user_profile.html.php +++ b/modules/gallery/views/user_profile.html.php @@ -1,27 +1,4 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<style> - #g-user-profile div { - margin-top: 1em; - } - - #g-user-profile fieldset { - border: 1px solid #CCCCCC; - padding: 0 1em 0.8em; - } - - #g-user-profile fieldset label { - font-weight: bold; - } - - #g-user-profile fieldset div { - padding-left: 1em; - } - - #g-user-profile td { - border: none; - padding: 0; - } -</style> <script type="text/javascript"> $(document).ready(function() { $("#g-profile-return").click(function(event) { @@ -31,45 +8,40 @@ }); </script> <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><?= html::purify($info->title) ?></label> - <div> - <?= $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" - href="<?= url::site("user_profile/contact/{$user->id}") ?>"> - <?= t("Contact") ?> + <div class="ui-helper-clearfix"> + <a id="g-profile-return" class="g-button g-right ui-state-default ui-corner-all" href="#"> + <?= t("Return") ?> </a> - <? endif ?> <? if ($editable): ?> - <a class="g-button ui-icon-right ui-state-default ui-corner-all g-dialog-link" href="<?= url::site("form/edit/users/{$user->id}") ?>"> - <?= t("Edit") ?> + <a class="g-button g-right ui-state-default ui-corner-all g-dialog-link" href="<?= url::site("users/form_change_email/{$user->id}") ?>"> + <?= t("Change email") ?> </a> - <a class="g-button ui-icon-right ui-state-default ui-corner-all g-dialog-link" href="<?= url::site("users/form_change_password/{$user->id}") ?>"> + <a class="g-button g-right ui-state-default ui-corner-all g-dialog-link" href="<?= url::site("users/form_change_password/{$user->id}") ?>"> <?= t("Change password") ?> </a> - <a class="g-button ui-icon-right ui-state-default ui-corner-all g-dialog-link" href="<?= url::site("users/form_change_email/{$user->id}") ?>"> - <?= t("Change email") ?> + <a class="g-button g-right ui-state-default ui-corner-all g-dialog-link" href="<?= url::site("form/edit/users/{$user->id}") ?>"> + <?= t("Edit") ?> </a> <? endif ?> - - <a id="g-profile-return" class="g-button ui-icon-right ui-state-default ui-corner-all" href="#"> - <?= t("Return") ?> + <? if ($contactable): ?> + <a class="g-button g-right ui-state-default ui-corner-all g-dialog-link" + href="<?= url::site("user_profile/contact/{$user->id}") ?>"> + <?= t("Contact") ?> </a> + <? endif ?> </div> + <h1> + <img src="<?= $user->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>" + alt="<?= html::clean_attribute($user->display_name()) ?>" + class="g-avatar g-left" width="40" height="40" /> + <?= t("User profile: %name", array("name" => $user->display_name())) ?> + </h1> + <? foreach ($info_parts as $info): ?> + <div class="g-block"> + <h2><?= html::purify($info->title) ?></h2> + <div class="g-block-content"> + <?= $info->view ?> + </div> + </div> + <? endforeach ?> </div> diff --git a/modules/gallery/views/user_profile_info.html.php b/modules/gallery/views/user_profile_info.html.php index 58e134bb..e559abda 100644 --- a/modules/gallery/views/user_profile_info.html.php +++ b/modules/gallery/views/user_profile_info.html.php @@ -2,7 +2,7 @@ <table> <? foreach ($user_profile_data as $label => $value): ?> <tr> - <td><?= html::clean($label) ?></td> + <th><?= html::clean($label) ?></th> <td><?= html::purify($value) ?></td> </tr> <? endforeach ?> diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index c8628ae4..19e8dedb 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -128,23 +128,31 @@ 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") + // Guests don't see comment listings + if (identity::active_user()->guest) { + return; + } + + // Only logged in users can see their comment listings + if (identity::active_user()->id != $data->user->id) { + return; + } + + $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); + 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/rest/helpers/rest.php b/modules/rest/helpers/rest.php index 3c53784d..1ee72aed 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -23,9 +23,13 @@ class rest_Core { if (Input::instance()->get("output") == "html") { header("Content-type: text/html"); - $html = preg_replace( - "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'<a href=\"\\1\" >\\1</a>'", - var_export(!empty($data) ? $data : t("Empty response"), 1)); + if ($data) { + $html = preg_replace( + "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'<a href=\"\\1\" >\\1</a>'", + var_export($data, 1)); + } else { + $html = t("Empty response"); + } print "<pre>$html</pre>"; } else { header("Content-type: application/json"); diff --git a/modules/rest/helpers/rest_event.php b/modules/rest/helpers/rest_event.php index f9aa34e3..c46e65c4 100644 --- a/modules/rest/helpers/rest_event.php +++ b/modules/rest/helpers/rest_event.php @@ -76,19 +76,27 @@ class rest_event { } static function show_user_profile($data) { - if ($data->display_all) { - $view = new View("user_profile_rest.html"); - $key = ORM::factory("user_access_token") + // Guests can't see a REST key + if (identity::active_user()->guest) { + return; + } + + // Only logged in users can see their own REST key + if (identity::active_user()->id != $data->user->id) { + return; + } + + $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); + 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/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 9e757ecd..729f087a 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -98,25 +98,25 @@ class user_installer { DEFAULT CHARSET=utf8;"); $everybody = ORM::factory("group"); - $everybody->name = (string) t("Everybody", array("locale" => "root")); + $everybody->name = "Everybody"; $everybody->special = true; $everybody->save(); $registered = ORM::factory("group"); - $registered->name = (string) t("Registered Users", array("locale" => "root")); + $registered->name = "Registered Users"; $registered->special = true; $registered->save(); $guest = ORM::factory("user"); $guest->name = "guest"; - $guest->full_name = (string) t("Guest User", array("locale" => "root")); + $guest->full_name = "Guest User"; $guest->password = ""; $guest->guest = true; $guest->save(); $admin = ORM::factory("user"); $admin->name = "admin"; - $admin->full_name = (string) t("Gallery Administrator", array("locale" => "root")); + $admin->full_name = "Gallery Administrator"; $admin->password = "admin"; $admin->email = "unknown@unknown.com"; $admin->admin = true; diff --git a/modules/user/models/user.php b/modules/user/models/user.php index aa752203..4404ee63 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -113,7 +113,7 @@ class User_Model extends ORM implements User_Definition { * @return string */ public function display_name() { - return empty($this->full_name) ? $this->name : t($this->full_name); + return empty($this->full_name) ? $this->name : $this->full_name; } /** diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 69d97547..270a7207 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -78,7 +78,7 @@ <?= html::clean($user->name) ?> </td> <td> - <?= t(html::clean($user->full_name)) ?> + <?= html::clean($user->full_name) ?> </td> <td> <?= html::clean($user->email) ?> diff --git a/modules/user/views/admin_users_group.html.php b/modules/user/views/admin_users_group.html.php index 8317d393..2362e42b 100644 --- a/modules/user/views/admin_users_group.html.php +++ b/modules/user/views/admin_users_group.html.php @@ -1,9 +1,11 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <h4> - <?= t(html::clean($group->name)) ?> + <a href="<?= url::site("admin/users/edit_group_form/$group->id") ?>" + title="<?= t("Edit the %name group's name", array("name" => $group->name))->for_html_attr() ?>" + class="g-dialog-link"><?= html::clean($group->name) ?></a> <? if (!$group->special): ?> <a href="<?= url::site("admin/users/delete_group_form/$group->id") ?>" - title="<?= t("Delete the %name group", array("name" => t(html::clean($group->name))))->for_html_attr() ?>" + title="<?= t("Delete the %name group", array("name" => $group->name))->for_html_attr() ?>" class="g-dialog-link g-button g-right"> <span class="ui-icon ui-icon-trash"><?= t("Delete") ?></span></a> <? else: ?> @@ -22,7 +24,7 @@ <a href="javascript:remove_user(<?= $user->id ?>, <?= $group->id ?>)" class="g-button g-right ui-state-default ui-corner-all ui-icon-left" title="<?= t("Remove %user from %group group", - array("user" => $user->name, "group" => t(html::clean($group->name))))->for_html_attr() ?>"> + array("user" => $user->name, "group" => $group->name))->for_html_attr() ?>"> <span class="ui-icon ui-icon-closethick"><?= t("Remove") ?></span> </a> <? endif ?> |