Version 2.2.0 RC-1
This commit is contained in:
1 parent
f73f8bff6d
commit
22f1b963ee
1034 files changed
+178610
-70897
No files matched your search
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2006 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
| > $Date: 2006-06-26 22:03:22 -0400 (Wed, 26 July 2006) $
|
||||
| > $Revision: 1 $
|
||||
| > $Author: w1lz0r $
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > API: Blog
|
||||
| > Module written by Remco Wilting
|
||||
| > Date started: Wednesday July 26th 2006 (21:22)
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* API: Blog
|
||||
*
|
||||
* EXAMPLE USAGE
|
||||
* <code>
|
||||
* $api = new api_blog();
|
||||
* # Optional - if $ipsclass is not passed, it'll init
|
||||
* $api->ipsclass =& $this->ipsclass;
|
||||
* $api->api_init();
|
||||
* $api->get_blog_id( $member_id );
|
||||
* $api->last_x_entries( $blog_id, $number_of_entries );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @package InvisionPowerBoard
|
||||
* @subpackage APIs
|
||||
* @author Matt Mecham
|
||||
* @copyright Invision Power Services, Inc.
|
||||
* @version 2.1
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IPS_API_PATH' ) )
|
||||
{
|
||||
/**
|
||||
* Define classes path
|
||||
*/
|
||||
define( 'IPS_API_PATH', dirname(__FILE__) ? dirname(__FILE__) : '.' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'BLOG_PATH' ) )
|
||||
{
|
||||
define( 'BLOG_PATH', ROOT_PATH.'modules/blog/' );
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'api_core' ) )
|
||||
{
|
||||
require_once( IPS_API_PATH.'/api_core.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* API: Blog
|
||||
*
|
||||
* This class deals with settings insertion functions
|
||||
*
|
||||
* @package InvisionPowerBoard
|
||||
* @subpackage APIs
|
||||
* @author Brandon Farber
|
||||
* @version 2.2
|
||||
* @since 2.2.0
|
||||
*/
|
||||
class api_blog extends api_core
|
||||
{
|
||||
/**
|
||||
* IPS Class Object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
var $blog_std;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Retrieve the Blog ID of a member
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Retrieve the Blog ID of a member
|
||||
*
|
||||
* @param int Member ID
|
||||
* @return int Blog ID ( 0 if no Blog found )
|
||||
*/
|
||||
function get_blog_id( $member_id=0 )
|
||||
{
|
||||
$member_id = intval( $member_id );
|
||||
|
||||
//-----------------------------------------
|
||||
// We entered here on member id, find blog_id and redirect them to here
|
||||
//-----------------------------------------
|
||||
$blog = $this->ipsclass->DB->build_and_exec_query( array ( 'select' => 'blog_id, blog_name, blog_friendly_url',
|
||||
'from' => 'blog_blogs',
|
||||
'where' => "member_id={$member_id}" ) );
|
||||
if ( !$blog['blog_id'] or !$blog['blog_name'] )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $blog['blog_id'];
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Retrieve the last x entries of a Blog
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Retrieve the last x entries of a Blog
|
||||
* Only public publishes entries are returned
|
||||
*
|
||||
* @param int Blog ID
|
||||
* @param int Number of entries (to return)
|
||||
* @return array Array of last X entries
|
||||
*/
|
||||
|
||||
function last_x_entries( $blog_id, $number_of_entries=10 )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Load the Blog functions library
|
||||
//-----------------------------------------
|
||||
require_once ( BLOG_PATH.'lib/lib_blogfunctions.php' );
|
||||
$this->blog_std = new blog_functions;
|
||||
$this->blog_std->ipsclass = & $this->ipsclass;
|
||||
|
||||
//-----------------------------------------
|
||||
// Build the permissions
|
||||
//-----------------------------------------
|
||||
$this->blog_std->build_perms();
|
||||
|
||||
if ( $this->ipsclass->check_perms($this->ipsclass->vars['blog_view_perms']) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Private Club Authed?
|
||||
//-----------------------------------------
|
||||
$extra = "";
|
||||
$allowguests = "";
|
||||
if ( !$this->ipsclass->member['id'] )
|
||||
{
|
||||
$allowguests .= " AND b.blog_allowguests = 1";
|
||||
}
|
||||
if ( !$this->ipsclass->member['_blogmod']['moderate_can_view_private'] )
|
||||
{
|
||||
$levelwhere = array( '(bc.blog_id IS NULL)' );
|
||||
if ( $this->ipsclass->member['_cache']['my_blog'] )
|
||||
{
|
||||
$levelwhere[] = "(b.blog_id = {$this->ipsclass->member['_cache']['my_blog']})";
|
||||
}
|
||||
if ( $this->ipsclass->member['_cache']['my_blog'] )
|
||||
{
|
||||
$levelwhere[] = "(bc.category_type = 'private' AND bc.blog_id={$this->ipsclass->member['_cache']['my_blog']})";
|
||||
}
|
||||
if ( is_array($this->ipsclass->member['g_blog_authed_blogs']) && count($this->ipsclass->member['g_blog_authed_blogs'])>1 )
|
||||
{
|
||||
$authblogs = implode(",", $this->ipsclass->member['g_blog_authed_blogs']);
|
||||
$levelwhere[] = "(bc.category_type = 'privateclub' AND bc.blog_id in(".$authblogs."))";
|
||||
$levelwhere[] = "(bc.category_type = 'public')";
|
||||
}
|
||||
else
|
||||
{
|
||||
$authblogs = "";
|
||||
$levelwhere[] = "(bc.category_type = 'public')";
|
||||
}
|
||||
$extra = "b.blog_private=0";
|
||||
if ($authblogs)
|
||||
{
|
||||
$extra = "(".$extra." or b.blog_id in(".$authblogs.($this->ipsclass->member['_cache']['my_blog']?",".$this->ipsclass->member['_cache']['my_blog']:"")."))";
|
||||
}
|
||||
elseif ( $this->ipsclass->member['_cache']['my_blog'] )
|
||||
{
|
||||
$extra = "(".$extra." or b.blog_id = {$this->ipsclass->member['_cache']['my_blog']})";
|
||||
}
|
||||
$extra = " AND ".$extra;
|
||||
$leveljoin = " AND (".implode( " or ", $levelwhere ).")";
|
||||
}
|
||||
|
||||
$this->ipsclass->DB->build_query( array( 'select' => "e.*",
|
||||
'from' => array('blog_entries' => 'e'),
|
||||
'add_join'=> array( 0 => array( 'select' => 'b.blog_name, b.blog_friendly_url',
|
||||
'from' => array( 'blog_blogs' => 'b' ),
|
||||
'where' => "e.blog_id=b.blog_id",
|
||||
'type' => 'left'
|
||||
),
|
||||
1 => array( 'from' => array( 'blog_categories' => 'bc' ),
|
||||
'where' => "e.blog_id=bc.blog_id and e.category_id=bc.category_id",
|
||||
'type' => 'left'
|
||||
) ),
|
||||
'where' => "b.blog_id = ".intval($blog_id)." AND e.entry_status='published' ".$allowguests.$extra.$leveljoin,
|
||||
'order' => 'e.entry_date DESC',
|
||||
'limit' => array(0, intval($number_of_entries) )
|
||||
) );
|
||||
$this->ipsclass->DB->exec_query();
|
||||
|
||||
$return_array = array();
|
||||
while ( $entry = $this->ipsclass->DB->fetch_row() )
|
||||
{
|
||||
$entry['blog_url'] = $this->blog_std->get_blog_url( $entry['blog_id'], $entry['blog_friendly_url'] );
|
||||
$entry['entry_url'] = $entry['blog_url'].'eid='.$entry['entry_id'];
|
||||
$return_array[] = $entry;
|
||||
}
|
||||
return $return_array;
|
||||
}
|
||||
else
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user