Commit 2101f6c4 authored by Dries's avatar Dries

- Rewrote the profile module:

   + Added a 'created' field to the users table and renamed the 'timestamp'
     fied to 'changed' (cfr. node table).  Update.php will try to determine
     a 'created' timestamp for existing users.

   + The profile module no longer uses serialized data but has its own set
     of tables.  Known existing profile data is migrated by these new tables.
       TODO: migrate the birthday field.

   + The profile fields can be grouped, and within each group, profile fields
     can be sorted using weights.

   + The profile pages can be themed.

   + The profiles can be browsed based on certain properties/settings.

   + Change the _user hook: (i) 'private_view' and 'public_view' are merged
     into 'view' as there are no private fields and (ii) 'edit_form' has
     been renamed to 'edit'.

   + Avatar handling has been refactored and is now part of the user module.
     The users table has a dedicted 'picture' field.

   + Simplified the way themes should use display/visualize pictures or
     avatars.

   + Made it possible for administrators to replace or delete avatars.

   + ...

  I hope this make for a good base to build on collectively.
parent f10cca11
Drupal x.x.x, xxxx-xx-xx
------------------------
- profile module:
* made it possible to administere profile fields.
* made it possible to browse the profiles by field.
Drupal 4.4.0, xxxx-xx-xx (release candidate)
--------------------------------------------
......
......@@ -282,13 +282,13 @@ CREATE TABLE node (
uid int(10) NOT NULL default '0',
status int(4) NOT NULL default '1',
created int(11) NOT NULL default '0',
changed int(11) NOT NULL default '0',
comment int(2) NOT NULL default '0',
promote int(2) NOT NULL default '0',
moderate int(2) NOT NULL default '0',
users longtext NOT NULL,
teaser longtext NOT NULL,
body longtext NOT NULL,
changed int(11) NOT NULL default '0',
revisions longtext NOT NULL,
static int(2) NOT NULL default '0',
PRIMARY KEY (nid),
......@@ -312,6 +312,38 @@ CREATE TABLE page (
PRIMARY KEY (nid)
) TYPE=MyISAM;
--
-- Table structure for table 'profile_fields'
--
CREATE TABLE profile_fields (
fid int(10) NOT NULL auto_increment,
title varchar(255) default NULL,
name varchar(128) default NULL,
explanation TEXT default NULL,
category varchar(255) default NULL,
type varchar(128) default NULL,
weight tinyint(1) DEFAULT '0' NOT NULL,
overview tinyint(1) DEFAULT '0' NOT NULL,
options text,
KEY category (category),
UNIQUE KEY name (name),
PRIMARY KEY (fid)
);
--
-- Table structure for table 'profile_values'
--
CREATE TABLE profile_values (
fid int(11) unsigned default '0',
uid int(11) unsigned default '0',
value text,
KEY uid (uid),
KEY fid (fid)
);
--
-- Table structure for table 'url_alias'
--
......@@ -514,10 +546,12 @@ CREATE TABLE users (
threshold tinyint(1) default '0',
theme varchar(255) NOT NULL default '',
signature varchar(255) NOT NULL default '',
timestamp int(11) NOT NULL default '0',
created int(11) NOT NULL default '0',
changed int(11) NOT NULL default '0',
status tinyint(4) NOT NULL default '0',
timezone varchar(8) default NULL,
language char(2) NOT NULL default '',
picture varchar(255) NOT NULL DEFAULT '',
init varchar(64) default '',
data longtext,
rid int(10) unsigned NOT NULL default '0',
......
......@@ -511,10 +511,12 @@ CREATE TABLE users (
threshold smallint default '0',
theme varchar(255) NOT NULL default '',
signature varchar(255) NOT NULL default '',
timestamp integer NOT NULL default '0',
created integer NOT NULL default '0',
changed integer NOT NULL default '0',
status smallint NOT NULL default '0',
timezone varchar(8) default NULL,
language char(2) NOT NULL default '',
picture varchar(255) NOT NULL DEFAULT '',
init varchar(64) default '',
data text default '',
rid integer NOT NULL default '0',
......
......@@ -50,7 +50,8 @@
"2004-01-11" => "update_76",
"2004-01-13" => "update_77",
"2004-02-03" => "update_78",
"2004-02-21" => "update_79"
"2004-02-21" => "update_79",
"2004-03-11: first update since Drupal 4.4.0 release" => "update_80"
);
function update_32() {
......@@ -760,6 +761,126 @@ function update_79() {
return $ret;
}
function update_80() {
// Add a 'created' field to the users table:
update_sql('ALTER TABLE {users} ADD created INT(11) NOT NULL');
update_sql('ALTER TABLE {users} CHANGE timestamp changed INT(11) NOT NULL');
// Add some indices to speed up the update process:
update_sql('ALTER TABLE {comments} ADD index (timestamp)');
update_sql('ALTER TABLE {node} ADD index (created)');
// Assign everyone a created timestamp to begin with:
update_sql("UPDATE {users} SET created = changed WHERE created = ''");
// Print a status message:"
print '<p>Note: this might take a while ...</p>';
// Try updating the user records using the comment table:
$result = db_query('SELECT DISTINCT(u.uid) FROM {comments} c LEFT JOIN {users} u ON c.uid = u.uid WHERE c.timestamp < u.created');
while ($account = db_fetch_object($result)) {
// Retrieve the proper timestamp:
$timestamp = db_result(db_query('SELECT MIN(timestamp) FROM {comments} WHERE uid = %d', $account->uid));
// Update this user record as well as older records with an older timestamp:
db_query('UPDATE {users} SET created = %d WHERE created > %d AND uid <= %d', $timestamp, $timestamp, $account->uid);
}
// Try updating the user records using the node table:
$result = db_query('SELECT DISTINCT(u.uid) FROM {node} n LEFT JOIN {users} u ON n.uid = u.uid WHERE n.created < u.created');
while ($account = db_fetch_object($result)) {
// Retrieve the proper timestamp:
$timestamp = db_result(db_query('SELECT MIN(created) FROM {node} WHERE uid = %d', $account->uid));
// Update this user record as well as older records with an older timestamp:
db_query('UPDATE {users} SET created = %d WHERE created > %d AND uid <= %d', $timestamp, $timestamp, $account->uid);
}
// Add profile module related tables:
update_sql("CREATE TABLE {profile_fields} (
fid int(10) NOT NULL auto_increment,
title varchar(255) default NULL,
name varchar(128) default NULL,
explanation TEXT default NULL,
category varchar(255) default NULL,
type varchar(128) default NULL,
weight tinyint(1) DEFAULT '0' NOT NULL,
overview tinyint(1) DEFAULT '0' NOT NULL,
options text,
KEY category (category),
UNIQUE KEY name (name),
PRIMARY KEY (fid)
);");
update_sql("CREATE TABLE {profile_values} (
fid int(11) unsigned default '0',
uid int(11) unsigned default '0',
value text,
KEY uid (uid),
KEY fid (fid)
);");
// Migrate the old profile data to the new scheme:
$fields = array(
array("Name", "realname", "textfield", NULL, 0),
array("Address", "address", "textfield", NULL, 0),
array("City", "city", "textfield", NULL, 0),
array("State, province or region", "state", "textfield", NULL, 0),
array("Zip or postal code", "zip", "textfield", NULL, 0),
array("Country", "country", "textfield", NULL, 1),
array("Gender", "gender", "selection", "male\nfemale", 1),
array("Job title", "job", "textfield", NULL, 0),
array("ICQ messenger ID", "icq", "textfield", NULL, 0),
array("MSN messenger ID", "msn", "textfield", NULL, 0),
array("Yahoo messenger ID", "yahoo", "textfield", NULL, 0),
array("AIM messenger ID", "aim", "textfield", NULL, 0),
array("URL of homepage", "homepage", "textfield", NULL, 1),
array("Biography", "biography", "textarea", NULL, 0),
array("Interests", "interests", "textarea", NULL, 0),
array("Public key", "publickey", "textarea", NULL, 0)
);
// Remove existing data (debug mode):
db_query('DELETE FROM {profile_fields}');
db_query('DELETE FROM {profile_values}');
foreach ($fields as $field) {
db_query("INSERT INTO {profile_fields} (title, name, type, category, options, overview) VALUES ('%s', '%s', '%s', 'Personal information', '%s', %d)", $field[0], $field[1], $field[2], $field[3], $field[4]);
}
db_query("ALTER TABLE {users} ADD picture varchar(255) NOT NULL DEFAULT ''");
$result = db_query("SELECT uid FROM {users}");
while ($account = db_fetch_object($result)) {
// Load the user record:
$account = user_load(array('uid' => $account->uid));
$edit = array();
// Modify the user record:
foreach ($fields as $field) {
$old = "profile_". $field[1];
$new = $field[1];
if ($account->$old) {
$edit[$new] = $account->$old;
}
unset($account->$old);
}
// Gender specific changes:
if ($edit['gender'] == 'f') $edit['gender'] = 'female';
if ($edit['gender'] == 'm') $edit['gender'] = 'male';
// Avatar specific changes:
if ($account->profile_avatar) {
$edit['picture'] = $account->profile_avatar;
}
unset($account->profile_avatar);
// Save the update record:
user_save($account, $edit);
}
}
function update_sql($sql) {
$edit = $_POST["edit"];
$result = db_query($sql);
......
......@@ -56,6 +56,7 @@ li a.active {
padding: 0.25em 1em 0.25em 0em;
}
#pager {
clear: both;
text-align: center;
}
#pager div {
......@@ -156,6 +157,14 @@ li a.active {
.form-submit {
margin: 0.5em 0;
}
.profile {
clear: both;
margin: 1em 0em 1em 0em;
}
.profile .picture {
float: right;
margin: 0 1em 1em 0;
}
#aggregator .feed img {
float: right;
}
......
......@@ -37,12 +37,8 @@ function blog_access($op, $node) {
}
function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
if (user_access("maintain personal blog", $user)) {
return form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name)))));
}
if ($type == 'view' && user_access("maintain personal blog", $user)) {
return form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name)))));
}
}
......
......@@ -37,12 +37,8 @@ function blog_access($op, $node) {
}
function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
if (user_access("maintain personal blog", $user)) {
return form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name)))));
}
if ($type == 'view' && user_access("maintain personal blog", $user)) {
return form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name)))));
}
}
......
......@@ -138,16 +138,15 @@ function comment_settings() {
function comment_user($type, $edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
case "view":
if ($user->signature) {
return form_item(t("Signature"), check_output($user->signature));
}
break;
case "edit_form":
case "edit":
// when user tries to edit his own data
return array(t('Personal information') => form_textarea(t("Signature"), "signature", $user->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". filter_tips_short()));
case "edit_validate":
case "edit":
// validate user data editing
return array("signature" => $edit["signature"]);
}
......@@ -203,7 +202,7 @@ function comment_reply($pid, $nid) {
*/
if ($pid) {
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid));
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid));
$comment = drupal_unpack($comment);
$output .= theme("comment_view", $comment);
}
......@@ -258,7 +257,7 @@ function comment_preview($edit) {
$output .= theme("comment_form", $edit, t("Reply"));
if ($edit["pid"]) {
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"]));
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"]));
$comment = drupal_unpack($comment);
$output .= theme("comment_view", $comment);
}
......@@ -559,7 +558,7 @@ function comment_render($node, $cid = 0) {
$output .= "<form method=\"post\" action=\"". url("comment") ."\"><div>\n";
$output .= form_hidden("nid", $nid);
$result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users", $cid);
$result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users", $cid);
if ($comment = db_fetch_object($result)) {
$output .= theme("comment_view", $comment, theme('links', module_invoke_all('link', 'comment', $comment, 1)));
......@@ -576,9 +575,9 @@ function comment_render($node, $cid = 0) {
** Multiple comments view
*/
$query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = '". check_query($nid) ."' AND c.status = 0";
$query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = '". check_query($nid) ."' AND c.status = 0";
$query .= " GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users, c.thread";
$query .= " GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread";
/*
** We want to use the standard pager, but threads would need every
......
......@@ -138,16 +138,15 @@ function comment_settings() {
function comment_user($type, $edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
case "view":
if ($user->signature) {
return form_item(t("Signature"), check_output($user->signature));
}
break;
case "edit_form":
case "edit":
// when user tries to edit his own data
return array(t('Personal information') => form_textarea(t("Signature"), "signature", $user->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". filter_tips_short()));
case "edit_validate":
case "edit":
// validate user data editing
return array("signature" => $edit["signature"]);
}
......@@ -203,7 +202,7 @@ function comment_reply($pid, $nid) {
*/
if ($pid) {
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid));
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid));
$comment = drupal_unpack($comment);
$output .= theme("comment_view", $comment);
}
......@@ -258,7 +257,7 @@ function comment_preview($edit) {
$output .= theme("comment_form", $edit, t("Reply"));
if ($edit["pid"]) {
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"]));
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"]));
$comment = drupal_unpack($comment);
$output .= theme("comment_view", $comment);
}
......@@ -559,7 +558,7 @@ function comment_render($node, $cid = 0) {
$output .= "<form method=\"post\" action=\"". url("comment") ."\"><div>\n";
$output .= form_hidden("nid", $nid);
$result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users", $cid);
$result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users", $cid);
if ($comment = db_fetch_object($result)) {
$output .= theme("comment_view", $comment, theme('links', module_invoke_all('link', 'comment', $comment, 1)));
......@@ -576,9 +575,9 @@ function comment_render($node, $cid = 0) {
** Multiple comments view
*/
$query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = '". check_query($nid) ."' AND c.status = 0";
$query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = '". check_query($nid) ."' AND c.status = 0";
$query .= " GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users, c.thread";
$query .= " GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread";
/*
** We want to use the standard pager, but threads would need every
......
......@@ -185,22 +185,4 @@ function drupal_login($arguments) {
}
}
function drupal_user($type, $edit, $user) {
$module = "drupal";
$name = module_invoke($module, "info", "name");
switch ($type) {
case "view_private":
$result = user_get_authname($user, $module);
$title = t("%name ID", array("%name" => $name));
if ($result) {
return form_item($title, $result);
}
else {
// TODO: use a variation of $base_url instead of $HTTP_HOST below
return form_item($title, "$user->name@". $_SERVER["HTTP_HOST"]);
}
}
}
?>
......@@ -185,22 +185,4 @@ function drupal_login($arguments) {
}
}
function drupal_user($type, $edit, $user) {
$module = "drupal";
$name = module_invoke($module, "info", "name");
switch ($type) {
case "view_private":
$result = user_get_authname($user, $module);
$title = t("%name ID", array("%name" => $name));
if ($result) {
return form_item($title, $result);
}
else {
// TODO: use a variation of $base_url instead of $HTTP_HOST below
return form_item($title, "$user->name@". $_SERVER["HTTP_HOST"]);
}
}
}
?>
......@@ -74,7 +74,7 @@ function locale_link($type) {
function locale_user($type, &$edit, &$user) {
global $languages;
if ($type == "edit_form" && count($languages) > 1) {
if ($type == 'edit' && count($languages) > 1) {
return array(t('Locale settings') => form_radios(t("Language"), 'language', $user->language, $languages, t("Selecting a different language will change the language of the site.")));
}
}
......
......@@ -74,7 +74,7 @@ function locale_link($type) {
function locale_user($type, &$edit, &$user) {
global $languages;
if ($type == "edit_form" && count($languages) > 1) {
if ($type == 'edit' && count($languages) > 1) {
return array(t('Locale settings') => form_radios(t("Language"), 'language', $user->language, $languages, t("Selecting a different language will change the language of the site.")));
}
}
......
......@@ -340,7 +340,7 @@ function node_load($conditions, $revision = -1) {
** Retrieve the node:
*/
$node = db_fetch_object(db_query('SELECT n.*, u.uid, u.name, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE '. implode(' AND ', $cond)));
$node = db_fetch_object(db_query('SELECT n.*, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE '. implode(' AND ', $cond)));
$node = drupal_unpack($node);
/*
......
......@@ -340,7 +340,7 @@ function node_load($conditions, $revision = -1) {
** Retrieve the node:
*/
$node = db_fetch_object(db_query('SELECT n.*, u.uid, u.name, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE '. implode(' AND ', $cond)));
$node = db_fetch_object(db_query('SELECT n.*, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE '. implode(' AND ', $cond)));
$node = drupal_unpack($node);
/*
......
This diff is collapsed.
This diff is collapsed.
......@@ -77,7 +77,7 @@ function system_link($type) {
}
function system_user($type, $edit, &$user) {
if ($type == "edit_form") {
if ($type == 'edit') {
$options = "<option value=\"\">". t("Default theme") ."</option>\n";
if (count($themes = list_themes()) > 1) {
foreach ($themes as $key => $value) {
......
......@@ -77,7 +77,7 @@ function system_link($type) {
}
function system_user($type, $edit, &$user) {
if ($type == "edit_form") {
if ($type == 'edit') {
$options = "<option value=\"\">". t("Default theme") ."</option>\n";
if (count($themes = list_themes()) > 1) {
foreach ($themes as $key => $value) {
......
......@@ -79,12 +79,8 @@ function tracker_posts($id = 0) {
}
function tracker_user($type, &$edit, &$user) {
switch ($type) {
case "view_private":
case "view_public":
if (user_access("access content")) {
return form_item(t("Recent posts"), l(t("recent posts"), "tracker/$user->uid"));
}
if ($type == 'view' && user_access("access content")) {
return form_item(t("Recent posts"), l(t("recent posts"), "tracker/$user->uid"));
}
}
......
......@@ -79,12 +79,8 @@ function tracker_posts($id = 0) {
}
function tracker_user($type, &$edit, &$user) {
switch ($type) {
case "view_private":
case "view_public":
if (user_access("access content")) {
return form_item(t("Recent posts"), l(t("recent posts"), "tracker/$user->uid"));
}
if ($type == 'view' && user_access("access content")) {
return form_item(t("Recent posts"), l(t("recent posts"), "tracker/$user->uid"));
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -222,7 +222,7 @@ table {
font-size: 0.8em;
padding: 1.5em;
}
.node .avatar {
.node .picture {
border: 1px solid #ddd;
float: right;
margin: 0.5em;
......@@ -242,7 +242,7 @@ table {
float: right;
color: red;
}
.comment .avatar {
.comment .picture {
border: 1px solid #abc;
float: right;
margin: 0.5em;
......
......@@ -56,9 +56,9 @@
<!-- BEGIN: node -->
<div class="node {static}">
<!-- BEGIN: avatar -->
<div class="avatar">{avatar}</div>
<!-- END: avatar -->
<!-- BEGIN: picture -->
{picture}
<!-- END: picture -->
<!-- BEGIN: title -->
<h2 class="title"><a href="{link}">{title}</a></h2>
<!-- END: title -->
......@@ -75,9 +75,9 @@
<!-- BEGIN: comment -->
<div class="comment">
<!-- BEGIN: avatar -->
<div class="avatar">{avatar}</div>
<!-- END: avatar -->
<!-- BEGIN: picture -->
{picture}
<!-- END: picture -->
<h3 class="title">{title}</h3><!-- BEGIN: new --><span class="new">{new}</span><!-- END: new -->
<div class="submitted">{submitted}</div>
<div class="content">{content}</div>
......
......@@ -312,7 +312,7 @@ table#footer-links {
font-size: 0.83em;
padding: 1.5em;
}
.node .avatar {
.node .picture {
border: 1px solid #fff;
float: right;
margin: 0.5em;
......@@ -334,7 +334,7 @@ table#footer-links {
float: right;
color: red;
}
.comment .avatar {
.comment .picture {
border: 1px solid #fff;
float: right;
margin: 0.5em;
......
......@@ -59,9 +59,9 @@
<!-- BEGIN: node -->
<div class="node {static}">
<!-- BEGIN: avatar -->
<div class="avatar">{avatar}</div>
<!-- END: avatar -->
<!-- BEGIN: picture -->
{picture}
<!-- END: picture -->
<!-- BEGIN: title -->
<h1 class="title"><a href="{link}">{title}</a></h1>
<!-- END: title -->
......@@ -78,9 +78,9 @@
<!-- BEGIN: comment -->
<div class="comment">
<!-- BEGIN: avatar -->
<div class="avatar">{avatar}</div>
<!-- END: avatar -->
<!-- BEGIN: picture -->
<div class="picture">{picture}</div>
<!-- END: picture -->
<h3 class="title">{title}</h3><!-- BEGIN: new --><span class="new">{new}</span><!-- END: new -->
<div class="submitted">{submitted}</div>
<div class="content">{content}</div>
......
......@@ -32,7 +32,8 @@ function xtemplate_settings() {
$group .= form_radios(t('Search box'), 'xtemplate_search_box', variable_get('xtemplate_search_box', 0), array(t('Disabled'), t('Enabled')), t('Show a search box in the upper right corner.'));
$output .= form_group(t('Header settings'), $group);
$group = form_checkbox(t('Display avatars with posts'), 'xtemplate_avatar_node', 1, variable_get('xtemplate_avatar_node', 0), t('Display individualized pictures identifying users with posts they start.')) . form_checkbox(t('Display avatars with comments'), 'xtemplate_avatar_comment', 1, variable_get('xtemplate_avatar_comment', 0), t('Display individualized pictures identifying users with their comments.')) . form_textfield(t('Default avatar'), 'xtemplate_avatar_default', variable_get('xtemplate_avatar_default', ''), 70, 300, t('URL of avatar to display for users with no custom avatar selected. Leave blank for none.'));
$group = form_checkbox(t('Display pictures with posts'), 'xtemplate_picture_node', 1, variable_get('xtemplate_picture_node', 0), t('Display individualized pictures identifying users with posts they start.'));
$gourp .= form_checkbox(t('Display pictures with comments'), 'xtemplate_picture_comment', 1, variable_get('xtemplate_picture_comment', 0), t('Display individualized pictures identifying users with their comments.'));
$output .= form_group(t('Avatar settings'), $group);
return $output;
......@@ -69,22 +70,9 @@ function xtemplate_node($node, $main = 0, $page = 0) {
$xtemplate->template->parse("node.title");
}
if (module_exist("profile") && variable_get("xtemplate_avatar_node", 0)) {
$avatar = $node->profile_avatar;
if (empty($avatar) || !file_exists($avatar)) {
$avatar = variable_get("xtemplate_avatar_default", "");
}
else {
$avatar = file_create_url($avatar);
}
if ($avatar) {
$avatar = "<img src=\"$avatar\" alt=\"" . t("%user's avatar", array("%user" => $node->name ? $node->name : t(variable_get("anonymous", "Anonymous")))) . "\" />";
if ($node->uid) {
$avatar = l($avatar, "user/view/$node->uid", array("title" => t("View user profile.")));
}
$xtemplate->template->assign("avatar", $avatar);
$xtemplate->template->parse("node.avatar");
}
if ($picture = theme('user_picture', $node)) {
$xtemplate->template->assign("picture", $picture);
$xtemplate->template->parse("node.picture");
}
if (module_exist("taxonomy") && ($taxonomy = taxonomy_link("taxonomy terms", $node))) {
......@@ -121,22 +109,9 @@ function xtemplate_comment($comment, $links = 0) {
$xtemplate->template->parse("comment.new");
}