Changeset 246 for trunk/app/controllers/commentnews_controller.php
- Timestamp:
- 02/22/08 13:58:35 (11 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/commentnews_controller.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/commentnews_controller.php
r77 r246 1 1 <?php 2 2 /** 3 Chipotle Software 4 GPL v3 3 * Chipotle Software 2002-2008 4 * GPLv3 manuel<arroba>mononeurona<punto>org 5 5 **/ 6 6 //File: /app/controllers/comentnews_controller.php 7 7 8 8 uses('sanitize'); 9 loadModel('News');10 loadModel('User');11 9 12 10 class CommentnewsController extends AppController 13 11 { 14 public $name = 'Commentnews';12 public $name = 'Commentnews'; 15 13 16 public $helpers = array('Form','Javascript', 'Ajax', 'Time', 'Gags');14 public $helpers = array('Javascript', 'Ajax', 'Time', 'Gags'); 17 15 18 public $components = array('Security', 'Captcha', 'Email'); 16 public $components = array('Security', 'Captcha', 'Email'); 17 18 public function isAuthorized() 19 { 20 if ( $this->Auth->user('group') != 1 ) 21 { 22 $this->Auth->deny(array('admin_delete', 'admin_listing', 'admin_edit')); 23 } 24 if ( $this->Auth->user() ) 25 { 26 $this->Auth->allow(array('newcomment')); 27 } 28 return true; 29 } 19 30 20 public function add() 21 { 22 if ( ! empty($this->data["Commentnews"]) ) 23 { 24 $this->Sanitize = new Sanitize; 31 public function newcomment() 32 { 33 die('sadsadasdsa'); 34 die(var_dump($this->data)); 35 36 if ( !empty($this->data["Commentnews"]) ) 37 { 38 $this->Sanitize = new Sanitize; 25 39 26 $this->Sanitize->cleanArray($this->data);40 $this->Sanitize->cleanArray($this->data); 27 41 28 $this->data["Commentnews"]["comment"] = nl2br($this->data["Commentnews"]["comment"]);42 $this->data["Commentnews"]["comment"] = nl2br($this->data["Commentnews"]["comment"]); 29 43 30 if ( $this->othAuth->user('id') )31 {32 $this->data["Commentnews"]["user_id"] = $this-> othAuth->user('id');33 }34 else35 {36 if ($this->data["Commentnews"]["captcha"] != $this->Session->read('captcha') || strlen($this->data["Commentnews"]["captcha"]) < 3)37 {38 $this->flash('Code incorrect, please pulse back button', '/news/display/'.$this->data["Commentnews"]["new_id"], 20); //wrong captcha, spambot ??39 exit();40 }44 if ( $this->Auth->user('id') ) 45 { 46 $this->data["Commentnews"]["user_id"] = $this->Auth->user('id'); 47 } 48 else 49 { 50 if ($this->data["Commentnews"]["captcha"] != $this->Session->read('captcha') || strlen($this->data["Commentnews"]["captcha"]) < 3) 51 { 52 $this->flash('Code incorrect, please pulse back button', '/news/view/'.$this->data["Commentnews"]["new_id"], 6); // wrong captcha, spambot ?? 53 exit(); 54 } 41 55 42 $this->data["Commentnews"]["user_id"] = 0;43 }56 $this->data["Commentnews"]["user_id"] = 0; 57 } 44 58 45 if ( $this->Commentnews->save($this->data["Commentnews"]) ) //save the comment46 {47 $this->News = new News;59 if ( $this->Commentnews->save($this->data["Commentnews"]) ) //save the comment 60 { 61 $this->News = new News; 48 62 49 $user_id = $this->News->field('user_id', array("News.id"=>$this->data["Commentnews"]["new_id"]));63 $user_id = $this->News->field('user_id', array("News.id"=>$this->data["Commentnews"]["new_id"])); 50 64 51 $this->sendMail($user_id, $this->data["Commentnews"]["new_id"]);65 $this->sendMail($user_id, $this->data["Commentnews"]["new_id"]); 52 66 53 $this->redirect('/news/display/'.$this->data["Commentnews"]["new_id"].'#cnews'); 54 } 67 $this->redirect('/news/view/'.$this->data["Commentnews"]["new_id"].'#cnews'); 55 68 } 69 } 56 70 } 57 71 … … 70 84 $data = $this->User->find(array("User.id"=>$user_id), $fields); 71 85 //exit($data["User"]["email"]); 72 $this->Email->sender = ':: MonoNeurona.org::';86 $this->Email->sender = '::Karamelo::'; 73 87 $this->Email->to = $data["User"]["email"]; 74 $this->Email->subject = ':: MonoNeurona.org:: New comment on your front-page New';88 $this->Email->subject = '::Karamelo:: New comment on your front-page New'; 75 89 $this->Email->sendAs = 'html'; 76 90 $this->Email->template = null; … … 80 94 //Note: the text can be an array, each element will appear as a 81 95 //seperate line in the message body. 82 $url = ' <img src="http://www.mononeurona.org/img/admin/new_user.jpg" alt="MonoNeurona" title="MonoNeurona" /><br />';96 $url = 'Karamelo<br />'; 83 97 $url .= '<h2>'.$data["User"]["username"].'</h2><p>You have a new comment in your new: '; 84 $url .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/news/ display/'.$new_id.'">';85 $url .= 'http://'.$_SERVER['SERVER_NAME'].'/news/ display/'.$new_id.'</a></p>';98 $url .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$new_id.'">'; 99 $url .= 'http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$new_id.'</a></p>'; 86 100 87 101 //die($url); … … 101 115 public function admin_listing($limit=20) 102 116 { 103 $this->layout = 'admin'; 104 $this->pageTitle = 'Comments on Blogs'; 117 $this->layout = 'admin'; 118 119 $this->pageTitle = 'Comments on Blogs'; 105 120 106 $conditions = null; 107 $fields = array("Commentnews.id", "News.title", "Commentnews.id", "Commentnews.comment", "Commentnews.created", "Commentnews.name", "Commentnews.user_id"); 108 $order = "Commentnews.id DESC"; 121 $conditions = null; 122 123 $fields = array("Commentnews.id", "News.title", "Commentnews.id", "Commentnews.comment", "Commentnews.created", "Commentnews.name", "Commentnews.user_id"); 124 $order = "Commentnews.id DESC"; 109 125 110 $this->set('data', $this->Commentnews->findAll($conditions, $fields, $order, $limit, null, 2));126 $this->set('data', $this->Commentnews->findAll($conditions, $fields, $order, $limit, null, 2)); 111 127 } 112 128 … … 136 152 public function admin_delete($id) 137 153 { 138 // deletes task fromdatabase139 $this->Commentnews->del($id);140 $this->msgFlash('Comment deleted', '/admin/commentnews/listing');154 // deletes comment on database 155 $this->Commentnews->del($id); 156 $this->msgFlash('Comment deleted', '/admin/commentnews/listing'); 141 157 } 142 158 }
