Changeset 331
- Timestamp:
- 03/23/08 13:42:50 (10 months ago)
- Location:
- trunk/app
- Files:
-
- 2 added
- 12 modified
-
app_controller.php (modified) (1 diff)
-
config/sql/karamelo_postgres.sql (modified) (1 diff)
-
controllers/forums_controller.php (modified) (9 diffs)
-
controllers/messages_controller.php (modified) (3 diffs)
-
controllers/topics_controller.php (modified) (3 diffs)
-
models/catforum.php (modified) (2 diffs)
-
models/message.php (modified) (2 diffs)
-
models/user.php (modified) (1 diff)
-
views/forums/admin_topics.ctp (modified) (1 diff)
-
views/messages/admin_add.ctp (modified) (1 diff)
-
views/messages/search.ctp (modified) (2 diffs)
-
views/topics/admin_edit.ctp (added)
-
views/topics/admin_listing.ctp (added)
-
webroot/js/prototype.js (modified) (74 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r325 r331 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', 'reply', 'register', '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', 23 'message', 'search', 'directory', 'bloggers', 'add', 'rss', 'discussion') ); 23 24 $this->Auth->autoRedirect = true; 24 25 $this->set('cU', $this->Auth->user()); // $cU current user array to use in the views if user logged -
trunk/app/config/sql/karamelo_postgres.sql
r330 r331 229 229 ); 230 230 231 CREATE TABLE replies ( -- replies to topics in forums 231 CREATE TABLE replies ( -- replies to topics in forums 232 232 id serial PRIMARY KEY, 233 233 reply text NOT NULL, -
trunk/app/controllers/forums_controller.php
r325 r331 3 3 * Chipotle Software TM 4 4 * Manuel Montoya 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org 5 * GPLv3 manuel<arroba>mononeurona<punto>org ASMO 6 6 */ 7 7 … … 31 31 32 32 $fields = array("Forum.title", "Forum.id", "Forum.user_id", "Forum.description", "Forum.catforum_id", "Topic.id"); 33 33 34 34 $data = $this->Forum->find($conditions, null, null, 2); 35 35 36 36 $this->pageTitle = $data['Catforum']['title'] . ' Forum'; 37 37 //die(debug($data)); 38 38 $this->set('data', $data); 39 39 40 $this->layout = $this->Edublog->layout($data['Forum']['user_id']);41 40 $this->layout = $this->Edublog->layout($data['Forum']['user_id']); 41 42 42 $this->Edublog->blog($data['Forum']['user_id']); // blogger elements 43 43 } … … 54 54 //die(debug($data)); 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);60 59 $this->layout = $this->Edublog->layout($user_id); 60 61 61 $this->Edublog->blog($user_id); // blogger elements 62 62 } 63 63 64 64 public function view($username, $user_id, $forum_id, $topic_id) 65 65 { … … 74 74 $this->set('data', $this->Forum->find($conditions, $fields, null, 2)); 75 75 76 $this->layout = $this->Edublog->layout($user_id);77 76 $this->layout = $this->Edublog->layout($user_id); 77 78 78 $this->Edublog->blog($user_id); // blogger elements 79 79 } … … 88 88 } 89 89 90 public function admin_topics( $forum_id)90 public function admin_topics( $f_id ) 91 91 { 92 if ( !intval($forum_id) ) 92 $forum_id = (int) $f_id; 93 94 if ( !is_int($forum_id) ) 93 95 { 94 96 $this->redirect('/'); 95 97 } 96 98 97 99 $this->layout = 'admin'; 98 100 … … 105 107 { 106 108 $this->layout = 'admin'; 107 109 108 110 if ( !empty( $this->data['Forum'] ) ) 109 111 { … … 115 117 116 118 $this->Forum->create(); 117 119 118 120 if ( $this->Forum->save($this->data['Forum']) ) 119 121 { 120 122 $this->msgFlash('Forum created', '/admin/catforums/listing'); 121 123 } 122 } 123 else 124 } 125 else 124 126 { 125 $this->set('catforum_id', $catforum_id);127 $this->set('catforum_id', $catforum_id); 126 128 } 127 129 } 128 130 129 public function admin_edit($id = null)130 {131 public function admin_edit($id = null) 132 { 131 133 if (empty($this->data['Forum'])) 132 134 { … … 139 141 else 140 142 { 141 $this->Sanitize = new Sanitize;142 143 $this->Sanitize->clean($this->data['Forum']);144 145 if ($this->Forum->save($this->data['Forum']))146 {143 $this->Sanitize = new Sanitize; 144 145 $this->Sanitize->clean($this->data['Forum']); 146 147 if ($this->Forum->save($this->data['Forum'])) 148 { 147 149 $this->msgFlash('Forum updated', '/admin/catforums/listing'); 148 150 exit(); 149 }151 } 150 152 } 151 153 } … … 175 177 } 176 178 } 177 179 178 180 } 179 181 ?> -
trunk/app/controllers/messages_controller.php
r330 r331 3 3 * Chipotle Software TM 4 4 * Manuel Montoya 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org 5 * GPLv3 manuel<arroba>mononeurona<punto>org ASMO 6 6 */ 7 8 uses('sanitize'); 9 10 class MessagesController extends AppController 11 { 12 public $helpers = array('Javascript', 'Ajax', 'Fck', 'Time'); 7 13 8 uses('sanitize');9 10 class MessagesController extends AppController11 {12 public $helpers = array('Javascript', 'Ajax', 'Fck', 'Time');13 14 14 public $components = array('Portal', 'Security', 'Email', 'Session'); 15 15 16 16 public function isAuthorized() 17 { 17 { 18 18 if (isset( $this->params[Configure::read('Routing.admin')] )) 19 19 { 20 20 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) // admin and teachers 21 21 { 22 return true;23 } 24 } 22 return true; 23 } 24 } 25 25 return false; // go away !! 26 26 } … … 75 75 $this->pageTitle = 'Write Message'; 76 76 77 $conditions = array("User.username ~ '".$this->data["Message"]["string"] ."'"); 78 79 $fields = array("User.username", "User.id"); 80 81 $order = "User.username"; 82 77 $conditions = array("User.username ~* '".'ad' ."'"); 78 79 $fields = array("User.username", "User.id"); 80 81 $order = "User.username"; 82 83 $this->Message->User->unbindModel($this->Message->User->notNow); 84 83 85 $limit = 15; 84 86 85 $this->User = new User; 86 87 $this->set('data', $this->User->findAll($conditions, $fields, $order, $limit)); // Using Portal component 87 $this->set('data', $this->Message->User->findAll($conditions, $fields, $order, $limit)); 88 88 89 89 $this->render('search', 'ajax'); … … 106 106 { 107 107 $this->Sanitize = new Sanitize; 108 108 109 109 $this->Sanitize->html($this->data["Message"]["title"]); 110 110 111 111 $this->Sanitize->html($this->data["Message"]["body"]); 112 112 113 113 $this->Message->create(); 114 115 if ($this->Message->save($this->data["Message"]))116 {114 115 if ($this->Message->save($this->data["Message"])) 116 { 117 117 $this->sendMail($this->data["Message"]["user_id"], $this->data["Message"]["username"], $this->data["Message"]["title"]); 118 118 119 119 if ( isset($this->data["Message"]["admin"])) 120 {120 { 121 121 $this->render('sentadmin','ajax'); 122 122 } 123 123 else 124 124 { 125 $this->render('send', 'ajax');126 }125 $this->render('send', 'ajax'); 126 } 127 127 } 128 128 } -
trunk/app/controllers/topics_controller.php
r329 r331 75 75 public function reply($user_id, $forum_id, $topic_id) 76 76 { 77 // adds new reply to topic78 77 // adds new reply to topic 78 79 79 $this->layout = $this->Edublog->layout($user_id); 80 80 … … 85 85 } 86 86 87 /*** ***** ADMIN METHODS********/88 public function admin_listing( )87 /***=== ADMIN METHODS ===********/ 88 public function admin_listing($topic_id) 89 89 { 90 $this->layout = 'admin'; 91 $this->pageTitle = 'Forums'; 90 $this->layout = 'admin'; 91 92 $this->pageTitle = 'Topics'; 92 93 93 $conditions = array("user_id"=>$this->Auth->user('id')); 94 $fields = array("id", "title", "description", "status"); 94 $conditions = array("Topic.user_id"=>$this->Auth->user('id'), "Topic.id"=>$topic_id); 95 96 $fields = array("id", "subject", "message", "status", "created"); 95 97 96 $this->set('data', $this->Topic->find All($conditions, $fields));98 $this->set('data', $this->Topic->find($conditions, $fields, null, 2)); 97 99 } 98 100 99 101 public function admin_edit($id = null) 100 102 { 101 if (empty($this->data))102 {103 $this->Topic->id = $id;104 105 $this->data = $this->Topic->read();106 }107 else108 {103 if (empty($this->data)) 104 { 105 $this->Topic->id = $id; 106 107 $this->data = $this->Topic->read(); 108 } 109 else 110 { 109 111 if ($this->Topic->save($this->data['Topic'])) 110 112 { 111 113 $this->flash('Your virtual classroom has been updated.','/vclassrooms'); 112 114 } 113 }115 } 114 116 } 115 117 116 118 // change status published/draft 117 119 public function admin_change($id, $status, $forum_id) … … 132 134 } 133 135 } 134 135 public function delete($topic_id, $forum_id)136 137 public function admin_delete($topic_id, $forum_id) 136 138 { 137 139 if ( $this->Topic->del($topic_id) ) 138 140 { 139 $this->msgFlash(' ','/admin/forums/topics/'.$forum_id);141 $this->msgFlash('Topic deleted','/admin/forums/topics/'.$forum_id); 140 142 } 141 } 143 } 142 144 } -
trunk/app/models/catforum.php
r322 r331 3 3 * Chipotle Software 4 4 * Manuel Montoya 2002-2008 5 * GPLv3 manuel<a t>mononeurona<dot>org5 * GPLv3 manuel<arroba>mononeurona<punto>org ASMO 6 6 */ 7 7 //File: /app/models/catforum.php … … 27 27 ); 28 28 public $validate = array( 29 'title' => VALID_NOT_EMPTY, //'/[a-z0-9\_\-]{3,}$/i',29 'title' => VALID_NOT_EMPTY, 30 30 'message' => VALID_NOT_EMPTY, 31 31 'user_id' => VALID_NOT_EMPTY, -
trunk/app/models/message.php
r282 r331 3 3 * Karamelo eLearning Platform 4 4 * Chipotle Software 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org 5 * GPLv3 manuel<arroba>mononeurona<punto>org ASMO 6 6 **/ 7 7 … … 11 11 12 12 public $belongsTo = 'User'; 13 14 public $validate = array( 15 'title' => VALID_NOT_EMPTY, 16 'body' => VALID_NOT_EMPTY, 17 'user_id' => VALID_NOT_EMPTY, 18 'sender_id' => VALID_NOT_EMPTY 19 ); 20 13 21 } 14 15 22 ?> -
trunk/app/models/user.php
r282 r331 36 36 ) 37 37 ); 38 39 40 public $validate = array( 38 39 public $notNow = array('hasMany'=>array('Entry', 'Category', 'Acquaintance', 'Faq', 'Glossary', 'Vclassroom', 'Lesson', 'Confirm')); 40 41 public $validate = array( 41 42 'login' => VALID_NOT_EMPTY, 42 43 'pwd' => VALID_NOT_EMPTY, -
trunk/app/views/forums/admin_topics.ctp
r322 r331 21 21 foreach ($data['Topic'] as $val) 22 22 { 23 $message = substr($val['message'], 0, 40) . '...'; 24 23 25 $st = ($val['status'] == 1 ) ? 'Published' : 'Hidden'; 24 $t = '<b>'.$val['subject'] . '</b><br />';25 $t .= $ val['message']. '<br />';26 $t = $html->link($val['subject'], '/admin/topics/listing/'.$val['id'], array('title'=>'View discussions')) . '<br />'; 27 $t .= $message . '<br />'; 26 28 $t .= 'Status: ' . $html->link($st, '/admin/topics/change/'.$val['id'].'/'.$val['status'].'/'.$val['forum_id'], array('title'=>'Change status')) . '<br />'; 27 29 $t .= $val['created'] . '<br />'; -
trunk/app/views/messages/admin_add.ctp
r330 r331 32 32 echo $ajax->form(); 33 33 echo $form->hidden('Message.sender_id', array("value"=>$cU['User']['id'])); 34 echo $form->hidden('Message.username', array("value"=>$cU['User']['username']));34 echo $form->hidden('Message.username', array("value"=>$cU['User']['username'])); 35 35 ?> 36 36 <fieldset> 37 37 <legend>Write Message:</legend> 38 <?php 39 38 <?php 40 39 echo $form->label('Message.user_id', 'Send message to:' ) . '<br />'; 41 40 42 echo '<div id="updater"></div>';41 echo $ajax->div('updater') . $ajax->divEnd('updater') ; 43 42 44 43 echo $cU['User']['username'] . " escribe: <br />"; 45 echo $form->label('Message.title', 'Asunto:' ) . "<br />";46 44 echo $form->input('Message.title', array("size" => 35, "maxlength" => 50)) . "<br />"; 47 45 echo $form->error('Message.title', 'Asunto is required.'); 48 49 ?> 46 ?> 50 47 51 48 </p> 52 49 <br /> 53 <?php echo $form->label('Message.body', 'Message:' );?><br /> 54 <?php echo $form->textarea('Message.body', array("cols"=>50, "rows"=>8)) ?> 55 <?php echo $fck->load('MessageBody', 'Basic', 500, 200); ?> 56 <?php echo $form->error('Message.body', 'Message is required.'); ?> 50 <?php 51 echo $form->label('Message.body', 'Message:' ); 52 echo $form->textarea('Message.body', array("cols"=>50, "rows"=>8)); 53 echo $fck->load('MessageBody', 'Basic', 500, 200); 54 echo $form->error('Message.body', 'Message is required.'); 55 ?> 57 56 <br /> 58 57 </p> -
trunk/app/views/messages/search.ctp
r330 r331 1 1 <?php 2 // var_dump($data);2 //die(debug($data)); 3 3 4 4 $values = array(); … … 8 8 $values[$val["User"]["id"]] = $val["User"]["username"]; 9 9 } 10 10 //die(debug($values)); 11 11 echo $form->select('Message.user_id', $values, null, null, null, false); 12 12 -
trunk/app/webroot/js/prototype.js
r1 r331 1 /* Prototype JavaScript framework, version 1.5. 0_rc12 * (c) 2005 Sam Stephenson <sam@conio.net>1 /* Prototype JavaScript framework, version 1.5.1.2 2 * (c) 2005-2008 Sam Stephenson 3 3 * 4 4 * Prototype is freely distributable under the terms of an MIT-style license. 5 * For details, see the Prototype web site: http:// prototype.conio.net/5 * For details, see the Prototype web site: http://www.prototypejs.org/ 6 6 * 7 7 /*--------------------------------------------------------------------------*/ 8 8 9 9 var Prototype = { 10 Version: '1.5.0_rc1', 10 Version: '1.5.1.2', 11 12 Browser: { 13 IE: !!(window.attachEvent && !window.opera), 14 Opera: !!window.opera, 15 WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, 16 Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 17 }, 18 11 19 BrowserFeatures: { 12 XPath: !!document.evaluate 13 }, 14 15 ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 16 emptyFunction: function() {}, 20 XPath: !!document.evaluate, 21 ElementExtensions: !!window.HTMLElement, 22 SpecificElementExtensions: 23 (document.createElement('div').__proto__ !== 24 document.createElement('form').__proto__) 25 }, 26 27 ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', 28 JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, 29 30 emptyFunction: function() { }, 17 31 K: function(x) { return x } 18 32 } … … 47 61 }, 48 62 63 toJSON: function(object) { 64 var type = typeof object; 65 switch(type) { 66 case 'undefined': 67 case 'function': 68 case 'unknown': return; 69 case 'boolean': return object.toString(); 70 } 71 if (object === null) return 'null'; 72 if (object.toJSON) return object.toJSON(); 73 if (object.ownerDocument === document) return; 74 var results = []; 75 for (var property in object) { 76 var value = Object.toJSON(object[property]); 77 if (value !== undefined) 78 results.push(property.toJSON() + ': ' + value); 79 } 80 return '{' + results.join(', ') + '}'; 81 }, 82 49 83 keys: function(object) { 50 84 var keys = []; … … 76 110 var __method = this, args = $A(arguments), object = args.shift(); 77 111 return function(event) { 78 return __method.apply(object, [ ( event || window.event)].concat(args).concat($A(arguments)));112 return __method.apply(object, [event || window.event].concat(args)); 79 113 } 80 114 } … … 82 116 Object.extend(Number.prototype, { 83 117 toColorPart: function() { 84 var digits = this.toString(16); 85 if (this < 16) return '0' + digits; 86 return digits; 118 return this.toPaddedString(2, 16); 87 119 }, 88 120 … … 94 126 $R(0, this, true).each(iterator); 95 127 return this; 128 }, 129 130 toPaddedString: function(length, radix) { 131 var string = this.toString(radix || 10); 132 return '0'.times(length - string.length) + string; 133 }, 134 135 toJSON: function() { 136 return isFinite(this) ? this.toString() : 'null'; 96 137 } 97 138 }); 139 140 Date.prototype.toJSON = function() { 141 return '"' + this.getFullYear() + '-' + 142 (this.getMonth() + 1).toPaddedString(2) + '-' + 143 this.getDate().toPaddedString(2) + 'T' + 144 this.getHours().toPaddedString(2) + ':' + 145 this.getMinutes().toPaddedString(2) + ':' + 146 this.getSeconds().toPaddedString(2) + '"'; 147 }; 98 148 99 149 var Try = { … … 101 151 var returnValue; 102 152 103 for (var i = 0 ; i < arguments.length; i++) {153 for (var i = 0, length = arguments.length; i < length; i++) { 104 154 var lambda = arguments[i]; 105 155 try { … … 146 196 } 147 197 } 198 Object.extend(String, { 199 interpret: function(value) { 200 return value == null ? '' : String(value); 201 }, 202 specialChar: { 203 '\b': '\\b', 204 '\t': '\\t', 205 '\n': '\\n', 206 '\f': '\\f', 207 '\r': '\\r', 208 '\\': '\\\\' 209 } 210 }); 211 148 212 Object.extend(String.prototype, { 149 213 gsub: function(pattern, replacement) { … … 154 218 if (match = source.match(pattern)) { 155
