Commit 747ee867 authored by Joakim Schramm's avatar Joakim Schramm

Bringing HEAD up in line with top of DRUPAL-5 branch, bringing forward the...

Bringing HEAD up in line with top of DRUPAL-5 branch, bringing forward the latest changes done by [mfer]
parent e5abc66d
......@@ -28,7 +28,7 @@ function bloginfo_user($op, &$edit, &$account, $category = NULL) {
case 'form':
return bloginfo_form_bloginfo($edit, $account, $category);
case 'delete':
db_query('DELETE FROM {bloginfo} WHERE uid = %d', $user->uid);
db_query('DELETE FROM {bloginfo} WHERE uid = %d', $account->uid);
}
}
......@@ -37,23 +37,37 @@ function bloginfo_user($op, &$edit, &$account, $category = NULL) {
*/
function bloginfo_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Blog information');
$blocks['bloginfo']['info'] = t('Blog information');
$blocks['blogroll']['info'] = t('Blogroll by blog title');
return $blocks;
}
else if ($op == 'view') {
if (arg(0) == 'node' && is_numeric(arg(1))) $node = node_load(arg(1));
if (((arg(0) == 'blog' && is_numeric(arg(1))) || $node->type == 'blog')) {
if (arg(0) == 'blog') $authorid = arg(1);
else if ($node->type == 'blog') $authorid = $node->uid;
$count = db_result(db_query("SELECT COUNT(*) FROM {bloginfo} WHERE uid = %d", $authorid));
if ($count == 1) {
$results = db_query("SELECT title, description, format FROM {bloginfo} WHERE uid = %d", $authorid);
$bloginfo = db_fetch_object($results);
$block['subject'] = check_plain($bloginfo->title);
$block['content'] = theme('bloginfo_block', $bloginfo->description, $bloginfo->format, $authorid);
return $block;
switch($delta) {
case 'bloginfo':
if (arg(0) == 'node' && is_numeric(arg(1))) $node = node_load(arg(1));
if (((arg(0) == 'blog' && is_numeric(arg(1))) || $node->type == 'blog')) {
if (arg(0) == 'blog') $authorid = arg(1);
else if ($node->type == 'blog') $authorid = $node->uid;
$count = db_result(db_query("SELECT COUNT(*) FROM {bloginfo} WHERE uid = %d", $authorid));
if ($count == 1) {
$results = db_query("SELECT title, description, format FROM {bloginfo} WHERE uid = %d", $authorid);
$bloginfo = db_fetch_object($results);
$block['subject'] = check_plain($bloginfo->title);
$block['content'] = theme('bloginfo_block', $bloginfo->description, $bloginfo->format, $authorid);
return $block;
}
}
}
break;
case 'blogroll':
$results = db_query("SELECT uid, title FROM {bloginfo} WHERE title <> '' ORDER BY title ASC");
while ($item = db_fetch_array($results)) {
$output[] = l($item['title'], 'blog/'. $item['uid']);
}
$block['subject'] = t('Blog Listing');
$block['content'] = theme('item_list', $output);
return $block;
break;
}
}
}
......@@ -102,12 +116,12 @@ function bloginfo_save_bloginfo(&$edit, &$user, $category) {
if ($category == 'account') {
if ( arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0 && arg(2) == 'edit') {
$results = db_query('SELECT uid FROM {bloginfo} WHERE uid = %d', arg(1));
//This is to update where info already exists in the database
if (db_num_rows($results) == 1) {
db_query("UPDATE {bloginfo} SET title = '%s', description = '%s', format = %d WHERE uid = %d", $edit['Title'], $edit['Description'], $edit['format'], arg(1));
db_query("UPDATE {bloginfo} SET title = '%s', description = '%s', format = %d WHERE uid = %d", $edit['Title'], $edit['Description'], $edit['format'], arg(1));
}
//This adds it to the database for the first time
else {
db_query("INSERT INTO {bloginfo} (uid, title, description, format) VALUES (%d, '%s', '%s', %d)", arg(1), $edit['Title'], $edit['Description'], $edit['format']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment