Show
Ignore:
Timestamp:
08/30/08 12:04:44 (5 years ago)
Author:
ha1t
Message:

show,controlの修正と実装

Files:
1 modified

Legend:

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

    r18059 r18466  
    3939    function show($id) 
    4040    { 
     41        $id = (int)$id; 
     42        $this->set('event_id', $id); 
     43 
    4144        $has_many = array( 
    4245            'EventComment' => array( 
     
    6063        ); 
    6164 
     65        $has_one2 = array( 
     66            'User' => array( 
     67                'className' => 'User', 
     68                'foreignKey' => 'user_id', 
     69            ) 
     70        ); 
     71 
    6272        $this->Event->bindModel(array('hasMany' => $has_many, 'hasOne' => $has_one)); 
    6373 
    64         $re = $this->Event->findById($id); 
     74        $this->Event->EventComment->bindModel(array('belongsTo' => $has_one2)); 
     75        $this->Event->EventAttendee->bindModel(array('belongsTo' => $has_one2)); 
     76 
     77        $re = $this->Event->findById($id, null,null,2); 
    6578 
    6679        // WikiPageのレンダリング 
     
    7285        foreach ($re['EventAttendee'] as $row) { 
    7386            // 自分が参加していたらフラグをたてる 
    74             /* 
    75             if (isset($_SESSION['name']) && $row['account_name'] == $_SESSION['name']) { 
    76                 $this->af->setApp('joined', true); 
     87            if ($this->Session->read('username') == $row['User']['username']) { 
     88                $this->set('joined', true); 
    7789                if ($row['canceled'] == 1) { 
    78                     $this->af->setApp('canceled', true); 
     90                    $this->set('canceled', true); 
     91                } else { 
     92                    $this->set('canceled', false); 
    7993                } 
     94            } else { 
     95                $this->set('joined', false); 
    8096            } 
    81              */ 
    8297 
    8398            if ($row['canceled'] != 1) { 
     
    88103        $this->set('attendee_count', $attendee_count); 
    89104        $this->set('attendee_nokori', $re['Event']['max_register'] - $attendee_count); 
     105        $this->set('is_over', $this->Event->isOver($id)); 
    90106        $this->set('data', $re); 
    91107    } 
     108 
     109    /** 
     110     * control 
     111     * 
     112     */ 
     113    function control() 
     114    { 
     115        // adminじゃなければさようなら 
     116        if ($this->Session->read('role') != 'admin') { 
     117            $this->redirect('/'); 
     118        } 
     119 
     120        $events = $this->Event->find('all', array('order' => 'Event.id DESC')); 
     121        $this->set('events', $events); 
     122    } 
     123 
     124    /** 
     125     * post 
     126     * 
     127     */ 
     128    function post() 
     129    { 
     130        if ($this->data) { 
     131        } 
     132    } 
     133 
    92134} 
    93135 
    94  
    95136?>