Changeset 631
- Timestamp:
- 07/07/08 20:33:12 (3 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/comments_controller.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/comments_controller.php
r593 r631 1 1 <?php 2 2 /** 3 * Karamelo e-Learning Platform4 * Chipotle Software TM 2002-20085 * GPLv36 * @author Manuel Montoya manuel<arroba>mononeurona<punto>org7 * @version 0.28 * @package Karamelo9 */3 * Karamelo e-Learning Platform 4 * Chipotle Software TM 2002-2008 5 * GPLv3 6 * @author Manuel Montoya manuel<arroba>mononeurona<punto>org 7 * @version 0.2 8 * @package Karamelo 9 */ 10 10 // file : app/controller/comments_controller.php 11 11 … … 14 14 class CommentsController extends AppController { 15 15 16 public $name = 'Comments';16 public $name = 'Comments'; 17 17 18 public $helpers = array('Fck', 'News', 'Time', 'Gags', 'Session');18 public $helpers = array('Fck', 'News', 'Time', 'Gags', 'Session'); 19 19 20 public function beforeFilter()21 {20 public function beforeFilter() 21 { 22 22 parent::beforeFilter(); 23 23 $this->Auth->allow(array('view', 'add')); 24 }24 } 25 25 26 public function view($username=null, $entry_id=null)27 {28 $this->pageTitle = $username . '\'s Comments';26 public function view($username=null, $entry_id=null) 27 { 28 $this->pageTitle = $username . '\'s Comments'; 29 29 30 $conditions = array("status"=>1);30 $conditions = array("status"=>1); 31 31 32 if ($username != null):33 $user_id = $this->User->field('id', array("username"=>$username));34 $conditions["user_id"] = $user_id;35 endif;32 if ($username != null): 33 $user_id = $this->User->field('id', array("username"=>$username)); 34 $conditions["user_id"] = $user_id; 35 endif; 36 36 37 if ($entry_id != null):38 $conditions["id"] = $entry_id;39 endif;37 if ($entry_id != null): 38 $conditions["id"] = $entry_id; 39 endif; 40 40 41 $fields = array("id", "title", "description", "pubdate", "size");42 $order = "id DESC";43 $limit = 12;41 $fields = array("id", "title", "description", "pubdate", "size"); 42 $order = "id DESC"; 43 $limit = 12; 44 44 45 $this->set('username',$username);46 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true));47 }45 $this->set('username',$username); 46 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true)); 47 } 48 48 49 public function add()50 {51 if (!empty($this->data["Comment"]) ):52 53 $this->Sanitize = new Sanitize;49 public function add() 50 { 51 if (!empty($this->data["Comment"]) ): 52 53 $this->Sanitize = new Sanitize; 54 54 55 $this->Sanitize->clean($this->data["Comment"]); //Hopefully this is enough55 $this->Sanitize->clean($this->data["Comment"]); //Hopefully this is enough 56 56 57 $this->Comment->create();57 $this->Comment->create(); 58 58 59 if ($this->Comment->save($this->data["Comment"])):60 $this->msgFlash('Comment added', $this->data['Comment']['redirect_to'].'/#comments');61 endif;62 endif;63 }59 if ($this->Comment->save($this->data["Comment"])): 60 $this->msgFlash('Comment added', $this->data['Comment']['redirect_to'].'/#comments'); 61 endif; 62 endif; 63 } 64 64 65 /** ===== ADMIN METHODS ====== **/65 /** ===== ADMIN METHODS ====== **/ 66 66 67 // change status enabled/disabled actived68 public function admin_change($comment_id, $status)69 {70 $this->data['Comment']['status'] = ($status == 0 ) ? 1 : 0;67 // change status enabled/disabled actived 68 public function admin_change($comment_id, $status) 69 { 70 $this->data['Comment']['status'] = ($status == 0 ) ? 1 : 0; 71 71 72 $this->data['Comment']['id'] = $comment_id;72 $this->data['Comment']['id'] = $comment_id; 73 73 74 if ($this->Comment->save($this->data['Comment'])):75 $this->msgFlash('Comment status changed', '/admin/entries/comments');76 endif;77 }74 if ($this->Comment->save($this->data['Comment'])): 75 $this->msgFlash('Comment status changed', '/admin/entries/comments'); 76 endif; 77 } 78 78 79 public function admin_edit($id=null)80 {81 $this->layout = 'admin';79 public function admin_edit($id=null) 80 { 81 $this->layout = 'admin'; 82 82 83 if ( empty( $this->data["Comment"] ) ):84 $this->data = $this->Comment->read(null, $id);85 else:86 $this->Sanitize = new Sanitize;83 if ( empty( $this->data["Comment"] ) ): 84 $this->data = $this->Comment->read(null, $id); 85 else: 86 $this->Sanitize = new Sanitize; 87 87 88 $this->Sanitize->html($this->data["Comment"]["comment"]);88 $this->Sanitize->html($this->data["Comment"]["comment"]); 89 89 90 if ($this->Comment->save($this->data["Comment"])):91 $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]);92 endif;93 endif;94 }90 if ($this->Comment->save($this->data["Comment"])): 91 $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]); 92 endif; 93 endif; 94 } 95 95 96 public function admin_delete($id)97 {98 if ($this->Comment->del($id)):99 $this->msgFlash('Comment deleted', '/admin/comments/listing');100 endif;101 }96 public function admin_delete($id) 97 { 98 if ($this->Comment->del($id)): 99 $this->msgFlash('Comment deleted', '/admin/comments/listing'); 100 endif; 101 } 102 102 } 103 103 ?>
