Changeset 461
- Timestamp:
- 05/08/08 11:43:23 (8 months ago)
- Location:
- trunk/app
- Files:
-
- 1 added
- 12 modified
-
config/sql/postgresql/replies.sql (modified) (1 diff)
-
config/sql/postgresql/visitors.sql (modified) (1 diff)
-
controllers/forums_controller.php (modified) (5 diffs)
-
controllers/replies_controller.php (modified) (2 diffs)
-
controllers/topics_controller.php (modified) (3 diffs)
-
models/topic.php (modified) (3 diffs)
-
views/forums/admin_edit.ctp (modified) (1 diff)
-
views/forums/display.ctp (modified) (1 diff)
-
views/topics/add.ctp (modified) (1 diff)
-
views/topics/display.ctp (modified) (5 diffs)
-
views/topics/reply.ctp (modified) (1 diff)
-
views/vclassrooms/show.ctp (modified) (1 diff)
-
webroot/img/static/return.jpg (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/postgresql/replies.sql
r436 r461 3 3 reply text NOT NULL, 4 4 created timestamp(0) with time zone DEFAULT now() NOT NULL, 5 topic_id integer NOT NULL REFERENCES topics(id) ON DELETE CASCADE, 6 user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE, 5 topic_id int NOT NULL REFERENCES topics(id) ON DELETE CASCADE, 6 vclassroom_id int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, -- just one facility to create student's reports 7 user_id int NOT NULL REFERENCES users(id) ON DELETE CASCADE, 7 8 status int NOT NULL DEFAULT 1 8 9 ); -
trunk/app/config/sql/postgresql/visitors.sql
r436 r461 2 2 id serial PRIMARY KEY, 3 3 user_id int NOT NULL REFERENCES users(id) ON DELETE CASCADE, 4 topic_id int NOT NULL REFERENCES topics(id) ON DELETE CASCADE, 5 UNIQUE (user_id, topic_id) -- constraint 4 topic_id int NOT NULL REFERENCES topics(id) ON DELETE CASCADE 6 5 ); 7 8 -
trunk/app/controllers/forums_controller.php
r397 r461 8 8 * @package Karamelo 9 9 */ 10 // file : app/controller/f aqs_controller.php10 // file : app/controller/forums_controller.php 11 11 12 12 uses('sanitize'); … … 16 16 public $helpers = array('Javascript', 'Ajax', 'Time'); 17 17 18 public $components = array('Edublog' );18 public $components = array('Edublog', 'Email'); 19 19 20 20 public function beforeFilter() … … 36 36 } 37 37 38 39 38 public function index($user_id) 40 39 { … … 137 136 $this->layout = 'admin'; 138 137 139 $vclassrooms = $this->Forum->getVclassrooms($this->Auth->user('id')); 140 141 $this->set('vclassrooms', $vclassrooms); 138 $this->set('vclassrooms', $this->Forum->getVclassrooms($this->Auth->user('id'))); 142 139 143 140 if ( !empty( $this->data['Forum'] ) ) … … 164 161 public function admin_edit($id = null) 165 162 { 166 $vclassrooms = $this->Forum->getVclassrooms($this->Auth->user('id')); 167 168 $this->set('vclassrooms', $vclassrooms); 163 164 $this->set('vclassrooms', $this->Forum->getVclassrooms($this->Auth->user('id'))); 169 165 170 166 if (empty($this->data['Forum'])) -
trunk/app/controllers/replies_controller.php
r400 r461 13 13 14 14 public $components = array('Edublog'); 15 16 public function beforeFilter() 17 { 18 $this->Auth->allow(array('add', 'reply')); 19 parent::beforeFilter(); 20 } 15 21 16 22 public function isAuthorized() … … 26 32 } 27 33 28 public function display($user_id, $forum_id, $topic_id) 29 { 30 $this->pageTitle = 'Discussion'; 31 32 $this->layout = $this->Edublog->layout($user_id); 33 34 $this->Edublog->blog($user_id); 35 36 $conditions = array('Reply.status'=>1, 'Reply.id'=>$topic_id); 37 $fields = null; 38 $order = 'Reply.created DESC'; 39 40 $this->set('data', $this->Reply->find($conditions, $fields, $order)); 41 } 42 43 public function add($username=null, $forum_id = null) 34 public function add() 44 35 { 45 36 if (!empty($this->data['Reply'])) -
trunk/app/controllers/topics_controller.php
r339 r461 14 14 public $components = array('Edublog'); 15 15 16 public function beforeFilter()16 public function beforeFilter() 17 17 { 18 18 $this->Auth->allow(array('display', 'add', 'reply')); … … 47 47 $this->Topic->Forum->unbindModel(array('hasMany'=>array('Topic'))); 48 48 $data = $this->Topic->find($conditions, $fields, $order, 2); 49 //die(debug($data)); 49 50 $this->set('data',$data); 50 51 51 if ( $this->Auth->user('id') )52 if ( !$this->Session->check('topic'.$topic_id) ) // add 1 to visit 52 53 { 53 $this->Topic->addVisitor($data['Visitor'], $this->Auth->user('id'), $data['Topic']['id']); 54 $this->Topic->addVisitor($topic_id, $this->Auth->user('id')); 55 $this->Session->write('topic'.$topic_id, $topic_id); //set session, only one visit per session 54 56 } 55 57 } 56 58 57 public function add($ username=null, $forum_id = null)59 public function add($vclassroom_id = null, $forum_id = null) 58 60 { 61 $this->layout='ajax'; 62 59 63 if (!empty($this->data['Topic'])) 60 64 { … … 74 78 else 75 79 { 76 $user_id = $this->Topic->User->field('id', array('User.username'=>$username));77 78 $this->layout = $this->Edublog->layout($user_id);79 80 $this->Edublog->blog($user_id);81 82 80 $this->set('forum_id', $forum_id); 83 }84 81 $this->set('vclassroom_id', $vclassroom_id); 82 } 85 83 } 86 84 87 public function reply($ user_id, $forum_id, $topic_id)85 public function reply($vclassroom_id, $forum_id, $topic_id, $blogger_id) 88 86 { 89 87 // adds new reply to topic 90 88 91 $this->layout = $this->Edublog->layout($user_id);89 $this->layout = 'ajax'; 92 90 93 $this-> Edublog->blog($user_id);94 95 $this->set(' forum_id', $forum_id);96 $this->set('topic_id', $topic_id);91 $this->set('forum_id', $forum_id); 92 $this->set('topic_id', $topic_id); 93 $this->set('blogger_id', $blogger_id); 94 $this->set('vclassroom_id', $vclassroom_id); 97 95 } 98 96 -
trunk/app/models/topic.php
r333 r461 2 2 /** 3 3 * Karamelo eLearning Platform 4 * Chipotle Software 2002-2008 4 * Chipotle Software 2002-2008 5 * @author: Manuel Montoya 5 6 * GPLv3 manuel<arroba>mononeurona<punto>org 6 7 **/ 8 // file: app/models/topic.php 7 9 8 10 class Topic extends AppModel … … 46 48 ); */ 47 49 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( 50 public $validate = array( 81 51 'subject' => VALID_NOT_EMPTY, 82 52 'message' => VALID_NOT_EMPTY, … … 84 54 'forum_id' => VALID_NOT_EMPTY 85 55 ); 56 57 public function addVisitor($topic_id, $user_id) 58 { 59 $this->data['Visitor']['topic_id'] = $topic_id; 60 $this->data['Visitor']['user_id'] = $user_id; 61 62 $this->Visitor->create(); 63 64 if ( $this->Visitor->save( $this->data['Visitor'] ) ): 65 return true; 66 else: 67 die('Error on addVisitor function'); 68 endif; 69 70 return true; 71 } 86 72 } 87 73 ?> -
trunk/app/views/forums/admin_edit.ctp
r321 r461 12 12 ?> 13 13 <br /> 14 <?php 15 echo $form->label('Forum.vclassroom_id', 'Class:'); 16 echo $form->select('Forum.vclassroom_id', $vclassrooms, null, null, false); 17 ?> 14 18 <br /> 15 19 <?php -
trunk/app/views/forums/display.ctp
r333 r461 7 7 ); 8 8 9 echo $html->div('titentry', $data["Forum"]["title"]);10 echo $html->para(null, $data["Forum"]["description"]);9 echo $html->div('titentry', $data["Forum"]["title"]); 10 echo $html->para(null, $data["Forum"]["description"]); 11 11 12 echo $html->div(null, 13 $html->link($html->image('static/new_post.gif', array("alt"=>"Add new topic", "title"=>"Add new topic")), 14 '/topics/add/'.$blog["User"]["username"].'/'.$data["Forum"]["id"], 15 null, null, false) 16 ); 12 $tmp = $ajax->link($html->image("static/new_post.gif", array("alt"=>"New Topic", "title"=>"New Topic")), '/topics/add/'.$data['Vclassroom']['id'].'/'.$data['Forum']['id'], 13 array("update" => "qn", 14 "loading"=>"Element.show('loading3');", 15 "complete"=>"Element.hide('loading3');Effect.Appear('qn')"), 16 null, 17 false 18 ); 19 20 $tmp .= '<div id="loading3" style="display: none;">'.$html->image("static/loading.gif", array("alt"=>"Loading")).'</div>'; 21 22 $tmp .= $ajax->div('qn', array("style"=>"padding:3px")) . $ajax->divEnd('qn'); 23 24 echo $html->div(null, $tmp); 17 25 18 26 //Topics 19 27 echo '<table style="border-collapse:collapse;width:100%">'; 20 if ( count($data["Topic"]) == 0) 21 { 28 if ( count($data["Topic"]) == 0): 22 29 echo '<tr><td colspan="6"><br /><h4>There is not topic on this forum yet</h4></td></tr>'; 23 } 24 else 25 { 26 $th = array('Read', 'Topics', 'Replies', 'Author', 'Views', 'Last Post'); 27 echo $html->tableHeaders($th); 28 } 30 else: 31 $th = array('Read', 'Topics', 'Replies', 'Author', 'Views', 'Last Post'); echo $html->tableHeaders($th); 32 endif; 29 33 //die(print_r($data["Topic"])); 30 34 -
trunk/app/views/topics/add.ctp
r321 r461 1 <?php echo $javascript->link('myfunctions'); ?>2 <div>3 <?php4 echo $html->addCrumb('Phorums', '/forums/view/'.$blog["User"]["id"]);5 echo $html->getCrumbs(' / ');6 ?>7 </div>8 <div class="title_section">New Topic</div>9 10 <div class="spaced">11 12 1 <?php 13 2 echo $form->create('Topic'); 14 3 echo $form->hidden('Topic.forum_id', array('value'=>$forum_id)); 15 ?> 4 echo $form->hidden('Topic.vclassroom_id', array('value'=>$vclassroom_id)); 5 ?> 16 6 17 7 <fieldset> 18 8 <legend>New Topic</legend> 19 9 <?php 20 echo $form->input('Topic.subject', array("size" => 40, "maxlength" => 60));10 echo $form->input('Topic.subject', array("size" => 30, "maxlength" => 60, 'between'=>': <br />')); 21 11 echo $form->error('Topic.subject', 'A subject is required.'); 22 12 ?> 23 13 <p> 24 14 <?php 25 echo $form->label('Topic.message', 'Message:' ) . '<br />'; 26 echo $form->textarea('Topic.message', array("rows" => 10, "cols" => 50)); 27 echo $form->error('Topic.message', 'A phorum message is required.'); 15 echo $form->label('Topic.message', 'Topic :') . '<br />'; 16 echo $form->textarea('Topic.message', array("rows" => 7, "cols" => 30)); 28 17 ?> 29 18 </p> 30 19 <br /> 31 < p><br /></fieldset>32 <?php echo $form->end('Save'); ?> </p>33 </ div>20 <br /> 21 <?php echo $form->end('Save'); ?> 22 </fieldset> -
trunk/app/views/topics/display.ctp
r329 r461 1 1 <?php 2 2 //die(debug($data)); 3 echo '<h1>'. $data['Forum']['title'] .'</h1>'; 3 4 4 echo '<div>'; 5 echo $html->para(null, $data['User']['username'] . ' suggest topic: <b>'.$data['Topic']['subject'] .'</b> at <span class="dates">'.$data['Topic']['created'].'</span>'); 6 7 echo $html->para(null, $html->link( 8 $html->image('static/return.jpg', array('alt'=>'Return to '. $data['Forum']['title'], 'title'=>'Return to '. $data['Forum']['title'])) 9 , '/forums/display/'.$data['Topic']['forum_id'], null, null, false)); 10 11 echo $html->div('titentry', 'Discussion on '.$data['Topic']['subject']); 5 12 6 13 if ( isset( $cU ) ): 7 8 echo$html->link( // add topic14 /* 15 $tmp = $html->link( // add topic 9 16 $html->image( 10 17 'static/new_topic.gif', array("alt"=>"New topic", "title"=>"New topic") … … 14 21 ) .' '; 15 22 16 echo $html->link( // add reply 17 $html->image( 18 'static/reply.gif', array("alt"=>"Reply", "title"=>"Reply")), 19 '/topics/reply/'.$blog["User"]["id"].'/'.$data['Forum']['id'] .'/'.$data['Topic']['id'], 20 false, false, null); 23 **/ 24 $tmp = $ajax->link($html->image("static/reply.gif", array("alt"=>"New reply", "title"=>"Reply")), 25 '/topics/reply/'.$data['Topic']['vclassroom_id'].'/'.$data['Forum']['id'] .'/'.$data['Topic']['id'].'/'.$data['Topic']['user_id'], 26 array("update" => "qn", 27 "loading"=>"Element.show('loading3');", 28 "complete"=>"Element.hide('loading3');Effect.Appear('qn')"), 29 null, 30 false 31 ); 32 33 $tmp .= '<div id="loading3" style="display: none;">'.$html->image("static/loading.gif", array("alt"=>"Loading")).'</div>'; 34 35 $tmp .= $ajax->div('qn', array("style"=>"padding:3px")) . $ajax->divEnd('qn'); 36 37 echo $html->div(null, $tmp); 38 21 39 endif; 22 40 23 echo '</div>';24 25 echo '<h1>'. $data['Forum']['title'] .'</h1>';26 echo '<p>'. $data['User']['username'] . ' suggest topic: <b>'.$data['Topic']['subject'] .'</b> <span class="dates">'.$data['Topic']['created'].'</span></p>';27 41 28 42 echo '<div style="padding:2px;margin:10px 5px 10px 5px">'; … … 38 52 { 39 53 $i = $int++; 40 $tmp = '<b>'. $i . '.-</b> ';54 $tmp = '<b>'. $i . '.-</b> '; 41 55 $tmp .= $html->link($val['User']['username'], '/users/about/'. $val['User']['username']); 42 56 $tmp .= $html->link($html->image('avatars/'.$val['User']['avatar'], array('alt'=>$val['User']['username'])), 43 57 '/users/about/'. $val['User']['username'], null, null, false) .'<br />'; 44 58 $tmp .= $html->image('static/time.png') .' '. $time->timeAgoInWords($val['created']).'<br /><br />' . $val['reply']; 59 45 60 echo $html->div('reply', $tmp); 46 61 … … 49 64 50 65 if ( isset( $cU ) ): 51 66 /* 52 67 echo $html->link( // add topic 53 68 $html->image( … … 57 72 false, false, null 58 73 ) . ' '; 59 60 echo $html->link( // add reply 61 $html->image( 62 'static/reply.gif', array("alt"=>"Reply", "title"=>"Reply")), 63 '/topics/reply/'.$blog["User"]["id"].'/'.$data['Forum']['id'] .'/'.$data['Topic']['id'], 64 false, false, null); 74 */ 65 75 endif; 66 67 76 ?> -
trunk/app/views/topics/reply.ctp
r329 r461 1 <?php echo $javascript->link('fckeditor/fckeditor'); ?>2 <div class="title_section">Reply</div>3 4 <div class="spaced">5 6 1 <?php 7 2 if ( isset ($cU['User']) ): 8 3 echo $form->create('Reply', array('action'=>'add')); 9 echo $form->hidden('Reply.redirect_to', array('value'=>'/topics/display/'.$blog ['User']['id'].'/'.$forum_id.'/'.$topic_id));4 echo $form->hidden('Reply.redirect_to', array('value'=>'/topics/display/'.$blogger_id.'/'.$forum_id.'/'.$topic_id)); 10 5 echo $form->hidden('Reply.topic_id', array('value'=>$topic_id)); 6 echo $form->hidden('Reply.vclassroom_id', array('value'=>$vclassroom_id)); 11 7 ?> 12 8 <fieldset> 13 <legend> New reply</legend>9 <legend><?php __('New reply'); ?></legend> 14 10 <?php 15 11 echo $form->label('Reply.reply', 'Message:' ) . '<br />'; 16 12 echo $form->textarea('Reply.reply', array("rows" => 10, "cols" => 50)); 17 13 echo $fck->load('ReplyReply', 'Basic', 500, 300); 18 echo $form->error('Reply.reply', 'A message is required.'); 19 ?> 20 </fieldset> 21 <?php 22 echo $form->end('Send'); 14 echo $form->end('Send'); 15 echo '</fieldset>'; 16 endif; 17 ?> 23 18 24 else:25 echo $html->para(null, $html->link('You must be logged in to write a reply', '/users/login'));26 endif;27 ?>28 </div> -
trunk/app/views/vclassrooms/show.ctp
r450 r461 36 36 foreach($data['Forum'] as $f) 37 37 { 38 echo $html->para(null, $html->link($f['title'], '/ vclassrooms/forums/'.$f['id']));38 echo $html->para(null, $html->link($f['title'], '/forums/display/'.$f['id'])); 39 39 } 40 40 }
