Commit f7904bb2 authored by mfer's avatar mfer
parent e341a769
<?php
// $Id$
/* Installing bloginfo */
function bloginfo_install() {
......@@ -28,7 +29,8 @@ function bloginfo_install() {
if ($ins) {
drupal_set_message(t('Bloginfo module installed succesfully.'));
} else {
}
else {
drupal_set_message(t('Bloginfo module installation was unsuccesfull. The necessary database table may be created by hand. See the "README.txt" file in the "bloginfo/" modules directory for instructions.', 'error'));
}
return $ins;
......@@ -41,7 +43,7 @@ function bloginfo_uninstall() {
db_query('DROP TABLE {bloginfo}');
}
function bloginfo_update_1(){
function bloginfo_update_1() {
$items = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
......@@ -67,5 +69,4 @@ function bloginfo_update_2() {
break;
}
return $items;
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
function bloginfo_help($section) {
switch ($section) {
case 'admin/help#bloginfo':
$output = '<p>'. 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.'). '</p>';
$output = '<p>'. 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.') .'</p>';
$output .= '<p>'. t('The title and description is displayed in a block and is editable in a users \'my account\' options.') .'</p>';
return $output;
}
......@@ -36,25 +36,25 @@ function bloginfo_user($op, &$edit, &$account, $category = NULL) {
* Implementation of hook_block().
*/
function bloginfo_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Blog information');
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;
}
}
}
if ($op == 'list') {
$blocks[0]['info'] = t('Blog information');
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;
}
}
}
}
/**
......@@ -68,52 +68,50 @@ function theme_bloginfo_block($description, $format, $author) {
* 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
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));
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 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']);
}
//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