From: Cake Date: Fri, 26 Mar 2010 13:16:02 +0000 (+0900) Subject: Adminユーザ詳細にキャラ表示 X-Git-Tag: version-alpha~77 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1ea638ed2f38699028e0deacaf0e187b8df0c2bc;p=trpgtools-onweb%2Fcake-frame.git Adminユーザ詳細にキャラ表示 --- diff --git a/app/controllers/app_controller.php b/app/controllers/app_controller.php index 4689938..7004b73 100644 --- a/app/controllers/app_controller.php +++ b/app/controllers/app_controller.php @@ -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; diff --git a/app/controllers/users_controller.php b/app/controllers/users_controller.php index a2aba58..cedb58d 100644 --- a/app/controllers/users_controller.php +++ b/app/controllers/users_controller.php @@ -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() { diff --git a/app/models/system.php b/app/models/system.php index 47cf4f5..db17668 100644 --- a/app/models/system.php +++ b/app/models/system.php @@ -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', ), diff --git a/app/models/user.php b/app/models/user.php index e55bc72..bca8c80 100644 --- a/app/models/user.php +++ b/app/models/user.php @@ -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 diff --git a/app/views/users/admin_listview.ctp b/app/views/users/admin_listview.ctp index d95d5d6..3d46e74 100644 --- a/app/views/users/admin_listview.ctp +++ b/app/views/users/admin_listview.ctp @@ -30,6 +30,7 @@ echo $paginator->counter(array( sort(__('Name', true), 'name');?> sort(__('Group', true), 'group_id');?> sort(__('Last Access', true), 'modified');?> + sort(__('ID', true), 'username');?> sort(__('PC', true), 'pcmail');?> sort(__('Mobile', true), 'mobile_mail');?> @@ -58,6 +59,32 @@ foreach ($users as $user): niceShort($user['User']['modified'], array('format' => 'Y/m/d H:i')); ?> + +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']) + ) + ); +} +?> + @@ -70,7 +97,7 @@ foreach ($users as $user): niceShort($user['User']['created'], array('format' => 'Y/m/d H:i')); ?> - + highlight($text->excerpt($user['User']['useragent'], 'MSIE', 28), 'MSIE'); diff --git a/app/views/users/admin_view.ctp b/app/views/users/admin_view.ctp index df69f0f..4626b69 100644 --- a/app/views/users/admin_view.ctp +++ b/app/views/users/admin_view.ctp @@ -1,21 +1,23 @@
-

-
-> -> - -   - -> -> - -   - -> -> + +
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', @@ -23,64 +25,99 @@ '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; ?> - -> -> - +
+

+
+
+
+
+  
-> -> +
+
-  
-> -> +
+
 
-> -> +
+
 
-> -> +
+
 
-> -> +
+
 
-> -> +
+
 
-> -> - -   -
-
-
    -
  • link(__('Change Password', true), array('action' => 'change_password', $target_user['User']['id'])); ?>
  • -
  • link(__('Delete User', true), array('action' => 'delete', $target_user['User']['id'])); ?>
  • -
+
+
+
+ +
+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'], + ), + )); +?>
+ +
\ No newline at end of file diff --git a/app/views/users/listview.ctp b/app/views/users/listview.ctp index c9af78c..4cbbdf7 100644 --- a/app/views/users/listview.ctp +++ b/app/views/users/listview.ctp @@ -1,4 +1,4 @@ -
+

options(array('url' => $this->passedArgs)); sort(__('ID', true), 'id');?> sort(__('Name', true), 'name');?> sort(__('Last Access', true), 'modified');?> + options(array('url' => $this->passedArgs)); niceShort($user['User']['modified'], array('format' => 'Y/m/d H:i')); ?> + +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']) + ) + ); +} +?> + diff --git a/app/webroot/css/base.css b/app/webroot/css/base.css index 93d622e..2bf18ac 100644 --- a/app/webroot/css/base.css +++ b/app/webroot/css/base.css @@ -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%; diff --git a/app/webroot/css/box.css b/app/webroot/css/box.css index 1cdf3f1..e3bf4e0 100644 --- a/app/webroot/css/box.css +++ b/app/webroot/css/box.css @@ -183,6 +183,34 @@ } /* ページごとの設定 */ +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; diff --git a/app/webroot/css/character-sheet.css b/app/webroot/css/character-sheet.css index d45a6e4..3bf4aa7 100644 --- a/app/webroot/css/character-sheet.css +++ b/app/webroot/css/character-sheet.css @@ -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; +} + diff --git a/app/webroot/css/ie.css b/app/webroot/css/ie.css index 127102c..e191af9 100644 --- a/app/webroot/css/ie.css +++ b/app/webroot/css/ie.css @@ -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;