Source for file _class_blog.php
Documentation is available at _class_blog.php
* This file implements the blog object
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
require_once dirname(__FILE__
).
'/_class_dataobject.php';
* Blog object with params
* Short name for use in navigation menus
* Tagline to be displayed on template
* {@internal Blog::Blog(-) }}
function Blog( $db_row =
NULL )
// Call parent constructor:
parent::DataObject( $tableblogs, 'blog_', 'blog_ID' );
// echo 'Creating blank blog';
$this->name =
T_('New weblog');
$this->locale =
$default_locale;
$this->ID =
$db_row->blog_ID;
$this->name =
$db_row->blog_name;
$this->tagline =
$db_row->blog_tagline;
$this->shortdesc =
$db_row->blog_description; // description
$this->longdesc =
$db_row->blog_longdesc;
$this->locale =
$db_row->blog_locale;
$this->siteurl =
$db_row->blog_siteurl;
$this->stub =
$db_row->blog_stub;
$this->notes =
$db_row->blog_notes;
$this->keywords =
$db_row->blog_keywords;
$this->UID =
$db_row->blog_UID;
* {@internal Blog::set(-) }}
* @param string Parameter name
* @return mixed Parameter value
function set( $parname, $parvalue )
parent::set_param( $parname, 'number', $parvalue );
if( $parvalue ==
'default' )
$Settings->set('default_blog_ID', $this->ID);
parent::set_param( $parname, 'string', $parvalue );
* {@internal Blog::gen_blogurl(-)}}
* @param string default|dynamic|static
* @param boolean should this be an absolute URL? (otherwise: relative to $baseurl)
function gen_blogurl( $type =
'default', $absolute =
true )
global $baseurl, $basepath, $Settings;
$base =
$absolute ?
$baseurl :
'';
{ // We want the static page, there is no acces type option here:
{ // If static page exists:
// Access through index.php as default blog
if( $Settings->get('default_blog_ID') ==
$this->ID )
{ // Safety check! We only do that kind of linking if this is really the default blog...
return $base.
$this->siteurl.
'/index.php';
// ... otherwise, we add the blog ID:
// Access through index.php + blog qualifier
if( $Settings->get('links_extrapath') )
return $base.
$this->siteurl.
'/index.php?blog='.
$this->ID;
// Access through stub file
if( ($type ==
'dynamic') &&
!( preg_match( '#.php$#', $blogurl ) ) )
{ // We want to force the dynamic page but the URL is not explicitely dynamic
die( 'Unhandled Blog access type ['.
$this->access_type.
']' );
* {@internal Blog::get(-)}}
global $xmlsrv_url, $admin_email, $baseurl, $basepath;
case 'link':
// RSS wording
return $baseurl.
$this->siteurl.
'/';
return ''; // Deprecated!
case 'description':
// RSS wording
return $xmlsrv_url.
'/rdf.php?blog='.
$this->ID;
return $xmlsrv_url.
'/rss.php?blog='.
$this->ID;
return $xmlsrv_url.
'/rss2.php?blog='.
$this->ID;
return $xmlsrv_url.
'/atom.php?blog='.
$this->ID;
return $xmlsrv_url.
'/rdf.comments.php?blog='.
$this->ID;
return $xmlsrv_url.
'/rss.comments.php?blog='.
$this->ID;
case 'comments_rss2_url':
return $xmlsrv_url.
'/rss2.comments.php?blog='.
$this->ID;
case 'comments_atom_url':
return $xmlsrv_url.
'/atom.comments.php?blog='.
$this->ID;
return $xmlsrv_url.
'/xmlrpc.php';
return parent::get( $parname );
* Delete a blog and dependencies from database
* Includes WAY TOO MANY requests because we try to be compatible with mySQL 3.23, bleh!
* {@internal Blog::dbdelete(-) }}
* @param boolean true if you want to try to delete the stub file
* @param boolean true if you want to try to delete the static file
* @param boolean true if you want to echo progress
function dbdelete( $delete_stub_file =
false, $delete_static_file =
false, $echo =
false )
global $DB, $tablehitlog, $tablecategories, $tablecomments, $tableposts,
$tablepostcats, $tableblogusers, $cache_blogs;
// Note: No need to localize the status messages...
if( $echo ) echo
'<p>mySQL 3.23 compatibility mode!';
// Get list of cats that are going to be deleted (3.23)
if( $echo ) echo
'<br />Getting category list to delete... ';
$cat_list =
$DB->get_list( "SELECT cat_ID
WHERE cat_blog_ID = $this->ID" );
{ // There are no cats to delete
{ // Delete the cats & dependencies
// Get list of posts that are going to be deleted (3.23)
if( $echo ) echo
'<br />Getting post list to delete... ';
$post_list =
$DB->get_list( "SELECT postcat_post_ID
WHERE postcat_cat_ID IN ($cat_list)" );
if( empty( $post_list ) )
{ // There are no posts to delete
{ // Delete the posts & dependencies
if( $echo ) echo
'<br />Deleting post-categories... ';
$ret =
$DB->query( "DELETE FROM $tablepostcats
WHERE postcat_cat_ID IN ($cat_list)" );
if( $echo ) printf( '(%d rows)', $ret );
if( $echo ) echo
'<br />Deleting comments on blog\'s posts... ';
$ret =
$DB->query( "DELETE FROM $tablecomments
WHERE comment_post_ID IN ($post_list)" );
if( $echo ) printf( '(%d rows)', $ret );
if( $echo ) echo
'<br />Deleting blog\'s posts... ';
$ret =
$DB->query( "DELETE FROM $tableposts
WHERE ID IN ($post_list)" );
if( $echo ) printf( '(%d rows)', $ret );
if( $echo ) echo
'<br />Deleting blog\'s categories... ';
$ret =
$DB->query( "DELETE FROM $tablecategories
WHERE cat_blog_ID = $this->ID" );
if( $echo ) printf( '(%d rows)', $ret );
if( $echo ) echo
'<br />Deleting user-blog permissions... ';
$ret =
$DB->query( "DELETE FROM $tableblogusers
WHERE bloguser_blog_ID = $this->ID" );
if( $echo ) printf( '(%d rows)', $ret );
if( $echo ) echo
'<br />Deleting blog hitlogs... ';
$ret =
$DB->query( "DELETE FROM $tablehitlog
WHERE hit_blog_ID = $this->ID" );
if( $echo ) printf( '(%d rows)', $ret );
if( $echo ) echo
'<br />Trying to delete stub file... ';
echo
'<span class="error">';
printf( T_('ERROR! Could not delete! You will have to delete the file [%s] by hand.'),
$this->get('dynfilepath') );
if( $delete_static_file )
if( $echo ) echo
'<br />Trying to delete static file... ';
if( ! @unlink( $this->get('staticfilepath') ) )
echo
'<span class="error">';
printf( T_('ERROR! Could not delete! You will have to delete the file [%s] by hand.'),
$this->get('staticfilepath') );
unset
( $cache_blogs[$this->ID] );
// Delete main (blog) object: