Changeset 636 for trunk/app/controllers/comments_controller.php
- Timestamp:
- 07/09/08 21:55:19 (5 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/comments_controller.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/comments_controller.php
r635 r636 23 23 $this->Auth->allow(array('view', 'add')); 24 24 } 25 26 public function view($username=null, $entry_id=null) 27 { 28 $this->pageTitle = $username . '\'s Comments'; 29 30 $conditions = array("status"=>1); 31 32 if ($username != null): 33 $user_id = $this->User->field('id', array("username"=>$username)); 34 $conditions["user_id"] = $user_id; 35 endif; 36 37 if ($entry_id != null): 38 $conditions["id"] = $entry_id; 39 endif; 40 41 $fields = array("id", "title", "description", "pubdate", "size"); 42 $order = "id DESC"; 43 $limit = 12; 44 45 $this->set('username',$username); 46 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true)); 47 } 48 25 49 26 public function add() 50 27 { 51 if (!empty($this->data[ "Comment"]) ):52 28 if (!empty($this->data['Comment']) ): 29 53 30 $this->Sanitize = new Sanitize; 54 $this->Sanitize->clean($this->data["Comment"]); //Hopefully this is enough 55 $this->Comment->create(); 56 57 if ($this->Comment->save($this->data["Comment"])): 31 $this->Sanitize->clean($this->data['Comment']); //Hopefully this is enough 32 33 if ($this->Comment->save($this->data)): 58 34 $this->msgFlash(__('Comment added', true), $this->data['Comment']['redirect_to'].'/#comments'); 35 else: 36 $this->flash('Problem, please report', $this->data['Comment']['redirect_to'].'/#comments'); 59 37 endif; 60 38 endif; … … 70 48 $this->data['Comment']['id'] = $comment_id; 71 49 72 if ($this->Comment->save($this->data ['Comment'])):73 $this->msgFlash('Comment status changed', '/admin/entries/comments');50 if ($this->Comment->save($this->data)): 51 $this->msgFlash('Comment status changed', '/admin/entries/comments'); 74 52 endif; 75 53 } … … 80 58 81 59 if ( empty( $this->data["Comment"] ) ): 82 $this->data = $this->Comment->read(null, $id);60 $this->data = $this->Comment->read(null, $id); 83 61 else: 84 $this->Sanitize = new Sanitize;62 $this->Sanitize = new Sanitize; 85 63 86 $this->Sanitize->html($this->data["Comment"]["comment"]);64 $this->Sanitize->html($this->data["Comment"]["comment"]); 87 65 88 if ($this->Comment->save($this->data["Comment"])):89 $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]);90 endif;91 endif;66 if ($this->Comment->save($this->data)): 67 $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]); 68 endif; 69 endif; 92 70 } 93 71 94 public function admin_delete($ id)72 public function admin_delete($comment_id) 95 73 { 96 if ($this->Comment->del($ id)):97 $this->msgFlash('Comment deleted', '/admin/comments/listing');74 if ($this->Comment->del($comment_id)): 75 $this->msgFlash('Comment deleted', '/admin/comments/listing'); 98 76 endif; 99 77 }
