Changeset 18477

Show
Ignore:
Timestamp:
08/30/08 20:15:49 (3 months ago)
Author:
ha1t
Message:

管理者制御の処理を実装

Location:
websites/events.php.gr.jp/branches/cake/app
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • websites/events.php.gr.jp/branches/cake/app/controllers/users_controller.php

    r18465 r18477  
    166166    } 
    167167 
     168    /** 
     169     * control 
     170     * 
     171     */ 
     172    function control() 
     173    { 
     174        // adminじゃなければさようなら 
     175        if ($this->Session->read('role') != 'admin') { 
     176            $this->redirect('/'); 
     177        } 
     178 
     179        // @TODO システムバージョン等を表示する事 
     180         
     181        $users = $this->User->find('all', array('conditions' => "User.role = 'admin'")); 
     182        $this->set('admins', $users); 
     183    } 
     184 
     185    /** 
     186     * upgrade 
     187     * 
     188     */ 
     189    function upgrade() 
     190    { 
     191        // adminじゃなければさようなら 
     192        if ($this->Session->read('role') != 'admin') { 
     193            $this->redirect('/'); 
     194        } 
     195 
     196        if ($this->data) { 
     197            $user = $this->User->findByUsername($this->data['User']['username']); 
     198            if ($user) { 
     199                $user['User']['role'] = 'admin'; 
     200            } 
     201            $this->User->save($user); 
     202        } 
     203 
     204        $this->redirect('/users/control'); 
     205    } 
     206 
     207    /** 
     208     * downgrade 
     209     * 
     210     */ 
     211    function downgrade() 
     212    { 
     213        // adminじゃなければさようなら 
     214        if ($this->Session->read('role') != 'admin') { 
     215            $this->redirect('/'); 
     216        } 
     217 
     218        if ($this->data) { 
     219            $user = $this->User->findByUsername($this->data['User']['username']); 
     220            if ($user) { 
     221                $user['User']['role'] = 'user'; 
     222            } 
     223            $this->User->save($user); 
     224        } 
     225 
     226        $this->redirect('/users/control'); 
     227    } 
     228 
    168229    private function setMessage($message) { 
    169230        $this->set('message', $message);