Changeset 661

Show
Ignore:
Timestamp:
07/21/08 22:11:14 (4 months ago)
Author:
aarkerio
Message:

Update general

Location:
trunk/app
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/subjects_controller.php

    r660 r661  
    4545 
    4646   $this->title     = __('Subject', true); 
    47        
    48    $conditions = array('Subject.code'=>$code); 
    4947    
    50    $this->set('data', $this->Subject->find($conditions)); 
     48   $this->set('data', $this->Subject->getSubject($code)); 
    5149 } 
    52     
    5350    
    5451  /** ==== ADMIN METHODS ==== */ 
  • trunk/app/models/subject.php

    r660 r661  
    4444                  ); 
    4545     
    46     public $validate = array( 
     46 public $validate = array( 
    4747      'title' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
    4848      'id' => VALID_NOT_EMPTY 
    49    ); 
     49 ); 
     50 
     51 public function getSubject($code) 
     52 { 
     53   $data           = array(); 
     54   $this->unbindAll(); 
     55   $data['S']      = $this->find(array('Subject.code'=>$code), array('Subject.id', 'Subject.code', 'Subject.title'));    
     56    
     57   $conditions     = array('Lesson.subject_id'=>$data['S']['Subject']['id']); 
     58   $fields         = array('Lesson.id', 'Lesson.title', 'User.username', 'User.id'); 
     59   $order          = 'Lesson.id DESC'; 
     60   $limit          = 10; 
     61   $data['Lesson'] = $this->Lesson->findAll($conditions, $fields, $order, $limit); 
     62 
     63 
     64   $conditions     = array('Entry.subject_id'=>$data['S']['Subject']['id']); 
     65   $fields         = array('Entry.id', 'Entry.title', 'User.username', 'User.id'); 
     66   $order          = 'Entry.id DESC'; 
     67   $limit          = 10; 
     68   $data['Entry']  = $this->Entry->findAll($conditions, $fields, $order, $limit); 
     69 
     70 
     71   $conditions     = array('Share.subject_id'=>$data['S']['Subject']['id'], 'Share.public'=>1); 
     72   $fields         = array('Share.secret', 'Share.description', 'User.username', 'User.id'); 
     73   $order          = 'Share.id DESC'; 
     74   $limit          = 10; 
     75   $data['Share']  = $this->Share->findAll($conditions, $fields, $order, $limit); 
     76 
     77   return $data; 
     78 } 
     79 
    5080/* 
    5181public $validate = array( 
  • trunk/app/views/subjects/view.ctp

    r660 r661  
    22//die(debug($data)); 
    33 
    4 echo '<h1>'. $data['Subject']['title']. ' '. $data['Subject']['code'] .'</h1>'; 
     4echo '<h1>'. $data['S']['Subject']['title']. ' '. $data['S']['Subject']['code'] .'</h1>'; 
     5 
     6echo '<br />'; 
    57 
    68if ( count($data['Lesson']) < 1 ): 
     
    1113 
    1214foreach($data['Lesson'] as $l): 
    13   echo $html->link('► '.$l['title'], '/lessons/view/'.$l['id']). '<br />'; 
     15  echo $html->link('► '.$l['Lesson']['title'], '/lessons/view/'.$l['Lesson']['id']). '<br />'; 
    1416endforeach; 
    1517 
    16  
     18echo '<br /><br />'; 
    1719 
    1820if ( count($data['Entry']) < 1 ): 
     
    2325 
    2426foreach($data['Entry'] as $e): 
    25   echo $html->link('► '.$e['title'], '/lessons/view/'.$e['id']). '<br />'; 
     27  echo $html->link('► '.$e['Entry']['title'], '/lessons/view/'.$e['Entry']['id']). '<br />'; 
    2628endforeach; 
    2729 
    28  
     30echo '<br /><br />'; 
    2931 
    3032if ( count($data['Share']) < 1 ): 
     
    3537 
    3638foreach($data['Share'] as $s): 
    37   echo $html->link('► '.$s['description'], '/shares/view/'.$s['secret']). '<br />'; 
     39  echo $html->link('► '.$s['Share']['description'], '/shares/view/'.$s['Share']['secret']). '<br />'; 
    3840endforeach; 
    3941