OSDN Git Service

Adminユーザ詳細にキャラ表示
authorCake <cake_67@users.sourceforge.jp>
Fri, 26 Mar 2010 13:16:02 +0000 (22:16 +0900)
committerCake <cake_67@users.sourceforge.jp>
Fri, 26 Mar 2010 13:16:02 +0000 (22:16 +0900)
app/controllers/app_controller.php
app/controllers/users_controller.php
app/models/system.php
app/models/user.php
app/views/users/admin_listview.ctp
app/views/users/admin_view.ctp
app/views/users/listview.ctp
app/webroot/css/base.css
app/webroot/css/box.css
app/webroot/css/character-sheet.css
app/webroot/css/ie.css

index 4689938..7004b73 100644 (file)
@@ -210,7 +210,7 @@ class AppController extends Controller
        }
 
        /* ユーザ情報取得 */
-       function getUser($id) {
+       function getUser($id, $isAdmin=false) {
                if (!$id) {
                        return array();
                }
@@ -219,21 +219,50 @@ class AppController extends Controller
                        $this->User = CorePlus::set_model('User');
                }
 
-               // Media.Attachmentから関連ファイルの取得
+               $conditions = array(
+                       'User.id' => $id,
+               );
+
+               $fields = array(
+                       'User.id',
+                       'User.group_id',
+                       'User.name',
+                       'User.pcmail',
+                       'User.mobile_mail',
+                       'User.modified',
+               );
+               if ($isAdmin === true) {
+                       $fields = array_merge($fields, array(
+                               'User.username',
+                               'User.useragent',
+                               'User.host',
+                               'User.created',
+                       ));
+               }
+
+               $contain = array(
+                        'Attachment',
+               );
+               if ($isAdmin === true) {
+                       $contain = array_merge($contain, array(
+                               'Character',
+                       ));
+
+                       unset($this->User->hasMany['Character']['conditions']['Character.public_flag']);
+                       unset($this->User->hasMany['Character']['limit']);
+               }
+
+               if (empty($contain)) {
+                       $recursive = -1;
+               } else {
+                       $recursive = Set::countDim($contain);
+               }
+
                $user = $this->User->find('first', array(
-                       'conditions' => array('User.id' => $id),
-                       'fields' => array(
-                               'User.id',
-                               'User.group_id',
-                               'User.name',
-                               'User.pcmail',
-                               'User.mobile_mail',
-                               'User.modified',
-                       ),
-                       'recursive' => 1,
-                       'contain' => array(
-                               'Attachment',
-                       ),
+                       'conditions' => $conditions,
+                       'fields' => $fields,
+                       'recursive' => $recursive,
+                       'contain' => $contain,
                ));
 
                return $user;
index a2aba58..cedb58d 100644 (file)
@@ -16,6 +16,26 @@ class UsersController extends ModuleController {
 
        var $disableTokenActions = array('add','mobile_add');
 
+       // listView用のpagenate設定
+       var $paginate = array(
+               'conditions' => array(
+               ),
+               'fields' => array(
+                       'User.id',
+                       'User.group_id',
+                       'User.name',
+                       'User.modified',
+               ),
+               'recursive' => 1,
+               'contain' => array(
+                       'Character',
+               ),
+               'limit' => 20,
+               'order' => array(
+                       'User.id' => 'asc'
+               ),
+       );
+
        function beforeFilter() {
 
                parent::beforeFilter();
@@ -241,8 +261,6 @@ class UsersController extends ModuleController {
        function admin_listview() {
 
                // 検索処理
-               $this->User->contain();
-               $contain = array();
                $searchword = array();
                if (!empty($this->data)) {
                        if (isset($this->data['User']['name'])) {
@@ -254,15 +272,26 @@ class UsersController extends ModuleController {
                        }
                }
 
-
                if (isset($name)) {
                        $this->data['User']['name'] = $name;
-                       $contain["User.name LIKE"] = "%".Sanitize::html($name)."%";
+                       $this->paginate['conditions']['User.name LIKE'] = '%'.Sanitize::html($name).'%';
                        $searchword['name'] = urlencode($name);
                }
                $this->set('searchword', $searchword);
 
-               $this->set('users', $this->paginate('User', $contain));
+               // 非公開キャラクター取得
+               unset($this->User->hasMany['Character']['conditions']['Character.public_flag']);
+
+               $this->paginate['fields'] = array_merge($this->paginate['fields'], array(
+                       'User.username',
+                       'User.pcmail',
+                       'User.mobile_mail',
+                       'User.useragent',
+                       'User.host',
+                       'User.created',
+               ));
+
+               self::_listview();
 
        }
 
@@ -272,13 +301,11 @@ class UsersController extends ModuleController {
                        $this->redirect(array('controller' => 'users', 'action'=>'index'));
                }
 
-               $user = $this->getUser($id);
+               $user = $this->getUser($id, true);
                if (!$user) {
                        $this->redirect(array('action'=>'listview'));
                }
                $this->set('target_user', $user);
-
-               $this->set('target_user', $this->User->read(null, $id));
        }
 
        function admin_add() {
@@ -373,8 +400,26 @@ class UsersController extends ModuleController {
        }
 
        function _listview() {
-               $this->User->recursive = -1;
-               $this->set('users', $this->paginate());
+               $users = $this->paginate();
+
+               if (!empty($users)) {
+                       // 全キャラクター数取得
+                       foreach ($users as $k => $v) {
+                               if (empty($v['Character'])) {
+                                       $users[$k]['User']['character_num'] = 0;
+                                       continue;
+                               }
+
+                               $users[$k]['User']['character_num'] = $this->User->Character->find('count', array(
+                                       'conditions' => array_merge($this->User->hasMany['Character']['conditions'],
+                                               array('Character.user_id' => $v['User']['id'])),
+                                       'recursive' => -1,
+                               ));
+                       }
+
+                       $users = $this->HtmlEscape->nl_unescape($users);
+               }
+               $this->set('users', $users);
        }
 
        function _add() {
index 47cf4f5..db17668 100644 (file)
@@ -71,7 +71,16 @@ class System extends AppModel {
                                'Character.public_flag' => 'public',
                                'Character.deleted' => '0',
                        ),
-                       'fields' => '',
+                       'fields' => array(
+                               'Character.id',
+                               'Character.system_id',
+                               'Character.user_id',
+                               'Character.name',
+                               'Character.main_picture',
+                               'Character.public_flag',
+                               'Character.status',
+                               'Character.modified',
+                       ),
                        'order' => 'Character.modified DESC',
                        'limit' => '5',
                ),
index e55bc72..bca8c80 100644 (file)
@@ -23,9 +23,30 @@ class User extends AppModel {
                        'order' => '',
                        'limit' => '',
                        'offset' => '',
-                       'finderQuery' => '',
-                       'deleteQuery' => '',
-                       'insertQuery' => ''
+               ),
+               'Character' => array(
+                       'className' => 'Character',
+                       'foreignKey' => 'user_id',
+                       'dependent' => false,
+                       'conditions' => array(
+                               'Character.public_flag' => 'public',
+                               'Character.deleted' => '0',
+                       ),
+                       'fields' => array(
+                               'Character.id',
+                               'Character.system_id',
+                               'Character.user_id',
+                               'Character.name',
+                               'Character.main_picture',
+                               'Character.public_flag',
+                               'Character.status',
+                               'Character.modified',
+                       ),
+                       'order' => array(
+                               'Character.modified' => 'DESC',
+                       ),
+                       'limit' => '5',
+                       'offset' => '',
                )
        );
 
@@ -161,4 +182,3 @@ class User extends AppModel {
        }
 
 }
-?>
\ No newline at end of file
index d95d5d6..3d46e74 100644 (file)
@@ -30,6 +30,7 @@ echo $paginator->counter(array(
        <th><?php echo $paginator->sort(__('Name', true), 'name');?></th>
        <th><?php echo $paginator->sort(__('Group', true), 'group_id');?></th>
        <th><?php echo $paginator->sort(__('Last Access', true), 'modified');?></th>
+       <th><?php echo __('Characters'); ?></th>
        <th><?php echo $paginator->sort(__('ID', true), 'username');?></th>
        <th><?php echo $paginator->sort(__('PC', true), 'pcmail');?></th>
        <th><?php echo $paginator->sort(__('Mobile', true), 'mobile_mail');?></th>
@@ -58,6 +59,32 @@ foreach ($users as $user):
 <td>
        <?php echo $time->niceShort($user['User']['modified'], array('format' => 'Y/m/d H:i')); ?>
 </td>
+<td class="characterList">
+<?php
+if (!empty($user['Character'])) {
+       foreach ($user['Character'] as $v) {
+               $picture = $this->renderElement('character_picture_image', array(
+                       'basename' => $v['main_picture'],
+                       'options' => array(
+                               'previewVersion' => 'xs',
+                               'class' => 'shadow',
+                               'url' => array('controller' => 'characters', 'action' => 'view', $v['id']),
+                               'alternative' => $text->truncate($v['name'], 32),
+                       )
+               ));
+
+               echo $html->tag('span', $picture, array('class' => 'image'));
+       }
+
+       echo $html->div('total_chara_num',
+               $html->link(
+                       sprintf(__('Total %d Characters', true), $user['User']['character_num']),
+                       $url = array('controller' => 'characters', 'action' => 'index', $user['User']['id'])
+               )
+       );
+}
+?>
+</td>
 <td>
        <?php echo $user['User']['username']; ?>
 </td>
@@ -70,7 +97,7 @@ foreach ($users as $user):
 <td>
        <?php echo $time->niceShort($user['User']['created'], array('format' => 'Y/m/d H:i')); ?>
 </td>
-<td>
+<td class="userAgent">
 <?php
 if (strrpos($user['User']['useragent'], 'MSIE') !== false) {
        echo $text->highlight($text->excerpt($user['User']['useragent'], 'MSIE', 28), 'MSIE');
index df69f0f..4626b69 100644 (file)
@@ -1,21 +1,23 @@
 <div class="users view">
-<h2><?php  __('User');?></h2>
-<dl><?php $i = 0; $class = ' class="altrow"';?>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-       <?php echo $target_user['User']['id']; ?>
-               &nbsp;
-</dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('GroupId'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-       <?php echo $target_user['User']['group_id']; ?>
-       &nbsp;
-</dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Image'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+
+<div class="user_data">
 <?php
+       $user_name = $target_user['User']['name'];
+       $id = $html->tag('span', 
+               '('. sprintf(__('UserNo %d', true), $target_user['User']['id']). ')',
+               array(
+                       'class' => 'text',
+               )
+       );
+       $group = $html->tag('span', 
+               $target_user['User']['group_id'],
+               array(
+                       'class' => 'text',
+               )
+       );
+
        $file = $upfile->file(
-               'filter/m', 
+               'filter/xs', 
                CorePlus::get_value($target_user, 'Attachment.0'),
                array(
                        'model_name' => 'User', 
                        'nodata' => 'image',
                )
        );
-
-       echo $medium->embed(
+       $user_img = $upfile->embed(
                $file,
                array(
-                       'alt' => CorePlus::get_value($user, 'User.name'),
-                       'class' => 'shadow',
-                       'id' => 'HomeUserImage',
-                       'restrict' => array('image')
+                       'alt' => $target_user['User']['name'],
+                       'restrict' => array('image'),
+                       'htmlAttributes' => array(
+                               'target' => '_blank',
+                       ),
+               )
+       );
+
+       $edit = $html->tag('span', 
+               "[".$html->link(__('Change Password', true), array('action' => 'change_password', $target_user['User']['id']))."]",
+               array(
+                       'class' => 'link',
+               )
+       );
+
+       $delete = $html->tag('span', 
+               "[".$html->link(__('Delete User', true), array('action' => 'delete', $target_user['User']['id']))."]",
+               array(
+                       'class' => 'link',
                )
        );
+
+       $footer = null;
 ?>
-</dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-       <?php echo $target_user['User']['name']; ?>
+<div class="box">
+<div class="boxHeader"><h3><?php echo $user_img. $user_name. $id. $group. $edit. $delete ?></h3></div>
+<div class="boxBody">
+<dl>
+<dt><?php __('Last Access'); ?></dt>
+<dd>
+       <?php echo $target_user['User']['modified']; ?>
        &nbsp;
 </dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('UserId'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+<dt><?php __('ID'); ?></dt>
+<dd>
        <?php echo $target_user['User']['username']; ?>
-       &nbsp;
 </dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Pc Mail Address'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+<dt><?php __('Pc Mail Address'); ?></dt>
+<dd>
        <?php echo $target_user['User']['pcmail']; ?>
        &nbsp;
 </dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Mobile Mail Address'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+<dt><?php __('Mobile Mail Address'); ?></dt>
+<dd>
        <?php echo $target_user['User']['mobile_mail']; ?>
        &nbsp;
 </dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Useragent'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+<dt><?php __('Useragent'); ?></dt>
+<dd>
        <?php echo $target_user['User']['useragent']; ?>
        &nbsp;
 </dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Host'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+<dt><?php __('Host'); ?></dt>
+<dd>
        <?php echo $target_user['User']['host']; ?>
        &nbsp;
 </dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+<dt><?php __('Created'); ?></dt>
+<dd>
        <?php echo $target_user['User']['created']; ?>
        &nbsp;
 </dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-       <?php echo $target_user['User']['modified']; ?>
-       &nbsp;
-</dd>
 </dl>
 </div>
 
-<div class="actions">
-<ul>
-<li><?php echo $html->link(__('Change Password', true), array('action' => 'change_password', $target_user['User']['id'])); ?> </li>
-<li><?php echo $html->link(__('Delete User', true), array('action' => 'delete', $target_user['User']['id'])); ?> </li>
-</ul>
+<div class="boxFooter"><?php if (isset($footer)): ?><?php echo $footer; ?><?php endif; ?></div>
+</div>
+</div>
+
+<div class="characters">
+<?php
+       $total =  $html->tag('span', sprintf(__('Total Characters %d', true), count($target_user['Character'])), array('class' => 'total_chara_num'));
+
+       echo $this->renderElement('character_picture_table', array(
+               'header' => __('Characters', true). $total,
+               'characters' => $target_user['Character'],
+               'previewVersion' => 'xs',
+               'colNum' => 15,
+               'id' => null,
+               'isUser' => false,
+               'isCharacter' => false,
+               'isSystem' => false,
+               'isModified' => false,
+               'more_url' => array(
+                       'controller' => 'characters', 
+                       'action' => 'index',
+                       $target_user['User']['id'],
+               ),
+       ));
+?>
 </div>
+
+</div>
\ No newline at end of file
index c9af78c..4cbbdf7 100644 (file)
@@ -1,4 +1,4 @@
-<div class="users list">
+<div class="users listview">
 <h2><?php __('Users');?> <?php __('List');?></h2>
 <p>
 <?php
@@ -20,6 +20,7 @@ $paginator->options(array('url' => $this->passedArgs));
 <th><?php echo $paginator->sort(__('ID', true), 'id');?></th>
 <th><?php echo $paginator->sort(__('Name', true), 'name');?></th>
 <th><?php echo $paginator->sort(__('Last Access', true), 'modified');?></th>
+<th><?php echo __('Characters'); ?></th>
 </tr>
 <?php
        $i = 0;
@@ -39,6 +40,32 @@ $paginator->options(array('url' => $this->passedArgs));
 <td>
        <?php echo $time->niceShort($user['User']['modified'], array('format' => 'Y/m/d H:i')); ?>
 </td>
+<td class="characterList">
+<?php
+if (!empty($user['Character'])) {
+       foreach ($user['Character'] as $v) {
+               $picture = $this->renderElement('character_picture_image', array(
+                       'basename' => $v['main_picture'],
+                       'options' => array(
+                               'previewVersion' => 'xs',
+                               'class' => 'shadow',
+                               'url' => array('controller' => 'characters', 'action' => 'view', $v['id']),
+                               'alternative' => $text->truncate($v['name'], 32),
+                       )
+               ));
+
+               echo $html->tag('span', $picture, array('class' => 'image'));
+       }
+
+       echo $html->div('total_chara_num',
+               $html->link(
+                       sprintf(__('Total %d Characters', true), $user['User']['character_num']),
+                       $url = array('controller' => 'characters', 'action' => 'index', $user['User']['id'])
+               )
+       );
+}
+?>
+</td>
 </tr>
 <?php endforeach; ?>
 </table>
index 93d622e..2bf18ac 100644 (file)
@@ -303,10 +303,20 @@ ul#navAdmin li {
        width: 100%;
        height:100%;
        min-height:100%;
-       padding: 5px 10px;
+       padding: 5px 0;
        overflow: hidden;
        position : relative
 }
+#content div#subNavi,
+#content div.view,
+#content div.index,
+#content div.add,
+#content div.edit,
+#content div.listview,
+#content div.admin_listview
+ {
+       margin-left: 10px;
+}
 
 #footer {
        width: 100%;
index 1cdf3f1..e3bf4e0 100644 (file)
 }
 
 /* ページごとの設定 */
+div.users .user_data .box {
+       width: 720px;
+       margin-bottom: 20px;
+}
+div.users .user_data .boxHeader {
+       padding-bottom: 0;
+}
+div.users .user_data .boxHeader h3 {
+       width: 720px;
+       overflow: hidden;
+       font-size: 250%;
+}
+div.users .user_data .boxHeader span {
+       font-size: 50%;
+}
+div.users .user_data .boxBody {
+       width: 720px;
+       padding: 10px;
+}
+div.users .user_data .boxFooter {
+       width: 720px;
+       overflow: hidden;
+       padding-left: 10px;
+}
+div.users .characters .box {
+       margin-bottom: 20px;
+}
+
 div.systems .system_data .box {
        width: 720px;
        margin-bottom: 20px;
index d45a6e4..3bf4aa7 100644 (file)
@@ -137,3 +137,31 @@ div.image div.action li {
        font-size: 80%;
        font-weight: normal;
 }
+
+/* ユーザ一覧のキャラ表示 */
+.users .characterList {
+       width: 185px;
+       white-space: nowrap;
+}
+.listview .characterList {
+       width: 330px;
+       white-space: nowrap;
+       padding-bottom: 0;
+}
+.users .characterList span.image {
+       padding-left: 4px;
+}
+.users .characterList .total_chara_num {
+       font-size: 80%;
+}
+.listview .characterList .total_chara_num {
+       display: inline;
+       position: relative;
+       top: -4px;
+       left: 5px;
+}
+
+td.userAgent {
+       width: 200px;
+}
+
index 127102c..e191af9 100644 (file)
@@ -29,6 +29,20 @@ div.picture a.shadow {
        margin: 0;
 }
 
+/* ユーザ一覧のキャラ表示 */
+.users .characterList span.image {
+       padding: 0 1px 0 0;
+       margin: 0;
+}
+.users .characterList span.image img {
+       padding: 0;
+       border-width: 2px;
+}
+.listview .characterList .total_chara_num {
+       top: -6px;
+}
+
+
 /* 画像キャプション */
 .boxBody div.picture .image_caption {
        left: 4px;