Changeset 632
- Timestamp:
- 07/07/08 22:23:03 (5 months ago)
- Location:
- trunk/app
- Files:
-
- 5 modified
-
controllers/annotations_controller.php (modified) (3 diffs)
-
controllers/lessons_controller.php (modified) (1 diff)
-
models/annotation.php (modified) (2 diffs)
-
models/lesson.php (modified) (1 diff)
-
views/lessons/view.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/annotations_controller.php
r630 r632 16 16 public function add() 17 17 { 18 if (!empty($this->data[' CommentsLesson']) ):18 if (!empty($this->data['Annotation']) ): 19 19 20 20 $this->Sanitize = new Sanitize; 21 21 22 $this->Sanitize->clean($this->data['CommentsLesson']); 23 24 $this->Comment->create(); 25 26 if ($this->Comment->save($this->data['CommenttsLesson'])): 27 $this->msgFlash(__('Comment added', true), $this->data['CommenttsLesson']['redirect_to'].'/#comments'); 22 $this->Sanitize->clean($this->data['Annotation']); 23 24 $this->data['Annotation']['user_id'] = $this->Auth->user('id'); 25 26 $this->Annotation->create(); 27 28 if ($this->Annotation->save($this->data['Annotation'])): 29 $this->msgFlash(__('Comment added', true), $this->data['Annotation']['redirect_to'].'/#comments'); 28 30 endif; 29 31 endif; … … 33 35 34 36 // change status enabled/disabled actived 35 public function admin_change($ comment_id, $status)37 public function admin_change($annotation_id, $status) 36 38 { 37 $this->data[' Comment']['status'] = ($status == 0 ) ? 1 : 0;39 $this->data['Annotation']['status'] = ($status == 0 ) ? 1 : 0; 38 40 39 $this->data[' Comment']['id'] = $comment_id;41 $this->data['Annotation']['id'] = $annotation_id; 40 42 41 if ($this-> Comment->save($this->data['Comment'])):42 $this->msgFlash(' Commentstatus changed', '/admin/entries/comments');43 if ($this->Annotation->save($this->data['Annotation'])): 44 $this->msgFlash('Annotation status changed', '/admin/entries/comments'); 43 45 endif; 44 46 } … … 48 50 $this->layout = 'admin'; 49 51 50 if ( empty( $this->data[" Comment"] ) ):51 $this->data = $this-> Comment->read(null, $id);52 if ( empty( $this->data["Annotation"] ) ): 53 $this->data = $this->Annotation->read(null, $id); 52 54 else: 53 55 $this->Sanitize = new Sanitize; 54 56 55 $this->Sanitize->html($this->data[" Comment"]["comment"]);57 $this->Sanitize->html($this->data["Annotation"]["comment"]); 56 58 57 if ($this-> Comment->save($this->data["Comment"])):58 $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]);59 if ($this->Annotation->save($this->data["Annotation"])): 60 $this->msgFlash('Annotation saved!', '/admin/comments/edit/'.$this->data["Annotation"]["id"]); 59 61 endif; 60 endif;62 endif; 61 63 } 62 64 63 public function admin_delete($ id)65 public function admin_delete($annotation_id) 64 66 { 65 if ($this-> Comment->del($id)):66 $this->msgFlash('Commentdeleted', '/admin/comments/listing');67 if ($this->Annotation->del($annotation_id)): 68 $this->msgFlash('Annotation deleted', '/admin/comments/listing'); 67 69 endif; 68 70 } -
trunk/app/controllers/lessons_controller.php
r625 r632 34 34 $this->LessonTitle = 'Lesson'; 35 35 36 $conditions = array( "Lesson.id"=>$id, "Lesson.status"=>1);36 $conditions = array('Lesson.id'=>$id, 'Lesson.status'=>1); 37 37 38 $fields = array( "Lesson.id", "Lesson.title", "Lesson.body", "Lesson.created", "Lesson.modified");38 $fields = array('Lesson.id', 'Lesson.title', 'Lesson.body', 'Lesson.created', 'Lesson.modified', 'Annotation.comment'); 39 39 40 40 $order = null; 41 41 42 $this->set('data', $this->Lesson->find($conditions , $fields, $order, null, null, 0));42 $this->set('data', $this->Lesson->find($conditions)); 43 43 } 44 44 -
trunk/app/models/annotation.php
r630 r632 13 13 'conditions' => '', 14 14 'order' => '', 15 'foreignKey' => 'user_id'15 'foreignKey' => 'user_id' 16 16 ), 17 17 'Lesson' => … … 19 19 'conditions' => '', 20 20 'order' => null, 21 'foreignKey' => 'lersson_id'21 'foreignKey' => 'lesson_id' 22 22 ) 23 23 ); 24 24 25 25 public $validate = array( 26 'comment' => VALID_NOT_EMPTY, 27 'user_id' => VALID_NOT_EMPTY 26 'comment' => VALID_NOT_EMPTY, 27 'user_id' => VALID_NOT_EMPTY, 28 'lesson_id' => VALID_NOT_EMPTY 28 29 ); 29 30 /* -
trunk/app/models/lesson.php
r630 r632 25 25 ); 26 26 27 public $hasMany = array(' CommentsLesson' =>28 array('className' => ' CommentsLesson',27 public $hasMany = array('Annotation' => 28 array('className' => 'Annotation', 29 29 'conditions' => null, 30 'order' => ' CommentsLesson.created',30 'order' => 'Annotation.created', 31 31 'limit' => null, 32 32 'foreignKey' => 'lesson_id', -
trunk/app/views/lessons/view.ctp
r630 r632 1 1 <?php 2 //die(debug($data)); 2 3 echo '<h1>' .$data['Lesson']['title'] . '</h1>'; 3 4 echo $html->div(null, $data['Lesson']['body']); 4 5 echo $html->div(null, __('Last edition', true). ': '.$data['Lesson']['created']); 5 6 6 echo $form->create(' CommentsLesson', array('onsubmit'=>'return chkForm()', 'action'=>'add'));7 echo $form->hidden(' CommentsLesson.redirect_to', array('value'=>'/lessons/view/'.$blog['User']['username'].'/'.$data['Lesson']['id']));8 echo $form->hidden(' CommentsLesson.lesson_id', array('value'=>$data['Lesson']['id']));7 echo $form->create('Annotation', array('onsubmit'=>'return chkForm()', 'action'=>'add')); 8 echo $form->hidden('Annotation.redirect_to', array('value'=>'/lessons/view/'.$blog['User']['username'].'/'.$data['Lesson']['id'])); 9 echo $form->hidden('Annotation.lesson_id', array('value'=>$data['Lesson']['id'])); 9 10 10 11 if ( $session->check('Auth.User') ): … … 15 16 echo $session->read('Auth.User.username') . ' ' . __('writes', true); 16 17 17 echo $form->label(' CommentsLesson.comment', 'Comment');18 echo $form->textarea(' CommentsLesson.comment', array('rows' => 10, 'cols' => 50));19 echo $form->error(' CommentsLesson.comment', 'A comment is required.');18 echo $form->label('Annotation.comment', 'Comment'); 19 echo $form->textarea('Annotation.comment', array('rows' => 10, 'cols' => 50)); 20 echo $form->error('Annotation.comment', 'A comment is required.'); 20 21 21 22 echo $form->end(__('Send', true));
