Changeset 333
- Timestamp:
- 03/23/08 20:16:44 (10 months ago)
- Location:
- trunk/app
- Files:
-
- 11 modified
-
app_controller.php (modified) (1 diff)
-
config/core.php (modified) (2 diffs)
-
config/sql/karamelo_postgres.sql (modified) (1 diff)
-
controllers/forums_controller.php (modified) (4 diffs)
-
controllers/replies_controller.php (modified) (3 diffs)
-
controllers/topics_controller.php (modified) (1 diff)
-
controllers/users_controller.php (modified) (2 diffs)
-
models/topic.php (modified) (1 diff)
-
views/forums/display.ctp (modified) (5 diffs)
-
views/lessons/admin_add.ctp (modified) (2 diffs)
-
views/topics/admin_listing.ctp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r331 r333 17 17 $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); 18 18 $this->Auth->loginRedirect = array('controller' => 'news', 'action' => 'display'); 19 $this->Auth->logoutRedirect = '/ ';19 $this->Auth->logoutRedirect = '/news/display'; 20 20 $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 21 21 $this->Auth->authorize = 'controller'; -
trunk/app/config/core.php
r330 r333 75 75 * 76 76 */ 77 Configure::write('Session.save', ' cake');77 Configure::write('Session.save', 'database'); 78 78 /** 79 79 * The name of the table used to store CakePHP database sessions. … … 120 120 * 'Security.level' is set to 'high'. 121 121 */ 122 Configure::write('Security.level', ' low');122 Configure::write('Security.level', 'medium'); 123 123 /** 124 124 * A random string used in security hashing methods. -
trunk/app/config/sql/karamelo_postgres.sql
r331 r333 237 237 status int NOT NULL DEFAULT 1 238 238 ); 239 240 CREATE TABLE visitors ( --save user id visitors on topics 241 id serial PRIMARY KEY, 242 user_id int NOT NULL REFERENCES users(id) ON DELETE CASCADE, 243 topic_id int NOT NULL REFERENCES topics(id) ON DELETE CASCADE, 244 UNIQUE (user_id, topic_id) -- constraint 245 ); 246 239 247 -- ** Forums tables ends ** 240 248 -
trunk/app/controllers/forums_controller.php
r331 r333 3 3 * Chipotle Software TM 4 4 * Manuel Montoya 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org ASMO5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 6 */ 7 7 … … 35 35 36 36 $this->pageTitle = $data['Catforum']['title'] . ' Forum'; 37 //die(debug($data));37 38 38 $this->set('data', $data); 39 39 40 $this->layout = $this->Edublog->layout($data['Forum']['user_id']);40 $this->layout = $this->Edublog->layout($data['Forum']['user_id']); 41 41 42 42 $this->Edublog->blog($data['Forum']['user_id']); // blogger elements 43 43 } 44 44 45 public function discussion($user_id, $forum_id, $topic_id) 45 public function discussion($user_id, $forum_id, $topic_id) 46 46 { 47 47 $conditions = array("Topic.id = $topic_id OR Topic.topic_id=$topic_id"); … … 49 49 $fields = null; //array("Forum.title", "Forum.id", "Forum.user_id", "Forum.description", "Forum.catforum_id"); 50 50 51 $this->Forum->Topic->User->unbindModel( array('belongsTo'=>array('Group'),'hasMany'=>array('Lesson', 'Entry', 'Comment', 'Bookmark', 'Podcast', 'Quote', 'Test', 'Webquest', 'Ecourse', 'Vclassroom', 'Acquaintance','Confirm')));51 $this->Forum->Topic->User->unbindModel($this->Forum->User->notNow); 52 52 53 53 $data = $this->Forum->Topic->findAll($conditions, $fields); 54 //die(debug($data));54 55 55 $this->pageTitle = $data[0]['Forum']['title'] . ' Forum'; 56 56 57 57 $this->set('data', $data); 58 58 59 $this->layout = $this->Edublog->layout($user_id);59 $this->layout = $this->Edublog->layout($user_id); 60 60 61 61 $this->Edublog->blog($user_id); // blogger elements … … 74 74 $this->set('data', $this->Forum->find($conditions, $fields, null, 2)); 75 75 76 $this->layout = $this->Edublog->layout($user_id);76 $this->layout = $this->Edublog->layout($user_id); 77 77 78 78 $this->Edublog->blog($user_id); // blogger elements -
trunk/app/controllers/replies_controller.php
r326 r333 64 64 **/ 65 65 66 public function admin_listing()67 {68 $this->layout = 'admin';69 $this->pageTitle = 'Forums';70 71 $conditions = array("user_id"=>$this->Auth->user('id'));72 $fields = array("id", "title", "description", "status");73 74 $this->set('data', $this->Reply->findAll($conditions, $fields));75 }76 77 66 public function admin_edit($id = null) 78 67 { … … 87 76 if ($this->Reply->save($this->data['Reply'])) 88 77 { 89 $this->flash(' Your virtual classroom has been updated.','/vclassrooms');78 $this->flash('Reply updated.','/admin/topics/listing/'.$topic_id); 90 79 } 91 80 } … … 93 82 94 83 // change status published/draft 95 public function admin_change($ id, $status, $forum_id)84 public function admin_change($topic_id, $status, $reply_id) 96 85 { 97 // die(' el intvade del status es '. intval($status));98 if ( !intval($id) || !is_numeric($status) || !intval($forum_id) )99 {100 $this->redirect('/');101 }102 103 86 $this->data['Reply']['status'] = ($status == 0 ) ? 1 : 0; 104 87 105 $this->data['Reply']['id'] = $ id;88 $this->data['Reply']['id'] = $reply_id; 106 89 107 90 if ($this->Reply->save($this->data['Reply'])) 108 91 { 109 $this->msgFlash('Reply status changed', '/admin/ forums/topics/'.$forum_id);92 $this->msgFlash('Reply status changed', '/admin/topics/listing/'.$topic_id); 110 93 } 111 94 } 112 95 113 public function admin_delete($topic_id, $ forum_id)96 public function admin_delete($topic_id, $reply_id) 114 97 { 115 if ( $this->Reply->del($ topic_id) )98 if ( $this->Reply->del($reply_id) ) 116 99 { 117 $this->msgFlash(' ','/admin/forums/topics/'.$forum_id);100 $this->msgFlash('Reply deleted','/admin/topics/listing/'.$topic_id); 118 101 } 119 } 102 } 120 103 } -
trunk/app/controllers/topics_controller.php
r331 r333 28 28 public function display($user_id, $forum_id, $topic_id) 29 29 { 30 $this->pageTitle = 'Discussion';30 $this->pageTitle = 'Discussion'; 31 31 32 $this->layout = $this->Edublog->layout($user_id);32 $this->layout = $this->Edublog->layout($user_id); 33 33 34 $this->Edublog->blog($user_id);34 $this->Edublog->blog($user_id); 35 35 36 $conditions = array("Topic.status"=>1, "Topic.id"=>$topic_id);37 $fields = null;38 $order = "Topic.created DESC";36 $conditions = array("Topic.status"=>1, "Topic.id"=>$topic_id); 37 $fields = null; 38 $order = "Topic.created DESC"; 39 39 40 $this->Topic->User->unbindModel(array('hasMany'=>array('Category', 'Faq', 'Lesson', 'Entry', 'Acquaintance', 'Vclassroom'))); 41 $this->Topic->Forum->unbindModel(array('hasMany'=>array('Topic'))); 42 $this->set('data', $this->Topic->find($conditions, $fields, $order, 2)); 40 $this->Topic->User->unbindModel(array('hasMany'=>array('Category', 'Faq', 'Lesson', 'Entry', 'Acquaintance', 'Vclassroom'))); 41 $this->Topic->Forum->unbindModel(array('hasMany'=>array('Topic'))); 42 $data = $this->Topic->find($conditions, $fields, $order, 2); 43 $this->set('data',$data); 44 45 if ( $this->Auth->user('id') ) 46 { 47 $this->Topic->addVisitor($data['Visitor'], $this->Auth->user('id'), $data['Topic']['id']); 48 } 43 49 } 44 50 -
trunk/app/controllers/users_controller.php
r330 r333 302 302 public function logout() 303 303 { 304 $this->Session->setFlash("You've successfully logged out.");305 $this->redirect($this->Auth->logout());306 }307 public function admin_login() 308 {309 $this->redirect('/users/login');310 } 304 $this->Cookie->del('User'); 305 306 $this->Session->setFlash('Logout'); 307 308 $this->redirect($this->Auth->logout()); 309 } 310 311 311 public function register() 312 312 { … … 445 445 } 446 446 447 /** === ADMIN SECTION ==***/ 448 /*** 449 ===== ADMIN METHODS==== 450 ****/ 451 public function admin_edit() 452 { 447 /*** ===== ADMIN METHODS==== ****/ 448 public function admin_login() 449 { 450 $this->redirect('/users/login'); 451 } 452 453 public function admin_edit() 454 { 453 455 454 456 $this->layout = 'admin'; -
trunk/app/models/topic.php
r326 r333 22 22 array('className' => 'Reply', 23 23 'foreignkey' => 'topic_id', 24 'order' => 'created ASC' 25 )); 26 27 public $validate = array( 24 'order' => 'created ASC' 25 ), 26 'Visitor' => 27 array('className' => 'Visitor', 28 'foreignkey' => 'topic_id', 29 'order' => null 30 ), 31 ); 32 /* public $hasAndBelongsToMany = array( 33 'Topic' => 34 array('className' => 'Topic', 35 'joinTable' => 'topics_users', 36 'foreignKey' => 'topic_id', 37 'associationForeignKey' => 'user_id', 38 'conditions' => '', 39 'order' => '', 40 'limit' => '', 41 'uniq' => true, 42 'finderQuery' => '', 43 'deleteQuery' => '', 44 'insertQuery' => '' 45 ) 46 ); */ 47 48 public function addVisitor($users = array(), $user_id, $topic_id) 49 { // this is just to set a flag to indicate user is visiting topic for first time 50 51 $ids = array(); 52 //die(var_dump( $users )); 53 foreach ($users as $v) 54 { 55 array_push($ids, $v['id']); 56 } 57 58 if ( in_array($user_id, $ids) ) 59 { 60 return false; 61 } 62 else 63 { 64 $this->data['Visitor']['topic_id'] = $topic_id; 65 $this->data['Visitor']['user_id'] = $user_id; 66 $this->Visitor->create(); 67 68 if ( $this->Visitor->save( $this->data['Visitor'] ) ) 69 { 70 return true; 71 } 72 else 73 { 74 die('Error on addVisitor function'); 75 } 76 } 77 return true; 78 } 79 80 public $validate = array( 28 81 'subject' => VALID_NOT_EMPTY, 29 82 'message' => VALID_NOT_EMPTY, -
trunk/app/views/forums/display.ctp
r327 r333 1 1 <?php 2 //die( print_r($data));2 //die(debug($data)); 3 3 echo $html->para(null, 4 4 'Foro: '.$html->link($data["Catforum"]["title"], … … 7 7 ); 8 8 9 echo '<div style="padding:6px;border:1px dotted gray;margin:15px 0 15px 0">'; 10 echo '<div style="padding:6px;border:1px solid orange;font-size:17pt;color:orange;font-weight:bold">'.$data["Forum"]["title"].'</div>'; 11 echo '<span ="font-size:pt">'. $data["Forum"]["description"] . "</span>"; 12 echo '<div style="width:100px;margin-top:15px">'; 9 echo $html->div('titentry', $data["Forum"]["title"]); 10 echo $html->para(null, $data["Forum"]["description"]); 13 11 14 echo $html->div( 'space',12 echo $html->div(null, 15 13 $html->link($html->image('static/new_post.gif', array("alt"=>"Add new topic", "title"=>"Add new topic")), 16 14 '/topics/add/'.$blog["User"]["username"].'/'.$data["Forum"]["id"], … … 18 16 ); 19 17 20 21 18 //Topics 22 19 echo '<table style="border-collapse:collapse;width:100%">'; … … 34 31 foreach ($data["Topic"] as $val) 35 32 { 36 $tr = array ( 33 34 $tr = array ( 37 35 $html->image('static/folder.gif'), 38 36 $html->link($val['subject'], '/topics/display/'.$data['Forum']['user_id'].'/'.$val['forum_id'].'/'.$val['id']), 39 count($ data["Topic"]),37 count($val['Reply']), 40 38 $val["User"]["username"], 41 39 $val['views'], … … 49 47 50 48 echo '</table>'; 51 echo '</div>';52 53 54 echo '<div style="text-align:center;width:50%;padding:6px">';55 49 56 50 if ( ! isset( $cU ) ) 57 51 { 58 echo $this->renderElement('login');52 echo $html->div(null, $this->renderElement('login')); 59 53 } 60 echo '</div>'; 54 55 echo $html->para(null, 'Leyenda del Tema'); 56 57 $tmp = $html->image('static/board.gif', array("alt"=>"Tema normal", "title"=>"Tema normal")) . ' Tema normal <br />'; 58 $tmp .= $html->image('static/locked.gif', array("alt"=>"Tema bloqueado", "title"=>"Tema bloqueado")) . ' Tema bloqueado<br />'; 59 $tmp .= $html->image('static/new.gif', array("alt"=>"Comentario nuevo", "title"=>"Comentario nuevo")). ' Comentario nuevo<br />'; 60 61 echo $html->para(null, $tmp); 61 62 ?> 62 63 <p style="padding:3px;border:1px dotted gray;font-size:9pt;font-weight:bold">Leyenda del Tema:</p>64 <p>65 <?php echo $html->image('static/board.gif', array("alt"=>"Tema normal", "title"=>"Tema normal")); ?> Tema normal<br />66 <?php echo $html->image('static/locked.gif', array("alt"=>"Tema bloqueado", "title"=>"Tema bloqueado")); ?> Tema bloqueado<br />67 <?php echo $html->image('static/new.gif', array("alt"=>"Comentario nuevo", "title"=>"Comentario nuevo")); ?> Comentario nuevo<br />68 </p> -
trunk/app/views/lessons/admin_add.ctp
r312 r333 1 1 <?php 2 echo $javascript->link('myfunctions'); 3 echo $javascript->link('fckeditor/fckeditor'); 2 echo $javascript->link('myfunctions'); 3 echo $javascript->link('fckeditor/fckeditor'); 4 echo $form->create('Lesson'); 4 5 ?> 5 6 6 <?php echo $html->formTag('/admin/lessons/add/','post'); ?>7 7 <fieldset> 8 8 <legend>Add Lesson</legend> 9 9 <table> 10 10 <tr><td> 11 <?php 12 echo $form->labelTag( 'Lesson/title', 'Title:' ); 13 echo $html->input('Lesson/title', array("size" => 50, "maxlength" => 120, "class"=>"formas")); 14 echo $html->tagErrorMsg('Lesson/title', 'Title is required.'); 11 <?php 12 echo $form->input('Lesson.title', array("size" => 50, "maxlength" => 120)); 13 echo $form->error('Lesson.title', 'Title is required.'); 15 14 ?> 16 15 </td> … … 22 21 <td colspan="2"> 23 22 <?php 24 echo $form->label Tag( 'Lesson/body', 'Body:' );25 echo $ html->textarea('Lesson/body', array("class"=>"formas","cols"=>80, "rows"=>45));26 echo $fck->load('Lesson /body', 'Karamelo');27 echo $ html->tagErrorMsg('Lesson/body', 'Body is required.');23 echo $form->label('Lesson.body', 'Body:' ); 24 echo $form->textarea('Lesson.body', array("cols"=>80, "rows"=>45)); 25 echo $fck->load('LessonBody', 'Karamelo'); 26 echo $form->error('Lesson.body', 'Body is required.'); 28 27 ?> 29 28 </td></tr> 30 29 <tr><td> 31 30 <?php 32 echo $form->label Tag( 'Lesson/status', 'Published:' );33 echo $ html->checkbox('Lesson/status');31 echo $form->label('Lesson.status', 'Published:' ); 32 echo $form->checkbox('Lesson.status', array('value'=>1)); 34 33 ?> 35 34 </td><td> 36 <? php37 echo $form->labelTag( 'Lesson/disc', 'Comments allowed to this Lesson:' );38 echo $ html->checkbox('Lesson/disc');35 <?Php 36 Echo $form->label('Lesson.disc', 'Comments allowed to this Lesson:' ); 37 echo $form->checkbox('Lesson.disc', array('value'=>1)); 39 38 ?> 40 39 </td></tr> 41 <tr><td colspan="2"> 42 <?php echo $ html->submit('Save'); ?>40 <tr><td colspan="2"> </fieldset> 41 <?php echo $form->end('Save'); ?> 43 42 </td></tr> 44 43 </table> 45 </fieldset>46 </form> -
trunk/app/views/topics/admin_listing.ctp
r331 r333 7 7 { 8 8 $st = ($val['status'] == 1) ? 'Published' : 'Hidden'; 9 $stl = $html->link($st, '/admin/replies/change/'.$val[' id'].'/'.$val['status']);9 $stl = $html->link($st, '/admin/replies/change/'.$val['topic_id'].'/'.$val['status'].'/'.$val['id']); 10 10 $tmp = $val['User']['username'] . $html->image('avatars/'.$val['User']['avatar'], array('alt'=>$val['User']['username'], 'title'=>$val['User']['username'])); 11 11 $tmp .= $html->para(null, $val['reply']); 12 12 $tmp .= $html->para('news_date', $val['created']); 13 $tmp .= $html->link('Delete', '/admin/replies/delete/'.$val['id']) . ' ' . $stl . ' '. $html->link('Edit', '/admin/replies/edit/'.$val['id']); 13 $tmp .= $html->link('Delete', '/admin/replies/delete/'.$val['topic_id'].'/'.$val['id']).' '; 14 $tmp .= $stl. ' '. $html->link('Edit', '/admin/replies/edit/'.$val['id']); 14 15 echo $html->div('adminblock', $tmp); 15 16 }
