From 554e8f7fedab096467b2d08e8a6f67910267c69d Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 16 Aug 2008 12:32:40 +0000 Subject: Individual profile items can now have access restrictions; also made the profile JS more cache friendly git-svn-id: https://code.elgg.org/elgg/trunk@1968 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/profile/actions/edit.php | 21 ++++++++++++++++++++- mod/profile/start.php | 12 ++++++++++++ mod/profile/views/default/profile/edit.php | 23 ++++++++++++++++++++--- mod/profile/views/default/profile/javascript.php | 2 ++ mod/profile/views/default/profile/metatags.php | 2 +- 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/mod/profile/actions/edit.php b/mod/profile/actions/edit.php index 46b7897df..c3673e4e6 100644 --- a/mod/profile/actions/edit.php +++ b/mod/profile/actions/edit.php @@ -15,8 +15,12 @@ // Get profile fields $input = array(); + $accesslevel = get_input('accesslevel'); + if (!is_array($accesslevel)) $accesslevel = array(); + foreach($CONFIG->profile as $shortname => $valuetype) { $input[$shortname] = get_input($shortname); + if ($valuetype == 'tags') $input[$shortname] = string_to_tag_array($input[$shortname]); } @@ -34,7 +38,22 @@ // Save stuff if (sizeof($input) > 0) foreach($input as $shortname => $value) { - $user->$shortname = $value; + + //$user->$shortname = $value; + remove_metadata($user->guid, $shortname); + if (isset($accesslevel[$shortname])) { + $access_id = (int) $accesslevel[$shortname]; + } else { + $access_id = 0; + } + if (is_array($value)) { + foreach($value as $interval) { + create_metadata($user->guid, $shortname, $interval, 'text', $user->guid, $access_id, true); + } + } else { + create_metadata($user->guid, $shortname, $value, 'text', $user->guid, $access_id); + } + } $user->save(); diff --git a/mod/profile/start.php b/mod/profile/start.php index b26abb93f..9ad88fab6 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -44,6 +44,7 @@ // Register a page handler, so we can have nice URLs register_page_handler('profile','profile_page_handler'); register_page_handler('icon','profile_icon_handler'); + register_page_handler('iconjs','profile_iconjs_handler'); // Add Javascript reference to the page header extend_view('metatags','profile/metatags'); @@ -103,6 +104,17 @@ } + /** + * Icon JS + */ + function profile_iconjs_handler($page) { + + global $CONFIG; + + include($CONFIG->pluginspath . "profile/javascript.php"); + + } + /** * Profile URL generator for $user->getUrl(); * diff --git a/mod/profile/views/default/profile/edit.php b/mod/profile/views/default/profile/edit.php index ea0a307fc..5d409140d 100644 --- a/mod/profile/views/default/profile/edit.php +++ b/mod/profile/views/default/profile/edit.php @@ -22,7 +22,23 @@ //var_export($vars['profile']); if (is_array($vars['config']->profile) && sizeof($vars['config']->profile) > 0) foreach($vars['config']->profile as $shortname => $valtype) { - + if ($metadata = get_metadata_byname($vars['entity']->guid, $shortname)) { + if (is_array($metadata)) { + $value = ''; + foreach($metadata as $md) { + if (!empty($value)) $value .= ', '; + $value .= $md->value; + $access_id = $md->access_id; + } + } else { + $value = $metadata->value; + $access_id = $metadata->access_id; + } + } else { + $value = ''; + $access_id = 1; + } + ?>

@@ -30,13 +46,14 @@
$shortname, - 'value' => $vars['entity']->$shortname, + 'value' => $value, )); ?> + 'accesslevel['.$shortname.']', 'value' => $access_id)); ?>

diff --git a/mod/profile/views/default/profile/javascript.php b/mod/profile/views/default/profile/javascript.php index e0f87522c..2620956b3 100644 --- a/mod/profile/views/default/profile/javascript.php +++ b/mod/profile/views/default/profile/javascript.php @@ -13,6 +13,8 @@ */ header("Content-type: text/javascript"); + header("Pragma: public"); + header("Cache-Control: public"); ?> diff --git a/mod/profile/views/default/profile/metatags.php b/mod/profile/views/default/profile/metatags.php index 84682f6f6..3a58651ca 100644 --- a/mod/profile/views/default/profile/metatags.php +++ b/mod/profile/views/default/profile/metatags.php @@ -13,4 +13,4 @@ ?> - + -- cgit v1.2.3