function admin_index($id = null) {
+ unset($this->Character->belongsTo['System']['conditions']['System.public_flag']);
$this->_index($id, array('isAdmin' => true));
}
function admin_view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Character.', true));
- $this->redirect(array('action'=>'admin_index'));
+ $this->redirect(array('action' => 'admin_index'));
}
$conditions = array(
/* 共通化アクションメソッド */
function _index($id, $conditions = array(), $limit = 20, $fields = array(), $contain = array(), $order = array(), $page = 1) {
- $contain = array_merge(array('System'), (array)$contain);
+ if (isset($conditions['isAdmin']) && $conditions['isAdmin'] === true) {
+ $isAdmin = true;
+ } else {
+ $isAdmin = false;
+ }
+ unset($conditions['isAdmin']);
+
+ // System指定分岐
+ if (isset($this->params['named']['system']) && intval($this->params['named']['system'])) {
+ //情報取得
+ $conditions['System.id'] = $this->params['named']['system'];
+ if ($isAdmin !== true) {
+ $conditions['System.public_flag'] = 'public';
+ }
+
+ $this_system = $this->Character->System->find('first', array(
+ 'conditions' => $conditions,
+ 'recursive' => -1,
+ ));
+
+ if (!isset($this_system['System'])) {
+ $this->Session->setFlash(__('Invalid System.', true));
+ $this->redirect(array('controller' => 'systems', 'action' => 'index'));
+ }
+
+ $this->set('this_system', $this_system);
+ } else {
+ $contain = array_merge(array('System'), (array)$contain);
+ }
$isOwner = false;
$user = array();
+ $conditions = array('User.id' => $id);
if (!empty($id)) {
$user = $this->Character->User->find('first', array(
- 'conditions' => array('User.id' => $id),
+ 'conditions' => $conditions,
'recursive' => -1,
'fields' => array(
'User.id',
}
}
+ $conditions = array();
+ if (!empty($id)) {
+ $conditions['Character.user_id'] = $id;
+ }
+ if (isset($this->params['named']['system']) && intval($this->params['named']['system'])) {
+ $conditions['Character.system_id'] = $this->params['named']['system'];
+ }
$characters = $this->HtmlEscape->nl_unescape($this->_get_characters_page4user_id($id, $conditions, $limit, $fields, $contain, $order, $page));
$this->set('characters', $characters);
'System' => array(
'className' => 'System',
'foreignKey' => 'system_id',
- 'conditions' => '',
+ 'conditions' => array(
+ 'System.public_flag' => 'public',
+ ),
'fields' => array('id', 'name'),
),
'User' => array(
<div class="characters index">
-<h2><?php if (!empty($userSet)): ?><?php echo $html->link($userSet['User']['name'], array('controller' => 'users', 'action' => 'view', $userSet['User']['id']), array(), false, false) ?><?php __("'s "); ?><?php else: ?><?php __('All ') ?><?php endif; ?><?php __('Characters');?></h2>
+<h2>
+<?php if (isset($this_system)): ?>
+ <?php echo $html->link($this_system['System']['name'], array('controller' => 'systems', 'action' => 'view', $this_system['System']['id']), array(), false, false) ?>
+<?php endif; ?>
+<?php if (!empty($userSet)): ?>
+ <?php
+ echo $html->link(
+ sprintf(__("%s's", true), $userSet['User']['name']),
+ array('controller' => 'users', 'action' => 'view', $userSet['User']['id']),
+ array(), false, false);
+?>
+<?php else: ?>
+ <?php __('All') ?>
+<?php endif; ?>
+ <?php __('Characters');?></h2>
<p>
<?php
$paginator->options(array('url' => $this->passedArgs));
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
+
+<div class="paging">
+<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?> |
+<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
+</div>
<table>
<tr>
<th><?php echo $paginator->sort('id');?></th>
<th><?php echo $paginator->sort('name');?></th>
<th><?php __('Picture');?></th>
+<?php if (!isset($this->params['named']['system'])): ?>
<th><?php echo $paginator->sort('system_id');?></th>
+<?php endif; ?>
<?php if (empty($userSet)): ?>
<th><?php echo $paginator->sort('user_id');?></th>
<?php endif; ?>
echo $html->div('attachments', $picture);
?>
</td>
+<?php
+ $character_list_url = array(
+ 'controller' => 'characters',
+ 'action' => 'index'
+ );
+
+ if (!empty($userSet)) {
+ $character_list_url[] = $userSet['User']['id'];
+ }
+
+ ?>
+<?php if (!isset($this_system)): ?>
<td>
- <?php echo $html->link($character['System']['name'], array('controller' => 'systems', 'action' => 'view', $character['System']['id'])); ?>
+<?php
+ echo $html->link($character['System']['name'], array_merge($character_list_url, array('system:'.$character['System']['id'])));
+?>
</td>
+<?php endif; ?>
<?php if (empty($userSet)): ?>
<td>
- <?php echo $html->link($character['User']['name'], array('controller' => 'characters', 'action' => 'admin_index', $character['User']['id']), array(), false, false); ?>
+<?php
+ $character_list_url[] = $character['User']['id'];
+ if (isset($this_system)) {
+ $character_list_url[] = 'system:'.$this_system['System']['id'];
+ }
+ echo $html->link($text->truncate($character['User']['name'], 16), $character_list_url);
+?>
</td>
<?php endif; ?>
<td>
<div class="characters index">
-<h2><?php if (!empty($userSet)): ?><?php echo $html->link($userSet['User']['name'], array('controller' => 'users', 'action' => 'view', $userSet['User']['id']), array(), false, false) ?><?php __("'s "); ?><?php else: ?><?php __('All ') ?><?php endif; ?><?php __('Characters');?></h2>
+<h2>
+<?php if (isset($this_system)): ?>
+ <?php echo $html->link($this_system['System']['name'], array('controller' => 'systems', 'action' => 'view', $this_system['System']['id']), array(), false, false) ?>
+<?php endif; ?>
+<?php if (!empty($userSet)): ?>
+ <?php
+ echo $html->link(
+ sprintf(__("%s's", true), $userSet['User']['name']),
+ array('controller' => 'users', 'action' => 'view', $userSet['User']['id']),
+ array(), false, false);
+?>
+<?php else: ?>
+ <?php __('All') ?>
+<?php endif; ?>
+ <?php __('Characters');?></h2>
<p>
<?php
$paginator->options(array('url' => $this->passedArgs));
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
+
+<div class="paging">
+<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?> |
+<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+
<table>
<tr>
<th><?php echo $paginator->sort('name');?></th>
<th><?php __('Picture');?></th>
+<?php if (!isset($this_system)): ?>
<th><?php echo $paginator->sort('system_id');?></th>
+<?php endif; ?>
<?php if (empty($userSet)): ?>
<th><?php echo $paginator->sort('user_id');?></th>
<?php endif; ?>
<td>
<?php echo $html->link($text->truncate($character['Character']['name'], 32), array('action' => 'view', $character['Character']['id'])); ?>
<?php if ($isOwner_userSet && $character['Character']['public_flag'] != 'public'): ?>
- <?php echo $select->get_i18n_public_flag($character['Character']['public_flag'], $public_flags) ?>
+<span class="publicFlag"><?php echo $select->get_i18n_unpublic_flag($character['Character']['public_flag'], $public_flags) ?></span>
<?php endif; ?>
</td>
<td class="center">
echo $html->div('attachments', $picture);
?>
</td>
+<?php
+ $character_list_url = array(
+ 'controller' => 'characters',
+ 'action' => 'index'
+ );
+
+ if (!empty($userSet)) {
+ $character_list_url[] = $userSet['User']['id'];
+ }
+
+ ?>
+<?php if (!isset($this_system)): ?>
<td>
- <?php echo $html->link($character['System']['name'], array('controller' => 'systems', 'action' => 'view', $character['System']['id'])); ?>
+<?php
+ echo $html->link($character['System']['name'], array_merge($character_list_url, array('system:'.$character['System']['id'])));
+?>
</td>
+<?php endif; ?>
<?php if (empty($userSet)): ?>
<td>
- <?php echo $html->link($character['User']['name'], array('controller' => 'characters', 'action' => 'index', $character['User']['id']), array(), false, false); ?>
+<?php
+ $character_list_url[] = $character['User']['id'];
+ if (isset($this_system)) {
+ $character_list_url[] = 'system:'.$this_system['System']['id'];
+ }
+ echo $html->link($text->truncate($character['User']['name'], 16), $character_list_url);
+?>
</td>
<?php endif; ?>
<td>
/* Paging */
div.paging {
background: transparent;
+ margin-bottom: 5px;
}
/* Forms */