OSDN Git Service

管理側ユーザ削除
authorCake <cake_67@users.sourceforge.jp>
Thu, 3 Jun 2010 08:26:54 +0000 (17:26 +0900)
committerCake <cake_67@users.sourceforge.jp>
Thu, 3 Jun 2010 08:26:54 +0000 (17:26 +0900)
app/config/init.php
app/controllers/app_controller.php
app/controllers/users_controller.php
app/views/users/admin_delete.ctp

index dbc1865..1acd018 100644 (file)
@@ -21,10 +21,9 @@ Configure::write('Group.admin', 1);
 Configure::write('Group.subadmin', 2);
 Configure::write('Group.watcher', 3);
 Configure::write('Group.member', 4);
-Configure::write('Group.pre', 5);
-Configure::write('Group.locked', 6);
+Configure::write('Group.locked', 5);
+Configure::write('Group.pre', 6);
 Configure::write('Group.deleted', 7);
-Configure::write('Group.banned', 8);
 
 /* TimeZone */
 date_default_timezone_set('Asia/Tokyo');
index 71fc2d5..bc2379b 100644 (file)
@@ -222,6 +222,24 @@ class AppController extends Controller
                $conditions = array(
                        'User.id' => $id,
                );
+               if ($isAdmin === true) {
+                       $conditions['User.group_id'] = array(
+                               Configure::read('Group.admin'),
+                               Configure::read('Group.subadmin'),
+                               Configure::read('Group.watcher'),
+                               Configure::read('Group.member'),
+                               Configure::read('Group.locked'),
+                               Configure::read('Group.pre'),
+                       );
+               } else {
+                       $conditions['User.group_id'] = array(
+                               Configure::read('Group.admin'),
+                               Configure::read('Group.subadmin'),
+                               Configure::read('Group.watcher'),
+                               Configure::read('Group.member'),
+                               Configure::read('Group.locked'),
+                       );
+               }
 
                $fields = array(
                        'User.id',
index bbd65ff..5e1c638 100644 (file)
@@ -70,7 +70,6 @@ class UsersController extends ModuleController {
                        self::_index();
                } else {
                        $this->pageTitle = sprintf(__("%s's Home", true), __('Guest', true));
-
                }
 
                // 全体の情報
@@ -287,6 +286,9 @@ class UsersController extends ModuleController {
                // 非公開キャラクター取得
                unset($this->User->hasMany['Character']['conditions']['Character.public_flag']);
 
+               // group設定
+               unset($this->User->hasMany['Character']['conditions']['Character.public_flag']);
+
                $this->paginate['fields'] = array_merge($this->paginate['fields'], array(
                        'User.username',
                        'User.pcmail',
@@ -296,7 +298,7 @@ class UsersController extends ModuleController {
                        'User.created',
                ));
 
-               self::_listview();
+               self::_listview(true);
 
        }
 
@@ -355,7 +357,7 @@ class UsersController extends ModuleController {
                        }
                }
 
-               $user = $this->getUser($id);
+               $user = $this->getUser($id, true, true);
                if (!$user) {
                        $this->Session->setFlash(__('No User', true));
                        $this->redirect(array('controller' => 'users', 'action'=>'listview'));
@@ -405,7 +407,25 @@ class UsersController extends ModuleController {
                $this->set_public_flag4view();
        }
 
-       function _listview() {
+       function _listview($isAdmin = false) {
+               if ($isAdmin === true) {
+                       $this->paginate['conditions']['User.group_id'] = array(
+                               Configure::read('Group.admin'),
+                               Configure::read('Group.subadmin'),
+                               Configure::read('Group.watcher'),
+                               Configure::read('Group.member'),
+                               Configure::read('Group.locked'),
+                               Configure::read('Group.pre'),
+                       );
+               } else {
+                       $this->paginate['conditions']['User.group_id'] = array(
+                               Configure::read('Group.admin'),
+                               Configure::read('Group.subadmin'),
+                               Configure::read('Group.watcher'),
+                               Configure::read('Group.member'),
+                               Configure::read('Group.locked'),
+                       );
+               }
                $users = $this->paginate();
 
                if (!empty($users)) {
@@ -536,18 +556,37 @@ class UsersController extends ModuleController {
                if (!$user) {
                        return false;
                }
-               if ($user['User']['group_id'] == 1) {
+               if ($user['User']['group_id'] == Configure::read('Group.admin')) {
                        $this->Session->setFlash(__('Super Administrator can not be deleted.', true));
                        return false;
                }
-               App::import('Controller', 'Characters');
-               $this->CharactersController = new CharactersController;
-               $this->CharactersController->Character = CorePlus::set_model('Character');
-               $this->CharactersController->Session = new SessionComponent;
-               $this->CharactersController->data['Character'] = $this->data['Character'];
 
-               if ($this->User->del($id)) {
+               if ($isAdmin) {
+                       $this->data['User']['id'] = $id;
+                       $this->data['User']['group_id'] = Configure::read('Group.deleted');
+
+                       $this->User->create();
+                       $result = $this->User->save(
+                                       $this->data,
+                                       array(
+                                               'validate' => false,
+                                               'fieldList' => array(
+                                                       'group_id',
+                                               ),
+                                       )
+                       );
+               } else {
+                       $result = $this->User->del($id);
+               }
+
+               if ($result) {
                        if (!empty($user['Character'])) {
+                               App::import('Controller', 'Characters');
+                               $this->CharactersController = new CharactersController;
+                               $this->CharactersController->Character = CorePlus::set_model('Character');
+                               $this->CharactersController->Session = new SessionComponent;
+                               $this->CharactersController->data['Character'] = $this->data['Character'];
+
                                foreach ($user['Character'] as $character) {
                                        $this->CharactersController->_delete($character['id'], array(), true);
                                }
index 5a97a74..17e0ab4 100644 (file)
 <fieldset>
 <legend><?php __('Do you really delete the account?');?></legend>
 
-<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']; ?>
+<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/xs', 
+               CorePlus::get_value($target_user, 'Attachment.0'),
+               array(
+                       'model_name' => 'User', 
+                       'mime_type' => 'original',
+                       'nodata' => 'image',
+               )
+       );
+       $user_img = $upfile->embed(
+               $file,
+               array(
+                       'alt' => $target_user['User']['name'],
+                       'restrict' => array('image'),
+                       'htmlAttributes' => array(
+                               'target' => '_blank',
+                       ),
+               )
+       );
+
+       $edit = null;
+
+       $delete = null;
+
+       $footer = null;
+?>
+<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 __('GroupId'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-       <?php echo $target_user['User']['group_id']; ?>
+<dt><?php __('Id'); ?></dt>
+<dd>
+       <?php echo $target_user['User']['username']; ?>
+</dd>
+<dt><?php __('Pc Mail Address'); ?></dt>
+<dd>
+       <?php echo $target_user['User']['pcmail']; ?>
        &nbsp;
 </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']; ?>
+<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 __('UserId'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-       <?php echo $target_user['User']['username']; ?>
+<dt><?php __('Useragent'); ?></dt>
+<dd>
+       <?php echo $target_user['User']['useragent']; ?>
        &nbsp;
 </dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
-<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-       <?php echo $target_user['User']['created']; ?>
+<dt><?php __('Host'); ?></dt>
+<dd>
+       <?php echo $target_user['User']['host']; ?>
        &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']; ?>
+<dt><?php __('Created'); ?></dt>
+<dd>
+       <?php echo $target_user['User']['created']; ?>
        &nbsp;
 </dd>
 </dl>
+</div>
+
+<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>
 
 <?php
+       echo $form->input('Character.confirm', array(
+                       'type' => 'hidden',
+                       'value' => 'yes',
+               )
+       );
        echo $token->create();
 ?>
 </fieldset>