Changeset 400
- Timestamp:
- 04/15/08 23:02:23 (9 months ago)
- Location:
- trunk/app
- Files:
-
- 1 added
- 11 modified
-
app_controller.php (modified) (2 diffs)
-
controllers/acquaintances_controller.php (modified) (3 diffs)
-
controllers/answers_controller.php (modified) (2 diffs)
-
controllers/commentnews_controller.php (modified) (4 diffs)
-
controllers/entries_controller.php (modified) (3 diffs)
-
controllers/news_controller.php (modified) (4 diffs)
-
controllers/newsletters_controller.php (modified) (3 diffs)
-
controllers/replies_controller.php (modified) (2 diffs)
-
controllers/wikis_controller.php (modified) (1 diff)
-
views/elements/email/text/newcomment.ctp (added)
-
views/news/display.ctp (modified) (3 diffs)
-
views/news/view.ctp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r374 r400 1 1 <?php 2 2 /** 3 * Karamelo eLearning Platform 4 * Chipotle Software 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 **/ 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 //file: app_controller.php 7 11 8 12 class AppController extends Controller { … … 24 28 $this->set('cU', $this->Auth->user()); // $cU current user array to use in the views if user logged 25 29 } 26 30 27 31 public function msgFlash($msg, $to) 28 32 { -
trunk/app/controllers/acquaintances_controller.php
r393 r400 8 8 * @package Karamelo 9 9 */ 10 // file: app/controllers/acquaitances_controller.php 10 11 11 12 uses('sanitize'); … … 50 51 /** === ADMIN METHODS === ***/ 51 52 public function admin_listing() 52 { 53 $this->layout = 'admin'; 53 { 54 $this->layout = 'admin'; 55 56 $conditions = array("user_id" => $this->Auth->user('id')); 54 57 55 $conditions = array("user_id" => $this->Auth->user('id'));58 //$fields = array("id", "title", "description", "pubdate", "size"); 56 59 57 //$fields = array("id", "title", "description", "pubdate", "size"); 58 59 $this->set('data', $this->Acquaintance->findAll($conditions)); 60 $this->set('data', $this->Acquaintance->findAll($conditions)); 60 61 } 61 62 62 63 public function admin_add($id = null) 63 64 { 65 $this->layout = 'admin'; 66 64 67 if (empty($this->data["Acquaintance"])) 65 68 { 66 $this->layout = 'admin';67 68 69 $this->Acquaintance->id = $id; 69 70 … … 88 89 89 90 public function admin_edit($id = null) 90 { 91 { 92 $this->layout = 'admin'; 93 91 94 if (empty($this->data["Acquaintance"])) 92 95 { 93 $this->layout = 'admin';94 95 96 $this->data = $this->Acquaintance->read(null, $id); 96 97 } -
trunk/app/controllers/answers_controller.php
r393 r400 63 63 public function admin_edit($answer_id = null) 64 64 { 65 $this->layout = 'admin';66 67 65 if (empty($this->data["Answer"])) 68 66 { … … 99 97 public function admin_questions($test_id) 100 98 { 101 $this->layout = 'admin';102 103 99 $this->pageTitle = 'Answers'; 104 100 -
trunk/app/controllers/commentnews_controller.php
r394 r400 12 12 uses('sanitize'); 13 13 14 App::import('Model','User'); 15 14 16 class CommentnewsController extends AppController 15 17 { … … 19 21 20 22 public $components = array('Captcha'); 23 24 public function beforeFilter() 25 { 26 $this->Auth->allow(array('captcha', 'insert', 'rss')); 27 parent::beforeFilter(); 28 } 21 29 22 30 public function isAuthorized() … … 35 43 { 36 44 37 die(var_dump($this->data));45 //die(var_dump($this->data)); 38 46 39 if ( !empty($this->data[ "Commentnews"]) )47 if ( !empty($this->data['Commentnews']) ) 40 48 { 41 49 $this->Sanitize = new Sanitize; 42 50 43 $this->Sanitize->clean($this->data );51 $this->Sanitize->clean($this->data['Commentnews']); 44 52 45 $this->data[ "Commentnews"]["comment"] = nl2br($this->data["Commentnews"]["comment"]);53 $this->data['Commentnews']['comment'] = nl2br($this->data['Commentnews']['comment']); 46 54 47 55 if ( $this->Auth->user('id') ) 48 56 { 49 $this->data["Commentnews"]["user_id"] = $this->Auth->user('id');57 $this->data['Commentnews']['user_id'] = $this->Auth->user('id'); 50 58 } 51 59 else … … 57 65 } 58 66 59 $this->data[ "Commentnews"]["user_id"] = 0;67 $this->data['Commentnews']['user_id'] = 0; 60 68 } 61 69 62 70 $this->Commentnews->create(); 63 71 64 if ( $this->Commentnews->save($this->data[ "Commentnews"]) )//save the comment72 if ( $this->Commentnews->save($this->data['Commentnews']) ) //save the comment 65 73 { 66 $ this->News = new News;74 $user_id = $this->Commentnews->News->field('user_id', array('News.id'=>$this->data['Commentnews']['new_id'])); 67 75 68 $ user_id = $this->News->field('user_id', array("News.id"=>$this->data["Commentnews"]["new_id"]));76 $this->__sendMail($user_id, $this->data['Commentnews']['new_id']); 69 77 70 $this->sendMail($user_id, $this->data["Commentnews"]["new_id"]); 71 72 $this->redirect('/news/view/'.$this->data["Commentnews"]["new_id"].'#cnews'); 73 } 78 $this->redirect('/news/view/'.$this->data['Commentnews']['new_id'].'#cnews'); 79 } 80 } 81 } 82 83 /* == PRIVATE == **/ 84 private function _sendEmail($user_id, $new_id) 85 { 86 $User = new User; 87 88 $this->User->unbindModel(array("hasMany"=>array('Entry', 'Lesson', 'Faq', 'Vclassroom', 'Acquaintance'))); 89 90 $user = $this->User->find(array('User.id'=>$user_id), array("User.name", "User.email")); 91 92 $this->layout = 'newcomment'; 93 $this->Email->to = $user['email']; 94 $this->Email->subject = 'Karamelo e-Learning:: New comment'; 95 $this->Email->replyTo = 'support@karamelo.org'; 96 $this->Email->from = 'Chipotle-software.com'; 97 $this->Email->template = 'confirmation'; // note no '.ctp' 98 //Send as 'html', 'text' or 'both' (default is 'text') 99 $this->Email->sendAs = 'text'; // because we like to send pretty mail 100 //Set view variables as normal 101 $this->set('name', $user['name']); 102 $this->set('new_id', $new_id); 103 104 //Do not pass any args to send() 105 if ( $this->Email->send() ) 106 { 107 return true; 108 } 109 else 110 { 111 return false; 74 112 } 75 113 } 76 114 77 115 public function captcha() 78 116 { 79 117 return $this->Captcha->render(); 80 118 } 81 82 private function sendMail($user_id, $new_id) 83 { 84 85 $this->User = new User; 86 87 $fields = array('email', 'username'); 88 89 $data = $this->User->find(array("User.id"=>$user_id), $fields); 90 //exit($data["User"]["email"]); 91 $this->Email->sender = '::Karamelo::'; 92 $this->Email->to = $data["User"]["email"]; 93 $this->Email->subject = '::Karamelo:: New comment on your front-page New'; 94 $this->Email->sendAs = 'html'; 95 $this->Email->template = null; 96 $this->Email->from = 'noreply@mononeurona.org'; 97 //$this->set('foo', 'Cake tastes good today'); 98 //Set the body of the mail as we send it. 99 //Note: the text can be an array, each element will appear as a 100 //seperate line in the message body. 101 $url = 'Karamelo<br />'; 102 $url .= '<h2>'.$data["User"]["username"].'</h2><p>You have a new comment in your new: '; 103 $url .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$new_id.'">'; 104 $url .= 'http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$new_id.'</a></p>'; 105 106 //die($url); 107 108 if ( $this->Email->send($url) ) 109 { 110 return true; 111 } 112 else 113 { 114 115 exit("Error!!"); 116 } 117 } 118 119 119 120 /*****#### ADMIN METHODS #####*****/ 120 121 public function admin_listing($limit=20) -
trunk/app/controllers/entries_controller.php
r394 r400 73 73 74 74 public function admin_add() 75 { 76 $this->layout = 'admin';75 { 76 $this->layout = 'admin'; 77 77 78 78 $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); … … 104 104 public function admin_start($order = null) 105 105 { 106 if (!$this->Auth->user('id')) 107 { 108 die($this->redirect('/users/general')); // Get Out!!! 109 } 106 $this->layout = 'admin'; 107 108 if ( !$this->Auth->user()) 109 { 110 $this->redirect('/users/login'); // Get Out!!! 111 } 110 112 111 $this->layout = 'admin'; 112 $this->pageTitle = 'Entries'; 113 114 $conditions = null; 115 $fields = array("id", "title", "body", "subject_id"); 116 $data = $this->Entry->findAll( $conditions, $fields, $order, null, null, true ); 117 118 $this->set('data', $data); 119 } 113 $this->pageTitle = 'Welcome! '. $this->Auth->user('username'); 114 } 120 115 121 public function admin_listing($page=1, $order = null) 122 { 123 $this->layout = 'admin'; 116 public function admin_listing($page=1, $order = null) 117 { 118 $this->layout = 'admin'; 119 120 $conditions = array("Entry.user_id"=>$this->Auth->user('id')); 124 121 125 $conditions = array("Entry.user_id"=>$this->Auth->user('id'));122 $fields = null; 126 123 127 $fields = null;124 $limit = 20; 128 125 129 $limit = 20; 130 131 $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit)); 132 } 126 $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit)); 127 } 133 128 134 public function admin_edit($id = null)135 {136 $this->layout = 'admin';137 138 $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')),"{n}.Subject.id","{n}.Subject.title"));129 public function admin_edit($id = null) 130 { 131 $this->layout = 'admin'; 132 133 $this->set('subjects',Set::combine($this->Entry->Subject->find('all',array('order'=>'title')),"{n}.Subject.id","{n}.Subject.title")); 139 134 140 if (empty($this->data[ "Entry"]))135 if (empty($this->data['Entry'])) 141 136 { 142 137 $this->data = $this->Entry->read(null, $id); … … 146 141 $this->Sanitize = new Sanitize; 147 142 148 $this->Sanitize->paranoid($this->data[ "Entry"]["title"]);143 $this->Sanitize->paranoid($this->data['Entry']['title']); 149 144 150 $this->Sanitize->html($this->data[ "Entry"]["body"]);145 $this->Sanitize->html($this->data['Entry']['body']); 151 146 152 147 if ($this->Entry->save($this->data['Entry'])) -
trunk/app/controllers/news_controller.php
r336 r400 1 1 <?php 2 2 /** 3 * Karamelo E-Learning Platform 4 * Manuel Montoya 2002-2008 5 * GPLv3 License manuel<at>mononeurona<punto>org 6 * Chipotle Software 7 */ 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 //file: app/controllers/news_controller.php 8 11 9 12 uses('Sanitize'); … … 11 14 class NewsController extends AppController { 12 15 13 public $helpers = array('Ajax', 'Fck', 'News', 'Time', 'Gags');14 15 public $components = array('Portal');16 17 public function beforeFilter()16 public $helpers = array('Ajax', 'Fck', 'News', 'Time', 'Gags'); 17 18 public $components = array('Portal'); 19 20 public function beforeFilter() 18 21 { 19 $this->Auth->allow(array('view', 'display', 'rss' ));22 $this->Auth->allow(array('view', 'display', 'rss', 'category')); 20 23 parent::beforeFilter(); 21 24 } … … 94 97 } 95 98 96 public function category($id =null, $order=null)99 public function category($id=null, $order=null) 97 100 { 98 101 $this->layout = 'portal'; 99 102 100 if ($id != null)101 { 102 $conditions["Theme.id"] = $id;103 if ($id == null) 104 { 105 $this->redirect('/'); 103 106 } 107 108 $conditions = array('Theme.id' => $id); 104 109 105 110 $fields = array("News.id", "News.title", "Theme.theme", "Theme.img"); … … 107 112 $this->pageTitle = 'News Category'; 108 113 109 $limit = null; 110 111 $this->News->bindModel( 112 array('belongsTo' => array( 113 'Theme' => array( 114 'className' => 'Theme' 115 ) 116 ) 117 ) 118 ); 114 $limit = 30; 119 115 120 116 $this->set('data', $this->News->findAll($conditions, $fields, $order, $limit)); 121 117 122 $this-> set('Element', $this->Portal->statics());// Charge Portal components aka Sidebars118 $this->Portal->statics(); // Charge Portal components aka Sidebars 123 119 } 124 120 -
trunk/app/controllers/newsletters_controller.php
r361 r400 66 66 } 67 67 68 /*** 69 === ADMIN METHODS 70 ***/ 68 /*** === ADMIN METHODS ***/ 71 69 72 70 public function admin_add() 73 71 { 74 $this->layout = 'admin';75 76 72 if (!empty($this->data['Newsletter'])) 77 73 { … … 150 146 public function admin_edit($newsletter_id=null) 151 147 { 152 $this->layout = 'admin';153 154 148 if (!empty($this->data['Newsletter'])) 155 149 { … … 186 180 $this->pageTitle = $this->Auth->user('username') . '\'s News'; 187 181 188 $this->layout = 'admin';189 190 182 $conditions = null; //array("Newsletter.status" => 1); 191 183 $fields = array("id", "title", "body", "created", "status", "delivered"); -
trunk/app/controllers/replies_controller.php
r333 r400 34 34 $this->Edublog->blog($user_id); 35 35 36 $conditions = array( "Reply.status"=>1, "Reply.id"=>$topic_id);36 $conditions = array('Reply.status'=>1, 'Reply.id'=>$topic_id); 37 37 $fields = null; 38 $order = "Reply.created DESC";38 $order = 'Reply.created DESC'; 39 39 40 40 $this->set('data', $this->Reply->find($conditions, $fields, $order)); … … 60 60 } 61 61 62 /** 63 --- ADMIN METHODS --- 64 **/ 62 /** --- ADMIN METHODS --- **/ 65 63 66 64 public function admin_edit($id = null) -
trunk/app/controllers/wikis_controller.php
r371 r400 1 1 <?php 2 2 /** 3 * Karamelo E-Learning Platform -- Chipotle Software TM 4 * Manuel Montoya 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 */ 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 //File: /app/controllers/commentnews_controller.php 7 11 8 12 uses('sanitize'); -
trunk/app/views/news/display.ctp
r399 r400 1 1 <?php 2 // die(debug($data));2 // die(debug($data)); 3 3 4 4 echo $html->div('title_section', 'News'); … … 6 6 foreach ($data as $val) 7 7 { 8 //echo $ajax->divEnd('wrapnew'); 9 echo $html->div('news_title', $html->link($val['News']['title'], '/news/view/'. $val['News']['id'])); 8 $tmp = $html->div('news_title', $html->link($val['News']['title'], '/news/view/'. $val['News']['id'])); 10 9 11 echo$html->div('news_date', $val['News']['created']);10 $tmp .= $html->div('news_date', $val['News']['created']); 12 11 13 echo$html->div('news_body',12 $tmp .= $html->div('news_body', 14 13 $html->div('img_new', $html->link( 15 $html->image('themes/'.$ data['Theme']['img'],16 array('alt'=>$ data['Theme']['theme'],17 'title'=>$ data['Theme']['theme'],14 $html->image('themes/'.$val['Theme']['img'], 15 array('alt'=>$val['Theme']['theme'], 16 'title'=>$val['Theme']['theme'], 18 17 'class'=>'themes') 19 18 ), 20 '/news/category/'.$ data['News']['theme_id'], null, null, false19 '/news/category/'.$val['News']['theme_id'], null, null, false 21 20 ) 22 21 ) … … 24 23 25 24 26 echo$val['News']['body'];25 $tmp .= $val['News']['body']; 27 26 28 27 if (strlen($val['News']['reference']) > 5 ) // the reference 29 28 { 30 echo $html->div(null, $html->link('Reference:', $val['News']['reference']));29 $tmp .= $html->div(null, $html->link('Reference', $val['News']['reference'])); 31 30 } 32 33 echo '</div>';31 32 echo $html->div('wrapnew', $tmp); 34 33 } 35 34 ?> -
trunk/app/views/news/view.ctp
r399 r400 59 59 <p> 60 60 <?php 61 echo $form->create('Commentnews', array("action"=>"add","onsubmit"=>"return validateNew()"));62 echo $form->hidden('Commentnews.new_id', $data['News']['id']);63 echo $form->hidden('Commentnews.level', 1);64 echo $form->hidden('Commentnews.comentnew_id', 1);61 echo $form->create('Commentnews', array('action'=>'add',"onsubmit"=>"return validateNew()")); 62 echo $form->hidden('Commentnews.new_id', array('value'=>$data['News']['id'])); 63 echo $form->hidden('Commentnews.level', array('value'=>1)); 64 echo $form->hidden('Commentnews.comentnew_id', array('value'=>1)); 65 65 ?> 66 66 <fieldset> 67 67 <legend>Add comment:</legend> 68 69 68 <?php 70 69 if ( isset( $cU['User']['id'] ) ) 71 70 { 72 echo $form->hidden('Commentnews.user_id', $cU['User']['id']);73 echo $form->hidden('Commentnews.name', $cU['User']['username']);74 echo '<b>'. $cU['User']['username'] . '</b> write s.';71 echo $form->hidden('Commentnews.user_id', array('value'=> $cU['User']['id'])); 72 echo $form->hidden('Commentnews.name', array('value'=>$cU['User']['username'])); 73 echo '<b>'. $cU['User']['username'] . '</b> write: <br />'; 75 74 } 76 75 else 77 76 { 78 echo $form->hidden('Commentnews.user_id', 0); 79 echo $form->input('Commentnews.name', array("size" => 25, "maxlength" => 50)); 80 echo $form->label('Commentnews.name', ' Name:' ); 81 echo $form->error('Commentnews.name', 'Name is required.'); 77 echo $form->hidden('Commentnews.user_id', array('value'=> 0)); 78 echo $form->input('Commentnews.name', array('size'=> 25, 'maxlength' => 40)); 82 79 83 echo '<br /><br /> <img src="'. $html->url('/comentnews/captcha') .'" alt="Captcha" /> <br />';80 echo '<br /><br /> <img src="'. $html->url('/comentnews/captcha') .'" alt="Captcha" title="Captcha" /> <br />'; 84 81 echo $form->input('Commentnews.captcha', array("size" => 6, "maxlength" => 6)); 85 echo $form->label('Commentnews.c ptcha', 'Introduce el codigo, todas la letras son minusculas' );82 echo $form->label('Commentnews.captcha', 'Introduce el código, todas la letras son minúsculas' ); 86 83 } 87 84 88 echo $form->label('Commentnews.comment', 'Comment:' ); 89 echo $form->textarea('Commentnews.comment', array("cols"=>70, "rows"=>10)); 90 echo $form->error('Commentnews.comment', 'Comment is required.'); ?> 91 <br /> 92 </p> 93 94 <br /> 95 <?php echo $form->end('Add comment') ?> 96 </fieldset> 85 echo $form->textarea('Commentnews.comment', array('cols'=>60, 'rows'=>10)); 97 86 98 <?php } ?> 87 ?> 88
