Changeset 246
- Timestamp:
- 02/22/08 13:58:35 (8 months ago)
- Location:
- trunk/app
- Files:
-
- 11 modified
-
app_controller.php (modified) (3 diffs)
-
config/core.php (modified) (1 diff)
-
controllers/commentnews_controller.php (modified) (5 diffs)
-
controllers/entries_controller.php (modified) (3 diffs)
-
controllers/users_controller.php (modified) (1 diff)
-
models/commentnews.php (modified) (1 diff)
-
views/elements/login.ctp (modified) (1 diff)
-
views/elements/login_hide.ctp (modified) (1 diff)
-
views/layouts/portal.ctp (modified) (2 diffs)
-
views/news/view.ctp (modified) (3 diffs)
-
views/users/login.ctp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r242 r246 1 1 <?php 2 /** Manuel Montoya GPL v3 */ 2 /** 3 * Karamelo eLearning Platform 4 * Chipotle Software 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 **/ 3 7 4 8 class AppController extends Controller { … … 10 14 public function beforeFilter() 11 15 { 12 $this->Auth->fields = array('username' => 'username', 'password' => 'p assword');16 $this->Auth->fields = array('username' => 'username', 'password' => 'pwd'); 13 17 $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); 14 18 $this->Auth->loginRedirect = array('controller' => 'news', 'action' => 'display'); … … 16 20 $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 17 21 $this->Auth->authorize = 'controller'; 18 $this->Auth->allow( array('display', 'view', 'register', 'recover' ) );22 $this->Auth->allow( array('display', 'view', 'register', 'recover', 'sendmail') ); 19 23 20 $this->set('cU', $this->Auth->user()); // $cU current user 24 $this->set('cU', $this->Auth->user()); // $cU current user array to use in the views if user logged 25 } 26 27 public function msgFlash($msg, $to) 28 { 29 $this->Session->setFlash($msg); // http://manual.cakephp.org/chapter/session 30 31 $this->redirect($to); 32 33 exit; 21 34 } 22 35 } -
trunk/app/config/core.php
r242 r246 14 14 * In development mode, you need to click the flash message to continue. 15 15 */ 16 Configure::write('debug', 1);16 Configure::write('debug', 2); 17 17 /** 18 18 * Application wide charset encoding -
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 } -
trunk/app/controllers/entries_controller.php
r177 r246 2 2 /** 3 3 * Karamelo E-Learning Platform 4 * Manuel Montoya 2002-200 75 * GPL manuel<at>mononeurona .org4 * Manuel Montoya 2002-2008 5 * GPL manuel<at>mononeurona<punto>org 6 6 */ 7 7 8 8 uses('sanitize'); 9 loadModel('User');10 loadModel('Category');11 9 12 10 class EntriesController extends AppController { 13 11 14 public $helpers = array('Ajax', 'F orm', 'Fck', 'Gags');12 public $helpers = array('Ajax', 'Fck', 'Gags'); 15 13 16 public $components = array('Edublog', 'Portal', 'Search', 'Mypagination'); 14 //public $components = array('Edublog', 'Portal', 'Search', 'Mypagination'); 15 public function isAuthorized() 16 { 17 if ($this->action == 'admin_listing') 18 { 19 if ($this->Auth->user('group_id') == 1) 20 { 21 return true; 22 } 23 else 24 { 25 return false; 26 } 27 } 17 28 29 return true; 30 } 31 18 32 public function results($string) 19 33 { … … 94 108 public function admin_start($order = null) 95 109 { 96 if (!$this-> othAuth->user('id'))110 if (!$this->Auth->user('id')) 97 111 { 98 112 die($this->redirect('/users/general')); // Get Out!!! … … 111 125 public function admin_listing($page=1, $order = null) 112 126 { 113 $order = ($order == null) ? 'Entry.id DESC': 'Entry.'.$order;114 115 127 $this->layout = 'admin'; 116 128 117 //pagination 118 $total_rows = $this->Entry->findCount(array("Entry.user_id"=>$this->othAuth->user('id'))); 119 120 $lmt = 25; // limit news 121 122 $targetpage = "/admin/entries/listing/"; 123 124 $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 125 126 $this->set('pagination', $pagination); 127 128 $conditions = array("Entry.user_id"=>$this->othAuth->user('id')); 129 $conditions = array("Entry.user_id"=>$this->Auth->user('id')); 129 130 130 131 $fields = null; 131 132 132 $ offset = (($page * $lmt) - $lmt);133 $limit = 20; 133 134 134 $limit = $lmt . " OFFSET " . $offset; 135 136 $data = $this->Entry->findAll($conditions, $fields, $order, $limit); 137 138 $this->set('data', $data); 135 $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit)); 139 136 } 140 137 -
trunk/app/controllers/users_controller.php
r244 r246 331 331 { 332 332 $this->layout = 'portal'; 333 334 //$this->Group = new Group; 333 335 334 $conditions = array("id"=>'>1', "id"=>"<5"); 336 // old: $this->set('groups', $this->User->Group->generateList($conditions, 'name', null, '{n}.Group.id', '{n}.Group.name'));337 335 338 336 $this->set('groups', Set::combine($this->User->Group->find('all'), "{n}.Group.id","{n}.Group.name")); 339 //$this->set('Element', $this->Portal->statics()); // Using Portal component 337 //$this->set('Element', $this->Portal->statics()); // Using Portal components 340 338 341 339 } -
trunk/app/models/commentnews.php
r77 r246 15 15 ) 16 16 ); 17 18 public $validate = array( 19 'username' => array( 20 'rule' => array('minLength', 6), 21 'message' => 'Usernames must be at least 6 characters long.' 22 ) 23 ); 17 24 } 18 25 ?> -
trunk/app/views/elements/login.ctp
r241 r246 4 4 <legend> Login</legend> 5 5 <?php 6 echo $form->input('User.username', array('id' => 'user_username', 'size' => '15', 'maxlength'=>'30')). '<br />'; 7 echo $form->input('User.passwd', array('id' => 'user_passwd', 'size' => '9', 'type'=>'password')); 8 ?><br /> 9 Remember me: <?php echo $form->checkbox("User.remember_me");?><br /> 10 11 <?php echo $form->end('Login'); ?> 12 </fieldset> 6 echo $form->input('User.username', array('id' => 'user_username', 'size' => 15, 'maxlength'=> 30)) . '<br />'; 7 echo $form->label('User.pwd', 'Password: '); 8 echo $form->password('User.pwd', array('id' => 'user_pwd', 'size' => 9, 'maxlength' => 9)); 9 echo $form->label('User.remember_me', 'Remember me: '); 10 echo $form->checkbox('User.remember_me'); 11 echo $form->end('Login'); 12 ?> 13 </fieldset> 13 14 14 <p><?php echo $html->link('Join us!', '/users/register'); ?></p> 15 <p><?php echo $html->link('forgot your password?', '/users/recover'); ?></p> 16 </div> 15 <?php 16 echo $html->para(null, $html->link('Join us!', '/users/register')); 17 echo $html->para(null, $html->link('forgot your password?', '/users/recover')); 18 ?> 19 </div> -
trunk/app/views/elements/login_hide.ctp
r242 r246 19 19 <legend>Login</legend> 20 20 <?php 21 echo $form->label( 'User.username', 'Username:') . "<br />";21 echo $form->label('User.username', 'Username:') . "<br />"; 22 22 echo $form->input('User.username', array('size' => 15, 'maxlength'=>30)) . "<br />"; 23 23 24 24 25 echo $form->label('User.p assword', 'Password:') . "<br />";26 echo $form->password('User.p assword', array('size' => 9, 'maxlength'=>9));25 echo $form->label('User.pwd', 'Password:') . "<br />"; 26 echo $form->password('User.pwd', array('size' => 9, 'maxlength' => 9)); 27 27 ?><br /> 28 28 Remember me: <?php echo $form->checkbox("User.cokie", null, array("value" => 1));?><br /> -
trunk/app/views/layouts/portal.ctp
r241 r246 31 31 echo $cU['User']['username'] .'</b></span>'.$html->link('(Logout)', '/users/logout') . ' | '; 32 32 33 if ( $othAuth->user('group_id')< 3 ) // the logged user is teacher or admin?33 if ( $cU['User']['group_id'] < 3 ) // the logged user is teacher or admin? 34 34 { 35 35 echo $html->link('Admin', '/admin/entries/start') . ' | '; … … 100 100 if ( !isset( $cU['User']) ) 101 101 { 102 echo $this->renderElement('login_hide');102 echo $this->renderElement('login_hide'); //login javascript popup 103 103 } 104 104 -
trunk/app/views/news/view.ctp
r242 r246 42 42 echo $news->socialNets($data['News']['id'], $data['News']['title']); // Social nets buttons 43 43 44 if ( $data['News']['comments'] == 1 ) // comments are actived ??44 if ( $data['News']['comments'] == 1 ) // comments in this new are actived ?? 45 45 { 46 46 $i = 1; 47 47 echo '<div id="cnews">'; 48 48 foreach($data["Commentnews"] as $v) 49 {49 { 50 50 $bg = ($i%2==0) ? "#e2e2e2" : "#fff"; 51 51 … … 55 55 echo "</div>"; 56 56 $i++; 57 }57 } 58 58 echo "</div>"; 59 59 ?> 60 60 <p> 61 61 <?php 62 echo $form->create('Commentnews',array("action"=>" add","onsubmit"=>"return validateNew()"));62 echo $form->create('Commentnews',array("action"=>"newcomment","onsubmit"=>"return validateNew()")); 63 63 echo $form->hidden('Commentnews.new_id', $data['News']['id']); 64 64 echo $form->hidden('Commentnews.level', 1); … … 69 69 70 70 <?php 71 if ( isset( $cU ser['User']['id'] ) )71 if ( isset( $cU['User']['id'] ) ) 72 72 { 73 echo $form->hidden('Commentnews.user_id', $cU ser['User']['id']);74 echo $form->hidden('Commentnews.name', $cU ser['User']['username']);75 echo '<b>'. $cU ser['User']['username'] . '</b> writes. ';73 echo $form->hidden('Commentnews.user_id', $cU['User']['id']); 74 echo $form->hidden('Commentnews.name', $cU['User']['username']); 75 echo '<b>'. $cU['User']['username'] . '</b> writes. '; 76 76 } 77 77 else -
trunk/app/views/users/login.ctp
r245 r246 3 3 echo $form->create('User', array('action' => 'login')); 4 4 echo $form->input('username'); 5 echo $form->input('password'); 5 echo $form->label('pwd', 'Password:'); 6 echo $form->password('pwd') . '<br />'; 6 7 echo $form->label('remember_me', 'Remember me:'); 7 8 echo $form->checkbox('remember_me');
