Changeset 342
- Timestamp:
- 03/25/08 01:03:27 (7 months ago)
- Location:
- trunk/app
- Files:
-
- 7 added
- 21 modified
-
config/sql/karamelo_postgres.sql (modified) (1 diff)
-
controllers/ecourses_controller.php (modified) (5 diffs)
-
controllers/messages_controller.php (modified) (6 diffs)
-
controllers/users_controller.php (modified) (5 diffs)
-
models/ecourse.php (modified) (1 diff)
-
models/group.php (modified) (2 diffs)
-
models/message.php (modified) (1 diff)
-
views/ecourses/admin_add.ctp (modified) (2 diffs)
-
views/ecourses/admin_edit.ctp (modified) (1 diff)
-
views/elements/login.ctp (modified) (1 diff)
-
views/entries/admin_add.ctp (modified) (1 diff)
-
views/groups/admin_edit.ctp (modified) (1 diff)
-
views/groups/admin_listing.ctp (modified) (2 diffs)
-
views/layouts/paris.ctp (modified) (3 diffs)
-
views/layouts/portal.ctp (modified) (1 diff)
-
views/layouts/rubyx.ctp (modified) (2 diffs)
-
views/layouts/school.ctp (added)
-
views/lessons/display.ctp (modified) (1 diff)
-
views/messages/message.ctp (modified) (4 diffs)
-
views/users/admin_edit.ctp (modified) (2 diffs)
-
views/users/admin_listing.ctp (modified) (1 diff)
-
views/users/blog.ctp (modified) (1 diff)
-
webroot/css/school (added)
-
webroot/css/school/school.css (added)
-
webroot/img/css (added)
-
webroot/img/css/school (added)
-
webroot/img/css/school/bg.gif (added)
-
webroot/img/css/school/school.jpg (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/karamelo_postgres.sql
r340 r342 22 22 modified timestamp(0) with time zone DEFAULT now() NOT NULL, 23 23 code varchar(7) NOT NULL DEFAULT 'f78Z67', 24 active smallint NOT NULL DEFAULT 1, -- active/desactive group 24 25 CHECK ( length(code) > 6 ) 25 26 ); -
trunk/app/controllers/ecourses_controller.php
r340 r342 36 36 $this->layout = 'admin'; 37 37 38 39 38 $conditions = array("user_id"=>$this->Auth->user('id')); 40 39 $fields = array('id', 'title', 'access', 'status', 'description'); 41 40 $order = "Ecourse.title DESC"; 42 41 43 42 $this->set('data', $this->Ecourse->findAll($conditions, $fields, $order)); 44 43 } … … 67 66 $this->set('data', $this->Ecourse->find($conditions, $fields)); 68 67 } 69 70 public function admin_add()71 {72 $this->layout = 'admin';73 74 if (!empty($this->data['Ecourse']))75 {76 $this->Sanitize = new Sanitize;77 78 $this->Sanitize->clean($this->data["Ecourse"]);79 80 $this->data['Ecourse']['user_id'] = $this->Auth->user('id');81 82 $this->Ecourse->create();83 84 if ($this->Ecourse->save($this->data['Ecourse']))85 {86 $this->msgFlash('Course saved', '/admin/ecourses/listing');87 }88 }89 else90 {91 92 $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title"));93 94 $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang"));95 96 }97 }98 68 99 69 public function admin_change($id, $status) … … 112 82 } 113 83 } 84 public function admin_add() 85 { 86 $this->layout = 'admin'; 87 88 $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 89 90 $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 91 92 if (!empty($this->data['Ecourse'])) 93 { 94 $this->Sanitize = new Sanitize; 95 96 $this->Sanitize->clean($this->data["Ecourse"]); 97 98 $this->data['Ecourse']['user_id'] = $this->Auth->user('id'); 99 100 $this->Ecourse->create(); 101 102 if ($this->Ecourse->save($this->data['Ecourse'])) 103 { 104 $this->msgFlash('Course saved', '/admin/ecourses/listing'); 105 } 106 } 107 } 114 108 115 109 public function admin_edit($id = null) 116 110 { 117 118 if (empty($this->data['Ecourse'])) 111 $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 112 113 $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 114 115 if ( empty($this->data['Ecourse']) ) 119 116 { 120 117 $this->layout = 'admin'; … … 124 121 $this->Subject = new Subject; 125 122 126 $this->set('subjects', $this->Ecourse->Subject->generateList(null, 'title'));127 128 $this->set('langs', $this->Ecourse->Lang->generateList(null, 'lang', null, '{n}.Lang.id', '{n}.Lang.lang'));129 130 123 $this->data = $this->Ecourse->read(); 124 131 125 } 132 126 else … … 135 129 136 130 $this->Sanitize->html($this->data["Ecourse"]['description']); 137 131 138 132 if ($this->Ecourse->save($this->data['Ecourse'])) 139 133 { -
trunk/app/controllers/messages_controller.php
r331 r342 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 … … 12 12 public $helpers = array('Javascript', 'Ajax', 'Fck', 'Time'); 13 13 14 public $components = array('Portal', 'Security', 'Email', 'Session'); 15 14 public $components = array('Portal', 'Security', 'Email', 'Session', 'Edublog'); 15 16 public function beforeFilter() 17 { 18 $this->Auth->allow(array('message', 'deliver')); 19 parent::beforeFilter(); 20 } 21 16 22 public function isAuthorized() 17 23 { … … 25 31 return false; // go away !! 26 32 } 27 28 public function show($username, $id) 29 { 30 $this->pageTitle = 'Classrooms'; 31 $this->layout = 'berlin'; //$this->Blog->field; 32 33 $conditions = array("Subject.status"=>1, "Subject.id"=>$id); 34 $fields = array("Subject.id", "Subject.name", "Subject.program_id", "Subject.created"); 35 $order = "Subject.name DESC"; 36 37 $this->set('blog', $this->Edublog->blog($username)); 38 39 $this->set('data', $this->Message->findAll($conditions, $fields, $order, null, null, 2, 2)); 40 } 41 42 public function message($user_id) 43 { 33 34 public function message($username) // show form to send message to teacher 35 { 44 36 $this->pageTitle = 'Contact'; 45 37 38 $user_id = $this->Message->User->field('id', array('username'=>$username)); 39 46 40 $this->layout = $this->Edublog->layout($user_id); 47 41 48 $this->set('blog', $this->Edublog->blog($user_id)); 49 50 $this->set('user_id', $user_id); 51 } 52 53 public function contact() 54 { 42 $this->Edublog->blog($user_id); 43 } 44 45 public function contact() 46 { 55 47 $this->layout = 'portal'; 56 48 57 49 $this->pageTitle = 'Contact'; 58 50 59 $this-> set('Element', $this->Portal->statics()); // Using Portal component60 }61 62 public function compose()63 {51 $this->Portal->statics(); // Using Portal component 52 } 53 54 public function compose() 55 { 64 56 $this->layout = 'portal'; 65 57 66 58 $this->pageTitle = 'Write Message'; 67 59 68 $this->set('Element', $this->Portal->statics()); // Using Portal component 69 } 70 71 public function search() 72 { 73 $this->layout = 'ajax'; 74 75 $this->pageTitle = 'Write Message'; 76 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 85 $limit = 15; 86 87 $this->set('data', $this->Message->User->findAll($conditions, $fields, $order, $limit)); 88 89 $this->render('search', 'ajax'); 90 } 91 92 public function chat($nick='mononeuron') 93 { 60 $this->Portal->statics(); // Using Portal component 61 } 62 63 public function chat($nick='mononeuron') 64 { 94 65 $this->pageTitle = 'IRC Chat'; 95 66 … … 97 68 98 69 $this->set('nick', $nick); 99 }100 101 public function deliver()102 {70 } 71 72 public function deliver() 73 { 103 74 $this->layout = 'ajax'; 104 75 105 if (!empty($this->data["Message"]))106 {76 if (!empty($this->data["Message"])) 77 { 107 78 $this->Sanitize = new Sanitize; 108 79 … … 123 94 else 124 95 { 125 $this->render('sen d', 'ajax');96 $this->render('sent', 'ajax'); 126 97 } 127 98 } 128 99 } 129 } 130 131 /**=== ADMIN METHODS ===**/ 132 public function admin_general() 133 { 134 if ($this->Auth->user('group_id') != 1) 135 { 136 $this->redirect('/admin/messages/listing'); 137 } 138 139 $this->layout = 'admin'; 140 141 if (!empty($this->data["Message"])) 142 { 143 $this->Sanitize = new Sanitize; 144 145 $this->Sanitize->html($this->data["Message"]["title"]); 146 147 $this->Sanitize->html($this->data["Message"]["body"]); 148 149 $this->Message->User->unbindModel( 150 array( 151 "hasMany"=>array( 152 "Entry", "News", "Category", "Lesson", "Podcast", "Bookmark"))); 153 154 $conditions = array("active"=>1); 155 156 $fields = array("id"); 157 158 $data = $this->User->findAll($conditions, $fields); 159 160 $j = 0; //counter 161 162 $this->data["Message"]["sender_id"] = $this->Auth->user('id'); 163 164 //exit(print_r($data)); 165 166 foreach($data as $val) 167 { 168 $this->Message->create(); 169 170 //exit(print_r($val)); 171 172 $this->data["Message"]["user_id"] = $val["User"]["id"]; 173 174 if ($this->Message->save($this->data["Message"])) 175 { 176 $j++; 177 } 178 else 179 { 180 exit('error on save'); 181 } 182 } 183 $this->msgFlash($j . ' messages sent', '/admin/messages/listing'); 184 } 185 } 186 187 private function sendMail($user_id, $username, $title) 100 } 101 private function sendMail($user_id, $username, $title) 188 102 { 189 103 $this->User = new User; … … 218 132 exit("Error!!"); 219 133 } 220 } 221 134 } 135 136 /**=== ADMIN METHODS ===**/ 137 public function admin_general() // send a general message to all commnunity 138 { 139 if ($this->Auth->user('group_id') != 1) 140 { 141 $this->redirect('/admin/messages/listing'); 142 } 143 144 $this->layout = 'admin'; 145 146 if (!empty($this->data["Message"])) 147 { 148 $this->Sanitize = new Sanitize; 149 150 $this->Sanitize->html($this->data["Message"]["title"]); 151 152 $this->Sanitize->html($this->data["Message"]["body"]); 153 154 $this->Message->User->unbindModel( 155 array( 156 "hasMany"=>array( 157 "Entry", "News", "Category", "Lesson", "Podcast", "Bookmark"))); 158 159 $conditions = array("active"=>1); 160 161 $fields = array("id"); 162 163 $data = $this->User->findAll($conditions, $fields); 164 165 $j = 0; //counter 166 167 $this->data["Message"]["sender_id"] = $this->Auth->user('id'); 168 169 //exit(print_r($data)); 170 171 foreach($data as $val) 172 { 173 $this->Message->create(); 174 175 //exit(print_r($val)); 176 177 $this->data["Message"]["user_id"] = $val["User"]["id"]; 178 179 if ($this->Message->save($this->data["Message"])) 180 { 181 $j++; 182 } 183 else 184 { 185 exit('error on save'); 186 } 187 } 188 $this->msgFlash($j . ' messages sent', '/admin/messages/listing'); 189 } 190 } 191 222 192 public function admin_change($message_id, $message_status) 223 193 { -
trunk/app/controllers/users_controller.php
r339 r342 55 55 56 56 $limit = 20; 57 57 58 58 $this->set('data', $this->User->Entry->findAll($conditions, $fields, $order, $limit)); 59 59 60 60 $this->layout = $this->Edublog->layout($user_id); 61 61 62 62 $this->Edublog->blog($user_id); 63 63 } … … 393 393 public function admin_edit() 394 394 { 395 396 $this->layout = 'admin';397 398 $this->set('Groups', $this->User->Group->generateList());399 400 if (empty($this->data)) 401 { 402 $this->User->id = $this->Auth->user('id'); 403 $this->data = $this->User->read( );395 if ( empty($this->data['User']) ) 396 { 397 $this->layout = 'admin'; 398 399 $this->set('Groups', Set::combine($this->User->Group->find('all', array('order' => 'name')), "{n}.Group.id","{n}.Group.name")); 400 401 $this->User->unbindModel($this->User->notNow); 402 403 $this->data = $this->User->read(null, $this->Auth->user('id')); 404 404 } 405 405 else … … 480 480 } 481 481 } 482 483 /*** DELETE **/ 484 public function delete($id) 485 { 486 $this->User->del($id); 487 $this->msgFlash('User has been deleted.', '/admin/users/listing'); 488 } 489 490 /*** List user's blog entries **/ 491 public function blogs($order = null) 492 { 493 494 $conditions = array("active" => 1 ); 495 496 $data = $this->User->findAll($conditions, $order); 497 498 $this->set('data', $data); 499 500 } 501 482 483 /*** DELETE **/ 484 public function admin_delete($id) 485 { 486 if ($this->User->del($id)) 487 { 488 $this->msgFlash('User has been deleted.', '/admin/users/listing'); 489 } 490 } 491 502 492 /**** AVATAR ***/ 503 493 public function admin_avatar() … … 573 563 } 574 564 575 $extension = $this-> get_extension($type);565 $extension = $this->Adds->get_extension($type); 576 566 577 567 $Name = $this->Auth->user('username') . "_avatar" . $extension; … … 607 597 608 598 } 609 }610 611 public function admin_delete($id)612 {613 if ( $this->User->del($id) )614 {615 $this->msgFlash('User has been deleted','/admin/users/listing');616 }617 599 } 618 600 -
trunk/app/models/ecourse.php
r282 r342 3 3 * Karamelo E-Learning Platform 4 4 * Chipotle Software 2002-2008 5 * GPLv3 manuel<a t>mononeurona<dot>org5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 6 */ 7 7 //File: /app/models/ecourse.php 8 8 9 9 class Ecourse extends AppModel { 10 10 11 11 public $name = 'Ecourse'; 12 12 13 13 public $belongsTo = array('User', 'Subject', 'Lang'); 14 14 15 15 public $hasMany = array('Vclassroom'); 16 16 17 17 public $validate = array( 18 'title' => VALID_NOT_EMPTY, 19 'access' => VALID_NOT_EMPTY, 20 'description' => VALID_NOT_EMPTY, 21 'lang_id' => VALID_NOT_EMPTY 22 ); 18 'title' => array( 19 'alphanumeric' => array( 20 'rule' => array('minLength', 4), 21 'required' => true, 22 'allowEmpty' => false, 23 'message' => 'Mimimum 4 characters long in title' 24 ) 25 ), 26 'description' => array( 27 'rule' => array('minLength', 20), 28 'allowEmpty' => false, 29 'message' => 'Mimimum 8 characters long' 30 ), 31 'code' => array( 32 'rule' => array('minLength', 4), 33 'allowEmpty' => false, 34 'message' => 'Mimimum 4 characters long' 35 ), 36 'lang_id' => array( 37 'rule' => 'numeric', 38 'message' => 'Enter a valid lang', 39 'allowEmpty' => true 40 ) 41 ); 23 42 } 24 43 ?> -
trunk/app/models/group.php
r282 r342 3 3 * Chipotle Software TM 4 4 * Manuel Montoya 2002-2008 5 * GPLv3 manuel<a t>mononeurona<dot>org5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 6 */ 7 7 class Group extends AppModel … … 10 10 11 11 public $hasMany = 'User'; 12 13 public $validate = array( 14 'code' => array( 15 'required' => true, 16 'rule' => array('minLength', 5), 17 'message' => 'Code must be at least 5 characters long.' 18 ) 19 ); 12 20 13 21 } -
trunk/app/models/message.php
r331 r342 3 3 * Karamelo eLearning Platform 4 4 * Chipotle Software 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org ASMO5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 6 **/ 7 7 -
trunk/app/views/ecourses/admin_add.ctp
r340 r342 1 <?php echo $form->create('Ecourse', array('onsubmit'=>'return chkForm()')); ?> 1 <?php 2 echo $javascript->link('fckeditor/fckeditor'); 3 echo $form->create('Ecourse', array('onsubmit'=>'return chkForm()')); 4 ?> 2 5 <fieldset> 3 6 <legend>New Course</legend> 4 <p>By default, your course is accessible to everybody. If you want some confidentiality, the simplest way is to open registration during one week, ask the students to register themselves, then close registration and check for possible intruders in the user list.</p>5 7 <?php 6 echo $form->input('Ecourse.title', array("size" => 30, "maxlength" => 90)) . ' e.g. History of Literature';7 echo $form-> error('Ecourse.title', 'A FAQ title is required.');8 9 echo $form->input('Ecourse.title', array("size" => 30, "maxlength" => 90, 'title'=>' e.g. History of Literature')); 8 10 9 11 echo $form->label('Ecourse.description', 'Description:'); 10 12 echo $form->textarea('Ecourse.description', array("cols" => 40, "rows" =>4)); 11 12 echo $form->input('Ecourse.code', array("size" => 12, "maxlenght" => 12)) . ' max. 12 characters, ie.ROM2121'; 13 echo $form->error('Ecourse.code', 'A category description is required.'); 13 echo $fck->load('EcourseDescription', 'Default'); 14 echo $form->error('Ecourse.description', 'You must describe course '); 15 16 echo $form->input('Ecourse.code', array("size" => 12, "maxlenght" => 12, 'title'=>' max. 12 characters. Example: ROM2121', 'error'=>'Code is required')); 14 17 15 18 echo $form->label('Ecourse.subject_id', 'Subject:'); … … 18 21 echo $form->label('Ecourse.lang_id', 'Lang:'); 19 22 echo $form->select('Ecourse.lang_id', $langs, null, null, null, false); 23 24 echo $form->label('Ecourse.status', 'Enabled:' ); 25 echo $form->checkbox('Ecourse.status', array("value"=>1, 'title'=>'Enabled course')); 20 26 ?> 21 22 <div style="clear:both"></div> 27 </fieldset> 23 28 <br /> 24 29 <?php echo $form->end('Save'); ?> 25 </fieldset>26 30 27 31 <script type="text/javascript"> -
trunk/app/views/ecourses/admin_edit.ctp
r340 r342 1 1 <?php 2 echo $form->create('Ecourse',array("onsubmit"=>"return chkForm();")); 3 echo $form->hidden('Ecourse.id'); 2
