<?php

/**
 * <pre>
 * Invision Power Services
 * IP.Board vVERSION_NUMBER
 * Reputation configuration for application
 * Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
 * </pre>
 *
 * @author 		$author$
 * @copyright	(c) 2001 - 2009 Invision Power Services, Inc.
 * @license		http://www.invisionpower.com/community/board/license.html
 * @package		IP.Content
 * @link		http://www.invisionpower.com
 * @version		$Rev: 5713 $ 
 **/

if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
	exit();
}

$rep_author_config = array( 
						'comment_id'	=> array( 'column' => 'comment_user', 'table'  => 'ccs_database_comments' ),
						'record_id'		=> array( 'column' => 'member_id', 'table'  => 'ccs_database_comments', 'misc' => true ),
					);
					
/*
 * The following config items are for the log viewer in the ACP 
 */
if( IN_ACP )
{
	$rep_log_joins = array(
						'comment_id' => array(
											array(
													'select'	=> "p.*, p.comment_record_id as repContentID",
													'from'		=> array( 'ccs_database_comments' => 'p' ),
													'where'		=> 'r.type="comment_id" AND r.type_id=p.comment_id AND r.app="ccs"',
													'type'		=> 'left'
												),
											),
						'record_id' => "getRecordRepLogJoin",
						);
	
	//-----------------------------------------
	// Get the join for record id request
	//-----------------------------------------
	
	function getRecordRepLogJoin()
	{
		return array(array());
	}
	
	
	$rep_log_where			= array( 
									'comment_id'	=> "p.comment_user=%s",
									'record_id'		=> "r.member_id=%s",
									);
	
	//-----------------------------------------
	// Define callbacks...
	//-----------------------------------------
	
	$rep_log_link_callback	= "getCcsRepLogLink";
	$rep_log_title_callback	= "getCcsRepLogTitle";
	
	//-----------------------------------------
	// Callback to get title
	//-----------------------------------------

	function getCcsRepLogTitle( $r )
	{
		$registry	= ipsRegistry::instance();
		$caches		= $registry->cache()->getCache('ccs_databases');
		$database	= $caches[ $r['comment_database_id'] ];
		$field		= $database['database_field_title'];

		//-----------------------------------------
		// Yes this is a query inside a loop...
		// only accessed via rep logs in ACP though
		//-----------------------------------------
		
		$record		= $registry->DB()->buildAndFetch( array( 'select' => $field, 'from' => $database['database_database'], 'where' => 'primary_id_field=' . $r['comment_record_id'] ) );

		//-----------------------------------------
		// Supposed to "format" the title, but that
		// could get kind of intensive...
		//-----------------------------------------
		
		return IPSText::truncate( $record[ $field ], 64 );
	}
	
	//-----------------------------------------
	// Callback to get link
	//-----------------------------------------
	
	function getCcsRepLogLink( $r )
	{
		return ipsRegistry::$settings['board_url'] . "/index.php?app=ccs&amp;module=pages&amp;section=pages&amp;do=redirect&amp;database={$r['comment_database_id']}&amp;record={$r['comment_record_id']}&amp;comment={$r['comment_id']}";
	}
}