'. t('This module allows bloggers to have a title and description for their blog that is seperate from their username. This is similar to the title and descriptioin of blogs such as those at blogspot.com provided by blogger.') .'

'; $output .= '

'. t('The title and description is displayed in a block and is editable in a users \'my account\' options.') .'

'; return $output; } } // hook_perm function bloginfo_perm() { return array('administer bloginfo', 'edit own bloginfo'); } /** * Implementation of hook_user(). */ function bloginfo_user($op, &$edit, &$account, $category = NULL) { switch ($op) { case 'update': case 'insert': return bloginfo_save_bloginfo($edit, $account, $category); case 'form': return bloginfo_form_bloginfo($edit, $account, $category); case 'delete': db_query('DELETE FROM {bloginfo} WHERE uid = %d', $account->uid); } } /** * Implementation of hook_block(). */ function bloginfo_block($op = 'list', $delta = 0) { if ($op == 'list') { $blocks['bloginfo']['info'] = t('Blog information'); $blocks['blogroll']['info'] = t('Blogroll by blog title'); return $blocks; } else if ($op == 'view') { 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; } } } /** * Theme Function: Theme bloginfo block content */ function theme_bloginfo_block($description, $format, $author) { return check_markup($description, $format, FALSE); } /** * Helper function: create the form on the user settings page */ function bloginfo_form_bloginfo($edit, $account, $category) { if ($category == 'account' && is_numeric(arg(1)) && (user_access('edit own bloginfo') || user_access('administer bloginfo'))) { $result = db_query('SELECT title, description, format FROM {bloginfo} WHERE uid = %d', arg(1)); while ($bloginfo = db_fetch_object($result)) { $mybloginfo['title'] = $bloginfo->title; $mybloginfo['description'] = $bloginfo->description; $mybloginfo['format'] = $bloginfo->format; } $fields['bloginfo_settings'] = array( '#type' => 'fieldset', '#title' => t('Blog Information'), '#weight' => 5); $fields['bloginfo_settings']['Title'] = array( '#type' => 'textfield', '#title' => t('Blog Title'), '#maxlength' => 128, '#default_value' => $mybloginfo['title'], '#description' => t('Your blog title will display on your blog and blog posts.')); $fields['bloginfo_settings']['Description'] = array( '#type' => 'textarea', '#title' => t('Blog Description'), '#default_value' => $mybloginfo['description'], '#description' => t('Your blog description will display on your blog and blog posts.')); $fields['bloginfo_settings']['desc_format'] = filter_form($mybloginfo['format']); return $fields; }//end if }//end function bloginfo_form_bloginfo() /** * Helper function: insert bloginfo into the database */ 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)); } //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']); } } } } /** * Token Functions */ function bloginfo_token_values($type, $object = NULL, $options = array()) { if ($type == 'user') { $user = $object; $results = db_query("SELECT title, description, format FROM {bloginfo} WHERE uid = %d", $user->uid); $bloginfo = db_fetch_object($results); $tokens['blog-title'] = t($bloginfo->title); } else if ($type == 'node') { $node = $object; $results = db_query("SELECT title, description, format FROM {bloginfo} WHERE uid = %d", $node->uid); $bloginfo = db_fetch_object($results); $tokens['blog-title'] = t($bloginfo->title); } return $tokens; } function bloginfo_token_list($type = 'all') { if ($type == 'user' || $type == 'all') { $tokens['user']['blog-title'] = 'Blog Title from bloginfo module.'; } if ($type == 'node' || $type == 'all') { $tokens['node']['blog-title'] = 'Blog Title from bloginfo module.'; } return $tokens; }