diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-01-13 19:25:37 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-01-13 19:25:37 +0000 |
commit | eee72bfa9509e99be79f9c92e6330bc00ea498dd (patch) | |
tree | 30c11ee855f1025325e617aeefa6ee307a957a2a /includes | |
parent | 75685d8c3d21eb8ac93e03b9f202aefdedaabe58 (diff) | |
download | brdo-eee72bfa9509e99be79f9c92e6330bc00ea498dd.tar.gz brdo-eee72bfa9509e99be79f9c92e6330bc00ea498dd.tar.bz2 |
- Patch 4859: new drupal_unpack() consolidates duplicate code and makes it
easy to show avatars next to nodes and comments. Patch by Moshe. As a
showcase, maybe Xtemplate should have an option to enable/disable avatars?
Diffstat (limited to 'includes')
-rw-r--r-- | includes/bootstrap.inc | 16 | ||||
-rw-r--r-- | includes/session.inc | 8 |
2 files changed, 17 insertions, 7 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 8f0fa9ec6..9f59b7237 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -161,6 +161,22 @@ function bootstrap_hooks() { return array('init', 'exit'); } +/* +** Unserializes and appends elements from a serialized string +** $obj is the object to which we shall append +** $field is the element whose value is a serialized string +*/ +function drupal_unpack($obj, $field = 'data') { + if ($obj->$field && $data = unserialize($obj->$field)) { + foreach ($data as $key => $value) { + if (!isset($obj->$key)) { + $obj->$key = $value; + } + } + } + return $obj; +} + function referer_uri() { if (isset($_SERVER["HTTP_REFERER"])) { return check_url($_SERVER["HTTP_REFERER"]); diff --git a/includes/session.inc b/includes/session.inc index f2eb64975..71dc64806 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -25,13 +25,7 @@ function sess_read($key) { } $user = db_fetch_object($result); - if ($user->data && $data = unserialize($user->data)) { - foreach ($data as $key => $value) { - if (!isset($user->$key)) { - $user->$key = $value; - } - } - } + $user = drupal_unpack($user); return !empty($user->session) ? $user->session : ''; } |