Changeset 636
- Timestamp:
- 07/09/08 21:55:19 (3 months ago)
- Location:
- trunk/app
- Files:
-
- 9 modified
-
controllers/comments_controller.php (modified) (3 diffs)
-
controllers/discussions_controller.php (modified) (3 diffs)
-
controllers/news_controller.php (modified) (2 diffs)
-
models/comment.php (modified) (1 diff)
-
models/discussion.php (modified) (1 diff)
-
views/discussions/admin_listing.ctp (modified) (1 diff)
-
views/entries/view.ctp (modified) (1 diff)
-
views/news/display.ctp (modified) (2 diffs)
-
views/news/view.ctp (modified) (2 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 } -
trunk/app/controllers/discussions_controller.php
r540 r636 19 19 20 20 public $components = array('Captcha', 'Email'); 21 22 public $paginate = array('limit' => 10, 'page' => 1, 'order' => array('Discussion.id' => 'DESC')); 21 23 22 24 public function beforeFilter() … … 58 60 $this->data['Discussion']['user_id'] = 0; 59 61 } 60 61 $this->Discussion->create();62 62 63 if ( $this->Discussion->save($this->data ['Discussion']) ): //save the comment63 if ( $this->Discussion->save($this->data) ): //save the comment 64 64 65 65 $user_id = $this->Discussion->News->field('user_id', array('News.id'=>$this->data['Discussion']['new_id'])); … … 121 121 $conditions = null; 122 122 123 $fields = array('Discussion.id','News.id','News.title','Discussion.id','Discussion.comment', 'Discussion.created', 'Discussion.user name', 'Discussion.user_id', 'Discussion.status');123 $fields = array('Discussion.id','News.id','News.title','Discussion.id','Discussion.comment', 'Discussion.created', 'Discussion.user_id', 'Discussion.status', 'User.username'); 124 124 125 125 $order = "Discussion.id DESC"; -
trunk/app/controllers/news_controller.php
r621 r636 32 32 $this->layout = 'portal'; 33 33 34 $this->pageTitle = 'Karamelo::Home'; 35 36 $conditions = array("News.status"=>1); 37 38 $fields = null; 39 40 $order = "News.id DESC"; 41 42 $limit = 8; 43 44 //$this->set('data', $this->News->findAll($conditions, $fields, $order, $limit)); 34 $this->pageTitle = 'News'; 35 45 36 $data = $this->paginate('News', array('News.status = 1')); 46 37 … … 61 52 62 53 $this->News->User->unbindAll(); 63 54 $this->News->Discussion->unbindModel(array('belongsTo'=>array('News'))); 64 55 $conditions = array('News.status'=>1, 'News.id'=>$new_id); 65 56 -
trunk/app/models/comment.php
r282 r636 25 25 26 26 public $validate = array( 27 'comment' => VALID_NOT_EMPTY, //'/[a-z0-9\_\-]{3,}$/i',28 'user_id' => VALID_NOT_EMPTY,27 'comment' => VALID_NOT_EMPTY, //'/[a-z0-9\_\-]{3,}$/i', 28 'user_id' => VALID_NOT_EMPTY, 29 29 'entry_id' => VALID_NOT_EMPTY, 30 30 'username' => VALID_NOT_EMPTY -
trunk/app/models/discussion.php
r537 r636 11 11 public $name = 'Discussion'; 12 12 13 /* public $belongsTo = array('News' => 14 array('className' => 'News', 15 'conditions' => null, 16 'order' => null, 17 'limit' => null, 18 'foreignKey' => 'new_id', 19 'dependent' => true, 20 'exclusive' => false, 21 'finderQuery' => '' 22 ) 23 ); */ 13 public $belongsTo = array( 14 'News' => 15 array('className' => 'News', 16 'conditions' => null, 17 'order' => null, 18 'limit' => null, 19 'foreignKey' => 'new_id', 20 'dependent' => true, 21 'exclusive' => false, 22 'finderQuery' => '' 23 ), 24 'User' => 25 array('className' => 'User', 26 'conditions' => null, 27 'fields' => 'id, username', 28 'order' => null, 29 'limit' => null, 30 'foreignKey' => 'user_id', 31 'dependent' => true, 32 'exclusive' => false, 33 'finderQuery' => '' 34 ) 35 ); 24 36 25 37 public $validate = array( -
trunk/app/views/discussions/admin_listing.ctp
r537 r636 8 8 9 9 foreach ($data as $val): 10 $st = ( $val['Discussion']['status'] == 1 ) ? 'Published' : 'Non published';10 $st = ( $val['Discussion']['status'] == 1 ) ? __('Published', true) : __('Non published', true); 11 11 $tmp = $html->link($val['News']['title'], '/news/view/'.$val['News']['id']) . '<br />'; 12 $tmp .= $val['Discussion']['created'].' <b>'.$val[' Discussion']['username'].' wrote:</b><br />';12 $tmp .= $val['Discussion']['created'].' <b>'.$val['User']['username'].' wrote:</b><br />'; 13 13 $tmp .= $html->para(null, $val['Discussion']['comment']); 14 14 $tmp .= $html->para(null, $html->link($st, '/admin/discussions/change/'.$val['Discussion']['id'].'/'.$val['Discussion']['status'])); -
trunk/app/views/entries/view.ctp
r635 r636 49 49 echo $form->hidden('Comment.user_id', array('value' => $session->read('Auth.User.id'))); 50 50 echo $form->hidden('Comment.username', array('value' => $session->read('Auth.User.username'))); 51 echo $session->read('Auth.User.username') . " writes:";51 echo $session->read('Auth.User.username') . ' '. __('writes', true) .' '; 52 52 53 echo $form->label('Comment.comment', 'Comment:' );54 echo $form->textarea('Comment.comment', array( "rows" => 10, "cols"=> 50));53 echo $form->label('Comment.comment', __('Comment',true)) .'<br />'; 54 echo $form->textarea('Comment.comment', array('rows' => 10, 'cols' => 50)); 55 55 echo $form->error('Comment.comment', 'A comment is required.'); 56 56 -
trunk/app/views/news/display.ctp
r621 r636 1 1 <?php 2 // die(debug($_SERVER));2 //die(debug($data)); 3 3 4 4 echo $html->div('title_portal', __('News on Campus', true)); … … 26 26 27 27 if ($val['News']['comments'] == 1 ): // comments enabled on this new 28 e cho $html->para(null, $html->link(__('Put your comment', true), '/news/view/'.$val['News']['id']));28 e($html->para(null,$html->link(__('Put your comment', true).' ('. count($val['Discussion']).')','/news/view/'.$val['News']['id']))); 29 29 endif; 30 30 ?> -
trunk/app/views/news/view.ctp
r620 r636 1 1 <?php 2 // die(debug($data));2 //die(debug($data)); 3 3 4 4 echo $html->div('news_title', $html->link($data['News']['title'], '/news/view/'. $data['News']['id'])); … … 47 47 $bg = ($i%2 == 0) ? "#e2e2e2" : "#fff"; 48 48 49 $tmp = $html->para(null,$time->timeAgoInWords($v['created']) . ' <b>'. $v[' username'] . '</b> wrote:<br />', array('style'=>'font-size:8pt;font-family:Georgia;'));49 $tmp = $html->para(null,$time->timeAgoInWords($v['created']) . ' <b>'. $v['User']['username'] . '</b> wrote:<br />', array('style'=>'font-size:8pt;font-family:Georgia;')); 50 50 $tmp .= $html->para(null, $v['comment']); 51 51 echo $html->div('divblock', $tmp, array('style'=>'background-color:'.$bg));
