Changeset 325
- Timestamp:
- 03/19/08 16:27:43 (10 months ago)
- Location:
- trunk/app
- Files:
-
- 1 added
- 18 modified
-
app_controller.php (modified) (1 diff)
-
config/core.php (modified) (1 diff)
-
config/sql/karamelo_postgres.sql (modified) (3 diffs)
-
controllers/catforums_controller.php (modified) (4 diffs)
-
controllers/comments_controller.php (modified) (3 diffs)
-
controllers/components/edublog.php (modified) (1 diff)
-
controllers/forums_controller.php (modified) (2 diffs)
-
controllers/replies_controller.php (added)
-
controllers/topics_controller.php (modified) (8 diffs)
-
views/catforums/admin_edit.ctp (modified) (2 diffs)
-
views/catforums/admin_listing.ctp (modified) (1 diff)
-
views/catforums/display.ctp (modified) (1 diff)
-
views/forums/display.ctp (modified) (2 diffs)
-
views/layouts/admin.ctp (modified) (1 diff)
-
views/layouts/rubyx.ctp (modified) (1 diff)
-
views/topics/display.ctp (modified) (1 diff)
-
views/topics/reply.ctp (modified) (1 diff)
-
views/topics/view.ctp (modified) (3 diffs)
-
views/users/entry.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r324 r325 20 20 $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 21 21 $this->Auth->authorize = 'controller'; 22 $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 're gister', 'insert', 'vote', 'entry', 'download', 'blog','portfolio', 'about', 'message', 'directory', 'bloggers', 'add', 'rss', 'discussion') );22 $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'reply', 'register', 'insert', 'vote', 'entry', 'download', 'blog','portfolio', 'about', 'message', 'directory', 'bloggers', 'add', 'rss', 'discussion') ); 23 23 $this->Auth->autoRedirect = true; 24 24 $this->set('cU', $this->Auth->user()); // $cU current user array to use in the views if user logged -
trunk/app/config/core.php
r324 r325 14 14 * In development mode, you need to click the flash message to continue. 15 15 */ 16 Configure::write('debug', 2);16 Configure::write('debug', 1); 17 17 /** 18 18 * Application wide charset encoding -
trunk/app/config/sql/karamelo_postgres.sql
r322 r325 198 198 ); 199 199 200 -- Forums tables200 -- ** Forums tables beggins ** 201 201 CREATE TABLE catforums ( -- phorums categories 202 202 id serial PRIMARY KEY, … … 217 217 ); 218 218 219 CREATE TABLE topics ( -- question and aswers in phorums219 CREATE TABLE topics ( -- question and aswers in forums 220 220 id serial PRIMARY KEY, 221 221 subject varchar(150) NOT NULL, … … 225 225 user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE, 226 226 status int NOT NULL DEFAULT 1, 227 level int NOT NULL DEFAULT 0, --level 0 = topic starts228 topic_id int NOT NULL DEFAULT 1, -- topic id and level 2 giveme answers229 227 views int NOT NULL DEFAULT 0 -- number of times the topic has been seen 230 228 ); 229 230 CREATE TABLE replies ( -- replies to topics in forums 231 id serial PRIMARY KEY, 232 reply text NOT NULL, 233 created timestamp(0) with time zone DEFAULT now() NOT NULL, 234 topic_id integer NOT NULL REFERENCES topics(id) ON DELETE CASCADE, 235 user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE, 236 status int NOT NULL DEFAULT 1 237 ); 238 -- ** Forums tables ends ** 231 239 232 240 -- News letters -
trunk/app/controllers/catforums_controller.php
r323 r325 46 46 ======= ADMIN METHODS ======= 47 47 ******/ 48 public function admin_listing( $admin = null, $order=null)48 public function admin_listing() 49 49 { 50 50 $this->layout = 'admin'; … … 54 54 $conditions = array("user_id"=>$this->Auth->user('id')); 55 55 56 if ($this->Auth->user('group_id') == 1 && $admin != null) 57 { 58 $conditions["website"] = 1; 59 } 56 $fields = array("id", "title", "description","created", "status"); 57 58 $order = 'Catforum.id ASC'; 60 59 61 $fields = array("id", "title", "description","created", "status"); 62 63 $this->set('data', $this->Catforum->findAll($conditions, $fields, $order, null, null, 2)); 60 $this->set('data', $this->Catforum->findAll($conditions, $fields, $order)); 64 61 65 }66 67 public function admin_add()68 {69 70 $this->layout = 'admin';71 // adds new classroom to database72 if (!empty($this->data['Catforum']))73 {62 } 63 64 public function admin_add() 65 { 66 67 $this->layout = 'admin'; 68 // adds new classroom to database 69 if (!empty($this->data['Catforum'])) 70 { 74 71 $this->Sanitize = new Sanitize; 75 72 … … 108 105 } 109 106 } 110 } 111 112 public function admin_delete($id) 113 { 107 } 108 // change status published/draft 109 public function admin_change($status, $forum_id) 110 { 111 if ( !is_numeric($status) || !intval($forum_id) ) 112 { 113 $this->redirect('/'); 114 } 115 116 $this->data['Forum']['status'] = ($status == 0 ) ? 1 : 0; 117 118 $this->data['Forum']['id'] = $id; 119 120 if ($this->Forum->save($this->data['Forum'])) 121 { 122 $this->msgFlash('Status changed', '/admin/catforums/listing'); 123 } 124 } 125 126 public function admin_delete($id) 127 { 114 128 // deletes task from database 115 129 $this->Catforum->del($id); … … 117 131 $this->msgFlash('Forum deleted', '/admin/catforums/listing'); 118 132 exit(); 119 }120 133 } 134 } 121 135 ?> -
trunk/app/controllers/comments_controller.php
r302 r325 45 45 } 46 46 47 // print_r($conditions);48 49 47 $fields = array("id", "title", "description", "pubdate", "size"); 50 48 $order = "id DESC"; … … 57 55 public function add() 58 56 { 59 60 57 if (!empty($this->data["Comment"]) ) 61 58 { 59 62 60 $this->Sanitize = new Sanitize; 63 61 64 $this->Sanitize->clean Array($this->data["Comment"]); //Hopefully this is enough62 $this->Sanitize->clean($this->data["Comment"]); //Hopefully this is enough 65 63 66 64 $this->Comment->create(); 67 65 68 66 if ($this->Comment->save($this->data["Comment"])) 69 67 { 70 68 $this->msgFlash('Comment added', $this->data['Comment']['redirect_to'].'/#comments'); 71 exit();72 69 } 73 70 } … … 80 77 public function admin_listing() 81 78 { 82 $this->pageTitle = $this-> othAuth->user('username') . '\'s Comments';79 $this->pageTitle = $this->Auth->user('username') . '\'s Comments'; 83 80 84 81 $this->layout = 'admin'; 85 82 86 $conditions = array("Comment.user_id"=>$this-> othAuth->user('id'));83 $conditions = array("Comment.user_id"=>$this->Auth->user('id')); 87 84 $fields = array("Comment.id", "Comment.created", "Comment.comment", "Comment.user_id", "Comment.username", "Entry.title", "Entry.id"); 88 85 $order = "Comment.id DESC"; -
trunk/app/controllers/components/edublog.php
r274 r325 1 1 <?php 2 2 /** 3 * Edublog component By Manuel Montoya. 4 * comments, bug reports are welcome: manuel _A T_ mononeurona _DOT_ org3 * Edublog component By Manuel Montoya. 2002-2008 4 * comments, bug reports are welcome: manuel _ARROBA_ mononeurona _PUNTO_ org 5 5 * @author aarkerio 6 6 * @version 0.2 -
trunk/app/controllers/forums_controller.php
r322 r325 150 150 } 151 151 } 152 // change status published/draft 153 public function admin_change($id, $status) 154 { 152 // change status published/draft 153 public function admin_change($status, $forum_id) 154 { 155 if ( !is_numeric($status) || !intval($forum_id) ) 156 { 157 $this->redirect('/'); 158 } 159 155 160 $this->data['Forum']['status'] = ($status == 0 ) ? 1 : 0; 156 161 … … 159 164 if ($this->Forum->save($this->data['Forum'])) 160 165 { 161 $this->msgFlash(' Forum status changed', '/admin/catforums/listing/');166 $this->msgFlash('Status changed', '/admin/catforums/listing'); 162 167 } 163 } 168 } 169 164 170 public function admin_delete($id) 165 171 { -
trunk/app/controllers/topics_controller.php
r324 r325 16 16 public function isAuthorized() 17 17 { 18 if (isset($this->params[Configure::read('Routing.admin')]))19 {20 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 )21 {22 return true;23 }24 }18 if (isset($this->params[Configure::read('Routing.admin')])) 19 { 20 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) 21 { 22 return true; 23 } 24 } 25 25 return false; 26 26 } 27 27 28 public function view($user _id, $forum_id)28 public function view($username, $forum_id) 29 29 { 30 30 $this->pageTitle = 'Forums'; 31 31 32 $user_id = $this->Topic->User->field('id', array('User.username'=>$username)); 33 32 34 $this->layout = $this->Edublog->layout($user_id); 33 35 … … 57 59 $order = "Topic.created DESC"; 58 60 59 $this->set('data', $this->Topic->find All($conditions, $fields, $order));61 $this->set('data', $this->Topic->find($conditions, $fields, $order)); 60 62 } 61 63 … … 73 75 public function add($username=null, $forum_id = null) 74 76 { 75 76 77 if (!empty($this->data['Topic'])) 77 78 { 78 79 79 $this->Sanitize = new Sanitize; 80 80 … … 87 87 if ($this->Topic->save($this->data)) 88 88 { 89 $this->flash(' New topic had been added.','/topics/view/'.$this->data['Topic']["user_id"].'/'.$this->data['Topic']['forum_id']);89 $this->flash('Topic added', '/forums/display/'.$this->data['Topic']['forum_id']); 90 90 } 91 91 } … … 93 93 { 94 94 $user_id = $this->Topic->User->field('id', array('User.username'=>$username)); 95 95 96 96 $this->layout = $this->Edublog->layout($user_id); 97 97 98 98 $this->Edublog->blog($user_id); 99 99 100 100 $this->set('forum_id', $forum_id); 101 101 } … … 103 103 } 104 104 105 public function reply($user_id = null, $forum_id = null) { 106 107 // adds new topic to forum 108 if (!empty($this->data["Topic"])) 109 { 110 // die(print_r($this->data)); 111 $this->Sanitize = new Sanitize; 112 113 $this->Sanitize->cleanArray($this->data["Topic"]); 114 115 if ($this->Topic->save($this->data)) 116 { 117 $this->flash('New topic had been added.','/topics/view/'.$this->data['Topic']["user_id"].'/'. $this->data['Topic']['forum_id']); 118 } 119 } 120 else 121 { 105 public function reply($user_id, $forum_id, $topic_id) 106 { 107 // adds new reply to topic 108 122 109 $this->layout = $this->Edublog->layout($user_id); 123 110 … … 125 112 126 113 $this->set('forum_id', $forum_id); 127 } 114 $this->set('topic_id', $topic_id); 128 115 } 129 116 … … 160 147 if ($this->Topic->save($this->data['Topic'])) 161 148 { 162 $this->msgFlash('Topic status changed', '/admin/forums/topics/'.$forum_id);149 $this->msgFlash('Topic status changed', '/admin/forums/topics/'.$forum_id); 163 150 } 164 151 } -
trunk/app/views/catforums/admin_edit.ctp
r258 r325 1 1 <div class="spaced"> 2 2 <?php 3 echo $ html->formTag('/admin/catforums/edit/', 'post');4 echo $ html->hidden('Catforum/id');3 echo $form->create('Catforum'); 4 echo $form->hidden('Catforum.id'); 5 5 ?> 6 6 <fieldset> … … 8 8 9 9 <?php 10 echo $form->labelTag('Catforum/title', 'Title:') . "<br />"; 11 echo $html->input('Catforum/title', array('size'=>60, 'maxlength'=>90)); 12 echo $html->tagErrorMsg('Catforum/title','Please enter a title.'); 10 echo $form->input('Catforum.title', array('size'=>60, 'maxlength'=>90)); 11 echo $form->error('Catforum.title','Please enter a title.'); 13 12 ?> 14 13 <br /> 15 14 <br /> 16 15 <?php 17 echo $form->labelTag('Catforum/description', 'Description:') . "<br />"; 18 echo $html->input('Catforum/description', array("size" => 60, "maxlength" => 90)); 19 echo $html->tagErrorMsg('Catforum/description','Please enter a description.'); 16 echo $form->input('Catforum.description', array("size" => 60, "maxlength" => 90)); 17 echo $form->error('Catforum.description','Please enter a description.'); 20 18 ?> 21 19 22 20 <br /><br /> 23 <?php echo $form->labelTag('Catforum/status', 'Status:') . "<br />"; ?> 24 <?php echo $html->checkbox('Catforum/status'); ?> 21 <?php 22 echo $form->label('Catforum.status', 'Status:') . "<br />"; 23 echo $form->checkbox('Catforum.status', array('value'=>1)); 24 ?> 25 25 <br /><br /> 26 <p style="clear:both"></p> 27 <?php echo $html->submit('Update') ?> 28 </fieldset> 29 </form> 26 <p style="clear:both"></p></fieldset> 27 <?php echo $form->end('Update'); ?> 28 30 29 </div> 31 30 -
trunk/app/views/catforums/admin_listing.ctp
r321 r325 60 60 echo '<tr><td> </td> <td> '. $gags->sendEdit($v["id"], 'forums') .'</td>'; 61 61 echo '<td>' . $html->link($v["title"], '/admin/forums/topics/'.$v['id']) .'</td> <td colspan="2"> '. $v["description"] .' </td>'; 62 echo '<td>' . $ gags->setStatus($v['status']).'</td> <td> ' . $gags->confirmDel($v['id'], 'forums') . '</td> </tr>';62 echo '<td>' . $html->link($gags->setStatus($v['status']), '/admin/forums/change/'.$v['status'].'/'.$v['id']).'</td> <td> ' . $gags->confirmDel($v['id'], 'forums') . '</td> </tr>'; 63 63 } 64 64 } -
trunk/app/views/catforums/display.ctp
r322 r325 27 27 } 28 28 ?> 29 -
trunk/app/views/forums/display.ctp
r323 r325 5 5 echo '<div style="padding:6px;border:1px dotted gray;margin:15px 0 15px 0">'; 6 6 echo '<div style="padding:6px;border:1px solid orange;font-size:17pt;color:orange;font-weight:bold">'.$data["Forum"]["title"].'</div>'; 7 echo '<span ="font-size:pt">'. $data["Forum"]["description"] . "</span>";8 echo '<div style="width:100px;margin-top:15px">';9 echo $html->link($html->image('static/new_post.gif', array("alt"=>"Add new topic", "title"=>"Add new topic")),7 echo '<span ="font-size:pt">'. $data["Forum"]["description"] . "</span>"; 8 echo '<div style="width:100px;margin-top:15px">'; 9 echo $html->link($html->image('static/new_post.gif', array("alt"=>"Add new topic", "title"=>"Add new topic")), 10 10 '/topics/add/'.$blog["User"]["username"].'/'.$data["Forum"]["id"], 11 11 null, null, false); 12 echo '</div>';12 echo '</div>'; 13 13 14 //Topics15 echo '<table style="border-collapse:collapse;width:100%">';16 if ( count($data["Topic"]) == 0)17 {14 //Topics 15 echo '<table style="border-collapse:collapse;width:100%">'; 16 if ( count($data["Topic"]) == 0) 17 { 18 18 echo '<tr><td colspan="6"><br /><h4>There is not topic on this forum yet</h4></td></tr>'; 19 }20 else21 {19 } 20 else 21 { 22 22 $th = array('Read', 'Topics', 'Replies', 'Author', 'Views', 'Last Post'); 23 23 echo $html->tableHeaders($th); 24 }25 //die(print_r($data["Topic"]));24 } 25 //die(print_r($data["Topic"])); 26 26 27 foreach ($data["Topic"] as $val) 28 { 29 if ($val['level'] == 0) 30 { 31 $tr = array ( 27 foreach ($data["Topic"] as $val) 28 { 29 $tr = array ( 32 30 $html->image('static/folder.gif'), 33 31 $html->link($val['subject'], '/topics/display/'.$data['Forum']['user_id'].'/'.$val['forum_id'].'/'.$val['id']), … … 40 38 echo $html->tableCells($tr, array("style"=>"border:1px solid gray;padding:6px;background-color:#e8f6fe"), 41 39 array("style"=>"border:1px solid gray;padding:6px;background-color:#c0c0c0")); 42 }43 }40 41 } 44 42 45 echo '</table>'; 46 47 echo '</div>'; 43 echo '</table>'; 44 echo '</div>'; 48 45 49 46 -
trunk/app/views/layouts/admin.ctp
r317 r325 50 50 51 51 <div id="footer"> 52 <p>Powered by the <a href="http://www.chipotle-software.com/" rel="external">Karamelo Project © GPLv3</a></p>52 <p>Powered by the <a href="http://www.chipotle-software.com/" rel="external">Karamelo Project © 2002-2008 GPLv3</a> </p> 53 53 </div> 54 54 -
trunk/app/views/layouts/rubyx.ctp
r281 r325 172 172 <p id="createdby">created by <a href="http://www.nuvio.cz">Nuvio | Webdesign</a> <!-- DON?T REMOVE, PLEASE! --></p> 173 173 174 <p id="copyright">Chipotle Software © 2002-200 7. Creative Commons. Some rights reserved.</p>174 <p id="copyright">Chipotle Software © 2002-2008. Creative Commons. Some rights reserved.</p> 175 175 </div> <!-- /footer --> 176 176 -
trunk/app/views/topics/display.ctp
r322 r325 1 1 <?php 2 die(debug($data)); 2 //die(debug($data)); 3 4 echo '<h1>'. $data['Forum']['title'] .'</h1>'; 5 echo '<p>'. $data['User']['username'] . ' write: <b>'.$data['Topic']['subject'] .'</b> <span class="dates">'.$data['Topic']['created'].'</span></p>'; 6 3 7 echo '<div>'; 4 8 5 echo $html->link( 9 echo $html->link( // add topic 6 10 $html->image( 7 11 'static/new_topic.gif', array("alt"=>"New topic", "title"=>"New topic") 8 12 ), 9 '/topics/add/'.$blog[ 0]["User"]["id"].'/'.$phorum_id,13 '/topics/add/'.$blog["User"]["username"].'/'.$data['Forum']['id'], 10 14 false, false, null 11 ); 15 ); 12 16 13 echo $html->link($html->image('static/reply.gif', array("alt"=>"Reply", "title"=>"Reply")), '/topics/reply/'.$blog[0]["User"]["id"].'/'.$topic_id, false, false, null); 17 echo $html->link( // add reply 18 $html->image( 19 'static/reply.gif', array("alt"=>"Reply", "title"=>"Reply")), 20 '/topics/reply/'.$blog["User"]["id"].'/'.$data['Forum']['id'] .'/'.$data['Topic']['id'], 21 false, false, null); 14 22 15 23 echo '</div>'; 24 16 25 echo '<div style="padding:5px;border:1px dotted black;background-color:#c0c0c0;margin:10px 5px 10px 5px">'; 17 18 foreach ($data as $key => $val) { 19 echo '<div> Title:<a href="/topics/display/'.$data[$key]['Topic']['id'].'">'. $data[$key]['Topic']['subject'].'</a><br />'; 20 echo $data[$key]['Topic']['message']; 26 27 if ( count($data['Reply']) < 1 ) 28 { 29 echo '<h2>No replies yet</h2>'; 30 } 31 32 foreach ($data['Reply'] as $val) 33 { 34 echo '<div> Title:<a href="/topics/display/'.$val['id'].'">'. $val['subject'].'</a><br />'; 35 echo $val['message']; 21 36 22 37 echo '</div>'; 23 }38 } 24 39 echo '</div>'; 25 40 26 41 27 echo '<div>';28 echo $html->link($html->image('static/new_topic.gif', array("alt"=>"New topic", "title"=>"New topic")), '/topics/add/'.$blog[0]["User"]["id"].'/'.$phorum_id, false, false, null);29 30 echo $html->link($html->image('static/reply.gif', array("alt"=>"Reply", "title"=>"Reply")), '/topics/reply/'.$blog[0]["User"]["id"].'/'.$topic_id, false, false, null);31 32 33 echo '</div>';34 35 42 ?> -
trunk/app/views/topics/reply.ctp
r314 r325 1 1 2 <?php echo $javascript->link('myfunctions'); ?> 3 4 <div> 5 <?php echo $html->addCrumb('Phorums', '/phorums/view/'.$blog[0]["User"]["id"]); ?> 6 <?php echo $html->getCrumbs(' / '); ?> 7 </div> 8 <div class="title_section">New Topic</div> 2 <div class="title_section">Reply</div> 9 3 10 4 <div class="spaced"> 11 5 12 <?php //echo $html->formTag('/topics/add/'. $blog[0]["User"]["id"] .'/'. $phorum_id, 'post'); 6 <?php 7 if ( isset ($cU) ): 8 echo $form->create('Reply', array('action'=>'add')); 9 echo $form->hidden('Reply.redirect_to', array('value'=>'/topics/display/'.$blog['User']['id'].'/
