<?php
/**
 * <pre>
 * Invision Power Services
 * Database moderators skin file
 * Last Updated: $Date: 2009-08-23 21:54:28 -0400 (Sun, 23 Aug 2009) $
 * </pre>
 *
 * @author 		$Author: bfarber $
 * @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
 * @since		24th September 2009
 * @version		$Revision: 67 $
 */
 
class cp_skin_database_moderators extends output
{

/**
 * Prevent our main destructor being called by this class
 *
 * @access	public
 * @return	void
 */
public function __destruct()
{
}

/**
 * Add or edit a moderator
 *
 * @access	public
 * @param	string		add|edit
 * @param	array		Database data
 * @param	array 		Moderator data
 * @return	string		HTML
 */
public function moderatorForm( $type, $database, $moderator )
{
$IPBHTML = "";
//--starthtml--//

$types			= array( array( 'group', $this->lang->words['mod_type_group'] ), array( 'member', $this->lang->words['mod_type_member'] ) );
$groups			= array();

foreach( $this->caches['group_cache'] as $id => $data )
{
	$groups[]	= array( $id, $data['g_title'] );
}

$_type			= $this->registry->output->formDropdown( 'moderator_type', $types, $moderator['moderator_type'] );
$group			= $this->registry->output->formDropdown( 'moderator_group', $groups, $moderator['moderator_type'] == 'group' ? $moderator['moderator_type_id'] : 0 );
$username		= $this->registry->output->formInput( 'moderator_member', $moderator['moderator_member'] );

$add			= $this->registry->output->formYesNo( 'moderator_add_record', $moderator['moderator_add_record'] );
$edit			= $this->registry->output->formYesNo( 'moderator_edit_record', $moderator['moderator_edit_record'] );
$delete			= $this->registry->output->formYesNo( 'moderator_delete_record', $moderator['moderator_delete_record'] );
$deletec		= $this->registry->output->formYesNo( 'moderator_delete_comment', $moderator['moderator_delete_comment'] );
$lock			= $this->registry->output->formYesNo( 'moderator_lock_record', $moderator['moderator_lock_record'] );
$unlock			= $this->registry->output->formYesNo( 'moderator_unlock_record', $moderator['moderator_unlock_record'] );
$approve		= $this->registry->output->formYesNo( 'moderator_approve_record', $moderator['moderator_approve_record'] );
$approvec		= $this->registry->output->formYesNo( 'moderator_approve_comment', $moderator['moderator_approve_comment'] );
$pin			= $this->registry->output->formYesNo( 'moderator_pin_record', $moderator['moderator_pin_record'] );
	
$text			= $type == 'edit' ? $this->lang->words['editing_moderator'] : $this->lang->words['adding_moderator'];
$action			= $type == 'edit' ? 'doEdit' : 'doAdd';

$IPBHTML .= <<<HTML
<div class='section_title'>
	<h2>{$text}</h2>
	<ul class='context_menu'>
		<li>
			<a href='{$this->settings['base_url']}&amp;module=databases&amp;section=moderators&amp;id={$database['database_id']}' title='{$this->lang->words['cancel_edit_alt']}'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/delete.png' alt='{$this->lang->words['icon']}' />
				{$this->lang->words['button__cancel']}
			</a>
		</li>
	</ul>
</div>

<script type='text/javascript' src='{$this->settings['js_app_url']}acp.ccs.js'></script>

<form action='{$this->settings['base_url']}{$this->form_code}&amp;do={$action}' method='post' id='adminform' name='adform'>
<input type='hidden' name='moderator' value='{$moderator['moderator_id']}' />
<div class='acp-box'>
	<h2 class='tablesubheader' style='font-weight: bold;'>{$this->lang->words['moderator_perms_head']}</h2>
	<ul class='acp-form alternate_rows'>
		<li>
			<label>{$this->lang->words['modform__type']}</label>
			{$_type}
		</li>
		<li>
			<label>{$this->lang->words['modform__sel']}</label>
			{$this->lang->words['mod_sel_group']} {$group} {$this->lang->words['mod__or_user']} {$username}
		</li>
		<li>
			<label>{$this->lang->words['modform__add']}</label>
			{$add}
		</li>
		<li>
			<label>{$this->lang->words['modform__edit']}</label>
			{$edit}
		</li>
		<li>
			<label>{$this->lang->words['modform__delete']}</label>
			{$delete}
		</li>
		<li>
			<label>{$this->lang->words['modform__deletec']}</label>
			{$deletec}
		</li>
		<li>
			<label>{$this->lang->words['modform__lock']}</label>
			{$lock}
		</li>
		<li>
			<label>{$this->lang->words['modform__pin']}</label>
			{$pin}
		</li>
		<li>
			<label>{$this->lang->words['modform__unlock']}</label>
			{$unlock}
		</li>
		<li>
			<label>{$this->lang->words['modform__approve']}</label>
			{$approve}
		</li>
		<li>
			<label>{$this->lang->words['modform__approvec']}</label>
			{$approvec}
		</li>
	</ul>

	<div class="acp-actionbar">
		<input type='submit' value=' {$this->lang->words['button__save']} ' class="button primary" />
	</div>
</div>	
</form>
HTML;

//--endhtml--//
return $IPBHTML;
}

/**
 * Show the list of moderators within a database
 *
 * @access	public
 * @param	array 		Database
 * @param	array 		Moderators
 * @param	array 		Member data (for member moderators)
 * @return	string		HTML
 */
public function moderators( $database, $moderators, $members=array() )
{
$IPBHTML = "";
//--starthtml--//

$IPBHTML .= <<<HTML
<div class='section_title'>
	<h2>{$this->lang->words['dbmods_title']} {$database['database_name']}</h2>
	<ul class='context_menu'>
		<li>
			<a href='{$this->settings['base_url']}&amp;module=databases&amp;section=moderators&amp;do=add&amp;id={$database['database_id']}' title='{$this->lang->words['add_mod_alt']}'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='{$this->lang->words['icon']}' />
				{$this->lang->words['add_mod_button']}
			</a>
		</li>
	</ul>
</div>

<script type='text/javascript' src='{$this->settings['js_app_url']}acp.ccs.js'></script>

<div class='acp-box adv_controls'>
	<h3>{$this->lang->words['all_moderators_t']}</h3>
	<ul class='alternate_rows'>
		<li>
			<table style='width:100%;'>
				<tr>
					<th style='width: 24%'>{$this->lang->words['moderator_th']}</th>
					<th style='width: 8%'>{$this->lang->words['moderator_col_add']}</th>
					<th style='width: 8%'>{$this->lang->words['mod_edit_th']}</th>
					<th style='width: 8%'>{$this->lang->words['mod_del_th']}</th>
					<th style='width: 8%'>{$this->lang->words['mod_del_c_th']}</th>
					<th style='width: 8%'>{$this->lang->words['mod_lock_th']}</th>
					<th style='width: 8%'>{$this->lang->words['mod_pin_th']}</th>
					<th style='width: 8%'>{$this->lang->words['mod_unlock_th']}</th>
					<th style='width: 8%'>{$this->lang->words['mod_approve_th']}</th>
					<th style='width: 8%'>{$this->lang->words['mod_approvec_th']}</th>
					<th style='width: 4%'>&nbsp;</th>
				</tr>
			</table>
		</li>
HTML;

if( !count( $moderators ) )
{
	$IPBHTML .= <<<HTML
		<li>
			<table style='width:100%;'>
				<tr>
					<td style='width:100%;'>
						<div style='padding: 20px; text-align: center'>
							<em>{$this->lang->words['no_mods_created_yet']} <a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add'>{$this->lang->words['create_moderator_now']}</a></em>
						</div>
					</td>
				</tr>
			</table>
		</li>
HTML;
}
else
{
	foreach( $moderators as $moderator )
	{
		$_add		= $moderator['moderator_add_record'] ? 'tick.png' : 'cross.png';
		$_edit		= $moderator['moderator_edit_record'] ? 'tick.png' : 'cross.png';
		$_delete	= $moderator['moderator_delete_record'] ? 'tick.png' : 'cross.png';
		$_deleteC	= $moderator['moderator_delete_comment'] ? 'tick.png' : 'cross.png';
		$_lock		= $moderator['moderator_lock_record'] ? 'tick.png' : 'cross.png';
		$_pin		= $moderator['moderator_pin_record'] ? 'tick.png' : 'cross.png';
		$_unlock	= $moderator['moderator_unlock_record'] ? 'tick.png' : 'cross.png';
		$_approve	= $moderator['moderator_approve_record'] ? 'tick.png' : 'cross.png';
		$_approvec	= $moderator['moderator_approve_comment'] ? 'tick.png' : 'cross.png';

		if( $moderator['moderator_type'] == 'group' )
		{
			$name	= $this->lang->words['mod_g_prefix'] . $this->caches['group_cache'][ $moderator['moderator_type_id'] ]['g_title'];
		}
		else
		{
			$name	= "<a href='{$this->settings['board_url']}/index.php?showuser={$moderator['moderator_type_id']}' target='_blank'>{$members[ $moderator['moderator_type_id'] ]['members_display_name']}</a>";
		}
		
		$IPBHTML .= <<<HTML
		<li class='control_row'>
			<table style='width:100%;'>
				<tr>
					<td style='width: 24%'><strong>{$name}</strong></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_add}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_edit}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_delete}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_deleteC}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_lock}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_pin}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_unlock}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_approve}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 8%'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/{$_approvec}' alt='{$this->lang->words['icon']}' /></td>
					<td style='width: 4%'>
						<ul class='controls no_extra'>
							<li class='left'>
								<a class='edit' href='{$this->settings['base_url']}&amp;module=databases&amp;section=moderators&amp;do=edit&amp;id={$database['database_id']}&amp;moderator={$moderator['moderator_id']}'>{$this->lang->words['edit_moderator_menu']}</a>
							</li>
							<li class='right ipbmenu' id='menu_page_root'>
								<a class='delete' href='#' onclick="return acp.confirmDelete( '{$this->settings['base_url']}&amp;module=databases&amp;section=moderators&amp;do=delete&amp;id={$database['database_id']}&amp;moderator={$moderator['moderator_id']}' );">{$this->lang->words['delete_moderator_menu']}</a>
							</li>
						</ul>
					</td>
				</tr>
			</table>
		</li>
HTML;
	}
}

$IPBHTML .= <<<HTML
	</ul>
</div>
HTML;
//--endhtml--//
return $IPBHTML;
}

}